password: Fix backspace in username prompt
PATCH 1/1 password: Fix backspace in username prompt
From: Egor Ignatov <[email protected]>
Make backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Use grub_printf() 3 times, because a line wrap will cause the cursor to get stuck at the end of the terminal line.
Resolves: #60114
--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-)
grub-core/normal/auth.c +3 -1
@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }
grub-core/normal/charset.c +1 -0
@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :
grub-core/term/gfxterm.c +9 -2
@@ -846,8 +846,15 @@ grub_gfxterm_putchar (struct grub_term_output *term,switch (c->base) {case '\b' : -if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; +if (virtual_screen.cursor_x >0 ) + { + virtual_screen.cursor_x--; + } +else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }break ;case '\n' :
Signature · 1 line
2.25.4
PATCH 1/1 password: Fix backspace in username prompt
From: Egor Ignatov <[email protected]>
Make backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Use grub_printf() 3 times, because a line wrap will cause the cursor to get stuck at the end of the terminal line.
Resolves: #60114
--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-)
grub-core/normal/auth.c +3 -1
@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }
grub-core/normal/charset.c +1 -0
@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :
grub-core/term/gfxterm.c +8 -1
@@ -847,7 +847,14 @@ grub_gfxterm_putchar (struct grub_term_output *term, {case '\b' :if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; + { + virtual_screen.cursor_x--; + } +else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }break ;case '\n' :
Signature · 1 line
2.25.4
PATCH 1/1 password: Fix backspace in username prompt
In reply to Egor IgnatovMake backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Use grub_printf() 3 times, because a line wrap will cause the cursor to get stuck at the end of the terminal line.
Resolves: #60114
--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 9 ++++++++- 3 files changed, 12 insertions(+), 2 deletions(-)
grub-core/normal/auth.c +3 -1
@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }
grub-core/normal/charset.c +1 -0
@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :
grub-core/term/gfxterm.c +8 -1
@@ -847,7 +847,14 @@ grub_gfxterm_putchar (struct grub_term_output *term, {case '\b' :if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; + { + virtual_screen.cursor_x--; + } +else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }break ;case '\n' :
Signature · 1 line
2.25.4
Quoted 23 lines · Egor Ignatov
From: Egor Ignatov <[email protected]>
Make backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Use
grub_printf()3 times, because a line wrap will cause the cursor to get stuck at the end of the terminal line.Resolves: #60114
Signed-off-by Egor Ignatov <[email protected]>--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-)grub-core/normal/auth.c +0
-0
grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 185
Quoted 10 lines
grub-core/normal/auth.c +3
-1@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }
Is this the part that the commit message refers to? I must admit I am not quite sure why this change makes a difference, but if it does, perhaps it is important (and non obvious) enough that the code should actually have a comment explaining it, or someone might come by and clean it up again later.
Signature · 1 line
Len Sorensen
I used grub_printf 3 times, because for some reason (line wrapping I guess) if you print "\b \b" at once the backspace key doesn't work on the second last character in the terminal line. The visual cursor gets stuck there and doesn't remove characters anymore, although you can still type more. This may be irrelevant because I doubt anyone is using a username longer than one line, but it solves the problem.
Quoted 40 lines · Lennart Sorensen
Quoted 23 lines · Egor Ignatov
From: Egor Ignatov <[email protected]>
Make backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Use
grub_printf()3 times, because a line wrap will cause the cursor to get stuck at the end of the terminal line.Resolves: #60114
Signed-off-by Egor Ignatov <[email protected]>--- grub-core/normal/auth.c | 4 +++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 11 +++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-)grub-core/normal/auth.c +0
-0grub-core/normal/auth.c grub_username_get (char buf[], unsigned buf_size) · line 185
Quoted 10 lines
grub-core/normal/auth.c +3
-1@@ -177,7 +177,9 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }Is this the part that the commit message refers to? I must admit I am not quite sure why this change makes a difference, but if it does, perhaps it is important (and non obvious) enough that the code should actually have a comment explaining it, or someone might come by and clean it up again later.
PATCH 1/1 password: Fix backspace in username prompt
From: Egor Ignatov <[email protected]>
Make backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Use grub_printf() 3 times, because if you print "\b \b" at once the cursor will get stuck on the second last character.
Resolves: #60114
--- grub-core/normal/auth.c | 10 +++++++++- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 9 ++++++++- 3 files changed, 18 insertions(+), 2 deletions(-)
grub-core/normal/auth.c +9 -1
@@ -177,7 +177,15 @@ grub_username_get (char buf[], unsigned buf_size)if (cur_len) { cur_len--; -grub_printf ("\b \b" ); +/* NOTE([email protected]): +grub_printf used 3 times, because for some reason +(line wrapping I guess) if you print "\b \b" at once +the backspace key doesn't work on the second last +character. +*/ +grub_printf ("\b" ); +grub_printf (" " ); +grub_printf ("\b" ); }continue ; }
grub-core/normal/charset.c +1 -0
@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :
grub-core/term/gfxterm.c +8 -1
@@ -847,7 +847,14 @@ grub_gfxterm_putchar (struct grub_term_output *term, {case '\b' :if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; + { + virtual_screen.cursor_x--; + } +else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }break ;case '\n' :
Signature · 1 line
2.25.4
PATCH v2 1/1 password: Fix backspace in username prompt
From: Egor Ignatov <[email protected]>
Make backspace work in superuser login prompt.
The problem was that bidi logical to visual ignored BN type, so you couldn't print control characters.
Resolves: #60114
--- grub-core/normal/charset.c | 1 + grub-core/term/gfxterm.c | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-)
grub-core/normal/charset.c +1 -0
@@ -931,6 +931,7 @@ grub_bidi_line_logical_to_visual (const grub_uint32_t *logical,pop_stack ();break ;case GRUB_BIDI_TYPE_BN : + visual_len++;break ;case GRUB_BIDI_TYPE_R :case GRUB_BIDI_TYPE_AL :
grub-core/term/gfxterm.c +8 -1
@@ -847,7 +847,14 @@ grub_gfxterm_putchar (struct grub_term_output *term, {case '\b' :if (virtual_screen.cursor_x >0 ) - virtual_screen.cursor_x--; + { + virtual_screen.cursor_x--; + } +else if (virtual_screen.cursor_y >0 ) + { + virtual_screen.cursor_y--; + virtual_screen.cursor_x = virtual_screen.columns-2 ; + }break ;case '\n' :
Signature · 1 line
2.25.4