Changes in uspace/app/bdsh/cmds/modules/cat/cat.c [28a3e74:f2d665b4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/cmds/modules/cat/cat.c
r28a3e74 rf2d665b4 39 39 #include <io/color.h> 40 40 #include <io/style.h> 41 #include <io/keycode.h>42 41 #include <errno.h> 43 42 #include <vfs/vfs.h> … … 63 62 static sysarg_t console_cols = 0; 64 63 static sysarg_t console_rows = 0; 65 static bool should_quit = false;66 64 67 65 static struct option const long_options[] = { … … 104 102 console_set_pos(fphone(stdout), 0, console_rows-1); 105 103 console_set_color(fphone(stdout), COLOR_BLUE, COLOR_WHITE, 0); 106 printf("ENTER/SPACE/PAGE DOWN - next page, " 107 "ESC/Q - quit, C - continue unpaged"); 104 printf("Press any key to continue"); 108 105 fflush(stdout); 109 106 console_set_style(fphone(stdout), STYLE_NORMAL); … … 119 116 } 120 117 if (ev.type == KEY_PRESS) { 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 } 118 return; 133 119 } 134 120 } … … 164 150 { 165 151 int fd, bytes = 0, count = 0, reads = 0; 152 off64_t total = 0; 166 153 char *buff = NULL; 167 154 int i; … … 173 160 return 1; 174 161 } 162 163 total = lseek(fd, 0, SEEK_END); 164 lseek(fd, 0, SEEK_SET); 175 165 176 166 if (NULL == (buff = (char *) malloc(blen + 1))) { … … 187 177 buff[bytes] = '\0'; 188 178 offset = 0; 189 for (i = 0; i < bytes && !should_quit; i++) {179 for (i = 0; i < bytes; i++) { 190 180 if (hex) { 191 181 paged_char(hexchars[((uint8_t)buff[i])/16]); … … 195 185 wchar_t c = str_decode(buff, &offset, bytes); 196 186 if (c == 0) { 197 / * Reached end of string */187 // reached end of string 198 188 break; 199 189 } … … 204 194 reads++; 205 195 } 206 } while (bytes > 0 && !should_quit);196 } while (bytes > 0); 207 197 208 198 close(fd); … … 228 218 int rc; 229 219 230 /* 231 * reset global state 232 * TODO: move to structure? 233 */ 220 // reset global state 221 // TODO: move to structure? 234 222 paging_enabled = false; 235 223 chars_remaining = 0; … … 237 225 console_cols = 0; 238 226 console_rows = 0; 239 should_quit = false;240 227 241 228 argc = cli_count_args(argv); … … 291 278 } 292 279 293 for (i = optind; argv[i] != NULL && !should_quit; i++)280 for (i = optind; argv[i] != NULL; i++) 294 281 ret += cat_file(argv[i], buffer, hex); 295 282
Note:
See TracChangeset
for help on using the changeset viewer.