lineedit: trivial simplifications. -7 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
27ff681cfa
commit
9963fe36c2
@ -397,17 +397,10 @@ static void put_till_end_and_adv_cursor(void)
|
|||||||
static void goto_new_line(void)
|
static void goto_new_line(void)
|
||||||
{
|
{
|
||||||
put_till_end_and_adv_cursor();
|
put_till_end_and_adv_cursor();
|
||||||
if (cmdedit_x)
|
if (cmdedit_x != 0)
|
||||||
bb_putchar('\n');
|
bb_putchar('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void out1str(const char *s)
|
|
||||||
{
|
|
||||||
if (s)
|
|
||||||
fputs(s, stdout);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void beep(void)
|
static void beep(void)
|
||||||
{
|
{
|
||||||
bb_putchar('\007');
|
bb_putchar('\007');
|
||||||
@ -417,7 +410,7 @@ static void put_prompt(void)
|
|||||||
{
|
{
|
||||||
unsigned w;
|
unsigned w;
|
||||||
|
|
||||||
out1str(cmdedit_prompt);
|
fputs(cmdedit_prompt, stdout);
|
||||||
fflush_all();
|
fflush_all();
|
||||||
cursor = 0;
|
cursor = 0;
|
||||||
w = cmdedit_termw; /* read volatile var once */
|
w = cmdedit_termw; /* read volatile var once */
|
||||||
@ -485,9 +478,8 @@ static void input_backward(unsigned num)
|
|||||||
* up to new cursor position (which is already known):
|
* up to new cursor position (which is already known):
|
||||||
*/
|
*/
|
||||||
unsigned sv_cursor;
|
unsigned sv_cursor;
|
||||||
if (cmdedit_y > 0) /* up to start y */
|
/* go to 1st column; go up to first line */
|
||||||
printf("\033[%uA", cmdedit_y);
|
printf("\r" "\033[%uA", cmdedit_y);
|
||||||
bb_putchar('\r');
|
|
||||||
cmdedit_y = 0;
|
cmdedit_y = 0;
|
||||||
sv_cursor = cursor;
|
sv_cursor = cursor;
|
||||||
put_prompt(); /* sets cursor to 0 */
|
put_prompt(); /* sets cursor to 0 */
|
||||||
@ -509,7 +501,7 @@ static void input_backward(unsigned num)
|
|||||||
/* draw prompt, editor line, and clear tail */
|
/* draw prompt, editor line, and clear tail */
|
||||||
static void redraw(int y, int back_cursor)
|
static void redraw(int y, int back_cursor)
|
||||||
{
|
{
|
||||||
if (y > 0) /* up to start y */
|
if (y > 0) /* up y lines */
|
||||||
printf("\033[%uA", y);
|
printf("\033[%uA", y);
|
||||||
bb_putchar('\r');
|
bb_putchar('\r');
|
||||||
put_prompt();
|
put_prompt();
|
||||||
@ -1616,7 +1608,7 @@ static void ask_terminal(void)
|
|||||||
pfd.events = POLLIN;
|
pfd.events = POLLIN;
|
||||||
if (safe_poll(&pfd, 1, 0) == 0) {
|
if (safe_poll(&pfd, 1, 0) == 0) {
|
||||||
S.sent_ESC_br6n = 1;
|
S.sent_ESC_br6n = 1;
|
||||||
out1str("\033" "[6n");
|
fputs("\033" "[6n", stdout);
|
||||||
fflush_all(); /* make terminal see it ASAP! */
|
fflush_all(); /* make terminal see it ASAP! */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user