[U-Boot] [PATCH v2 05/11] cfb_console: Add functions for moving with cursor
Marek Vasut
marex at denx.de
Sun Apr 29 00:18:21 CEST 2012
Dear Pali Rohár,
> * console_cursor_fix - fix cursor position (check for out of screen)
> * console_cursor_up, console_cursor_down, console_cursor_left,
> console_cursor_right, console_cursor_set_position for change cursor
> position * console_newline - added param to specify count of creating new
> lines * console_previewsline - opposite of console_newline
How/where do you use these? Documentation entry is missing and there're no
comments in the code.
> Signed-off-by: Pali Rohár <pali.rohar at gmail.com>
> ---
> Changes since original version:
> - Fixed commit message
>
> drivers/video/cfb_console.c | 64
> +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58
> insertions(+), 6 deletions(-)
>
> diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c
> index 0d1e6b2..43eb994 100644
> --- a/drivers/video/cfb_console.c
> +++ b/drivers/video/cfb_console.c
> @@ -771,9 +771,54 @@ static void console_back(void)
> }
> }
>
> -static void console_newline(void)
> +static void console_cursor_fix(void)
> {
> - console_row++;
> + if (console_row < 0)
> + console_row = 0;
> + if (console_row >= CONSOLE_ROWS)
> + console_row = CONSOLE_ROWS-1;
> + if (console_col < 0)
> + console_col = 0;
> + if (console_col >= CONSOLE_COLS)
> + console_col = CONSOLE_COLS-1;
> +}
> +
> +static void console_cursor_up(int n)
> +{
> + console_row -= n;
> + console_cursor_fix();
> +}
> +
> +static void console_cursor_down(int n)
> +{
> + console_row += n;
> + console_cursor_fix();
> +}
> +
> +static void console_cursor_left(int n)
> +{
> + console_col -= n;
> + console_cursor_fix();
> +}
> +
> +static void console_cursor_right(int n)
> +{
> + console_col += n;
> + console_cursor_fix();
> +}
> +
> +static void console_cursor_set_position(int row, int col)
> +{
> + if (console_row != -1)
> + console_row = row;
> + if (console_col != -1)
> + console_col = col;
> + console_cursor_fix();
> +}
> +
> +static void console_newline(int n)
> +{
> + console_row += n;
> console_col = 0;
>
> /* Check if we need to scroll the terminal */
> @@ -782,10 +827,17 @@ static void console_newline(void)
> console_scrollup();
>
> /* Decrement row number */
> - console_row--;
> + console_row = CONSOLE_ROWS-1;
> }
> }
>
> +static void console_previewsline(int n)
> +{
> + /* FIXME: also scroll terminal ? */
> + console_row -= n;
> + console_cursor_fix();
> +}
> +
> static void console_cr(void)
> {
> console_col = 0;
> @@ -804,7 +856,7 @@ void video_putc(const char c)
>
> case '\n': /* next line */
> if (console_col || (!console_col && nl))
> - console_newline();
> + console_newline(1);
> nl = 1;
> break;
>
> @@ -813,7 +865,7 @@ void video_putc(const char c)
> console_col &= ~0x0007;
>
> if (console_col >= CONSOLE_COLS)
> - console_newline();
> + console_newline(1);
> break;
>
> case 8: /* backspace */
> @@ -827,7 +879,7 @@ void video_putc(const char c)
>
> /* check for newline */
> if (console_col >= CONSOLE_COLS) {
> - console_newline();
> + console_newline(1);
> nl = 0;
> }
> }
More information about the U-Boot
mailing list