Changeset f1b37d6 in mainline
- Timestamp:
- 2009-12-05T17:13:33Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- cedd33b
- Parents:
- 2a5af223
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/input.c
r2a5af223 rf1b37d6 39 39 #include <vfs/vfs.h> 40 40 #include <clipboard.h> 41 #include <macros.h> 41 42 #include <errno.h> 42 43 #include <assert.h> … … 86 87 87 88 static char *tinput_read(tinput_t *ti); 89 static void tinput_insert_string(tinput_t *ti, const char *str); 88 90 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb); 89 91 static bool tinput_sel_active(tinput_t *ti); … … 245 247 } 246 248 249 static void tinput_insert_string(tinput_t *ti, const char *str) 250 { 251 int i; 252 int new_width, new_height; 253 int ilen; 254 wchar_t c; 255 size_t off; 256 257 ilen = min(str_length(str), INPUT_MAX - ti->nc); 258 if (ilen == 0) 259 return; 260 261 new_width = ti->col0 + ti->nc + ilen; 262 new_height = (new_width / ti->con_cols) + 1; 263 if (new_height >= ti->con_rows) 264 return; /* Disallow text longer than 1 page for now. */ 265 266 for (i = ti->nc - 1; i >= ti->pos; --i) 267 ti->buffer[i + ilen] = ti->buffer[i]; 268 269 off = 0; i = 0; 270 while (i < ilen) { 271 c = str_decode(str, &off, STR_NO_LIMIT); 272 if (c == '\0') 273 break; 274 275 /* Filter out non-printable chars. */ 276 if (c < 32) 277 c = 32; 278 279 ti->buffer[i++] = c; 280 } 281 282 ti->pos += ilen; 283 ti->nc += ilen; 284 ti->buffer[ti->nc] = '\0'; 285 ti->sel_start = ti->pos; 286 287 tinput_display_tail(ti, ti->pos - ilen, 0); 288 tinput_update_origin(ti); 289 tinput_position_caret(ti); 290 } 291 247 292 static void tinput_backspace(tinput_t *ti) 248 293 { … … 484 529 { 485 530 char *str; 486 size_t off;487 wchar_t c;488 531 int rc; 489 532 … … 492 535 return; /* TODO: Give the user some warning. */ 493 536 494 off = 0; 495 496 while (true) { 497 c = str_decode(str, &off, STR_NO_LIMIT); 498 if (c == '\0') 499 break; 500 501 tinput_insert_char(ti, c); 502 } 503 537 tinput_insert_string(ti, str); 504 538 free(str); 505 539 }
Note:
See TracChangeset
for help on using the changeset viewer.