diff mbox

[U-Boot,v2,05/11] cfb_console: Add functions for moving with cursor

Message ID 1335634011-9104-6-git-send-email-pali.rohar@gmail.com
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Commit Message

Pali Rohár April 28, 2012, 5:26 p.m. UTC
* 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

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
Changes since original version:
   - Fixed commit message

 drivers/video/cfb_console.c |   64 +++++++++++++++++++++++++++++++++++++++----
 1 file changed, 58 insertions(+), 6 deletions(-)

Comments

Marek Vasut April 28, 2012, 10:18 p.m. UTC | #1
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@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;
>  		}
>  	}
Pali Rohár April 29, 2012, 7:26 a.m. UTC | #2
On Sunday 29 April 2012 00:18:21 Marek Vasut wrote:
> 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.
> 

In ansi terminal.
Marek Vasut April 29, 2012, 9:09 a.m. UTC | #3
Dear Pali Rohár,

> On Sunday 29 April 2012 00:18:21 Marek Vasut wrote:
> > 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.
> 
> In ansi terminal.

Mailing list isn't really the proper place for documentation ;-)

Best regards,
Marek Vasut
Wolfgang Denk April 29, 2012, 12:18 p.m. UTC | #4
Dear Pali =?ISO-8859-1?Q?Roh=E1r?=,

In message <1704132.kQI9AKOLjq@pali> you wrote:
> 
> > How/where do you use these? Documentation entry is missing and
> > there're no comments in the code.
> 
> In ansi terminal.

I cannot parse this.  Where is the documentation?

Best regards,

Wolfgang Denk
diff mbox

Patch

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;
 		}
 	}