Changeset e228280 in mainline
- Timestamp:
- 2009-12-01T21:14:09Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3041fef1, 4a2aa91
- Parents:
- fd34f4e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
rfd34f4e re228280 39 39 #include <errno.h> 40 40 #include <assert.h> 41 #include <macros.h> 41 42 #include <bool.h> 42 43 … … 125 126 int i; 126 127 127 console_goto(fphone(stdout), ti->col0 + start, ti->row0); 128 console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols, 129 ti->row0 + (ti->col0 + start) / ti->con_cols); 128 130 printf("%ls", ti->buffer + start); 129 131 for (i = 0; i < pad; ++i) … … 139 141 static void tinput_position_caret(tinput_t *ti) 140 142 { 141 console_goto(fphone(stdout), ti->col0 + ti->pos, ti->row0); 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; 142 158 } 143 159 … … 145 161 { 146 162 int i; 163 int new_width, new_height; 147 164 148 165 if (ti->nc == INPUT_MAX) 149 166 return; 150 167 151 if (ti->col0 + ti->nc >= ti->con_cols - 1) 152 return; 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 } 153 175 154 176 for (i = ti->nc; i > ti->pos; --i) … … 161 183 162 184 tinput_display_tail(ti, ti->pos - 1, 0); 185 tinput_update_origin(ti); 163 186 tinput_position_caret(ti); 164 187 } … … 239 262 } 240 263 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 241 274 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir) 242 275 { … … 298 331 tinput_set_str(ti, ti->history[ti->hpos]); 299 332 tinput_display_tail(ti, 0, pad); 333 tinput_update_origin(ti); 300 334 tinput_position_caret(ti); 301 335 } … … 341 375 tinput_seek_word(ti, seek_forward); 342 376 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; 343 383 } 344 384 } … … 382 422 383 423 done: 424 ti->pos = ti->nc; 425 tinput_position_caret(ti); 384 426 putchar('\n'); 385 427
Note:
See TracChangeset
for help on using the changeset viewer.