mirror of
https://github.com/sheumann/hush.git
synced 2024-07-04 21:29:34 +00:00
Fix problems with editing of commands that extend to multiple lines.
This commit is contained in:
parent
038f37f9eb
commit
4f7d95d896
@ -135,8 +135,6 @@ char *right_cmd = ESC"[C";
|
|||||||
char *clear_to_end_of_screen_cmd = ESC"[J";
|
char *clear_to_end_of_screen_cmd = ESC"[J";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool automargin; /* Does terminal have automatic margins? */
|
|
||||||
|
|
||||||
char termcap_string_buf[TERMCAP_BUFSIZ];
|
char termcap_string_buf[TERMCAP_BUFSIZ];
|
||||||
|
|
||||||
/* Terminal escape sequences to process in input (used by read_key) */
|
/* Terminal escape sequences to process in input (used by read_key) */
|
||||||
@ -269,8 +267,6 @@ void init_termcap(void)
|
|||||||
return;
|
return;
|
||||||
tgetent(termcap_buffer, term);
|
tgetent(termcap_buffer, term);
|
||||||
|
|
||||||
automargin = tgetflag("am");
|
|
||||||
|
|
||||||
result = tgetstr("up", &string_buf);
|
result = tgetstr("up", &string_buf);
|
||||||
if (result != NULL)
|
if (result != NULL)
|
||||||
up_cmd = result;
|
up_cmd = result;
|
||||||
@ -474,10 +470,8 @@ static void put_cur_glyph_and_inc_cursor(void)
|
|||||||
* have automargin (IOW: it is moving cursor to next line
|
* have automargin (IOW: it is moving cursor to next line
|
||||||
* by itself (which is wrong for VT-10x terminals)),
|
* by itself (which is wrong for VT-10x terminals)),
|
||||||
* this will break things: there will be one extra empty line */
|
* this will break things: there will be one extra empty line */
|
||||||
if (!automargin) {
|
|
||||||
bb_putchar_binary('\r');
|
bb_putchar_binary('\r');
|
||||||
bb_putchar_binary('\n');
|
bb_putchar_binary('\n');
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
/* VT-10x terminals don't wrap cursor to next line when last char
|
/* VT-10x terminals don't wrap cursor to next line when last char
|
||||||
* on the line is printed - cursor stays "over" this char.
|
* on the line is printed - cursor stays "over" this char.
|
||||||
@ -592,6 +586,7 @@ static void input_backward(unsigned num)
|
|||||||
*/
|
*/
|
||||||
unsigned sv_cursor;
|
unsigned sv_cursor;
|
||||||
/* go to 1st column; go up to first line */
|
/* go to 1st column; go up to first line */
|
||||||
|
bb_putchar_binary('\r');
|
||||||
go_up(cmdedit_y);
|
go_up(cmdedit_y);
|
||||||
cmdedit_y = 0;
|
cmdedit_y = 0;
|
||||||
sv_cursor = cursor;
|
sv_cursor = cursor;
|
||||||
@ -609,13 +604,14 @@ static void input_backward(unsigned num)
|
|||||||
cmdedit_x = (width * cmdedit_y - num) % width;
|
cmdedit_x = (width * cmdedit_y - num) % width;
|
||||||
cmdedit_y -= lines_up;
|
cmdedit_y -= lines_up;
|
||||||
/* go to 1st column; go up */
|
/* go to 1st column; go up */
|
||||||
|
bb_putchar_binary('\r');
|
||||||
go_up(lines_up);
|
go_up(lines_up);
|
||||||
/* go to correct column.
|
/* go to correct column.
|
||||||
* xterm, konsole, Linux VT interpret 0 as 1 below! wow.
|
* xterm, konsole, Linux VT interpret 0 as 1 below! wow.
|
||||||
* need to *make sure* we skip it if cmdedit_x == 0 */
|
* need to *make sure* we skip it if cmdedit_x == 0 */
|
||||||
if (cmdedit_x) {
|
if (cmdedit_x) {
|
||||||
int cols_right;
|
int cols_right;
|
||||||
for (cols_right = cmdedit_x; cols_right > 0; cols_right++) {
|
for (cols_right = cmdedit_x; cols_right > 0; cols_right--) {
|
||||||
tputs(right_cmd, 1, bb_putchar);
|
tputs(right_cmd, 1, bb_putchar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user