/**
 * $Id$
 * Copyright (C) 2008 - 2014 Nils Asmussen
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

#pragma once

#include <sys/common.h>

/* the movement-types for mvCurHor */
enum {
	HOR_MOVE_HOME,
	HOR_MOVE_END,
	HOR_MOVE_LEFT,
	HOR_MOVE_RIGHT,
};

#include "buffer.h"

/**
 * Inits the display with the given line-list
 *
 * @param lineList the line-list from the buffer-module
 */
void displ_init(sFileBuffer *buf);

/**
 * Finishes the display (restores the screen-content)
 */
void displ_finish();

/**
 * Retrieves the current cursor-position (in the buffer, not on the screen)
 *
 * @param col will be set to the column
 * @param row will be set to the row
 */
void displ_getCurPos(int *col,int *row);

/**
 * Moves the cursor horizontal. Maybe a vertical movement is done, too
 *
 * @param type the movement-type. See HOR_MOVE_*
 */
void displ_mvCurHor(uint type);

/**
 * Moves the cursor one page up or down
 *
 * @param up move up?
 */
void displ_mvCurVertPage(bool up);

/**
 * Moves the cursor down or up by <lineCount>
 *
 * @param lineCount if positive, move down, otherwise up
 */
void displ_mvCurVert(int lineCount);

/**
 * Marks the given region "dirty"
 *
 * @param start the first row
 * @param count the number of rows
 */
void displ_markDirty(size_t start,size_t count);

/**
 * Updates all dirty regions
 */
void displ_update();

/**
 * Lets the user enter the filename. It will be put to <file>.
 *
 * @param file the buffer to write to
 * @param bufSize the size of <file>
 * @return the result of scanl()
 */
int displ_getSaveFile(char *file,size_t bufSize);

/**
 * @param c the char
 * @return the display-length of the given character
 */
size_t displ_getCharLen(char c);
