Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 68f1254c in mainline


Ignore:
Timestamp:
2018-12-30T11:49:13Z (2 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master
Children:
e8d3165e
Parents:
59cce22
Message:

Terminal/console need to handle invalid coordinates

chargrid_set_cursor asserted that arguments are valid yet they are passed
directly from client by terminal/console. Chargrid is probably best
positioned to validate the agruments so instead of assert, check
the arguments and don't do anything if they are invalid.

tinput was clearly forgetting about some cases where the screen could have
scrolled so simply call tinput_update_origin every time from
tinput_position_caret. This was happenning when the input line was
longer than one screen row and tab completion was invoked
(which caused assertion failure in chargrid).

Location:
uspace/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/io/chargrid.c

    r59cce22 r68f1254c  
    263263void chargrid_set_cursor(chargrid_t *scrbuf, sysarg_t col, sysarg_t row)
    264264{
     265        if (col >= scrbuf->cols || row >= scrbuf->rows)
     266                return;
     267
    265268        scrbuf->col = col;
    266269        scrbuf->row = row;
  • uspace/lib/clui/tinput.c

    r59cce22 r68f1254c  
    5656} seek_dir_t;
    5757
     58static void tinput_update_origin(tinput_t *);
    5859static void tinput_init(tinput_t *);
    5960static void tinput_insert_string(tinput_t *, const char *);
     
    7172static void tinput_console_set_lpos(tinput_t *ti, unsigned lpos)
    7273{
    73         console_set_pos(ti->console, LIN_TO_COL(ti, lpos),
    74             LIN_TO_ROW(ti, lpos));
     74        unsigned col = LIN_TO_COL(ti, lpos);
     75        unsigned row = LIN_TO_ROW(ti, lpos);
     76
     77        assert(col < ti->con_cols);
     78        assert(row < ti->con_rows);
     79        console_set_pos(ti->console, col, row);
    7580}
    7681
     
    163168static void tinput_position_caret(tinput_t *ti)
    164169{
     170        tinput_update_origin(ti);
    165171        tinput_console_set_lpos(ti, ti->text_coord + ti->pos);
    166172}
     
    232238
    233239        tinput_display_tail(ti, ti->pos - 1, 0);
    234         tinput_update_origin(ti);
    235240        tinput_position_caret(ti);
    236241}
     
    276281
    277282        tinput_display_tail(ti, ti->pos - ilen, 0);
    278         tinput_update_origin(ti);
    279283        tinput_position_caret(ti);
    280284}
Note: See TracChangeset for help on using the changeset viewer.