Changeset 73060801 in mainline


Ignore:
Timestamp:
2010-04-04T22:02:11Z (14 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3aae4e8, ecb6ac32
Parents:
ee7e82a9 (diff), 5db9084 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge Ctrl-Q CLUI feature.

Location:
uspace
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/input.c

    ree7e82a9 r73060801  
    5050#include "errors.h"
    5151#include "exec.h"
     52
     53extern volatile unsigned int cli_quit;
    5254
    5355/** Text input field. */
     
    107109{
    108110        char *str;
     111        int rc;
    109112
    110113        fflush(stdout);
     
    114117        console_set_style(fphone(stdout), STYLE_NORMAL);
    115118
    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        }
    117131
    118132        /* Check for empty input. */
  • uspace/app/bdsh/scli.c

    ree7e82a9 r73060801  
    100100                }
    101101        }
    102         goto finit;
    103102
    104 finit:
     103        printf("Leaving %s.\n", progname);
     104
    105105        cli_finit(&usr);
    106106        return ret;
  • uspace/app/sbi/src/os/helenos.c

    ree7e82a9 r73060801  
    105105{
    106106        char *line;
     107        int rc;
    107108
    108109        if (tinput == NULL) {
     
    112113        }
    113114
    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 */
    116124                return EIO;
     125        }
    117126
    118127        /* XXX Input module needs trailing newline to keep going. */
  • uspace/lib/clui/tinput.c

    ree7e82a9 r73060801  
    513513}
    514514
    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 */
     522int tinput_read(tinput_t *ti, char **dstr)
    517523{
    518524        console_event_t ev;
     
    522528
    523529        if (console_get_size(fphone(stdin), &ti->con_cols, &ti->con_rows) != EOK)
    524                 return NULL;
     530                return EIO;
    525531        if (console_get_pos(fphone(stdin), &ti->col0, &ti->row0) != EOK)
    526                 return NULL;
     532                return EIO;
    527533
    528534        ti->pos = ti->sel_start = 0;
     
    530536        ti->buffer[0] = '\0';
    531537        ti->done = false;
     538        ti->exit_clui = false;
    532539
    533540        while (!ti->done) {
    534541                fflush(stdout);
    535542                if (!console_get_event(fphone(stdin), &ev))
    536                         return NULL;
     543                        return EIO;
    537544
    538545                if (ev.type != KEY_PRESS)
     
    565572        }
    566573
     574        if (ti->exit_clui)
     575                return ENOENT;
     576
    567577        ti->pos = ti->nc;
    568578        tinput_position_caret(ti);
     
    575585        ti->hpos = 0;
    576586
    577         return str;
     587        *dstr = str;
     588        return EOK;
    578589}
    579590
     
    606617        case KC_A:
    607618                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;
    608624                break;
    609625        default:
  • uspace/lib/clui/tinput.h

    ree7e82a9 r73060801  
    6464        /** Current position in history */
    6565        int hpos;
    66         /** Exit flag */
     66        /** @c true if finished with this line (return to caller) */
    6767        bool done;
     68        /** @c true if user requested to abort interactive loop */
     69        bool exit_clui;
    6870} tinput_t;
    6971
    7072extern tinput_t *tinput_new(void);
    7173extern void tinput_destroy(tinput_t *ti);
    72 extern char *tinput_read(tinput_t *ti);
     74extern int tinput_read(tinput_t *ti, char **str);
    7375
    7476#endif
Note: See TracChangeset for help on using the changeset viewer.