Changeset 3b3e776 in mainline for uspace/app
- Timestamp:
- 2010-02-05T10:57:50Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0358da0
- Parents:
- 3f085132 (diff), b4cbef1 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/app
- Files:
-
- 17 added
- 14 deleted
- 24 edited
- 9 moved
-
Makefile.common (moved) (moved from uspace/srv/dd/Makefile.build ) (2 diffs)
-
bdsh/Makefile (modified) (1 diff)
-
bdsh/Makefile.build (deleted)
-
bdsh/cmds/modules/ls/ls.c (modified) (1 diff)
-
bdsh/cmds/modules/mkfile/entry.h (added)
-
bdsh/cmds/modules/mkfile/mkfile.c (added)
-
bdsh/cmds/modules/mkfile/mkfile.h (added)
-
bdsh/cmds/modules/mkfile/mkfile_def.h (added)
-
bdsh/cmds/modules/module_aliases.h (modified) (1 diff)
-
bdsh/cmds/modules/modules.h (modified) (4 diffs)
-
bdsh/cmds/modules/unmount/entry.h (added)
-
bdsh/cmds/modules/unmount/unmount.c (added)
-
bdsh/cmds/modules/unmount/unmount.h (added)
-
bdsh/cmds/modules/unmount/unmount_def.h (added)
-
bdsh/input.c (modified) (4 diffs)
-
bdsh/input.h (modified) (1 diff)
-
bdsh/scli.c (modified) (1 diff)
-
edit/Makefile (modified) (1 diff)
-
edit/edit.c (modified) (28 diffs)
-
getterm/Makefile (moved) (moved from uspace/app/redir/Makefile.common ) (2 diffs)
-
getterm/Makefile.build (moved) (moved from uspace/app/getvc/Makefile.build )
-
getterm/Makefile.common (moved) (moved from uspace/app/getvc/Makefile.common )
-
getterm/getterm.c (moved) (moved from uspace/app/getvc/getvc.c ) (2 diffs)
-
getterm/getterm.h (moved) (moved from uspace/app/getvc/getvc.h ) (2 diffs)
-
getterm/version.c (moved) (moved from uspace/app/getvc/version.c ) (3 diffs)
-
getterm/version.h (moved) (moved from uspace/app/getvc/version.h ) (2 diffs)
-
init/Makefile (modified) (1 diff)
-
init/Makefile.build (deleted)
-
init/init.c (modified) (10 diffs)
-
init/init.h (modified) (1 diff)
-
klog/Makefile (modified) (1 diff)
-
klog/Makefile.build (deleted)
-
mkfat/Makefile (moved) (moved from uspace/app/bdsh/Makefile.common ) (2 diffs)
-
mkfat/fat.h (added)
-
mkfat/mkfat.c (added)
-
redir/Makefile (modified) (1 diff)
-
redir/Makefile.build (deleted)
-
shutters/Makefile (modified) (1 diff)
-
shutters/Makefile.build (deleted)
-
shutters/Makefile.common (deleted)
-
taskdump/Makefile (added)
-
taskdump/include/elf.h (added)
-
taskdump/include/symtab.h (added)
-
taskdump/symtab.c (added)
-
taskdump/taskdump.c (added)
-
test_serial/Makefile (modified) (1 diff)
-
test_serial/Makefile.build (deleted)
-
test_serial/Makefile.common (deleted)
-
tester/Makefile (modified) (1 diff)
-
tester/Makefile.build (deleted)
-
tester/Makefile.common (deleted)
-
tester/fault/fault3.c (added)
-
tester/fault/fault3.def (added)
-
tester/tester.c (modified) (1 diff)
-
tester/tester.h (modified) (1 diff)
-
tester/vfs/vfs1.c (modified) (1 diff)
-
tetris/Makefile (modified) (1 diff)
-
tetris/Makefile.build (deleted)
-
tetris/Makefile.common (deleted)
-
trace/Makefile (modified) (1 diff)
-
trace/Makefile.build (deleted)
-
trace/Makefile.common (deleted)
-
trace/ipcp.c (modified) (4 diffs)
-
trace/trace.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/Makefile.common
r3f085132 r3b3e776 28 28 # 29 29 30 ## Setup toolchain30 ## Common rules for building apps. 31 31 # 32 32 33 include Makefile.common 34 include $(LIBC_PREFIX)/Makefile.toolchain 35 36 ## Sources 33 # Individual makefiles set: 34 # 35 # USPACE_PREFIX relative path to uspace/ directory 36 # LIBS libraries to link with (with relative path) 37 # EXTRA_CFLAGS additional flags to pass to C compiler 38 # JOB job file name (like appname.job) 39 # OUTPUT output binary name (like appname) 40 # SOURCES list of source files 37 41 # 38 42 39 SOURCES = \ 40 main.c \ 41 pic.c \ 42 pci.c \ 43 intel_piix3.c \ 44 isa.c \ 45 serial.c 43 DEPEND = Makefile.depend 44 DEPEND_PREV = $(DEPEND).prev 46 45 47 ifeq ($(PROCESSOR), us) 48 SOURCES += psycho.c 49 endif 46 LIBC_PREFIX = $(USPACE_PREFIX)/lib/libc 47 LIBBLOCK_PREFIX = $(USPACE_PREFIX)/lib/libblock 48 SOFTINT_PREFIX = $(USPACE_PREFIX)/lib/softint 50 49 51 ifeq ($(UARCH), ia32) 52 SOURCES += intel_method1.c 53 endif 54 50 JOB = $(OUTPUT).job 55 51 56 52 OBJECTS := $(addsuffix .o,$(basename $(SOURCES))) 57 53 58 .PHONY: all 54 include $(LIBC_PREFIX)/Makefile.toolchain 59 55 60 all: $(OUTPUT) $(OUTPUT).disasm 56 CFLAGS += $(EXTRA_CFLAGS) 57 58 .PHONY: all build clean 59 60 all: \ 61 $(LIBC_PREFIX)/../../../version \ 62 $(LIBC_PREFIX)/../../../Makefile.config \ 63 $(LIBC_PREFIX)/../../../config.h \ 64 $(LIBC_PREFIX)/../../../config.defs \ 65 $(LIBS) \ 66 \ 67 $(OUTPUT) $(OUTPUT).disasm 68 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 69 70 clean: 71 rm -f $(DEPEND) $(DEPEND_PREV) $(JOB) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 72 find . -name '*.o' -follow -exec rm \{\} \; 73 74 build: 61 75 62 76 -include $(DEPEND) … … 70 84 %.o: %.c $(DEPEND) 71 85 $(CC) $(DEFS) $(CFLAGS) -c $< -o $@ 86 ifeq ($(PRECHECK),y) 87 $(JOBFILE) $(JOB) $< $@ cc core $(DEFS) $(CFLAGS) 88 endif 72 89 73 90 $(DEPEND): -
uspace/app/bdsh/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I. -Icmds/ -Icmds/builtins -Icmds/modules 31 33 32 .PHONY: all clean 34 OUTPUT = bdsh 33 35 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 36 SOURCES = \ 37 cmds/modules/help/help.c \ 38 cmds/modules/mkdir/mkdir.c \ 39 cmds/modules/mkfile/mkfile.c \ 40 cmds/modules/rm/rm.c \ 41 cmds/modules/bdd/bdd.c \ 42 cmds/modules/cat/cat.c \ 43 cmds/modules/touch/touch.c \ 44 cmds/modules/ls/ls.c \ 45 cmds/modules/pwd/pwd.c \ 46 cmds/modules/sleep/sleep.c \ 47 cmds/modules/cp/cp.c \ 48 cmds/modules/mv/mv.c \ 49 cmds/modules/mount/mount.c \ 50 cmds/modules/unmount/unmount.c \ 51 cmds/modules/kcon/kcon.c \ 52 cmds/builtins/exit/exit.c \ 53 cmds/builtins/cd/cd.c \ 54 cmds/mod_cmds.c \ 55 cmds/builtin_cmds.c \ 56 errors.c \ 57 input.c \ 58 util.c \ 59 exec.c \ 60 scli.c 37 61 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 62 include ../Makefile.common -
uspace/app/bdsh/cmds/modules/ls/ls.c
r3f085132 r3b3e776 100 100 if (s.is_file) 101 101 printf("%-40s\t%llu\n", name, (long long) s.size); 102 else if (s.is_directory) 103 printf("%-40s\t<dir>\n", name); 102 104 else 103 105 printf("%-40s\n", name); -
uspace/app/bdsh/cmds/modules/module_aliases.h
r3f085132 r3b3e776 14 14 char *mod_aliases[] = { 15 15 "ren", "mv", 16 "umount", "unmount", 16 17 NULL, NULL 17 18 }; -
uspace/app/bdsh/cmds/modules/modules.h
r3f085132 r3b3e776 20 20 #include "help/entry.h" 21 21 #include "mkdir/entry.h" 22 #include "mkfile/entry.h" 22 23 #include "rm/entry.h" 23 24 #include "bdd/entry.h" … … 30 31 #include "mv/entry.h" 31 32 #include "mount/entry.h" 33 #include "unmount/entry.h" 32 34 #include "kcon/entry.h" 33 35 … … 39 41 #include "help/help_def.h" 40 42 #include "mkdir/mkdir_def.h" 43 #include "mkfile/mkfile_def.h" 41 44 #include "rm/rm_def.h" 42 45 #include "bdd/bdd_def.h" … … 49 52 #include "mv/mv_def.h" 50 53 #include "mount/mount_def.h" 54 #include "unmount/unmount_def.h" 51 55 #include "kcon/kcon_def.h" 52 56 -
uspace/app/bdsh/input.c
r3f085132 r3b3e776 36 36 #include <io/keycode.h> 37 37 #include <io/style.h> 38 #include <io/color.h> 38 39 #include <vfs/vfs.h> 40 #include <clipboard.h> 41 #include <macros.h> 39 42 #include <errno.h> 43 #include <assert.h> 40 44 #include <bool.h> 41 45 … … 47 51 #include "exec.h" 48 52 49 static void read_line(char *, int); 53 #define HISTORY_LEN 10 54 55 /** Text input field. */ 56 typedef struct { 57 /** Buffer holding text currently being edited */ 58 wchar_t buffer[INPUT_MAX + 1]; 59 /** Screen coordinates of the top-left corner of the text field */ 60 int col0, row0; 61 /** Screen dimensions */ 62 int con_cols, con_rows; 63 /** Number of characters in @c buffer */ 64 int nc; 65 /** Caret position within buffer */ 66 int pos; 67 /** Selection mark position within buffer */ 68 int sel_start; 69 70 /** History (dynamically allocated strings) */ 71 char *history[1 + HISTORY_LEN]; 72 /** Number of entries in @c history, not counting [0] */ 73 int hnum; 74 /** Current position in history */ 75 int hpos; 76 /** Exit flag */ 77 bool done; 78 } tinput_t; 79 80 /** Seek direction */ 81 typedef enum { 82 seek_backward = -1, 83 seek_forward = 1 84 } seek_dir_t; 85 86 static tinput_t tinput; 87 88 static char *tinput_read(tinput_t *ti); 89 static void tinput_insert_string(tinput_t *ti, const char *str); 90 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb); 91 static bool tinput_sel_active(tinput_t *ti); 92 static void tinput_sel_all(tinput_t *ti); 93 static void tinput_sel_delete(tinput_t *ti); 94 static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev); 95 static void tinput_key_shift(tinput_t *ti, console_event_t *ev); 96 static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev); 97 static void tinput_key_unmod(tinput_t *ti, console_event_t *ev); 98 static void tinput_pre_seek(tinput_t *ti, bool shift_held); 99 static void tinput_post_seek(tinput_t *ti, bool shift_held); 50 100 51 101 /* Tokenizes input from console, sees if the first word is a built-in, if so … … 99 149 } 100 150 101 static void read_line(char *buffer, int n) 151 static void tinput_display_tail(tinput_t *ti, int start, int pad) 152 { 153 static wchar_t dbuf[INPUT_MAX + 1]; 154 int sa, sb; 155 int i, p; 156 157 tinput_sel_get_bounds(ti, &sa, &sb); 158 159 console_goto(fphone(stdout), (ti->col0 + start) % ti->con_cols, 160 ti->row0 + (ti->col0 + start) / ti->con_cols); 161 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 162 163 p = start; 164 if (p < sa) { 165 memcpy(dbuf, ti->buffer + p, (sa - p) * sizeof(wchar_t)); 166 dbuf[sa - p] = '\0'; 167 printf("%ls", dbuf); 168 p = sa; 169 } 170 171 if (p < sb) { 172 fflush(stdout); 173 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_RED, 0); 174 memcpy(dbuf, ti->buffer + p, 175 (sb - p) * sizeof(wchar_t)); 176 dbuf[sb - p] = '\0'; 177 printf("%ls", dbuf); 178 p = sb; 179 } 180 181 fflush(stdout); 182 console_set_color(fphone(stdout), COLOR_BLACK, COLOR_WHITE, 0); 183 184 if (p < ti->nc) { 185 memcpy(dbuf, ti->buffer + p, 186 (ti->nc - p) * sizeof(wchar_t)); 187 dbuf[ti->nc - p] = '\0'; 188 printf("%ls", dbuf); 189 } 190 191 for (i = 0; i < pad; ++i) 192 putchar(' '); 193 fflush(stdout); 194 } 195 196 static char *tinput_get_str(tinput_t *ti) 197 { 198 return wstr_to_astr(ti->buffer); 199 } 200 201 static void tinput_position_caret(tinput_t *ti) 202 { 203 console_goto(fphone(stdout), (ti->col0 + ti->pos) % ti->con_cols, 204 ti->row0 + (ti->col0 + ti->pos) / ti->con_cols); 205 } 206 207 /** Update row0 in case the screen could have scrolled. */ 208 static void tinput_update_origin(tinput_t *ti) 209 { 210 int width, rows; 211 212 width = ti->col0 + ti->nc; 213 rows = (width / ti->con_cols) + 1; 214 215 /* Update row0 if the screen scrolled. */ 216 if (ti->row0 + rows > ti->con_rows) 217 ti->row0 = ti->con_rows - rows; 218 } 219 220 static void tinput_insert_char(tinput_t *ti, wchar_t c) 221 { 222 int i; 223 int new_width, new_height; 224 225 if (ti->nc == INPUT_MAX) 226 return; 227 228 new_width = ti->col0 + ti->nc + 1; 229 if (new_width % ti->con_cols == 0) { 230 /* Advancing to new line. */ 231 new_height = (new_width / ti->con_cols) + 1; 232 if (new_height >= ti->con_rows) 233 return; /* Disallow text longer than 1 page for now. */ 234 } 235 236 for (i = ti->nc; i > ti->pos; --i) 237 ti->buffer[i] = ti->buffer[i - 1]; 238 239 ti->buffer[ti->pos] = c; 240 ti->pos += 1; 241 ti->nc += 1; 242 ti->buffer[ti->nc] = '\0'; 243 ti->sel_start = ti->pos; 244 245 tinput_display_tail(ti, ti->pos - 1, 0); 246 tinput_update_origin(ti); 247 tinput_position_caret(ti); 248 } 249 250 static void tinput_insert_string(tinput_t *ti, const char *str) 251 { 252 int i; 253 int new_width, new_height; 254 int ilen; 255 wchar_t c; 256 size_t off; 257 258 ilen = min((ssize_t) str_length(str), INPUT_MAX - ti->nc); 259 if (ilen == 0) 260 return; 261 262 new_width = ti->col0 + ti->nc + ilen; 263 new_height = (new_width / ti->con_cols) + 1; 264 if (new_height >= ti->con_rows) 265 return; /* Disallow text longer than 1 page for now. */ 266 267 for (i = ti->nc - 1; i >= ti->pos; --i) 268 ti->buffer[i + ilen] = ti->buffer[i]; 269 270 off = 0; i = 0; 271 while (i < ilen) { 272 c = str_decode(str, &off, STR_NO_LIMIT); 273 if (c == '\0') 274 break; 275 276 /* Filter out non-printable chars. */ 277 if (c < 32) 278 c = 32; 279 280 ti->buffer[ti->pos + i] = c; 281 ++i; 282 } 283 284 ti->pos += ilen; 285 ti->nc += ilen; 286 ti->buffer[ti->nc] = '\0'; 287 ti->sel_start = ti->pos; 288 289 tinput_display_tail(ti, ti->pos - ilen, 0); 290 tinput_update_origin(ti); 291 tinput_position_caret(ti); 292 } 293 294 static void tinput_backspace(tinput_t *ti) 295 { 296 int i; 297 298 if (tinput_sel_active(ti)) { 299 tinput_sel_delete(ti); 300 return; 301 } 302 303 if (ti->pos == 0) 304 return; 305 306 for (i = ti->pos; i < ti->nc; ++i) 307 ti->buffer[i - 1] = ti->buffer[i]; 308 ti->pos -= 1; 309 ti->nc -= 1; 310 ti->buffer[ti->nc] = '\0'; 311 ti->sel_start = ti->pos; 312 313 tinput_display_tail(ti, ti->pos, 1); 314 tinput_position_caret(ti); 315 } 316 317 static void tinput_delete(tinput_t *ti) 318 { 319 if (tinput_sel_active(ti)) { 320 tinput_sel_delete(ti); 321 return; 322 } 323 324 if (ti->pos == ti->nc) 325 return; 326 327 ti->pos += 1; 328 ti->sel_start = ti->pos; 329 330 tinput_backspace(ti); 331 } 332 333 static void tinput_seek_cell(tinput_t *ti, seek_dir_t dir, bool shift_held) 334 { 335 tinput_pre_seek(ti, shift_held); 336 337 if (dir == seek_forward) { 338 if (ti->pos < ti->nc) 339 ti->pos += 1; 340 } else { 341 if (ti->pos > 0) 342 ti->pos -= 1; 343 } 344 345 tinput_post_seek(ti, shift_held); 346 } 347 348 static void tinput_seek_word(tinput_t *ti, seek_dir_t dir, bool shift_held) 349 { 350 tinput_pre_seek(ti, shift_held); 351 352 if (dir == seek_forward) { 353 if (ti->pos == ti->nc) 354 return; 355 356 while (1) { 357 ti->pos += 1; 358 359 if (ti->pos == ti->nc) 360 break; 361 362 if (ti->buffer[ti->pos - 1] == ' ' && 363 ti->buffer[ti->pos] != ' ') 364 break; 365 } 366 } else { 367 if (ti->pos == 0) 368 return; 369 370 while (1) { 371 ti->pos -= 1; 372 373 if (ti->pos == 0) 374 break; 375 376 if (ti->buffer[ti->pos - 1] == ' ' && 377 ti->buffer[ti->pos] != ' ') 378 break; 379 } 380 381 } 382 383 tinput_post_seek(ti, shift_held); 384 } 385 386 static void tinput_seek_vertical(tinput_t *ti, seek_dir_t dir, bool shift_held) 387 { 388 tinput_pre_seek(ti, shift_held); 389 390 if (dir == seek_forward) { 391 if (ti->pos + ti->con_cols <= ti->nc) 392 ti->pos = ti->pos + ti->con_cols; 393 } else { 394 if (ti->pos - ti->con_cols >= 0) 395 ti->pos = ti->pos - ti->con_cols; 396 } 397 398 tinput_post_seek(ti, shift_held); 399 } 400 401 static void tinput_seek_max(tinput_t *ti, seek_dir_t dir, bool shift_held) 402 { 403 tinput_pre_seek(ti, shift_held); 404 405 if (dir == seek_backward) 406 ti->pos = 0; 407 else 408 ti->pos = ti->nc; 409 410 tinput_post_seek(ti, shift_held); 411 } 412 413 static void tinput_pre_seek(tinput_t *ti, bool shift_held) 414 { 415 if (tinput_sel_active(ti) && !shift_held) { 416 /* Unselect and redraw. */ 417 ti->sel_start = ti->pos; 418 tinput_display_tail(ti, 0, 0); 419 tinput_position_caret(ti); 420 } 421 } 422 423 static void tinput_post_seek(tinput_t *ti, bool shift_held) 424 { 425 if (shift_held) { 426 /* Selecting text. Need redraw. */ 427 tinput_display_tail(ti, 0, 0); 428 } else { 429 /* Shift not held. Keep selection empty. */ 430 ti->sel_start = ti->pos; 431 } 432 tinput_position_caret(ti); 433 } 434 435 static void tinput_history_insert(tinput_t *ti, char *str) 436 { 437 int i; 438 439 if (ti->hnum < HISTORY_LEN) { 440 ti->hnum += 1; 441 } else { 442 if (ti->history[HISTORY_LEN] != NULL) 443 free(ti->history[HISTORY_LEN]); 444 } 445 446 for (i = ti->hnum; i > 1; --i) 447 ti->history[i] = ti->history[i - 1]; 448 449 ti->history[1] = str_dup(str); 450 451 if (ti->history[0] != NULL) { 452 free(ti->history[0]); 453 ti->history[0] = NULL; 454 } 455 } 456 457 static void tinput_set_str(tinput_t *ti, char *str) 458 { 459 str_to_wstr(ti->buffer, INPUT_MAX, str); 460 ti->nc = wstr_length(ti->buffer); 461 ti->pos = ti->nc; 462 ti->sel_start = ti->pos; 463 } 464 465 static void tinput_sel_get_bounds(tinput_t *ti, int *sa, int *sb) 466 { 467 if (ti->sel_start < ti->pos) { 468 *sa = ti->sel_start; 469 *sb = ti->pos; 470 } else { 471 *sa = ti->pos; 472 *sb = ti->sel_start; 473 } 474 } 475 476 static bool tinput_sel_active(tinput_t *ti) 477 { 478 return ti->sel_start != ti->pos; 479 } 480 481 static void tinput_sel_all(tinput_t *ti) 482 { 483 ti->sel_start = 0; 484 ti->pos = ti->nc; 485 tinput_display_tail(ti, 0, 0); 486 tinput_position_caret(ti); 487 } 488 489 static void tinput_sel_delete(tinput_t *ti) 490 { 491 int sa, sb; 492 493 tinput_sel_get_bounds(ti, &sa, &sb); 494 if (sa == sb) 495 return; 496 497 memmove(ti->buffer + sa, ti->buffer + sb, 498 (ti->nc - sb) * sizeof(wchar_t)); 499 ti->pos = ti->sel_start = sa; 500 ti->nc -= (sb - sa); 501 ti->buffer[ti->nc] = '\0'; 502 503 tinput_display_tail(ti, sa, sb - sa); 504 tinput_position_caret(ti); 505 } 506 507 static void tinput_sel_copy_to_cb(tinput_t *ti) 508 { 509 int sa, sb; 510 wchar_t tmp_c; 511 char *str; 512 513 tinput_sel_get_bounds(ti, &sa, &sb); 514 515 if (sb < ti->nc) { 516 tmp_c = ti->buffer[sb]; 517 ti->buffer[sb] = '\0'; 518 } 519 520 str = wstr_to_astr(ti->buffer + sa); 521 522 if (sb < ti->nc) 523 ti->buffer[sb] = tmp_c; 524 525 if (str == NULL) 526 goto error; 527 528 if (clipboard_put_str(str) != EOK) 529 goto error; 530 531 free(str); 532 return; 533 error: 534 return; 535 /* TODO: Give the user some warning. */ 536 } 537 538 static void tinput_paste_from_cb(tinput_t *ti) 539 { 540 char *str; 541 int rc; 542 543 rc = clipboard_get_str(&str); 544 if (rc != EOK || str == NULL) 545 return; /* TODO: Give the user some warning. */ 546 547 tinput_insert_string(ti, str); 548 free(str); 549 } 550 551 static void tinput_history_seek(tinput_t *ti, int offs) 552 { 553 int pad; 554 555 if (ti->hpos + offs < 0 || ti->hpos + offs > ti->hnum) 556 return; 557 558 if (ti->history[ti->hpos] != NULL) { 559 free(ti->history[ti->hpos]); 560 ti->history[ti->hpos] = NULL; 561 } 562 563 ti->history[ti->hpos] = tinput_get_str(ti); 564 ti->hpos += offs; 565 566 pad = ti->nc - str_length(ti->history[ti->hpos]); 567 if (pad < 0) pad = 0; 568 569 tinput_set_str(ti, ti->history[ti->hpos]); 570 tinput_display_tail(ti, 0, pad); 571 tinput_update_origin(ti); 572 tinput_position_caret(ti); 573 } 574 575 /** Initialize text input field. 576 * 577 * Must be called before using the field. It clears the history. 578 */ 579 static void tinput_init(tinput_t *ti) 580 { 581 ti->hnum = 0; 582 ti->hpos = 0; 583 ti->history[0] = NULL; 584 } 585 586 /** Read in one line of input. */ 587 static char *tinput_read(tinput_t *ti) 102 588 { 103 589 console_event_t ev; 104 size_t offs, otmp; 105 wchar_t dec; 106 107 offs = 0; 108 while (true) { 590 char *str; 591 592 fflush(stdout); 593 594 if (console_get_size(fphone(stdin), &ti->con_cols, &ti->con_rows) != EOK) 595 return NULL; 596 if (console_get_pos(fphone(stdin), &ti->col0, &ti->row0) != EOK) 597 return NULL; 598 599 ti->pos = ti->sel_start = 0; 600 ti->nc = 0; 601 ti->buffer[0] = '\0'; 602 ti->done = false; 603 604 while (!ti->done) { 109 605 fflush(stdout); 110 606 if (!console_get_event(fphone(stdin), &ev)) 111 return ;112 607 return NULL; 608 113 609 if (ev.type != KEY_PRESS) 114 610 continue; 115 116 if (ev.key == KC_ENTER || ev.key == KC_NENTER) 117 break; 118 if (ev.key == KC_BACKSPACE) { 119 if (offs > 0) { 120 /* 121 * Back up until we reach valid start of 122 * character. 123 */ 124 while (offs > 0) { 125 --offs; otmp = offs; 126 dec = str_decode(buffer, &otmp, n); 127 if (dec != U_SPECIAL) 128 break; 129 } 130 putchar('\b'); 131 } 132 continue; 611 612 if ((ev.mods & KM_CTRL) != 0 && 613 (ev.mods & (KM_ALT | KM_SHIFT)) == 0) { 614 tinput_key_ctrl(ti, &ev); 133 615 } 616 617 if ((ev.mods & KM_SHIFT) != 0 && 618 (ev.mods & (KM_CTRL | KM_ALT)) == 0) { 619 tinput_key_shift(ti, &ev); 620 } 621 622 if ((ev.mods & KM_CTRL) != 0 && 623 (ev.mods & KM_SHIFT) != 0 && 624 (ev.mods & KM_ALT) == 0) { 625 tinput_key_ctrl_shift(ti, &ev); 626 } 627 628 if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 629 tinput_key_unmod(ti, &ev); 630 } 631 134 632 if (ev.c >= ' ') { 135 if (chr_encode(ev.c, buffer, &offs, n - 1) == EOK)136 putchar(ev.c);633 tinput_sel_delete(ti); 634 tinput_insert_char(ti, ev.c); 137 635 } 138 636 } 637 638 ti->pos = ti->nc; 639 tinput_position_caret(ti); 139 640 putchar('\n'); 140 buffer[offs] = '\0'; 141 } 142 143 /* TODO: 144 * Implement something like editline() / readline(), if even 145 * just for command history and making arrows work. */ 641 642 str = tinput_get_str(ti); 643 if (str_cmp(str, "") != 0) 644 tinput_history_insert(ti, str); 645 646 ti->hpos = 0; 647 648 return str; 649 } 650 651 static void tinput_key_ctrl(tinput_t *ti, console_event_t *ev) 652 { 653 switch (ev->key) { 654 case KC_LEFT: 655 tinput_seek_word(ti, seek_backward, false); 656 break; 657 case KC_RIGHT: 658 tinput_seek_word(ti, seek_forward, false); 659 break; 660 case KC_UP: 661 tinput_seek_vertical(ti, seek_backward, false); 662 break; 663 case KC_DOWN: 664 tinput_seek_vertical(ti, seek_forward, false); 665 break; 666 case KC_X: 667 tinput_sel_copy_to_cb(ti); 668 tinput_sel_delete(ti); 669 break; 670 case KC_C: 671 tinput_sel_copy_to_cb(ti); 672 break; 673 case KC_V: 674 tinput_sel_delete(ti); 675 tinput_paste_from_cb(ti); 676 break; 677 case KC_A: 678 tinput_sel_all(ti); 679 break; 680 default: 681 break; 682 } 683 } 684 685 static void tinput_key_ctrl_shift(tinput_t *ti, console_event_t *ev) 686 { 687 switch (ev->key) { 688 case KC_LEFT: 689 tinput_seek_word(ti, seek_backward, true); 690 break; 691 case KC_RIGHT: 692 tinput_seek_word(ti, seek_forward, true); 693 break; 694 case KC_UP: 695 tinput_seek_vertical(ti, seek_backward, true); 696 break; 697 case KC_DOWN: 698 tinput_seek_vertical(ti, seek_forward, true); 699 break; 700 default: 701 break; 702 } 703 } 704 705 static void tinput_key_shift(tinput_t *ti, console_event_t *ev) 706 { 707 switch (ev->key) { 708 case KC_LEFT: 709 tinput_seek_cell(ti, seek_backward, true); 710 break; 711 case KC_RIGHT: 712 tinput_seek_cell(ti, seek_forward, true); 713 break; 714 case KC_UP: 715 tinput_seek_vertical(ti, seek_backward, true); 716 break; 717 case KC_DOWN: 718 tinput_seek_vertical(ti, seek_forward, true); 719 break; 720 case KC_HOME: 721 tinput_seek_max(ti, seek_backward, true); 722 break; 723 case KC_END: 724 tinput_seek_max(ti, seek_forward, true); 725 break; 726 default: 727 break; 728 } 729 } 730 731 static void tinput_key_unmod(tinput_t *ti, console_event_t *ev) 732 { 733 switch (ev->key) { 734 case KC_ENTER: 735 case KC_NENTER: 736 ti->done = true; 737 break; 738 case KC_BACKSPACE: 739 tinput_backspace(ti); 740 break; 741 case KC_DELETE: 742 tinput_delete(ti); 743 break; 744 case KC_LEFT: 745 tinput_seek_cell(ti, seek_backward, false); 746 break; 747 case KC_RIGHT: 748 tinput_seek_cell(ti, seek_forward, false); 749 break; 750 case KC_HOME: 751 tinput_seek_max(ti, seek_backward, false); 752 break; 753 case KC_END: 754 tinput_seek_max(ti, seek_forward, false); 755 break; 756 case KC_UP: 757 tinput_history_seek(ti, +1); 758 break; 759 case KC_DOWN: 760 tinput_history_seek(ti, -1); 761 break; 762 default: 763 break; 764 } 765 } 766 146 767 void get_input(cliuser_t *usr) 147 768 { 148 char line[INPUT_MAX];769 char *str; 149 770 150 771 fflush(stdout); … … 154 775 console_set_style(fphone(stdout), STYLE_NORMAL); 155 776 156 read_line(line, INPUT_MAX); 157 /* Make sure we don't have rubbish or a C/R happy user */ 158 if (str_cmp(line, "") == 0 || str_cmp(line, "\n") == 0) 159 return; 160 usr->line = str_dup(line); 161 777 str = tinput_read(&tinput); 778 779 /* Check for empty input. */ 780 if (str_cmp(str, "") == 0) { 781 free(str); 782 return; 783 } 784 785 usr->line = str; 162 786 return; 163 787 } 164 788 789 void input_init(void) 790 { 791 tinput_init(&tinput); 792 } -
uspace/app/bdsh/input.h
r3f085132 r3b3e776 8 8 extern void get_input(cliuser_t *); 9 9 extern int tok_input(cliuser_t *); 10 extern void input_init(void); 10 11 11 12 #endif -
uspace/app/bdsh/scli.c
r3f085132 r3b3e776 64 64 usr->prompt = (char *) NULL; 65 65 usr->lasterr = 0; 66 67 input_init(); 68 66 69 return (int) cli_set_prompt(usr); 67 70 } -
uspace/app/edit/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = edit 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV)36 $(MAKE) -f Makefile.build35 SOURCES = \ 36 edit.c \ 37 sheet.c 37 38 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 39 include ../Makefile.common -
uspace/app/edit/edit.c
r3f085132 r3b3e776 36 36 37 37 #include <stdio.h> 38 #include <stdlib.h> 38 39 #include <sys/types.h> 39 40 #include <vfs/vfs.h> … … 44 45 #include <align.h> 45 46 #include <macros.h> 47 #include <clipboard.h> 46 48 #include <bool.h> 47 49 … … 73 75 tag_t caret_pos; 74 76 77 /** Start of selection */ 78 tag_t sel_start; 79 75 80 /** 76 81 * Ideal column where the caret should try to get. This is used … … 93 98 static bool done; 94 99 static pane_t pane; 100 static bool cursor_visible; 95 101 96 102 static int scr_rows, scr_columns; … … 101 107 #define ED_INFTY 65536 102 108 109 /** Maximum filename length that can be entered. */ 110 #define INFNAME_MAX_LEN 128 111 112 static void cursor_show(void); 113 static void cursor_hide(void); 114 static void cursor_setvis(bool visible); 115 103 116 static void key_handle_unmod(console_event_t const *ev); 104 117 static void key_handle_ctrl(console_event_t const *ev); 118 static void key_handle_shift(console_event_t const *ev); 119 static void key_handle_movement(unsigned int key, bool shift); 120 105 121 static int file_save(char const *fname); 122 static void file_save_as(void); 106 123 static int file_insert(char *fname); 107 124 static int file_save_range(char const *fname, spt_t const *spos, 108 125 spt_t const *epos); 126 static char *filename_prompt(char const *prompt, char const *init_value); 127 static char *range_get_str(spt_t const *spos, spt_t const *epos); 128 109 129 static void pane_text_display(void); 110 130 static void pane_row_display(void); … … 112 132 static void pane_status_display(void); 113 133 static void pane_caret_display(void); 134 114 135 static void insert_char(wchar_t c); 115 136 static void delete_char_before(void); … … 117 138 static void caret_update(void); 118 139 static void caret_move(int drow, int dcolumn, enum dir_spec align_dir); 140 141 static bool selection_active(void); 142 static void selection_sel_all(void); 143 static void selection_get_points(spt_t *pa, spt_t *pb); 144 static void selection_delete(void); 145 static void selection_copy(void); 146 static void insert_clipboard_data(void); 147 119 148 static void pt_get_sof(spt_t *pt); 120 149 static void pt_get_eof(spt_t *pt); 150 static int tag_cmp(tag_t const *a, tag_t const *b); 151 static int spt_cmp(spt_t const *a, spt_t const *b); 152 static int coord_cmp(coord_t const *a, coord_t const *b); 153 121 154 static void status_display(char const *str); 122 155 … … 150 183 151 184 if (argc == 2) { 152 doc.file_name = argv[1];185 doc.file_name = str_dup(argv[1]); 153 186 } else if (argc > 1) { 154 187 printf("Invalid arguments.\n"); 155 188 return -2; 156 189 } else { 157 doc.file_name = "/edit.txt";190 doc.file_name = NULL; 158 191 } 159 192 160 193 new_file = false; 161 194 162 if ( file_insert(doc.file_name) != EOK)195 if (doc.file_name == NULL || file_insert(doc.file_name) != EOK) 163 196 new_file = true; 164 197 … … 166 199 caret_move(-ED_INFTY, -ED_INFTY, dir_before); 167 200 201 /* Place selection start tag. */ 202 tag_get_pt(&pane.caret_pos, &pt); 203 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 204 168 205 /* Initial display */ 206 cursor_visible = true; 207 208 cursor_hide(); 169 209 console_clear(con); 170 210 pane_text_display(); 171 211 pane_status_display(); 172 if (new_file )173 status_display("File not found. Createdempty file.");212 if (new_file && doc.file_name != NULL) 213 status_display("File not found. Starting empty file."); 174 214 pane_caret_display(); 175 215 cursor_show(); 176 216 177 217 done = false; … … 184 224 /* Handle key press. */ 185 225 if (((ev.mods & KM_ALT) == 0) && 226 ((ev.mods & KM_SHIFT) == 0) && 186 227 (ev.mods & KM_CTRL) != 0) { 187 228 key_handle_ctrl(&ev); 188 } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) { 229 } else if (((ev.mods & KM_ALT) == 0) && 230 ((ev.mods & KM_CTRL) == 0) && 231 (ev.mods & KM_SHIFT) != 0) { 232 key_handle_shift(&ev); 233 } else if ((ev.mods & (KM_CTRL | KM_ALT | KM_SHIFT)) == 0) { 189 234 key_handle_unmod(&ev); 190 235 } … … 192 237 193 238 /* Redraw as necessary. */ 239 240 cursor_hide(); 194 241 195 242 if (pane.rflags & REDRAW_TEXT) … … 201 248 if (pane.rflags & REDRAW_CARET) 202 249 pane_caret_display(); 203 250 251 cursor_show(); 204 252 } 205 253 … … 207 255 208 256 return 0; 257 } 258 259 static void cursor_show(void) 260 { 261 cursor_setvis(true); 262 } 263 264 static void cursor_hide(void) 265 { 266 cursor_setvis(false); 267 } 268 269 static void cursor_setvis(bool visible) 270 { 271 if (cursor_visible != visible) { 272 console_cursor_visibility(con, visible); 273 cursor_visible = visible; 274 } 209 275 } 210 276 … … 214 280 switch (ev->key) { 215 281 case KC_ENTER: 282 selection_delete(); 216 283 insert_char('\n'); 217 284 caret_update(); 218 285 break; 219 286 case KC_LEFT: 220 caret_move(0, -1, dir_before);221 break;222 287 case KC_RIGHT: 223 caret_move(0, 0, dir_after);224 break;225 288 case KC_UP: 226 caret_move(-1, 0, dir_before);227 break;228 289 case KC_DOWN: 229 caret_move(+1, 0, dir_before);230 break;231 290 case KC_HOME: 232 caret_move(0, -ED_INFTY, dir_before);233 break;234 291 case KC_END: 235 caret_move(0, +ED_INFTY, dir_before);236 break;237 292 case KC_PAGE_UP: 238 caret_move(-pane.rows, 0, dir_before);239 break;240 293 case KC_PAGE_DOWN: 241 caret_move(+pane.rows, 0, dir_before);294 key_handle_movement(ev->key, false); 242 295 break; 243 296 case KC_BACKSPACE: 244 delete_char_before(); 297 if (selection_active()) 298 selection_delete(); 299 else 300 delete_char_before(); 245 301 caret_update(); 246 302 break; 247 303 case KC_DELETE: 248 delete_char_after(); 304 if (selection_active()) 305 selection_delete(); 306 else 307 delete_char_after(); 249 308 caret_update(); 250 309 break; 251 310 default: 252 311 if (ev->c >= 32 || ev->c == '\t') { 312 selection_delete(); 253 313 insert_char(ev->c); 254 314 caret_update(); … … 258 318 } 259 319 320 /** Handle Shift-key combination. */ 321 static void key_handle_shift(console_event_t const *ev) 322 { 323 switch (ev->key) { 324 case KC_LEFT: 325 case KC_RIGHT: 326 case KC_UP: 327 case KC_DOWN: 328 case KC_HOME: 329 case KC_END: 330 case KC_PAGE_UP: 331 case KC_PAGE_DOWN: 332 key_handle_movement(ev->key, true); 333 break; 334 default: 335 if (ev->c >= 32 || ev->c == '\t') { 336 selection_delete(); 337 insert_char(ev->c); 338 caret_update(); 339 } 340 break; 341 } 342 } 343 260 344 /** Handle Ctrl-key combination. */ 261 345 static void key_handle_ctrl(console_event_t const *ev) … … 266 350 break; 267 351 case KC_S: 268 (void) file_save(doc.file_name); 352 if (doc.file_name != NULL) 353 file_save(doc.file_name); 354 else 355 file_save_as(); 356 break; 357 case KC_E: 358 file_save_as(); 359 break; 360 case KC_C: 361 selection_copy(); 362 break; 363 case KC_V: 364 selection_delete(); 365 insert_clipboard_data(); 366 pane.rflags |= REDRAW_TEXT; 367 caret_update(); 368 break; 369 case KC_X: 370 selection_copy(); 371 selection_delete(); 372 pane.rflags |= REDRAW_TEXT; 373 caret_update(); 374 break; 375 case KC_A: 376 selection_sel_all(); 269 377 break; 270 378 default: … … 273 381 } 274 382 383 static void key_handle_movement(unsigned int key, bool select) 384 { 385 spt_t pt; 386 spt_t caret_pt; 387 coord_t c_old, c_new; 388 bool had_sel; 389 390 /* Check if we had selection before. */ 391 tag_get_pt(&pane.caret_pos, &caret_pt); 392 tag_get_pt(&pane.sel_start, &pt); 393 had_sel = !spt_equal(&caret_pt, &pt); 394 395 switch (key) { 396 case KC_LEFT: 397 caret_move(0, -1, dir_before); 398 break; 399 case KC_RIGHT: 400 caret_move(0, 0, dir_after); 401 break; 402 case KC_UP: 403 caret_move(-1, 0, dir_before); 404 break; 405 case KC_DOWN: 406 caret_move(+1, 0, dir_before); 407 break; 408 case KC_HOME: 409 caret_move(0, -ED_INFTY, dir_before); 410 break; 411 case KC_END: 412 caret_move(0, +ED_INFTY, dir_before); 413 break; 414 case KC_PAGE_UP: 415 caret_move(-pane.rows, 0, dir_before); 416 break; 417 case KC_PAGE_DOWN: 418 caret_move(+pane.rows, 0, dir_before); 419 break; 420 default: 421 break; 422 } 423 424 if (select == false) { 425 /* Move sel_start to the same point as caret. */ 426 sheet_remove_tag(&doc.sh, &pane.sel_start); 427 tag_get_pt(&pane.caret_pos, &pt); 428 sheet_place_tag(&doc.sh, &pt, &pane.sel_start); 429 } 430 431 if (select) { 432 tag_get_pt(&pane.caret_pos, &pt); 433 spt_get_coord(&caret_pt, &c_old); 434 spt_get_coord(&pt, &c_new); 435 436 if (c_old.row == c_new.row) 437 pane.rflags |= REDRAW_ROW; 438 else 439 pane.rflags |= REDRAW_TEXT; 440 441 } else if (had_sel == true) { 442 /* Redraw because text was unselected. */ 443 pane.rflags |= REDRAW_TEXT; 444 } 445 } 275 446 276 447 /** Save the document. */ … … 285 456 286 457 rc = file_save_range(fname, &sp, &ep); 287 status_display("File saved."); 458 459 switch (rc) { 460 case EINVAL: 461 status_display("Error opening file!"); 462 break; 463 case EIO: 464 status_display("Error writing data!"); 465 break; 466 default: 467 status_display("File saved."); 468 break; 469 } 288 470 289 471 return rc; 472 } 473 474 /** Change document name and save. */ 475 static void file_save_as(void) 476 { 477 char *old_fname, *fname; 478 int rc; 479 480 old_fname = (doc.file_name != NULL) ? doc.file_name : ""; 481 fname = filename_prompt("Save As", old_fname); 482 if (fname == NULL) { 483 status_display("Save cancelled."); 484 return; 485 } 486 487 rc = file_save(fname); 488 if (rc != EOK) 489 return; 490 491 if (doc.file_name != NULL) 492 free(doc.file_name); 493 doc.file_name = fname; 494 } 495 496 /** Ask for a file name. */ 497 static char *filename_prompt(char const *prompt, char const *init_value) 498 { 499 console_event_t ev; 500 char *str; 501 wchar_t buffer[INFNAME_MAX_LEN + 1]; 502 int max_len; 503 int nc; 504 bool done; 505 506 asprintf(&str, "%s: %s", prompt, init_value); 507 status_display(str); 508 console_goto(con, 1 + str_length(str), scr_rows - 1); 509 free(str); 510 511 console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0); 512 513 max_len = min(INFNAME_MAX_LEN, scr_columns - 4 - str_length(prompt)); 514 str_to_wstr(buffer, max_len + 1, init_value); 515 nc = wstr_length(buffer); 516 done = false; 517 518 while (!done) { 519 console_get_event(con, &ev); 520 521 if (ev.type == KEY_PRESS) { 522 /* Handle key press. */ 523 if (((ev.mods & KM_ALT) == 0) && 524 (ev.mods & KM_CTRL) != 0) { 525 ; 526 } else if ((ev.mods & (KM_CTRL | KM_ALT)) == 0) { 527 switch (ev.key) { 528 case KC_ESCAPE: 529 return NULL; 530 case KC_BACKSPACE: 531 if (nc > 0) { 532 putchar('\b'); 533 fflush(stdout); 534 --nc; 535 } 536 break; 537 case KC_ENTER: 538 done = true; 539 break; 540 default: 541 if (ev.c >= 32 && nc < max_len) { 542 putchar(ev.c); 543 fflush(stdout); 544 buffer[nc++] = ev.c; 545 } 546 break; 547 } 548 } 549 } 550 } 551 552 buffer[nc] = '\0'; 553 str = wstr_to_astr(buffer); 554 555 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 556 557 return str; 290 558 } 291 559 … … 359 627 } while (!spt_equal(&bep, epos)); 360 628 361 fclose(f); 629 if (fclose(f) != EOK) 630 return EIO; 362 631 363 632 return EOK; 633 } 634 635 /** Return contents of range as a new string. */ 636 static char *range_get_str(spt_t const *spos, spt_t const *epos) 637 { 638 char *buf; 639 spt_t sp, bep; 640 size_t bytes; 641 size_t buf_size, bpos; 642 643 buf_size = 1; 644 645 buf = malloc(buf_size); 646 if (buf == NULL) 647 return NULL; 648 649 bpos = 0; 650 sp = *spos; 651 652 while (true) { 653 sheet_copy_out(&doc.sh, &sp, epos, &buf[bpos], buf_size - bpos, 654 &bep); 655 bytes = str_size(&buf[bpos]); 656 bpos += bytes; 657 sp = bep; 658 659 if (spt_equal(&bep, epos)) 660 break; 661 662 buf_size *= 2; 663 buf = realloc(buf, buf_size); 664 if (buf == NULL) 665 return NULL; 666 } 667 668 return buf; 364 669 } 365 670 … … 408 713 { 409 714 int i, j, fill; 410 spt_t rb, re, dep ;715 spt_t rb, re, dep, pt; 411 716 coord_t rbc, rec; 412 717 char row_buf[ROW_BUF_SIZE]; … … 414 719 size_t pos, size; 415 720 unsigned s_column; 721 coord_t csel_start, csel_end, ctmp; 722 723 /* Determine selection start and end. */ 724 725 tag_get_pt(&pane.sel_start, &pt); 726 spt_get_coord(&pt, &csel_start); 727 728 tag_get_pt(&pane.caret_pos, &pt); 729 spt_get_coord(&pt, &csel_end); 730 731 if (coord_cmp(&csel_start, &csel_end) > 0) { 732 ctmp = csel_start; 733 csel_start = csel_end; 734 csel_end = ctmp; 735 } 416 736 417 737 /* Draw rows from the sheet. */ … … 434 754 /* Display text from the buffer. */ 435 755 756 if (coord_cmp(&csel_start, &rbc) <= 0 && 757 coord_cmp(&rbc, &csel_end) < 0) { 758 fflush(stdout); 759 console_set_color(con, COLOR_BLACK, COLOR_RED, 0); 760 fflush(stdout); 761 } 762 436 763 console_goto(con, 0, i); 437 764 size = str_size(row_buf); 438 765 pos = 0; 439 s_column = 1;766 s_column = pane.sh_column; 440 767 while (pos < size) { 768 if (csel_start.row == rbc.row && csel_start.column == s_column) { 769 fflush(stdout); 770 console_set_color(con, COLOR_BLACK, COLOR_RED, 0); 771 fflush(stdout); 772 } 773 774 if (csel_end.row == rbc.row && csel_end.column == s_column) { 775 fflush(stdout); 776 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 777 fflush(stdout); 778 } 779 441 780 c = str_decode(row_buf, &pos, size); 442 781 if (c != '\t') { … … 453 792 } 454 793 794 if (csel_end.row == rbc.row && csel_end.column == s_column) { 795 fflush(stdout); 796 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 797 fflush(stdout); 798 } 799 455 800 /* Fill until the end of display area. */ 456 801 … … 463 808 putchar(' '); 464 809 fflush(stdout); 810 console_set_color(con, COLOR_BLACK, COLOR_WHITE, 0); 465 811 } 466 812 … … 473 819 spt_t caret_pt; 474 820 coord_t coord; 821 char *fname; 475 822 int n; 476 823 … … 478 825 spt_get_coord(&caret_pt, &coord); 479 826 827 fname = (doc.file_name != NULL) ? doc.file_name : "<unnamed>"; 828 480 829 console_goto(con, 0, scr_rows - 1); 481 830 console_set_color(con, COLOR_WHITE, COLOR_BLACK, 0); 482 n = printf(" %d, %d: File '%s'. Ctrl- S Save Ctrl-Q Quit",483 coord.row, coord.column, doc.file_name);831 n = printf(" %d, %d: File '%s'. Ctrl-Q Quit Ctrl-S Save " 832 "Ctrl-E Save As", coord.row, coord.column, fname); 484 833 printf("%*s", scr_columns - 1 - n, ""); 485 834 fflush(stdout); … … 648 997 } 649 998 999 /** Check for non-empty selection. */ 1000 static bool selection_active(void) 1001 { 1002 return (tag_cmp(&pane.caret_pos, &pane.sel_start) != 0); 1003 } 1004 1005 static void selection_get_points(spt_t *pa, spt_t *pb) 1006 { 1007 spt_t pt; 1008 1009 tag_get_pt(&pane.sel_start, pa); 1010 tag_get_pt(&pane.caret_pos, pb); 1011 1012 if (spt_cmp(pa, pb) > 0) { 1013 pt = *pa; 1014 *pa = *pb; 1015 *pb = pt; 1016 } 1017 } 1018 1019 /** Delete selected text. */ 1020 static void selection_delete(void) 1021 { 1022 spt_t pa, pb; 1023 coord_t ca, cb; 1024 int rel; 1025 1026 tag_get_pt(&pane.sel_start, &pa); 1027 tag_get_pt(&pane.caret_pos, &pb); 1028 spt_get_coord(&pa, &ca); 1029 spt_get_coord(&pb, &cb); 1030 rel = coord_cmp(&ca, &cb); 1031 1032 if (rel == 0) 1033 return; 1034 1035 if (rel < 0) 1036 sheet_delete(&doc.sh, &pa, &pb); 1037 else 1038 sheet_delete(&doc.sh, &pb, &pa); 1039 1040 if (ca.row == cb.row) 1041 pane.rflags |= REDRAW_ROW; 1042 else 1043 pane.rflags |= REDRAW_TEXT; 1044 } 1045 1046 static void selection_sel_all(void) 1047 { 1048 spt_t spt, ept; 1049 1050 pt_get_sof(&spt); 1051 pt_get_eof(&ept); 1052 sheet_remove_tag(&doc.sh, &pane.sel_start); 1053 sheet_place_tag(&doc.sh, &spt, &pane.sel_start); 1054 sheet_remove_tag(&doc.sh, &pane.caret_pos); 1055 sheet_place_tag(&doc.sh, &ept, &pane.caret_pos); 1056 1057 pane.rflags |= REDRAW_TEXT; 1058 caret_update(); 1059 } 1060 1061 static void selection_copy(void) 1062 { 1063 spt_t pa, pb; 1064 char *str; 1065 1066 selection_get_points(&pa, &pb); 1067 str = range_get_str(&pa, &pb); 1068 if (str == NULL || clipboard_put_str(str) != EOK) { 1069 status_display("Copying to clipboard failed!"); 1070 } 1071 free(str); 1072 } 1073 1074 static void insert_clipboard_data(void) 1075 { 1076 char *str; 1077 size_t off; 1078 wchar_t c; 1079 int rc; 1080 1081 rc = clipboard_get_str(&str); 1082 if (rc != EOK || str == NULL) 1083 return; 1084 1085 off = 0; 1086 1087 while (true) { 1088 c = str_decode(str, &off, STR_NO_LIMIT); 1089 if (c == '\0') 1090 break; 1091 1092 insert_char(c); 1093 } 1094 1095 free(str); 1096 } 650 1097 651 1098 /** Get start-of-file s-point. */ … … 669 1116 670 1117 sheet_get_cell_pt(&doc.sh, &coord, dir_after, pt); 1118 } 1119 1120 /** Compare tags. */ 1121 static int tag_cmp(tag_t const *a, tag_t const *b) 1122 { 1123 spt_t pa, pb; 1124 1125 tag_get_pt(a, &pa); 1126 tag_get_pt(b, &pb); 1127 1128 return spt_cmp(&pa, &pb); 1129 } 1130 1131 /** Compare s-points. */ 1132 static int spt_cmp(spt_t const *a, spt_t const *b) 1133 { 1134 coord_t ca, cb; 1135 1136 spt_get_coord(a, &ca); 1137 spt_get_coord(b, &cb); 1138 1139 return coord_cmp(&ca, &cb); 1140 } 1141 1142 /** Compare coordinats. */ 1143 static int coord_cmp(coord_t const *a, coord_t const *b) 1144 { 1145 if (a->row - b->row != 0) 1146 return a->row - b->row; 1147 1148 return a->column - b->column; 671 1149 } 672 1150 -
uspace/app/getterm/Makefile
r3f085132 r3b3e776 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 30 include ../../../version 31 DEFS += -DRELEASE=$(RELEASE) "-DNAME=$(NAME)" 29 32 30 ## Common names 31 # 32 33 LIBC_PREFIX = ../../lib/libc 34 SOFTINT_PREFIX = ../../lib/softint 33 USPACE_PREFIX = ../.. 35 34 LIBS = $(LIBC_PREFIX)/libc.a 36 35 37 DEPEND = Makefile.depend 38 DEPEND_PREV = $(DEPEND).prev 39 OUTPUT = redir 36 OUTPUT = getterm 37 38 SOURCES = \ 39 getterm.c \ 40 version.c 41 42 include ../Makefile.common -
uspace/app/getterm/getterm.c
r3f085132 r3b3e776 27 27 */ 28 28 29 /** @addtogroup get vc GetVC29 /** @addtogroup getterm GetTerm 30 30 * @brief Console initialization task. 31 31 * @{ … … 44 44 static void usage(void) 45 45 { 46 printf("Usage: get vc <device> <path>\n");46 printf("Usage: getterm <terminal> <path>\n"); 47 47 } 48 48 -
uspace/app/getterm/getterm.h
r3f085132 r3b3e776 27 27 */ 28 28 29 /** @addtogroup get vc29 /** @addtogroup getterm 30 30 * @{ 31 31 */ … … 34 34 */ 35 35 36 #ifndef GET VC_H__37 #define GET VC_H__36 #ifndef GETTERM_H__ 37 #define GETTERM_H__ 38 38 39 39 #endif -
uspace/app/getterm/version.c
r3f085132 r3b3e776 27 27 */ 28 28 29 /** @addtogroup get vc29 /** @addtogroup getterm 30 30 * @{ 31 31 */ … … 37 37 #include <stdio.h> 38 38 #include <macros.h> 39 #include "get vc.h"39 #include "getterm.h" 40 40 #include "version.h" 41 41 … … 57 57 58 58 /** Print version information. */ 59 void version_print(const char * vc)59 void version_print(const char *term) 60 60 { 61 61 printf("HelenOS release %s (%s)%s%s\n", release, name, revision, timestamp); 62 printf("Running on %s (%s)\n", arch, vc);62 printf("Running on %s (%s)\n", arch, term); 63 63 printf("Copyright (c) 2001-2009 HelenOS project\n\n"); 64 64 } -
uspace/app/getterm/version.h
r3f085132 r3b3e776 27 27 */ 28 28 29 /** @addtogroup get vc29 /** @addtogroup getterm 30 30 * @{ 31 31 */ … … 37 37 #define VERSION_H__ 38 38 39 extern void version_print(const char * vc);39 extern void version_print(const char *term); 40 40 41 41 #endif -
uspace/app/init/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = init 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 init.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../Makefile.common -
uspace/app/init/init.c
r3f085132 r3b3e776 50 50 #include "init.h" 51 51 52 #define DEVFS_MOUNT_POINT "/dev" 53 54 #define SRV_CONSOLE "/srv/console" 55 #define APP_GETTERM "/app/getterm" 56 52 57 static void info_print(void) 53 58 { … … 58 63 { 59 64 char *opts = ""; 60 const char *root_dev = " initrd";65 const char *root_dev = "bd/initrd"; 61 66 62 67 if (str_cmp(fstype, "tmpfs") == 0) … … 89 94 static bool mount_devfs(void) 90 95 { 91 char null[MAX_DEVICE_NAME]; 92 int null_id = devmap_null_create(); 93 94 if (null_id == -1) { 95 printf(NAME ": Unable to create null device\n"); 96 return false; 97 } 98 99 snprintf(null, MAX_DEVICE_NAME, "null%d", null_id); 100 int rc = mount("devfs", "/dev", null, "", IPC_FLAG_BLOCKING); 96 int rc = mount("devfs", DEVFS_MOUNT_POINT, "", "", IPC_FLAG_BLOCKING); 101 97 102 98 switch (rc) { … … 106 102 case EBUSY: 107 103 printf(NAME ": Device filesystem already mounted\n"); 108 devmap_null_destroy(null_id); 104 109 105 return false; 110 106 case ELIMIT: 111 107 printf(NAME ": Unable to mount device filesystem\n"); 112 devmap_null_destroy(null_id); 108 113 109 return false; 114 110 case ENOENT: 115 111 printf(NAME ": Unknown filesystem type (devfs)\n"); 116 devmap_null_destroy(null_id); 112 117 113 return false; 118 114 default: 119 115 printf(NAME ": Error mounting device filesystem (%d)\n", rc); 120 devmap_null_destroy(null_id); 116 121 117 return false; 122 118 } … … 170 166 } 171 167 172 if ( texit != TASK_EXIT_NORMAL || retval != 0) {168 if ((texit != TASK_EXIT_NORMAL) || (retval != 0)) { 173 169 printf(NAME ": Server %s failed to start (returned %d)\n", 174 170 fname, retval); … … 176 172 } 177 173 178 static void getvc(char *dev, char *app)179 { 180 char *argv[ 4];181 char vc[MAX_DEVICE_NAME];174 static void console(char *dev) 175 { 176 char *argv[3]; 177 char hid_in[DEVMAP_NAME_MAXLEN]; 182 178 int rc; 183 179 184 snprintf(vc, MAX_DEVICE_NAME, "/dev/%s", dev); 185 186 printf(NAME ": Spawning getvc on %s\n", vc); 187 180 snprintf(hid_in, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 181 182 printf(NAME ": Spawning %s with %s\n", SRV_CONSOLE, hid_in); 183 184 /* Wait for the input device to be ready */ 188 185 dev_handle_t handle; 189 186 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 190 187 191 188 if (rc == EOK) { 192 argv[0] = "/app/getvc"; 193 argv[1] = vc; 189 argv[0] = SRV_CONSOLE; 190 argv[1] = hid_in; 191 argv[2] = NULL; 192 193 if (!task_spawn(SRV_CONSOLE, argv)) 194 printf(NAME ": Error spawning %s with %s\n", SRV_CONSOLE, hid_in); 195 } else 196 printf(NAME ": Error waiting on %s\n", hid_in); 197 } 198 199 static void getterm(char *dev, char *app) 200 { 201 char *argv[4]; 202 char term[DEVMAP_NAME_MAXLEN]; 203 int rc; 204 205 snprintf(term, DEVMAP_NAME_MAXLEN, "%s/%s", DEVFS_MOUNT_POINT, dev); 206 207 printf(NAME ": Spawning %s with %s %s\n", APP_GETTERM, term, app); 208 209 /* Wait for the terminal device to be ready */ 210 dev_handle_t handle; 211 rc = devmap_device_get_handle(dev, &handle, IPC_FLAG_BLOCKING); 212 213 if (rc == EOK) { 214 argv[0] = APP_GETTERM; 215 argv[1] = term; 194 216 argv[2] = app; 195 217 argv[3] = NULL; 196 218 197 if (!task_spawn( "/app/getvc", argv))198 printf(NAME ": Error spawning getvc on %s\n", vc);199 } else {200 printf(NAME ": Error waiting on %s\n", vc);201 }202 } 203 204 static void mount_ data(void)219 if (!task_spawn(APP_GETTERM, argv)) 220 printf(NAME ": Error spawning %s with %s %s\n", APP_GETTERM, 221 term, app); 222 } else 223 printf(NAME ": Error waiting on %s\n", term); 224 } 225 226 static void mount_scratch(void) 205 227 { 206 228 int rc; 207 229 208 printf("Trying to mount disk0 on /data... ");230 printf("Trying to mount null/0 on /scratch... "); 209 231 fflush(stdout); 210 232 211 rc = mount(" fat", "/data", "disk0", "wtcache", 0);233 rc = mount("tmpfs", "/scratch", "null/0", "", 0); 212 234 if (rc == EOK) 213 235 printf("OK\n"); … … 216 238 } 217 239 240 static void mount_data(void) 241 { 242 int rc; 243 244 printf("Trying to mount bd/disk0 on /data... "); 245 fflush(stdout); 246 247 rc = mount("fat", "/data", "bd/disk0", "wtcache", 0); 248 if (rc == EOK) 249 printf("OK\n"); 250 else 251 printf("Failed\n"); 252 } 253 218 254 int main(int argc, char *argv[]) 219 255 { … … 224 260 return -1; 225 261 } 262 263 /* Make sure tmpfs is running. */ 264 if (str_cmp(STRING(RDFMT), "tmpfs") != 0) { 265 spawn("/srv/tmpfs"); 266 } 226 267 227 268 spawn("/srv/devfs"); 269 spawn("/srv/taskmon"); 228 270 229 271 if (!mount_devfs()) { … … 231 273 return -2; 232 274 } 233 275 276 mount_scratch(); 277 278 spawn("/srv/fhc"); 279 spawn("/srv/obio"); 280 srv_start("/srv/cuda_adb"); 281 srv_start("/srv/i8042"); 282 srv_start("/srv/adb_ms"); 283 srv_start("/srv/char_ms"); 284 234 285 spawn("/srv/fb"); 235 286 spawn("/srv/kbd"); 236 spawn("/srv/console");237 spawn("/srv/fhc");238 spawn("/srv/ obio");287 console("hid_in/kbd"); 288 289 spawn("/srv/clip"); 239 290 240 291 /* … … 255 306 #endif 256 307 257 get vc("vc0", "/app/bdsh");258 get vc("vc1", "/app/bdsh");259 get vc("vc2", "/app/bdsh");260 get vc("vc3", "/app/bdsh");261 get vc("vc4", "/app/bdsh");262 get vc("vc5", "/app/bdsh");263 get vc("vc6", "/app/klog");264 308 getterm("term/vc0", "/app/bdsh"); 309 getterm("term/vc1", "/app/bdsh"); 310 getterm("term/vc2", "/app/bdsh"); 311 getterm("term/vc3", "/app/bdsh"); 312 getterm("term/vc4", "/app/bdsh"); 313 getterm("term/vc5", "/app/bdsh"); 314 getterm("term/vc6", "/app/klog"); 315 265 316 usleep(1000000); 266 317 spawn("/srv/dd"); -
uspace/app/init/init.h
r3f085132 r3b3e776 39 39 #define NAME "init" 40 40 41 #define MAX_DEVICE_NAME 3242 43 41 #endif 44 42 -
uspace/app/klog/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = klog 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 klog.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../Makefile.common -
uspace/app/mkfat/Makefile
r3f085132 r3b3e776 1 1 # 2 2 # Copyright (c) 2005 Martin Decky 3 # Copyright (c) 2007 Jakub Jermar 3 4 # All rights reserved. 4 5 # … … 27 28 # 28 29 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a 32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) 29 33 30 ## Common names 31 # 34 OUTPUT = mkfat 32 35 33 LIBC_PREFIX = ../../lib/libc 34 SOFTINT_PREFIX = ../../lib/softint 35 LIBBLOCK_PREFIX = ../../lib/libblock 36 LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBC_PREFIX)/libc.a 36 SOURCES = \ 37 mkfat.c 37 38 38 DEPEND = Makefile.depend 39 DEPEND_PREV = $(DEPEND).prev 40 OUTPUT = bdsh 39 include ../Makefile.common -
uspace/app/redir/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = redir 33 34 34 all: $(LIBC_PREFIX)/../../../version $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 redir.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../Makefile.common -
uspace/app/shutters/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = shutters 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 shutters.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../Makefile.common -
uspace/app/test_serial/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = test_serial 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 test_serial.c 37 37 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 38 include ../Makefile.common -
uspace/app/tester/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = tester 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 tester.c \ 37 thread/thread1.c \ 38 print/print1.c \ 39 print/print2.c \ 40 print/print3.c \ 41 print/print4.c \ 42 console/console1.c \ 43 stdio/stdio1.c \ 44 stdio/stdio2.c \ 45 fault/fault1.c \ 46 fault/fault2.c \ 47 fault/fault3.c \ 48 vfs/vfs1.c \ 49 ipc/ping_pong.c \ 50 ipc/register.c \ 51 ipc/connect.c \ 52 loop/loop1.c \ 53 mm/malloc1.c 37 54 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 55 include ../Makefile.common -
uspace/app/tester/tester.c
r3f085132 r3b3e776 56 56 #include "fault/fault1.def" 57 57 #include "fault/fault2.def" 58 #include "fault/fault3.def" 58 59 #include "vfs/vfs1.def" 59 60 #include "ipc/ping_pong.def" -
uspace/app/tester/tester.h
r3f085132 r3b3e776 73 73 extern char *test_fault1(void); 74 74 extern char *test_fault2(void); 75 extern char *test_fault3(void); 75 76 extern char *test_vfs1(void); 76 77 extern char *test_ping_pong(void); -
uspace/app/tester/vfs/vfs1.c
r3f085132 r3b3e776 79 79 TPRINTF("Created directory %s\n", MOUNT_POINT); 80 80 81 char null[MAX_DEVICE_NAME]; 82 int null_id = devmap_null_create(); 83 84 if (null_id == -1) 85 return "Unable to create null device"; 86 87 snprintf(null, MAX_DEVICE_NAME, "null%d", null_id); 88 int rc = mount(FS_TYPE, MOUNT_POINT, null, OPTIONS, FLAGS); 81 int rc = mount(FS_TYPE, MOUNT_POINT, "", OPTIONS, FLAGS); 89 82 switch (rc) { 90 83 case EOK: 91 TPRINTF("Mounted /dev/%s as %s on %s\n", null, FS_TYPE, MOUNT_POINT);84 TPRINTF("Mounted %s on %s\n", FS_TYPE, MOUNT_POINT); 92 85 break; 93 86 case EBUSY: -
uspace/app/tetris/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = tetris 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 shapes.c \ 37 scores.c \ 38 input.c \ 39 tetris.c \ 40 screen.c 37 41 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 42 include ../Makefile.common -
uspace/app/trace/Makefile
r3f085132 r3b3e776 28 28 # 29 29 30 include Makefile.common 30 USPACE_PREFIX = ../.. 31 LIBS = $(LIBC_PREFIX)/libc.a 31 32 32 .PHONY: all clean 33 OUTPUT = trace 33 34 34 all: $(LIBC_PREFIX)/../../../Makefile.config $(LIBC_PREFIX)/../../../config.h $(LIBC_PREFIX)/../../../config.defs $(LIBS) 35 -[ -f $(DEPEND) ] && mv -f $(DEPEND) $(DEPEND_PREV) 36 $(MAKE) -f Makefile.build 35 SOURCES = \ 36 trace.c \ 37 syscalls.c \ 38 ipcp.c \ 39 ipc_desc.c \ 40 proto.c \ 41 errors.c 37 42 38 clean: 39 rm -f $(DEPEND) $(DEPEND_PREV) $(OUTPUT) $(OUTPUT).map $(OUTPUT).disasm 40 find . -name '*.o' -follow -exec rm \{\} \; 43 include ../Makefile.common -
uspace/app/trace/ipcp.c
r3f085132 r3b3e776 36 36 #include <stdlib.h> 37 37 #include <adt/hash_table.h> 38 #include <sys/typefmt.h> 38 39 39 40 #include "ipc_desc.h" … … 200 201 201 202 if ((display_mask & DM_IPC) != 0) { 202 printf("Call ID: 0x%lx, phone: %d, proto: %s, method: ", hash,203 printf("Call ID: %p, phone: %d, proto: %s, method: ", hash, 203 204 phone, (proto ? proto->name : "n/a")); 204 205 ipc_m_print(proto, IPC_GET_METHOD(*call)); 205 printf(" args: (%lu, %lu, %lu, %lu, %lu)\n", args[1], args[2], 206 printf(" args: (%" PRIuIPCARG ", %" PRIuIPCARG ", %" PRIuIPCARG 207 ", %" PRIuIPCARG ", %" PRIuIPCARG ")\n", args[1], args[2], 206 208 args[3], args[4], args[5]); 207 209 } … … 279 281 280 282 if ((display_mask & DM_IPC) != 0) { 281 printf("Response to 0x%lx: retval=%ld, args = (%lu, %lu, %lu, %lu, %lu)\n", 282 hash, retval, IPC_GET_ARG1(*answer), 283 IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), 284 IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); 283 printf("Response to %p: retval=%ld, args = (%" PRIuIPCARG 284 ", %" PRIuIPCARG ", %" PRIuIPCARG ", %" PRIuIPCARG 285 ", %" PRIuIPCARG ")\n", 286 hash, retval, IPC_GET_ARG1(*answer), 287 IPC_GET_ARG2(*answer), IPC_GET_ARG3(*answer), 288 IPC_GET_ARG4(*answer), IPC_GET_ARG5(*answer)); 285 289 } 286 290 … … 336 340 /* Not a response */ 337 341 if ((display_mask & DM_IPC) != 0) { 338 printf("Not a response (hash 0x%lx)\n", hash);342 printf("Not a response (hash %p)\n", hash); 339 343 } 340 344 return; -
uspace/app/trace/trace.c
r3f085132 r3b3e776 48 48 #include <io/console.h> 49 49 #include <io/keycode.h> 50 #include <fibril_sync.h> 50 #include <fibril_synch.h> 51 #include <sys/types.h> 52 #include <sys/typefmt.h> 51 53 52 54 #include <libc.h> … … 159 161 if (rc < 0) { 160 162 printf("Error connecting\n"); 161 printf("ipc_connect_task(% lld) -> %d ", task_id, rc);163 printf("ipc_connect_task(%" PRIdTASKID ") -> %d ", task_id, rc); 162 164 return rc; 163 165 } … … 198 200 printf("Threads:"); 199 201 for (i = 0; i < n_threads; i++) { 200 printf(" [%d] (hash 0x%lx)", 1+i, thread_hash_buf[i]);202 printf(" [%d] (hash %p)", 1+i, thread_hash_buf[i]); 201 203 } 202 204 printf("\ntotal of %u threads\n", tb_needed / sizeof(uintptr_t)); … … 222 224 case V_HASH: 223 225 case V_PTR: 224 printf(" 0x%08lx", val);226 printf("%p", val); 225 227 break; 226 228 … … 275 277 276 278 putchar('('); 277 if (n > 0) printf("% ld", sc_args[0]);279 if (n > 0) printf("%" PRIdSYSARG, sc_args[0]); 278 280 for (i = 1; i < n; i++) { 279 printf(", % ld", sc_args[i]);281 printf(", %" PRIdSYSARG, sc_args[i]); 280 282 } 281 283 putchar(')'); … … 508 510 } 509 511 510 printf("Start tracing thread [%d] (hash 0x%lx).\n", thread_id, thread_hash);512 printf("Start tracing thread [%d] (hash %p).\n", thread_id, thread_hash); 511 513 512 514 while (!abort_trace) { … … 552 554 break; 553 555 case UDEBUG_EVENT_THREAD_E: 554 printf("Thread 0x%lxexited.\n", val0);556 printf("Thread %p exited.\n", val0); 555 557 fibril_mutex_lock(&state_lock); 556 558 abort_trace = true; … … 972 974 rc = connect_task(task_id); 973 975 if (rc < 0) { 974 printf("Failed connecting to task % lld.\n", task_id);976 printf("Failed connecting to task %" PRIdTASKID ".\n", task_id); 975 977 return 1; 976 978 } 977 979 978 printf("Connected to task % lld.\n", task_id);980 printf("Connected to task %" PRIdTASKID ".\n", task_id); 979 981 980 982 if (task_ldr != NULL)
Note:
See TracChangeset
for help on using the changeset viewer.
