Changes in uspace/app/edit/edit.c [994f87b:46bd63c9] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r994f87b r46bd63c9 1 1 /* 2 * Copyright (c) 202 4Jiri Svoboda2 * Copyright (c) 2023 Jiri Svoboda 3 3 * Copyright (c) 2012 Martin Sucha 4 4 * All rights reserved. … … 177 177 static void pos_handle(pos_event_t *ev); 178 178 179 static errno_t file_new(void);180 static void file_open(void);181 static errno_t file_open_file(const char *fname);182 179 static errno_t file_save(char const *fname); 183 180 static void file_save_as(void); 184 static errno_t file_insert(c onst char *fname);181 static errno_t file_insert(char *fname); 185 182 static errno_t file_save_range(char const *fname, spt_t const *spos, 186 183 spt_t const *epos); … … 241 238 242 239 static void edit_wnd_close(ui_window_t *, void *); 243 static void edit_wnd_focus(ui_window_t *, void *, unsigned);244 240 static void edit_wnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 245 static void edit_wnd_unfocus(ui_window_t *, void *, unsigned);246 241 247 242 static ui_window_cb_t edit_window_cb = { 248 243 .close = edit_wnd_close, 249 .focus = edit_wnd_focus, 250 .kbd = edit_wnd_kbd_event, 251 .unfocus = edit_wnd_unfocus 244 .kbd = edit_wnd_kbd_event 252 245 }; 253 246 254 static void edit_menubar_activate(ui_menu_bar_t *, void *);255 static void edit_menubar_deactivate(ui_menu_bar_t *, void *);256 257 static ui_menu_bar_cb_t edit_menubar_cb = {258 .activate = edit_menubar_activate,259 .deactivate = edit_menubar_deactivate260 };261 262 static void edit_file_new(ui_menu_entry_t *, void *);263 static void edit_file_open(ui_menu_entry_t *, void *);264 247 static void edit_file_save(ui_menu_entry_t *, void *); 265 248 static void edit_file_save_as(ui_menu_entry_t *, void *); … … 286 269 }; 287 270 288 static void open_dialog_bok(ui_file_dialog_t *, void *, const char *);289 static void open_dialog_bcancel(ui_file_dialog_t *, void *);290 static void open_dialog_close(ui_file_dialog_t *, void *);291 292 static ui_file_dialog_cb_t open_dialog_cb = {293 .bok = open_dialog_bok,294 .bcancel = open_dialog_bcancel,295 .close = open_dialog_close296 };297 298 271 static void save_as_dialog_bok(ui_file_dialog_t *, void *, const char *); 299 272 static void save_as_dialog_bcancel(ui_file_dialog_t *, void *); … … 328 301 int main(int argc, char *argv[]) 329 302 { 303 bool new_file; 330 304 errno_t rc; 331 305 332 306 pane.sh_row = 1; 333 307 pane.sh_column = 1; 308 309 /* Start with an empty sheet. */ 310 rc = sheet_create(&doc.sh); 311 if (rc != EOK) { 312 printf("Out of memory.\n"); 313 return -1; 314 } 315 316 /* Place caret at the beginning of file. */ 317 spt_t sof; 318 pt_get_sof(&sof); 319 sheet_place_tag(doc.sh, &sof, &pane.caret_pos); 320 pane.ideal_column = 1; 321 322 if (argc == 2) { 323 doc.file_name = str_dup(argv[1]); 324 } else if (argc > 1) { 325 printf("Invalid arguments.\n"); 326 return -2; 327 } else { 328 doc.file_name = NULL; 329 } 330 331 new_file = false; 332 333 if (doc.file_name == NULL || file_insert(doc.file_name) != EOK) 334 new_file = true; 335 336 /* Place selection start tag. */ 337 sheet_place_tag(doc.sh, &sof, &pane.sel_start); 338 339 /* Move to beginning of file. */ 340 pt_get_sof(&sof); 334 341 335 342 /* Create UI */ … … 338 345 return 1; 339 346 340 if (argc == 2) { 341 doc.file_name = str_dup(argv[1]); 342 rc = file_open_file(argv[1]); 343 if (rc != EOK) { 344 status_display("File not found. Starting empty file."); 345 rc = file_new(); 346 } 347 } else if (argc > 1) { 348 printf("Invalid arguments.\n"); 349 return -2; 350 } else { 351 rc = file_new(); 352 } 347 caret_move(sof, true, true); 353 348 354 349 /* Initial display */ … … 358 353 return rc; 359 354 } 355 356 pane_status_display(&pane); 357 if (new_file && doc.file_name != NULL) 358 status_display("File not found. Starting empty file."); 359 pane_caret_display(&pane); 360 cursor_setvis(true); 360 361 361 362 ui_run(edit.ui); … … 377 378 ui_menu_t *mfile = NULL; 378 379 ui_menu_t *medit = NULL; 379 ui_menu_entry_t *mnew = NULL;380 ui_menu_entry_t *mopen = NULL;381 380 ui_menu_entry_t *msave = NULL; 382 381 ui_menu_entry_t *msaveas = NULL; … … 432 431 } 433 432 434 ui_menu_bar_set_cb(edit->menubar, &edit_menubar_cb, (void *) edit);435 436 433 rc = ui_menu_dd_create(edit->menubar, "~F~ile", NULL, &mfile); 437 434 if (rc != EOK) { … … 440 437 } 441 438 442 rc = ui_menu_entry_create(mfile, "~ N~ew", "Ctrl-N", &mnew);439 rc = ui_menu_entry_create(mfile, "~S~ave", "Ctrl-S", &msave); 443 440 if (rc != EOK) { 444 441 printf("Error creating menu.\n"); … … 446 443 } 447 444 448 ui_menu_entry_set_cb(m new, edit_file_new, (void *) edit);449 450 rc = ui_menu_entry_create(mfile, " ~O~pen", "Ctrl-O", &mopen);445 ui_menu_entry_set_cb(msave, edit_file_save, (void *) edit); 446 447 rc = ui_menu_entry_create(mfile, "Save ~A~s", "Ctrl-E", &msaveas); 451 448 if (rc != EOK) { 452 449 printf("Error creating menu.\n"); … … 454 451 } 455 452 456 ui_menu_entry_set_cb(m open, edit_file_open, (void *) edit);457 458 rc = ui_menu_entry_ create(mfile, "~S~ave", "Ctrl-S", &msave);453 ui_menu_entry_set_cb(msaveas, edit_file_save_as, (void *) edit); 454 455 rc = ui_menu_entry_sep_create(mfile, &mfsep); 459 456 if (rc != EOK) { 460 457 printf("Error creating menu.\n"); … … 462 459 } 463 460 464 ui_menu_entry_set_cb(msave, edit_file_save, (void *) edit); 465 466 rc = ui_menu_entry_create(mfile, "Save ~A~s", "Ctrl-E", &msaveas); 461 rc = ui_menu_entry_create(mfile, "E~x~it", "Ctrl-Q", &mexit); 467 462 if (rc != EOK) { 468 463 printf("Error creating menu.\n"); … … 470 465 } 471 466 472 ui_menu_entry_set_cb(m saveas, edit_file_save_as, (void *) edit);473 474 rc = ui_menu_ entry_sep_create(mfile, &mfsep);467 ui_menu_entry_set_cb(mexit, edit_file_exit, (void *) edit); 468 469 rc = ui_menu_dd_create(edit->menubar, "~E~dit", NULL, &medit); 475 470 if (rc != EOK) { 476 471 printf("Error creating menu.\n"); … … 478 473 } 479 474 480 rc = ui_menu_entry_create(m file, "E~x~it", "Ctrl-Q", &mexit);475 rc = ui_menu_entry_create(medit, "Cu~t~", "Ctrl-X", &mcut); 481 476 if (rc != EOK) { 482 477 printf("Error creating menu.\n"); … … 484 479 } 485 480 486 ui_menu_entry_set_cb(m exit, edit_file_exit, (void *) edit);487 488 rc = ui_menu_ dd_create(edit->menubar, "~E~dit", NULL, &medit);481 ui_menu_entry_set_cb(mcut, edit_edit_cut, (void *) edit); 482 483 rc = ui_menu_entry_create(medit, "~C~opy", "Ctrl-C", &mcopy); 489 484 if (rc != EOK) { 490 485 printf("Error creating menu.\n"); … … 492 487 } 493 488 494 rc = ui_menu_entry_create(medit, "Cu~t~", "Ctrl-X", &mcut); 489 ui_menu_entry_set_cb(mcopy, edit_edit_copy, (void *) edit); 490 491 rc = ui_menu_entry_create(medit, "~P~aste", "Ctrl-V", &mpaste); 495 492 if (rc != EOK) { 496 493 printf("Error creating menu.\n"); … … 498 495 } 499 496 500 ui_menu_entry_set_cb(m cut, edit_edit_cut, (void *) edit);501 502 rc = ui_menu_entry_create(medit, "~ C~opy", "Ctrl-C", &mcopy);497 ui_menu_entry_set_cb(mpaste, edit_edit_paste, (void *) edit); 498 499 rc = ui_menu_entry_create(medit, "~D~elete", "Del", &mdelete); 503 500 if (rc != EOK) { 504 501 printf("Error creating menu.\n"); … … 506 503 } 507 504 508 ui_menu_entry_set_cb(m copy, edit_edit_copy, (void *) edit);509 510 rc = ui_menu_entry_ create(medit, "~P~aste", "Ctrl-V", &mpaste);505 ui_menu_entry_set_cb(mdelete, edit_edit_delete, (void *) edit); 506 507 rc = ui_menu_entry_sep_create(medit, &mesep); 511 508 if (rc != EOK) { 512 509 printf("Error creating menu.\n"); … … 514 511 } 515 512 516 ui_menu_entry_set_cb(mpaste, edit_edit_paste, (void *) edit); 517 518 rc = ui_menu_entry_create(medit, "~D~elete", "Del", &mdelete); 513 rc = ui_menu_entry_create(medit, "Select ~A~ll", "Ctrl-A", &mselall); 519 514 if (rc != EOK) { 520 515 printf("Error creating menu.\n"); … … 522 517 } 523 518 524 ui_menu_entry_set_cb(m delete, edit_edit_delete, (void *) edit);525 526 rc = ui_menu_ entry_sep_create(medit, &mesep);519 ui_menu_entry_set_cb(mselall, edit_edit_select_all, (void *) edit); 520 521 rc = ui_menu_dd_create(edit->menubar, "~S~earch", NULL, &msearch); 527 522 if (rc != EOK) { 528 523 printf("Error creating menu.\n"); … … 530 525 } 531 526 532 rc = ui_menu_entry_create(m edit, "Select ~A~ll", "Ctrl-A", &mselall);527 rc = ui_menu_entry_create(msearch, "~F~ind", "Ctrl-F", &mfind); 533 528 if (rc != EOK) { 534 529 printf("Error creating menu.\n"); … … 536 531 } 537 532 538 ui_menu_entry_set_cb(m selall, edit_edit_select_all, (void *) edit);539 540 rc = ui_menu_ dd_create(edit->menubar, "~S~earch", NULL, &msearch);533 ui_menu_entry_set_cb(mfind, edit_search_find, (void *) edit); 534 535 rc = ui_menu_entry_create(msearch, "~R~everse Find", "Ctrl-Shift-F", &mfindr); 541 536 if (rc != EOK) { 542 537 printf("Error creating menu.\n"); … … 544 539 } 545 540 546 rc = ui_menu_entry_create(msearch, "~F~ind", "Ctrl-F", &mfind);547 if (rc != EOK) {548 printf("Error creating menu.\n");549 return rc;550 }551 552 ui_menu_entry_set_cb(mfind, edit_search_find, (void *) edit);553 554 rc = ui_menu_entry_create(msearch, "~R~everse Find", "Ctrl-Shift-F", &mfindr);555 if (rc != EOK) {556 printf("Error creating menu.\n");557 return rc;558 }559 560 541 ui_menu_entry_set_cb(mfindr, edit_search_reverse_find, (void *) edit); 561 542 562 rc = ui_menu_entry_create(msearch, "Find ~N~ext", "Ctrl- R", &mfindn);543 rc = ui_menu_entry_create(msearch, "Find ~N~ext", "Ctrl-N", &mfindn); 563 544 if (rc != EOK) { 564 545 printf("Error creating menu.\n"); … … 746 727 ui_quit(edit.ui); 747 728 break; 748 case KC_N:749 file_new();750 break;751 case KC_O:752 file_open();753 break;754 729 case KC_S: 755 730 if (doc.file_name != NULL) … … 785 760 search_prompt(false); 786 761 break; 787 case KC_ R:762 case KC_N: 788 763 search_repeat(); 789 764 break; … … 924 899 } 925 900 926 /** Create new document. */ 927 static errno_t file_new(void) 928 { 901 /** Save the document. */ 902 static errno_t file_save(char const *fname) 903 { 904 spt_t sp, ep; 929 905 errno_t rc; 930 sheet_t *sh; 931 932 /* Create empty sheet. */ 933 rc = sheet_create(&sh); 934 if (rc != EOK) { 935 printf("Out of memory.\n"); 936 return ENOMEM; 937 } 938 939 if (doc.sh != NULL) 940 sheet_destroy(doc.sh); 941 942 doc.sh = sh; 943 944 /* Place caret at the beginning of file. */ 945 spt_t sof; 946 pt_get_sof(&sof); 947 sheet_place_tag(doc.sh, &sof, &pane.caret_pos); 948 pane.ideal_column = 1; 949 950 doc.file_name = NULL; 951 952 /* Place selection start tag. */ 953 sheet_place_tag(doc.sh, &sof, &pane.sel_start); 954 955 /* Move to beginning of file. */ 956 pt_get_sof(&sof); 957 958 caret_move(sof, true, true); 959 960 pane_status_display(&pane); 961 pane_caret_display(&pane); 962 pane_text_display(&pane); 963 cursor_setvis(true); 964 965 return EOK; 966 } 967 968 /** Open Open File dialog. */ 969 static void file_open(void) 906 907 status_display("Saving..."); 908 pt_get_sof(&sp); 909 pt_get_eof(&ep); 910 911 rc = file_save_range(fname, &sp, &ep); 912 913 switch (rc) { 914 case EINVAL: 915 status_display("Error opening file!"); 916 break; 917 case EIO: 918 status_display("Error writing data!"); 919 break; 920 default: 921 status_display("File saved."); 922 break; 923 } 924 925 return rc; 926 } 927 928 /** Open Save As dialog. */ 929 static void file_save_as(void) 970 930 { 971 931 const char *old_fname = (doc.file_name != NULL) ? doc.file_name : ""; … … 975 935 976 936 ui_file_dialog_params_init(&fdparams); 977 fdparams.caption = " Open File";937 fdparams.caption = "Save As"; 978 938 fdparams.ifname = old_fname; 979 939 … … 984 944 } 985 945 986 ui_file_dialog_set_cb(dialog, &open_dialog_cb, &edit);987 }988 989 /** Open exising document. */990 static errno_t file_open_file(const char *fname)991 {992 errno_t rc;993 sheet_t *sh;994 char *fn;995 996 /* Create empty sheet. */997 rc = sheet_create(&sh);998 if (rc != EOK) {999 printf("Out of memory.\n");1000 return ENOMEM;1001 }1002 1003 fn = str_dup(fname);1004 if (fn == NULL) {1005 sheet_destroy(sh);1006 return ENOMEM;1007 }1008 1009 if (doc.sh != NULL)1010 sheet_destroy(doc.sh);1011 1012 doc.sh = sh;1013 1014 /* Place caret at the beginning of file. */1015 spt_t sof;1016 pt_get_sof(&sof);1017 sheet_place_tag(doc.sh, &sof, &pane.caret_pos);1018 pane.ideal_column = 1;1019 1020 rc = file_insert(fname);1021 if (rc != EOK)1022 return rc;1023 1024 doc.file_name = fn;1025 1026 /* Place selection start tag. */1027 sheet_place_tag(doc.sh, &sof, &pane.sel_start);1028 1029 /* Move to beginning of file. */1030 pt_get_sof(&sof);1031 1032 caret_move(sof, true, true);1033 1034 pane_status_display(&pane);1035 pane_caret_display(&pane);1036 pane_text_display(&pane);1037 cursor_setvis(true);1038 1039 return EOK;1040 }1041 1042 /** Save the document. */1043 static errno_t file_save(char const *fname)1044 {1045 spt_t sp, ep;1046 errno_t rc;1047 1048 status_display("Saving...");1049 pt_get_sof(&sp);1050 pt_get_eof(&ep);1051 1052 rc = file_save_range(fname, &sp, &ep);1053 1054 switch (rc) {1055 case EINVAL:1056 status_display("Error opening file!");1057 break;1058 case EIO:1059 status_display("Error writing data!");1060 break;1061 default:1062 status_display("File saved.");1063 break;1064 }1065 1066 return rc;1067 }1068 1069 /** Open Save As dialog. */1070 static void file_save_as(void)1071 {1072 const char *old_fname = (doc.file_name != NULL) ? doc.file_name : "";1073 ui_file_dialog_params_t fdparams;1074 ui_file_dialog_t *dialog;1075 errno_t rc;1076 1077 ui_file_dialog_params_init(&fdparams);1078 fdparams.caption = "Save As";1079 fdparams.ifname = old_fname;1080 1081 rc = ui_file_dialog_create(edit.ui, &fdparams, &dialog);1082 if (rc != EOK) {1083 printf("Error creating message dialog.\n");1084 return;1085 }1086 1087 946 ui_file_dialog_set_cb(dialog, &save_as_dialog_cb, &edit); 1088 947 } … … 1093 952 * of the caret. 1094 953 */ 1095 static errno_t file_insert(c onst char *fname)954 static errno_t file_insert(char *fname) 1096 955 { 1097 956 FILE *f; … … 2362 2221 } 2363 2222 2364 /** Window focus event2365 *2366 * @param window Window2367 * @param arg Argument (edit_t *)2368 * @param focus Focus number2369 */2370 static void edit_wnd_focus(ui_window_t *window, void *arg, unsigned focus)2371 {2372 edit_t *edit = (edit_t *)arg;2373 2374 (void)edit;2375 pane_caret_display(&pane);2376 cursor_setvis(true);2377 }2378 2379 2223 /** Window keyboard event 2380 2224 * … … 2398 2242 } 2399 2243 2400 /** Window unfocus event2401 *2402 * @param window Window2403 * @param arg Argument (edit_t *)2404 * @param focus Focus number2405 */2406 static void edit_wnd_unfocus(ui_window_t *window, void *arg, unsigned focus)2407 {2408 edit_t *edit = (edit_t *) arg;2409 2410 (void)edit;2411 cursor_setvis(false);2412 }2413 2414 /** Menu bar activate event2415 *2416 * @param mbar Menu bar2417 * @param arg Argument (edit_t *)2418 */2419 static void edit_menubar_activate(ui_menu_bar_t *mbar, void *arg)2420 {2421 edit_t *edit = (edit_t *)arg;2422 2423 (void)edit;2424 cursor_setvis(false);2425 }2426 2427 /** Menu bar deactivate event2428 *2429 * @param mbar Menu bar2430 * @param arg Argument (edit_t *)2431 */2432 static void edit_menubar_deactivate(ui_menu_bar_t *mbar, void *arg)2433 {2434 edit_t *edit = (edit_t *)arg;2435 2436 (void)edit;2437 pane_caret_display(&pane);2438 cursor_setvis(true);2439 }2440 2441 /** File / New menu entry selected.2442 *2443 * @param mentry Menu entry2444 * @param arg Argument (edit_t *)2445 */2446 static void edit_file_new(ui_menu_entry_t *mentry, void *arg)2447 {2448 edit_t *edit = (edit_t *) arg;2449 2450 (void)edit;2451 file_new();2452 (void) gfx_update(ui_window_get_gc(edit->window));2453 }2454 2455 /** File / Open menu entry selected.2456 *2457 * @param mentry Menu entry2458 * @param arg Argument (edit_t *)2459 */2460 static void edit_file_open(ui_menu_entry_t *mentry, void *arg)2461 {2462 edit_t *edit = (edit_t *) arg;2463 2464 (void)edit;2465 file_open();2466 }2467 2468 2244 /** File / Save menu entry selected. 2469 2245 * … … 2621 2397 } 2622 2398 2623 /** Open Filedialog OK button press.2624 * 2625 * @param dialog Open Filedialog2399 /** Save As dialog OK button press. 2400 * 2401 * @param dialog Save As dialog 2626 2402 * @param arg Argument (ui_demo_t *) 2627 2403 * @param fname File name 2628 2404 */ 2629 static void open_dialog_bok(ui_file_dialog_t *dialog, void *arg,2405 static void save_as_dialog_bok(ui_file_dialog_t *dialog, void *arg, 2630 2406 const char *fname) 2631 2407 { 2632 2408 edit_t *edit = (edit_t *)arg; 2409 gfx_context_t *gc = ui_window_get_gc(edit->window); 2633 2410 char *cname; 2634 2411 errno_t rc; 2635 2412 2636 (void)edit;2637 2413 ui_file_dialog_destroy(dialog); 2414 // TODO Smarter cursor management 2415 pane.rflags |= REDRAW_CARET; 2416 (void) pane_update(&pane); 2417 gfx_cursor_set_visible(gc, true); 2638 2418 2639 2419 cname = str_dup(fname); … … 2643 2423 } 2644 2424 2645 rc = file_ open_file(fname);2425 rc = file_save(fname); 2646 2426 if (rc != EOK) 2647 2427 return; … … 2651 2431 doc.file_name = cname; 2652 2432 2653 (void) gfx_update(ui_window_get_gc(edit->window)); 2654 } 2655 2656 /** Open File dialog cancel button press. 2433 } 2434 2435 /** Save As dialog cancel button press. 2657 2436 * 2658 2437 * @param dialog File dialog 2659 2438 * @param arg Argument (ui_demo_t *) 2660 2439 */ 2661 static void open_dialog_bcancel(ui_file_dialog_t *dialog, void *arg)2440 static void save_as_dialog_bcancel(ui_file_dialog_t *dialog, void *arg) 2662 2441 { 2663 2442 edit_t *edit = (edit_t *)arg; 2664 2665 (void)edit; 2443 gfx_context_t *gc = ui_window_get_gc(edit->window); 2444 2666 2445 ui_file_dialog_destroy(dialog); 2667 } 2668 2669 /** Open File dialog close request. 2446 // TODO Smarter cursor management 2447 pane.rflags |= REDRAW_CARET; 2448 (void) pane_update(&pane); 2449 gfx_cursor_set_visible(gc, true); 2450 } 2451 2452 /** Save As dialog close request. 2670 2453 * 2671 2454 * @param dialog File dialog 2672 2455 * @param arg Argument (ui_demo_t *) 2673 2456 */ 2674 static void open_dialog_close(ui_file_dialog_t *dialog, void *arg)2457 static void save_as_dialog_close(ui_file_dialog_t *dialog, void *arg) 2675 2458 { 2676 2459 edit_t *edit = (edit_t *)arg; 2677 2678 (void)edit; 2460 gfx_context_t *gc = ui_window_get_gc(edit->window); 2461 2679 2462 ui_file_dialog_destroy(dialog); 2680 } 2681 2682 /** Save As dialog OK button press. 2683 * 2684 * @param dialog Save As dialog 2685 * @param arg Argument (ui_demo_t *) 2686 * @param fname File name 2687 */ 2688 static void save_as_dialog_bok(ui_file_dialog_t *dialog, void *arg, 2689 const char *fname) 2690 { 2691 edit_t *edit = (edit_t *)arg; 2692 char *cname; 2693 errno_t rc; 2694 2695 (void)edit; 2696 ui_file_dialog_destroy(dialog); 2697 2698 cname = str_dup(fname); 2699 if (cname == NULL) { 2700 printf("Out of memory.\n"); 2701 return; 2702 } 2703 2704 rc = file_save(fname); 2705 if (rc != EOK) 2706 return; 2707 2708 if (doc.file_name != NULL) 2709 free(doc.file_name); 2710 doc.file_name = cname; 2711 2712 } 2713 2714 /** Save As dialog cancel button press. 2715 * 2716 * @param dialog File dialog 2717 * @param arg Argument (ui_demo_t *) 2718 */ 2719 static void save_as_dialog_bcancel(ui_file_dialog_t *dialog, void *arg) 2720 { 2721 edit_t *edit = (edit_t *)arg; 2722 2723 (void)edit; 2724 ui_file_dialog_destroy(dialog); 2725 } 2726 2727 /** Save As dialog close request. 2728 * 2729 * @param dialog File dialog 2730 * @param arg Argument (ui_demo_t *) 2731 */ 2732 static void save_as_dialog_close(ui_file_dialog_t *dialog, void *arg) 2733 { 2734 edit_t *edit = (edit_t *)arg; 2735 2736 (void)edit; 2737 ui_file_dialog_destroy(dialog); 2463 // TODO Smarter cursor management 2464 pane.rflags |= REDRAW_CARET; 2465 (void) pane_update(&pane); 2466 gfx_cursor_set_visible(gc, true); 2738 2467 } 2739 2468 … … 2748 2477 { 2749 2478 edit_t *edit = (edit_t *) arg; 2479 gfx_context_t *gc = ui_window_get_gc(edit->window); 2750 2480 char *endptr; 2751 2481 int line; … … 2759 2489 2760 2490 caret_move_absolute(line, pane.ideal_column, dir_before, false); 2761 (void)edit;2491 // TODO Smarter cursor management 2762 2492 (void) pane_update(&pane); 2493 gfx_cursor_set_visible(gc, true); 2494 (void) gfx_update(gc); 2763 2495 } 2764 2496 … … 2771 2503 { 2772 2504 edit_t *edit = (edit_t *) arg; 2773 2774 (void)edit; 2505 gfx_context_t *gc = ui_window_get_gc(edit->window); 2506 2775 2507 ui_prompt_dialog_destroy(dialog); 2508 // TODO Smarter cursor management 2509 pane.rflags |= REDRAW_CARET; 2510 (void) pane_update(&pane); 2511 gfx_cursor_set_visible(gc, true); 2776 2512 } 2777 2513 … … 2784 2520 { 2785 2521 edit_t *edit = (edit_t *) arg; 2786 2787 (void)edit; 2522 gfx_context_t *gc = ui_window_get_gc(edit->window); 2523 2788 2524 ui_prompt_dialog_destroy(dialog); 2525 // TODO Smarter cursor management 2526 pane.rflags |= REDRAW_CARET; 2527 (void) pane_update(&pane); 2528 gfx_cursor_set_visible(gc, true); 2789 2529 } 2790 2530 … … 2799 2539 { 2800 2540 edit_t *edit = (edit_t *) arg; 2541 gfx_context_t *gc = ui_window_get_gc(edit->window); 2801 2542 char *pattern; 2802 2543 bool reverse; 2803 2544 2804 (void)edit;2805 2545 ui_prompt_dialog_destroy(dialog); 2806 2546 … … 2819 2559 search(pattern, reverse); 2820 2560 2561 // TODO Smarter cursor management 2821 2562 (void) pane_update(&pane); 2563 gfx_cursor_set_visible(gc, true); 2564 (void) gfx_update(gc); 2822 2565 } 2823 2566 … … 2830 2573 { 2831 2574 edit_t *edit = (edit_t *) arg; 2832 2833 (void)edit; 2575 gfx_context_t *gc = ui_window_get_gc(edit->window); 2576 2834 2577 ui_prompt_dialog_destroy(dialog); 2578 // TODO Smarter cursor management 2579 pane.rflags |= REDRAW_CARET; 2580 (void) pane_update(&pane); 2581 gfx_cursor_set_visible(gc, true); 2835 2582 } 2836 2583 … … 2843 2590 { 2844 2591 edit_t *edit = (edit_t *) arg; 2845 2846 (void)edit; 2592 gfx_context_t *gc = ui_window_get_gc(edit->window); 2593 2847 2594 ui_prompt_dialog_destroy(dialog); 2595 // TODO Smarter cursor management 2596 pane.rflags |= REDRAW_CARET; 2597 (void) pane_update(&pane); 2598 gfx_cursor_set_visible(gc, true); 2848 2599 } 2849 2600
Note:
See TracChangeset
for help on using the changeset viewer.