Changes in / [4a2aa91:e866806] in mainline


Ignore:
File:
1 edited

Legend:

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

    r4a2aa91 re866806  
    3939#include <errno.h>
    4040#include <assert.h>
    41 #include <macros.h>
    4241#include <bool.h>
    4342
     
    126125        int i;
    127126
    128         console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols,
    129             ti->row0 + (ti->col0 + start) / ti->con_cols);
     127        console_goto(fphone(stdout), ti->col0 + start, ti->row0);
    130128        printf("%ls", ti->buffer + start);
    131129        for (i = 0; i < pad; ++i)
     
    141139static void tinput_position_caret(tinput_t *ti)
    142140{
    143         console_goto(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols,
    144             ti->row0 + (ti->col0 + ti->pos) / ti->con_cols);
    145 }
    146 
    147 /** Update row0 in case the screen could have scrolled. */
    148 static void tinput_update_origin(tinput_t *ti)
    149 {
    150         int width, rows;
    151 
    152         width = ti->col0 + ti->nc;
    153         rows = (width / ti->con_cols) + 1;
    154  
    155         /* Update row0 if the screen scrolled. */
    156         if (ti->row0 + rows > ti->con_rows)
    157                 ti->row0 = ti->con_rows - rows;
     141        console_goto(fphone(stdout), ti->col0 + ti->pos, ti->row0);
    158142}
    159143
     
    161145{
    162146        int i;
    163         int new_width, new_height;
    164147
    165148        if (ti->nc == INPUT_MAX)
    166149                return;
    167150
    168         new_width = ti->col0 + ti->nc + 1;
    169         if (new_width % ti->con_cols == 0) {
    170                 /* Advancing to new line. */
    171                 new_height = (new_width / ti->con_cols) + 1;
    172                 if (new_height >= ti->con_rows)
    173                         return; /* Disallow text longer than 1 page for now. */
    174         }
     151        if (ti->col0 + ti->nc >= ti->con_cols - 1)
     152                return;
    175153
    176154        for (i = ti->nc; i > ti->pos; --i)
     
    183161
    184162        tinput_display_tail(ti, ti->pos - 1, 0);
    185         tinput_update_origin(ti);
    186163        tinput_position_caret(ti);
    187164}
     
    262239}
    263240
    264 static void tinput_seek_vertical(tinput_t *ti, seek_dir_t dir)
    265 {
    266         if (dir == seek_forward)
    267                 ti->pos = min(ti->pos + ti->con_cols, ti->nc);
    268         else
    269                 ti->pos = max(0, ti->pos - ti->con_cols);
    270 
    271         tinput_position_caret(ti);
    272 }
    273 
    274241static void tinput_seek_max(tinput_t *ti, seek_dir_t dir)
    275242{
     
    331298        tinput_set_str(ti, ti->history[ti->hpos]);
    332299        tinput_display_tail(ti, 0, pad);
    333         tinput_update_origin(ti);
    334300        tinput_position_caret(ti);
    335301}
     
    356322        ti->pos = 0;
    357323        ti->nc = 0;
    358         ti->buffer[0] = '\0';
    359324
    360325        while (true) {
     
    375340                                tinput_seek_word(ti, seek_forward);
    376341                                break;
    377                         case KC_UP:
    378                                 tinput_seek_vertical(ti, seek_backward);
    379                                 break;
    380                         case KC_DOWN:
    381                                 tinput_seek_vertical(ti, seek_forward);
    382                                 break;
    383342                        }
    384343                }
     
    422381
    423382done:
    424         ti->pos = ti->nc;
    425         tinput_position_caret(ti);
    426383        putchar('\n');
    427384
Note: See TracChangeset for help on using the changeset viewer.