Changes in uspace/app/bdsh/input.c [e228280:b67c7d64] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
re228280 rb67c7d64 39 39 #include <errno.h> 40 40 #include <assert.h> 41 #include <macros.h>42 41 #include <bool.h> 43 42 … … 126 125 int i; 127 126 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); 130 128 printf("%ls", ti->buffer + start); 131 129 for (i = 0; i < pad; ++i) … … 141 139 static void tinput_position_caret(tinput_t *ti) 142 140 { 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); 158 142 } 159 143 … … 161 145 { 162 146 int i; 163 int new_width, new_height;164 147 165 148 if (ti->nc == INPUT_MAX) 166 149 return; 167 150 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; 175 153 176 154 for (i = ti->nc; i > ti->pos; --i) … … 183 161 184 162 tinput_display_tail(ti, ti->pos - 1, 0); 185 tinput_update_origin(ti);186 163 tinput_position_caret(ti); 187 164 } … … 262 239 } 263 240 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 else269 ti->pos = max(0, ti->pos - ti->con_cols);270 271 tinput_position_caret(ti);272 }273 274 241 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir) 275 242 { … … 331 298 tinput_set_str(ti, ti->history[ti->hpos]); 332 299 tinput_display_tail(ti, 0, pad); 333 tinput_update_origin(ti);334 300 tinput_position_caret(ti); 335 301 } … … 356 322 ti->pos = 0; 357 323 ti->nc = 0; 358 ti->buffer[0] = '\0';359 324 360 325 while (true) { … … 375 340 tinput_seek_word(ti, seek_forward); 376 341 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;383 342 } 384 343 } … … 422 381 423 382 done: 424 ti->pos = ti->nc;425 tinput_position_caret(ti);426 383 putchar('\n'); 427 384
Note:
See TracChangeset
for help on using the changeset viewer.