Changes in / [ee7e82a9:73060801] in mainline
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
ree7e82a9 r73060801 50 50 #include "errors.h" 51 51 #include "exec.h" 52 53 extern volatile unsigned int cli_quit; 52 54 53 55 /** Text input field. */ … … 107 109 { 108 110 char *str; 111 int rc; 109 112 110 113 fflush(stdout); … … 114 117 console_set_style(fphone(stdout), STYLE_NORMAL); 115 118 116 str = tinput_read(tinput); 119 rc = tinput_read(tinput, &str); 120 if (rc == ENOENT) { 121 /* User requested exit */ 122 cli_quit = 1; 123 putchar('\n'); 124 return; 125 } 126 127 if (rc != EOK) { 128 /* Error in communication with console */ 129 return; 130 } 117 131 118 132 /* Check for empty input. */ -
uspace/app/bdsh/scli.c
ree7e82a9 r73060801 100 100 } 101 101 } 102 goto finit;103 102 104 finit: 103 printf("Leaving %s.\n", progname); 104 105 105 cli_finit(&usr); 106 106 return ret; -
uspace/app/sbi/src/os/helenos.c
ree7e82a9 r73060801 105 105 { 106 106 char *line; 107 int rc; 107 108 108 109 if (tinput == NULL) { … … 112 113 } 113 114 114 line = tinput_read(tinput); 115 if (line == NULL) 115 rc = tinput_read(tinput, &line); 116 if (rc == ENOENT) { 117 /* User-requested abort */ 118 *ptr = os_str_dup(""); 119 return EOK; 120 } 121 122 if (rc != EOK) { 123 /* Error in communication with console */ 116 124 return EIO; 125 } 117 126 118 127 /* XXX Input module needs trailing newline to keep going. */ -
uspace/lib/clui/tinput.c
ree7e82a9 r73060801 513 513 } 514 514 515 /** Read in one line of input. */ 516 char *tinput_read(tinput_t *ti) 515 /** Read in one line of input. 516 * 517 * @param ti Text input. 518 * @param dstr Place to save pointer to new string. 519 * @return EOK on success, ENOENT if user requested abort, EIO 520 * if communication with console failed. 521 */ 522 int tinput_read(tinput_t *ti, char **dstr) 517 523 { 518 524 console_event_t ev; … … 522 528 523 529 if (console_get_size(fphone(stdin), &ti->con_cols, &ti->con_rows) != EOK) 524 return NULL;530 return EIO; 525 531 if (console_get_pos(fphone(stdin), &ti->col0, &ti->row0) != EOK) 526 return NULL;532 return EIO; 527 533 528 534 ti->pos = ti->sel_start = 0; … … 530 536 ti->buffer[0] = '\0'; 531 537 ti->done = false; 538 ti->exit_clui = false; 532 539 533 540 while (!ti->done) { 534 541 fflush(stdout); 535 542 if (!console_get_event(fphone(stdin), &ev)) 536 return NULL;543 return EIO; 537 544 538 545 if (ev.type != KEY_PRESS) … … 565 572 } 566 573 574 if (ti->exit_clui) 575 return ENOENT; 576 567 577 ti->pos = ti->nc; 568 578 tinput_position_caret(ti); … … 575 585 ti->hpos = 0; 576 586 577 return str; 587 *dstr = str; 588 return EOK; 578 589 } 579 590 … … 606 617 case KC_A: 607 618 tinput_sel_all(ti); 619 break; 620 case KC_Q: 621 /* Signal libary client to quit interactive loop. */ 622 ti->done = true; 623 ti->exit_clui = true; 608 624 break; 609 625 default: -
uspace/lib/clui/tinput.h
ree7e82a9 r73060801 64 64 /** Current position in history */ 65 65 int hpos; 66 /** Exit flag*/66 /** @c true if finished with this line (return to caller) */ 67 67 bool done; 68 /** @c true if user requested to abort interactive loop */ 69 bool exit_clui; 68 70 } tinput_t; 69 71 70 72 extern tinput_t *tinput_new(void); 71 73 extern void tinput_destroy(tinput_t *ti); 72 extern char *tinput_read(tinput_t *ti);74 extern int tinput_read(tinput_t *ti, char **str); 73 75 74 76 #endif
Note:
See TracChangeset
for help on using the changeset viewer.