Changeset 3cefd70 in mainline for uspace/app/bdsh/cmds/modules/cat/cat.c
- Timestamp:
- 2011-03-24T21:30:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 47f7adfc
- Parents:
- 5ea37b1
- git-author:
- Martin Sucha <> (2011-03-24 21:30:41)
- git-committer:
- Jakub Jermar <jakub@…> (2011-03-24 21:30:41)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
r5ea37b1 r3cefd70 39 39 #include <io/color.h> 40 40 #include <io/style.h> 41 #include <io/keycode.h> 41 42 #include <errno.h> 42 43 #include <vfs/vfs.h> … … 62 63 static sysarg_t console_cols = 0; 63 64 static sysarg_t console_rows = 0; 65 static bool should_quit = false; 64 66 65 67 static struct option const long_options[] = { … … 102 104 console_set_pos(fphone(stdout), 0, console_rows-1); 103 105 console_set_color(fphone(stdout), COLOR_BLUE, COLOR_WHITE, 0); 104 printf("Press any key to continue"); 106 printf("ENTER/SPACE/PAGE DOWN - next page, " 107 "ESC/Q - quit, C - continue unpaged"); 105 108 fflush(stdout); 106 109 console_set_style(fphone(stdout), STYLE_NORMAL); … … 116 119 } 117 120 if (ev.type == KEY_PRESS) { 118 return; 121 if (ev.key == KC_ESCAPE || ev.key == KC_Q) { 122 should_quit = true; 123 return; 124 } 125 if (ev.key == KC_C) { 126 paging_enabled = false; 127 return; 128 } 129 if (ev.key == KC_ENTER || ev.key == KC_SPACE || 130 ev.key == KC_PAGE_DOWN) { 131 return; 132 } 119 133 } 120 134 } … … 177 191 buff[bytes] = '\0'; 178 192 offset = 0; 179 for (i = 0; i < bytes ; i++) {193 for (i = 0; i < bytes && !should_quit; i++) { 180 194 if (hex) { 181 195 paged_char(hexchars[((uint8_t)buff[i])/16]); … … 194 208 reads++; 195 209 } 196 } while (bytes > 0 );210 } while (bytes > 0 && !should_quit); 197 211 198 212 close(fd); … … 225 239 console_cols = 0; 226 240 console_rows = 0; 241 should_quit = false; 227 242 228 243 argc = cli_count_args(argv); … … 278 293 } 279 294 280 for (i = optind; argv[i] != NULL ; i++)295 for (i = optind; argv[i] != NULL && !should_quit; i++) 281 296 ret += cat_file(argv[i], buffer, hex); 282 297
Note:
See TracChangeset
for help on using the changeset viewer.