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