Changes in uspace/app/edit/edit.c [e0cf963:994f87b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
re0cf963 r994f87b 1 1 /* 2 * Copyright (c) 202 1Jiri Svoboda2 * Copyright (c) 2024 Jiri Svoboda 3 3 * Copyright (c) 2012 Martin Sucha 4 4 * All rights reserved. … … 60 60 #include <ui/menu.h> 61 61 #include <ui/menubar.h> 62 #include <ui/menudd.h> 62 63 #include <ui/menuentry.h> 63 64 #include <ui/promptdialog.h> … … 176 177 static void pos_handle(pos_event_t *ev); 177 178 179 static errno_t file_new(void); 180 static void file_open(void); 181 static errno_t file_open_file(const char *fname); 178 182 static errno_t file_save(char const *fname); 179 183 static void file_save_as(void); 180 static errno_t file_insert(c har *fname);184 static errno_t file_insert(const char *fname); 181 185 static errno_t file_save_range(char const *fname, spt_t const *spos, 182 186 spt_t const *epos); … … 237 241 238 242 static void edit_wnd_close(ui_window_t *, void *); 243 static void edit_wnd_focus(ui_window_t *, void *, unsigned); 239 244 static void edit_wnd_kbd_event(ui_window_t *, void *, kbd_event_t *); 245 static void edit_wnd_unfocus(ui_window_t *, void *, unsigned); 240 246 241 247 static ui_window_cb_t edit_window_cb = { 242 248 .close = edit_wnd_close, 243 .kbd = edit_wnd_kbd_event 249 .focus = edit_wnd_focus, 250 .kbd = edit_wnd_kbd_event, 251 .unfocus = edit_wnd_unfocus 244 252 }; 245 253 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_deactivate 260 }; 261 262 static void edit_file_new(ui_menu_entry_t *, void *); 263 static void edit_file_open(ui_menu_entry_t *, void *); 246 264 static void edit_file_save(ui_menu_entry_t *, void *); 247 265 static void edit_file_save_as(ui_menu_entry_t *, void *); … … 268 286 }; 269 287 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_close 296 }; 297 270 298 static void save_as_dialog_bok(ui_file_dialog_t *, void *, const char *); 271 299 static void save_as_dialog_bcancel(ui_file_dialog_t *, void *); … … 300 328 int main(int argc, char *argv[]) 301 329 { 302 bool new_file;303 330 errno_t rc; 304 331 … … 306 333 pane.sh_column = 1; 307 334 308 /* Start with an empty sheet. */ 309 rc = sheet_create(&doc.sh); 310 if (rc != EOK) { 311 printf("Out of memory.\n"); 312 return -1; 313 } 314 315 /* Place caret at the beginning of file. */ 316 spt_t sof; 317 pt_get_sof(&sof); 318 sheet_place_tag(doc.sh, &sof, &pane.caret_pos); 319 pane.ideal_column = 1; 335 /* Create UI */ 336 rc = edit_ui_create(&edit); 337 if (rc != EOK) 338 return 1; 320 339 321 340 if (argc == 2) { 322 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 } 323 347 } else if (argc > 1) { 324 348 printf("Invalid arguments.\n"); 325 349 return -2; 326 350 } else { 327 doc.file_name = NULL; 328 } 329 330 new_file = false; 331 332 if (doc.file_name == NULL || file_insert(doc.file_name) != EOK) 333 new_file = true; 334 335 /* Place selection start tag. */ 336 sheet_place_tag(doc.sh, &sof, &pane.sel_start); 337 338 /* Move to beginning of file. */ 339 pt_get_sof(&sof); 340 341 /* Create UI */ 342 rc = edit_ui_create(&edit); 343 if (rc != EOK) 344 return 1; 345 346 caret_move(sof, true, true); 351 rc = file_new(); 352 } 347 353 348 354 /* Initial display */ … … 352 358 return rc; 353 359 } 354 355 pane_status_display(&pane);356 if (new_file && doc.file_name != NULL)357 status_display("File not found. Starting empty file.");358 pane_caret_display(&pane);359 cursor_setvis(true);360 360 361 361 ui_run(edit.ui); … … 377 377 ui_menu_t *mfile = NULL; 378 378 ui_menu_t *medit = NULL; 379 ui_menu_entry_t *mnew = NULL; 380 ui_menu_entry_t *mopen = NULL; 379 381 ui_menu_entry_t *msave = NULL; 380 382 ui_menu_entry_t *msaveas = NULL; … … 430 432 } 431 433 432 rc = ui_menu_create(edit->menubar, "File", &mfile); 434 ui_menu_bar_set_cb(edit->menubar, &edit_menubar_cb, (void *) edit); 435 436 rc = ui_menu_dd_create(edit->menubar, "~F~ile", NULL, &mfile); 433 437 if (rc != EOK) { 434 438 printf("Error creating menu.\n"); … … 436 440 } 437 441 438 rc = ui_menu_entry_create(mfile, " Save", "Ctrl-S", &msave);442 rc = ui_menu_entry_create(mfile, "~N~ew", "Ctrl-N", &mnew); 439 443 if (rc != EOK) { 440 444 printf("Error creating menu.\n"); … … 442 446 } 443 447 448 ui_menu_entry_set_cb(mnew, edit_file_new, (void *) edit); 449 450 rc = ui_menu_entry_create(mfile, "~O~pen", "Ctrl-O", &mopen); 451 if (rc != EOK) { 452 printf("Error creating menu.\n"); 453 return rc; 454 } 455 456 ui_menu_entry_set_cb(mopen, edit_file_open, (void *) edit); 457 458 rc = ui_menu_entry_create(mfile, "~S~ave", "Ctrl-S", &msave); 459 if (rc != EOK) { 460 printf("Error creating menu.\n"); 461 return rc; 462 } 463 444 464 ui_menu_entry_set_cb(msave, edit_file_save, (void *) edit); 445 465 446 rc = ui_menu_entry_create(mfile, "Save As", "Ctrl-E", &msaveas);466 rc = ui_menu_entry_create(mfile, "Save ~A~s", "Ctrl-E", &msaveas); 447 467 if (rc != EOK) { 448 468 printf("Error creating menu.\n"); … … 458 478 } 459 479 460 rc = ui_menu_entry_create(mfile, "E xit", "Ctrl-Q", &mexit);480 rc = ui_menu_entry_create(mfile, "E~x~it", "Ctrl-Q", &mexit); 461 481 if (rc != EOK) { 462 482 printf("Error creating menu.\n"); … … 466 486 ui_menu_entry_set_cb(mexit, edit_file_exit, (void *) edit); 467 487 468 rc = ui_menu_ create(edit->menubar, "Edit", &medit);488 rc = ui_menu_dd_create(edit->menubar, "~E~dit", NULL, &medit); 469 489 if (rc != EOK) { 470 490 printf("Error creating menu.\n"); … … 472 492 } 473 493 474 rc = ui_menu_entry_create(medit, "Cu t", "Ctrl-X", &mcut);494 rc = ui_menu_entry_create(medit, "Cu~t~", "Ctrl-X", &mcut); 475 495 if (rc != EOK) { 476 496 printf("Error creating menu.\n"); … … 480 500 ui_menu_entry_set_cb(mcut, edit_edit_cut, (void *) edit); 481 501 482 rc = ui_menu_entry_create(medit, " Copy", "Ctrl-C", &mcopy);502 rc = ui_menu_entry_create(medit, "~C~opy", "Ctrl-C", &mcopy); 483 503 if (rc != EOK) { 484 504 printf("Error creating menu.\n"); … … 488 508 ui_menu_entry_set_cb(mcopy, edit_edit_copy, (void *) edit); 489 509 490 rc = ui_menu_entry_create(medit, " Paste", "Ctrl-V", &mpaste);510 rc = ui_menu_entry_create(medit, "~P~aste", "Ctrl-V", &mpaste); 491 511 if (rc != EOK) { 492 512 printf("Error creating menu.\n"); … … 496 516 ui_menu_entry_set_cb(mpaste, edit_edit_paste, (void *) edit); 497 517 498 rc = ui_menu_entry_create(medit, " Delete", "Del", &mdelete);518 rc = ui_menu_entry_create(medit, "~D~elete", "Del", &mdelete); 499 519 if (rc != EOK) { 500 520 printf("Error creating menu.\n"); … … 510 530 } 511 531 512 rc = ui_menu_entry_create(medit, "Select All", "Ctrl-A", &mselall);532 rc = ui_menu_entry_create(medit, "Select ~A~ll", "Ctrl-A", &mselall); 513 533 if (rc != EOK) { 514 534 printf("Error creating menu.\n"); … … 518 538 ui_menu_entry_set_cb(mselall, edit_edit_select_all, (void *) edit); 519 539 520 rc = ui_menu_ create(edit->menubar, "Search", &msearch);540 rc = ui_menu_dd_create(edit->menubar, "~S~earch", NULL, &msearch); 521 541 if (rc != EOK) { 522 542 printf("Error creating menu.\n"); … … 524 544 } 525 545 526 rc = ui_menu_entry_create(msearch, " Find", "Ctrl-F", &mfind);546 rc = ui_menu_entry_create(msearch, "~F~ind", "Ctrl-F", &mfind); 527 547 if (rc != EOK) { 528 548 printf("Error creating menu.\n"); … … 532 552 ui_menu_entry_set_cb(mfind, edit_search_find, (void *) edit); 533 553 534 rc = ui_menu_entry_create(msearch, " Reverse Find", "Ctrl-Shift-F", &mfindr);554 rc = ui_menu_entry_create(msearch, "~R~everse Find", "Ctrl-Shift-F", &mfindr); 535 555 if (rc != EOK) { 536 556 printf("Error creating menu.\n"); … … 540 560 ui_menu_entry_set_cb(mfindr, edit_search_reverse_find, (void *) edit); 541 561 542 rc = ui_menu_entry_create(msearch, "Find Next", "Ctrl-N", &mfindn);562 rc = ui_menu_entry_create(msearch, "Find ~N~ext", "Ctrl-R", &mfindn); 543 563 if (rc != EOK) { 544 564 printf("Error creating menu.\n"); … … 554 574 } 555 575 556 rc = ui_menu_entry_create(msearch, "Go To Line", "Ctrl-L", &mgoto);576 rc = ui_menu_entry_create(msearch, "Go To ~L~ine", "Ctrl-L", &mgoto); 557 577 if (rc != EOK) { 558 578 printf("Error creating menu.\n"); … … 726 746 ui_quit(edit.ui); 727 747 break; 748 case KC_N: 749 file_new(); 750 break; 751 case KC_O: 752 file_open(); 753 break; 728 754 case KC_S: 729 755 if (doc.file_name != NULL) … … 759 785 search_prompt(false); 760 786 break; 761 case KC_ N:787 case KC_R: 762 788 search_repeat(); 763 789 break; … … 898 924 } 899 925 900 /** Save the document. */ 901 static errno_t file_save(char const *fname) 902 { 903 spt_t sp, ep; 926 /** Create new document. */ 927 static errno_t file_new(void) 928 { 904 929 errno_t rc; 905 906 status_display("Saving..."); 907 pt_get_sof(&sp); 908 pt_get_eof(&ep); 909 910 rc = file_save_range(fname, &sp, &ep); 911 912 switch (rc) { 913 case EINVAL: 914 status_display("Error opening file!"); 915 break; 916 case EIO: 917 status_display("Error writing data!"); 918 break; 919 default: 920 status_display("File saved."); 921 break; 922 } 923 924 return rc; 925 } 926 927 /** Open Save As dialog. */ 928 static void file_save_as(void) 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) 929 970 { 930 971 const char *old_fname = (doc.file_name != NULL) ? doc.file_name : ""; … … 934 975 935 976 ui_file_dialog_params_init(&fdparams); 977 fdparams.caption = "Open File"; 978 fdparams.ifname = old_fname; 979 980 rc = ui_file_dialog_create(edit.ui, &fdparams, &dialog); 981 if (rc != EOK) { 982 printf("Error creating message dialog.\n"); 983 return; 984 } 985 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); 936 1078 fdparams.caption = "Save As"; 937 1079 fdparams.ifname = old_fname; … … 951 1093 * of the caret. 952 1094 */ 953 static errno_t file_insert(c har *fname)1095 static errno_t file_insert(const char *fname) 954 1096 { 955 1097 FILE *f; … … 978 1120 979 1121 bcnt -= off; 980 mem cpy(buf, buf + off, bcnt);1122 memmove(buf, buf + off, bcnt); 981 1123 982 1124 insert_char(c); … … 1259 1401 1260 1402 gfx_text_fmt_init(&fmt); 1403 fmt.font = font; 1261 1404 fmt.color = pane->color; 1262 1405 … … 1318 1461 return rc; 1319 1462 1320 rc = gfx_puttext( font,&tpos, &fmt, cbuf);1463 rc = gfx_puttext(&tpos, &fmt, cbuf); 1321 1464 if (rc != EOK) 1322 1465 return rc; … … 1408 1551 */ 1409 1552 while (true) { 1410 int rc = asprintf(&text, "%d, %d (%d): File '%s'. Ctrl-Q Quit Ctrl-S Save"1411 " Ctrl-E Save As", coord.row, coord.column, last_row, fname);1553 int rc = asprintf(&text, "%d, %d (%d): File '%s'. Ctrl-Q Quit " 1554 "F10 Menu", coord.row, coord.column, last_row, fname); 1412 1555 if (rc < 0) { 1413 1556 n = 0; … … 2219 2362 } 2220 2363 2364 /** Window focus event 2365 * 2366 * @param window Window 2367 * @param arg Argument (edit_t *) 2368 * @param focus Focus number 2369 */ 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 2221 2379 /** Window keyboard event 2222 2380 * … … 2229 2387 { 2230 2388 pane.keymod = event->mods; 2389 2390 if (ui_window_def_kbd(window, event) == ui_claimed) 2391 return; 2231 2392 2232 2393 if (event->type == KEY_PRESS) { … … 2237 2398 } 2238 2399 2400 /** Window unfocus event 2401 * 2402 * @param window Window 2403 * @param arg Argument (edit_t *) 2404 * @param focus Focus number 2405 */ 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 event 2415 * 2416 * @param mbar Menu bar 2417 * @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 event 2428 * 2429 * @param mbar Menu bar 2430 * @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 entry 2444 * @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 entry 2458 * @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 2239 2468 /** File / Save menu entry selected. 2240 2469 * … … 2392 2621 } 2393 2622 2394 /** Save Asdialog OK button press.2395 * 2396 * @param dialog Save Asdialog2623 /** Open File dialog OK button press. 2624 * 2625 * @param dialog Open File dialog 2397 2626 * @param arg Argument (ui_demo_t *) 2398 2627 * @param fname File name 2399 2628 */ 2400 static void save_as_dialog_bok(ui_file_dialog_t *dialog, void *arg,2629 static void open_dialog_bok(ui_file_dialog_t *dialog, void *arg, 2401 2630 const char *fname) 2402 2631 { 2403 2632 edit_t *edit = (edit_t *)arg; 2404 gfx_context_t *gc = ui_window_get_gc(edit->window);2405 2633 char *cname; 2406 2634 errno_t rc; 2407 2635 2636 (void)edit; 2408 2637 ui_file_dialog_destroy(dialog); 2409 // TODO Smarter cursor management2410 pane.rflags |= REDRAW_CARET;2411 (void) pane_update(&pane);2412 gfx_cursor_set_visible(gc, true);2413 2638 2414 2639 cname = str_dup(fname); … … 2418 2643 } 2419 2644 2645 rc = file_open_file(fname); 2646 if (rc != EOK) 2647 return; 2648 2649 if (doc.file_name != NULL) 2650 free(doc.file_name); 2651 doc.file_name = cname; 2652 2653 (void) gfx_update(ui_window_get_gc(edit->window)); 2654 } 2655 2656 /** Open File dialog cancel button press. 2657 * 2658 * @param dialog File dialog 2659 * @param arg Argument (ui_demo_t *) 2660 */ 2661 static void open_dialog_bcancel(ui_file_dialog_t *dialog, void *arg) 2662 { 2663 edit_t *edit = (edit_t *)arg; 2664 2665 (void)edit; 2666 ui_file_dialog_destroy(dialog); 2667 } 2668 2669 /** Open File dialog close request. 2670 * 2671 * @param dialog File dialog 2672 * @param arg Argument (ui_demo_t *) 2673 */ 2674 static void open_dialog_close(ui_file_dialog_t *dialog, void *arg) 2675 { 2676 edit_t *edit = (edit_t *)arg; 2677 2678 (void)edit; 2679 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 2420 2704 rc = file_save(fname); 2421 2705 if (rc != EOK) … … 2436 2720 { 2437 2721 edit_t *edit = (edit_t *)arg; 2438 gfx_context_t *gc = ui_window_get_gc(edit->window); 2439 2722 2723 (void)edit; 2440 2724 ui_file_dialog_destroy(dialog); 2441 // TODO Smarter cursor management2442 pane.rflags |= REDRAW_CARET;2443 (void) pane_update(&pane);2444 gfx_cursor_set_visible(gc, true);2445 2725 } 2446 2726 … … 2453 2733 { 2454 2734 edit_t *edit = (edit_t *)arg; 2455 gfx_context_t *gc = ui_window_get_gc(edit->window); 2456 2735 2736 (void)edit; 2457 2737 ui_file_dialog_destroy(dialog); 2458 // TODO Smarter cursor management2459 pane.rflags |= REDRAW_CARET;2460 (void) pane_update(&pane);2461 gfx_cursor_set_visible(gc, true);2462 2738 } 2463 2739 … … 2472 2748 { 2473 2749 edit_t *edit = (edit_t *) arg; 2474 gfx_context_t *gc = ui_window_get_gc(edit->window);2475 2750 char *endptr; 2476 2751 int line; … … 2484 2759 2485 2760 caret_move_absolute(line, pane.ideal_column, dir_before, false); 2486 // TODO Smarter cursor management2761 (void)edit; 2487 2762 (void) pane_update(&pane); 2488 gfx_cursor_set_visible(gc, true);2489 (void) gfx_update(gc);2490 2763 } 2491 2764 … … 2498 2771 { 2499 2772 edit_t *edit = (edit_t *) arg; 2500 gfx_context_t *gc = ui_window_get_gc(edit->window); 2501 2773 2774 (void)edit; 2502 2775 ui_prompt_dialog_destroy(dialog); 2503 // TODO Smarter cursor management2504 pane.rflags |= REDRAW_CARET;2505 (void) pane_update(&pane);2506 gfx_cursor_set_visible(gc, true);2507 2776 } 2508 2777 … … 2515 2784 { 2516 2785 edit_t *edit = (edit_t *) arg; 2517 gfx_context_t *gc = ui_window_get_gc(edit->window); 2518 2786 2787 (void)edit; 2519 2788 ui_prompt_dialog_destroy(dialog); 2520 // TODO Smarter cursor management2521 pane.rflags |= REDRAW_CARET;2522 (void) pane_update(&pane);2523 gfx_cursor_set_visible(gc, true);2524 2789 } 2525 2790 … … 2534 2799 { 2535 2800 edit_t *edit = (edit_t *) arg; 2536 gfx_context_t *gc = ui_window_get_gc(edit->window);2537 2801 char *pattern; 2538 2802 bool reverse; 2539 2803 2804 (void)edit; 2540 2805 ui_prompt_dialog_destroy(dialog); 2541 2806 … … 2554 2819 search(pattern, reverse); 2555 2820 2556 // TODO Smarter cursor management2557 2821 (void) pane_update(&pane); 2558 gfx_cursor_set_visible(gc, true);2559 (void) gfx_update(gc);2560 2822 } 2561 2823 … … 2568 2830 { 2569 2831 edit_t *edit = (edit_t *) arg; 2570 gfx_context_t *gc = ui_window_get_gc(edit->window); 2571 2832 2833 (void)edit; 2572 2834 ui_prompt_dialog_destroy(dialog); 2573 // TODO Smarter cursor management2574 pane.rflags |= REDRAW_CARET;2575 (void) pane_update(&pane);2576 gfx_cursor_set_visible(gc, true);2577 2835 } 2578 2836 … … 2585 2843 { 2586 2844 edit_t *edit = (edit_t *) arg; 2587 gfx_context_t *gc = ui_window_get_gc(edit->window); 2588 2845 2846 (void)edit; 2589 2847 ui_prompt_dialog_destroy(dialog); 2590 // TODO Smarter cursor management2591 pane.rflags |= REDRAW_CARET;2592 (void) pane_update(&pane);2593 gfx_cursor_set_visible(gc, true);2594 2848 } 2595 2849
Note:
See TracChangeset
for help on using the changeset viewer.