Changes in / [9904eb90:e435537] in mainline
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
r9904eb90 re435537 202 202 * 203 203 */ 204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t * 204 NO_TRACE static int cmdtab_compl(char *input, size_t size, indev_t *indev) 205 205 { 206 206 const char *name = input; 207 207 208 208 size_t found = 0; 209 /* Maximum Match Length : Length of longest matching common substring in 210 case more than one match is found */ 209 210 /* 211 * Maximum Match Length: Length of longest matching common 212 * substring in case more than one match is found. 213 */ 211 214 size_t max_match_len = size; 212 215 size_t max_match_len_tmp = size; … … 229 232 } 230 233 231 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 234 /* 235 * If the number of possible completions is more than MAX_TAB_HINTS, 236 * ask the user whether to display them or not. 237 */ 232 238 if (found > MAX_TAB_HINTS) { 233 239 printf("\n"); 234 continue_showing_hints = console_prompt_display_all_hints(indev, found); 240 continue_showing_hints = 241 console_prompt_display_all_hints(indev, found); 235 242 } 236 243 … … 240 247 while (cmdtab_search_one(name, &pos)) { 241 248 cmd_info_t *hlp = list_get_instance(pos, cmd_info_t, link); 242 249 243 250 if (continue_showing_hints) { 244 251 printf("%s (%s)\n", hlp->name, hlp->description); 245 252 --hints_to_show; 246 253 ++total_hints_shown; 247 248 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 249 continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show); 254 255 if ((hints_to_show == 0) && (total_hints_shown != found)) { 256 /* Ask user to continue */ 257 continue_showing_hints = 258 console_prompt_more_hints(indev, &hints_to_show); 250 259 } 251 260 } 252 261 253 262 pos = pos->next; 254 for(max_match_len_tmp = 0; output[max_match_len_tmp] == hlp->name[input_len + max_match_len_tmp] 255 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 263 264 for (max_match_len_tmp = 0; 265 (output[max_match_len_tmp] == 266 hlp->name[input_len + max_match_len_tmp]) && 267 (max_match_len_tmp < max_match_len); ++max_match_len_tmp); 268 256 269 max_match_len = max_match_len_tmp; 257 270 } 258 /* keep only the characters common in all completions */ 271 272 /* Keep only the characters common in all completions */ 259 273 output[max_match_len] = 0; 260 274 } … … 310 324 continue; 311 325 312 /* Find the beginning of the word 313 and copy it to tmp */ 326 /* 327 * Find the beginning of the word 328 * and copy it to tmp 329 */ 314 330 size_t beg; 315 331 for (beg = position - 1; (beg > 0) && (!isspace(current[beg])); … … 333 349 continue; 334 350 335 /* We have hints, may be many. In case of more than one hint, 336 tmp will contain the common prefix. */ 351 /* 352 * We have hints, possibly many. In case of more than one hint, 353 * tmp will contain the common prefix. 354 */ 337 355 size_t off = 0; 338 356 size_t i = 0; … … 340 358 if (!wstr_linsert(current, ch, position + i, MAX_CMDLINE)) 341 359 break; 360 342 361 i++; 343 362 } -
kernel/generic/src/console/prompt.c
r9904eb90 re435537 43 43 * @param indev Where to read characters from. 44 44 * @param hints Number of hints that would be displayed. 45 * 45 46 * @return Whether to print all hints. 47 * 46 48 */ 47 49 bool console_prompt_display_all_hints(indev_t *indev, size_t hints) … … 49 51 ASSERT(indev); 50 52 ASSERT(hints > 0); 51 52 printf("Display all %zu possibilities? (y or n) ", hints);53 53 54 printf("Display all %zu possibilities? (y or n) ", hints); 55 54 56 while (true) { 55 57 wchar_t answer = indev_pop_character(indev); 56 57 if ( answer == 'y' || answer == 'Y') {58 printf(" 58 59 if ((answer == 'y') || (answer == 'Y')) { 60 printf("y"); 59 61 return true; 60 62 } 61 62 if ( answer == 'n' || answer == 'N') {63 printf(" 63 64 if ((answer == 'n') || (answer == 'N')) { 65 printf("n"); 64 66 return false; 65 67 } … … 71 73 * When the function returns false, @p display_hints is set to zero. 72 74 * 73 * @param[in] indevWhere to read characters from.75 * @param[in] indev Where to read characters from. 74 76 * @param[out] display_hints How many hints to display. 77 * 75 78 * @return Whether to display more hints. 79 * 76 80 */ 77 81 bool console_prompt_more_hints(indev_t *indev, size_t *display_hints) … … 79 83 ASSERT(indev); 80 84 ASSERT(display_hints != NULL); 81 85 82 86 printf("--More--"); 83 87 while (true) { 84 88 wchar_t continue_showing_hints = indev_pop_character(indev); 85 89 /* Display a full page again? */ 86 if ( continue_showing_hints == 'y'87 || continue_showing_hints == 'Y'88 || continue_showing_hints == ' ') {90 if ((continue_showing_hints == 'y') || 91 (continue_showing_hints == 'Y') || 92 (continue_showing_hints == ' ')) { 89 93 *display_hints = MAX_TAB_HINTS - 1; 90 94 break; 91 95 } 92 96 93 97 /* Stop displaying hints? */ 94 if ( continue_showing_hints == 'n'95 || continue_showing_hints == 'N'96 || continue_showing_hints == 'q'97 || continue_showing_hints == 'Q') {98 if ((continue_showing_hints == 'n') || 99 (continue_showing_hints == 'N') || 100 (continue_showing_hints == 'q') || 101 (continue_showing_hints == 'Q')) { 98 102 *display_hints = 0; 99 103 break; 100 104 } 101 105 102 106 /* Show one more hint? */ 103 107 if (continue_showing_hints == '\n') { … … 106 110 } 107 111 } 108 112 109 113 /* Delete the --More-- option */ 110 114 printf("\r \r"); 111 115 112 116 return *display_hints > 0; 113 117 } -
kernel/generic/src/debug/symtab.c
r9904eb90 re435537 210 210 * 211 211 */ 212 int symtab_compl(char *input, size_t size, indev_t * 212 int symtab_compl(char *input, size_t size, indev_t *indev) 213 213 { 214 214 #ifdef CONFIG_SYMTAB … … 227 227 const char *hint; 228 228 char output[MAX_SYMBOL_NAME]; 229 /* Maximum Match Length : Length of longest matching common substring in 230 case more than one match is found */ 229 230 /* 231 * Maximum Match Length: Length of longest matching common substring in 232 * case more than one match is found. 233 */ 231 234 size_t max_match_len = size; 232 235 size_t max_match_len_tmp = size; … … 238 241 239 242 output[0] = 0; 240 241 while ((hint = symtab_search_one(name, &pos))) { 242 ++pos; 243 } 244 243 244 while ((hint = symtab_search_one(name, &pos))) 245 pos++; 246 245 247 pos = 0; 246 248 … … 253 255 } 254 256 255 /* If possible completions are more than MAX_TAB_HINTS, ask user whether to display them or not. */ 257 /* 258 * If the number of possible completions is more than MAX_TAB_HINTS, 259 * ask the user whether to display them or not. 260 */ 256 261 if (found > MAX_TAB_HINTS) { 257 262 printf("\n"); 258 continue_showing_hints = console_prompt_display_all_hints(indev, found); 263 continue_showing_hints = 264 console_prompt_display_all_hints(indev, found); 259 265 } 260 266 … … 265 271 sym_name = symbol_table[pos].symbol_name; 266 272 pos++; 267 268 if (continue_showing_hints) { /* We are still showing hints */ 273 274 if (continue_showing_hints) { 275 /* We are still showing hints */ 269 276 printf("%s\n", sym_name); 270 277 --hints_to_show; 271 278 ++total_hints_shown; 272 273 if (hints_to_show == 0 && total_hints_shown != found) { /* Time to ask user to continue */ 274 continue_showing_hints = console_prompt_more_hints(indev, &hints_to_show); 279 280 if ((hints_to_show == 0) && (total_hints_shown != found)) { 281 /* Ask the user to continue */ 282 continue_showing_hints = 283 console_prompt_more_hints(indev, &hints_to_show); 275 284 } 276 285 } 277 278 for(max_match_len_tmp = 0; output[max_match_len_tmp] == sym_name[input_len + max_match_len_tmp] 279 && max_match_len_tmp < max_match_len; ++max_match_len_tmp); 286 287 for (max_match_len_tmp = 0; 288 (output[max_match_len_tmp] == 289 sym_name[input_len + max_match_len_tmp]) && 290 (max_match_len_tmp < max_match_len); ++max_match_len_tmp); 291 280 292 max_match_len = max_match_len_tmp; 281 293 } 282 /* keep only the characters common in all completions */ 294 295 /* Keep only the characters common in all completions */ 283 296 output[max_match_len] = 0; 284 297 } -
uspace/app/bdsh/cmds/modules/cat/cat.c
r9904eb90 re435537 176 176 177 177 bool reading_stdin = dash_represents_stdin && (str_cmp(fname, "-") == 0); 178 178 179 179 if (reading_stdin) { 180 180 fd = fileno(stdin); 181 181 /* Allow storing the whole UTF-8 character. */ 182 182 blen = STR_BOUNDS(1); 183 } else {183 } else 184 184 fd = open(fname, O_RDONLY); 185 }185 186 186 if (fd < 0) { 187 187 printf("Unable to open %s\n", fname); … … 222 222 bytes_to_read = 1; 223 223 } else { 224 if ((length != CAT_FULL_FILE) 225 &&(length - (off64_t)count <= (off64_t)(blen - copied_bytes))) {224 if ((length != CAT_FULL_FILE) && 225 (length - (off64_t)count <= (off64_t)(blen - copied_bytes))) { 226 226 bytes_to_read = (size_t) (length - count); 227 227 } else { … … 229 229 } 230 230 } 231 231 232 bytes = read(fd, buff + copied_bytes, bytes_to_read); 232 233 bytes += copied_bytes; … … 261 262 reads++; 262 263 } 263 264 if (reading_stdin) {264 265 if (reading_stdin) 265 266 fflush(stdout); 266 }267 267 } while (bytes > 0 && !should_quit && (count < length || length == CAT_FULL_FILE)); 268 268 -
uspace/srv/hid/console/console.c
r9904eb90 re435537 617 617 618 618 size_t pos = 0; 619 619 620 620 /* 621 621 * Read input from keyboard and copy it to the buffer. … … 628 628 buf[pos] = cons->char_remains[0]; 629 629 pos++; 630 630 631 /* Unshift the array. */ 631 for (size_t i = 1; i < cons->char_remains_len; i++) {632 for (size_t i = 1; i < cons->char_remains_len; i++) 632 633 cons->char_remains[i - 1] = cons->char_remains[i]; 633 }634 634 635 cons->char_remains_len--; 635 636 } 637 636 638 /* Still not enough? Then get another key from the queue. */ 637 639 if (pos < size) { 638 640 link_t *link = prodcons_consume(&cons->input_pc); 639 641 kbd_event_t *event = list_get_instance(link, kbd_event_t, link); 640 642 641 643 /* Accept key presses of printable chars only. */ 642 644 if ((event->type == KEY_PRESS) && (event->c != 0)) { … … 645 647 cons->char_remains_len = str_size(cons->char_remains); 646 648 } 647 649 648 650 free(event); 649 651 }
Note:
See TracChangeset
for help on using the changeset viewer.