Changes in uspace/app/edit/edit.c [e0cf963:994f87b] in mainline


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/edit/edit.c

    re0cf963 r994f87b  
    11/*
    2  * Copyright (c) 2021 Jiri Svoboda
     2 * Copyright (c) 2024 Jiri Svoboda
    33 * Copyright (c) 2012 Martin Sucha
    44 * All rights reserved.
     
    6060#include <ui/menu.h>
    6161#include <ui/menubar.h>
     62#include <ui/menudd.h>
    6263#include <ui/menuentry.h>
    6364#include <ui/promptdialog.h>
     
    176177static void pos_handle(pos_event_t *ev);
    177178
     179static errno_t file_new(void);
     180static void file_open(void);
     181static errno_t file_open_file(const char *fname);
    178182static errno_t file_save(char const *fname);
    179183static void file_save_as(void);
    180 static errno_t file_insert(char *fname);
     184static errno_t file_insert(const char *fname);
    181185static errno_t file_save_range(char const *fname, spt_t const *spos,
    182186    spt_t const *epos);
     
    237241
    238242static void edit_wnd_close(ui_window_t *, void *);
     243static void edit_wnd_focus(ui_window_t *, void *, unsigned);
    239244static void edit_wnd_kbd_event(ui_window_t *, void *, kbd_event_t *);
     245static void edit_wnd_unfocus(ui_window_t *, void *, unsigned);
    240246
    241247static ui_window_cb_t edit_window_cb = {
    242248        .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
    244252};
    245253
     254static void edit_menubar_activate(ui_menu_bar_t *, void *);
     255static void edit_menubar_deactivate(ui_menu_bar_t *, void *);
     256
     257static ui_menu_bar_cb_t edit_menubar_cb = {
     258        .activate = edit_menubar_activate,
     259        .deactivate = edit_menubar_deactivate
     260};
     261
     262static void edit_file_new(ui_menu_entry_t *, void *);
     263static void edit_file_open(ui_menu_entry_t *, void *);
    246264static void edit_file_save(ui_menu_entry_t *, void *);
    247265static void edit_file_save_as(ui_menu_entry_t *, void *);
     
    268286};
    269287
     288static void open_dialog_bok(ui_file_dialog_t *, void *, const char *);
     289static void open_dialog_bcancel(ui_file_dialog_t *, void *);
     290static void open_dialog_close(ui_file_dialog_t *, void *);
     291
     292static 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
    270298static void save_as_dialog_bok(ui_file_dialog_t *, void *, const char *);
    271299static void save_as_dialog_bcancel(ui_file_dialog_t *, void *);
     
    300328int main(int argc, char *argv[])
    301329{
    302         bool new_file;
    303330        errno_t rc;
    304331
     
    306333        pane.sh_column = 1;
    307334
    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;
    320339
    321340        if (argc == 2) {
    322341                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                }
    323347        } else if (argc > 1) {
    324348                printf("Invalid arguments.\n");
    325349                return -2;
    326350        } 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        }
    347353
    348354        /* Initial display */
     
    352358                return rc;
    353359        }
    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);
    360360
    361361        ui_run(edit.ui);
     
    377377        ui_menu_t *mfile = NULL;
    378378        ui_menu_t *medit = NULL;
     379        ui_menu_entry_t *mnew = NULL;
     380        ui_menu_entry_t *mopen = NULL;
    379381        ui_menu_entry_t *msave = NULL;
    380382        ui_menu_entry_t *msaveas = NULL;
     
    430432        }
    431433
    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);
    433437        if (rc != EOK) {
    434438                printf("Error creating menu.\n");
     
    436440        }
    437441
    438         rc = ui_menu_entry_create(mfile, "Save", "Ctrl-S", &msave);
     442        rc = ui_menu_entry_create(mfile, "~N~ew", "Ctrl-N", &mnew);
    439443        if (rc != EOK) {
    440444                printf("Error creating menu.\n");
     
    442446        }
    443447
     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
    444464        ui_menu_entry_set_cb(msave, edit_file_save, (void *) edit);
    445465
    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);
    447467        if (rc != EOK) {
    448468                printf("Error creating menu.\n");
     
    458478        }
    459479
    460         rc = ui_menu_entry_create(mfile, "Exit", "Ctrl-Q", &mexit);
     480        rc = ui_menu_entry_create(mfile, "E~x~it", "Ctrl-Q", &mexit);
    461481        if (rc != EOK) {
    462482                printf("Error creating menu.\n");
     
    466486        ui_menu_entry_set_cb(mexit, edit_file_exit, (void *) edit);
    467487
    468         rc = ui_menu_create(edit->menubar, "Edit", &medit);
     488        rc = ui_menu_dd_create(edit->menubar, "~E~dit", NULL, &medit);
    469489        if (rc != EOK) {
    470490                printf("Error creating menu.\n");
     
    472492        }
    473493
    474         rc = ui_menu_entry_create(medit, "Cut", "Ctrl-X", &mcut);
     494        rc = ui_menu_entry_create(medit, "Cu~t~", "Ctrl-X", &mcut);
    475495        if (rc != EOK) {
    476496                printf("Error creating menu.\n");
     
    480500        ui_menu_entry_set_cb(mcut, edit_edit_cut, (void *) edit);
    481501
    482         rc = ui_menu_entry_create(medit, "Copy", "Ctrl-C", &mcopy);
     502        rc = ui_menu_entry_create(medit, "~C~opy", "Ctrl-C", &mcopy);
    483503        if (rc != EOK) {
    484504                printf("Error creating menu.\n");
     
    488508        ui_menu_entry_set_cb(mcopy, edit_edit_copy, (void *) edit);
    489509
    490         rc = ui_menu_entry_create(medit, "Paste", "Ctrl-V", &mpaste);
     510        rc = ui_menu_entry_create(medit, "~P~aste", "Ctrl-V", &mpaste);
    491511        if (rc != EOK) {
    492512                printf("Error creating menu.\n");
     
    496516        ui_menu_entry_set_cb(mpaste, edit_edit_paste, (void *) edit);
    497517
    498         rc = ui_menu_entry_create(medit, "Delete", "Del", &mdelete);
     518        rc = ui_menu_entry_create(medit, "~D~elete", "Del", &mdelete);
    499519        if (rc != EOK) {
    500520                printf("Error creating menu.\n");
     
    510530        }
    511531
    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);
    513533        if (rc != EOK) {
    514534                printf("Error creating menu.\n");
     
    518538        ui_menu_entry_set_cb(mselall, edit_edit_select_all, (void *) edit);
    519539
    520         rc = ui_menu_create(edit->menubar, "Search", &msearch);
     540        rc = ui_menu_dd_create(edit->menubar, "~S~earch", NULL, &msearch);
    521541        if (rc != EOK) {
    522542                printf("Error creating menu.\n");
     
    524544        }
    525545
    526         rc = ui_menu_entry_create(msearch, "Find", "Ctrl-F", &mfind);
     546        rc = ui_menu_entry_create(msearch, "~F~ind", "Ctrl-F", &mfind);
    527547        if (rc != EOK) {
    528548                printf("Error creating menu.\n");
     
    532552        ui_menu_entry_set_cb(mfind, edit_search_find, (void *) edit);
    533553
    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);
    535555        if (rc != EOK) {
    536556                printf("Error creating menu.\n");
     
    540560        ui_menu_entry_set_cb(mfindr, edit_search_reverse_find, (void *) edit);
    541561
    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);
    543563        if (rc != EOK) {
    544564                printf("Error creating menu.\n");
     
    554574        }
    555575
    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);
    557577        if (rc != EOK) {
    558578                printf("Error creating menu.\n");
     
    726746                ui_quit(edit.ui);
    727747                break;
     748        case KC_N:
     749                file_new();
     750                break;
     751        case KC_O:
     752                file_open();
     753                break;
    728754        case KC_S:
    729755                if (doc.file_name != NULL)
     
    759785                search_prompt(false);
    760786                break;
    761         case KC_N:
     787        case KC_R:
    762788                search_repeat();
    763789                break;
     
    898924}
    899925
    900 /** Save the document. */
    901 static errno_t file_save(char const *fname)
    902 {
    903         spt_t sp, ep;
     926/** Create new document. */
     927static errno_t file_new(void)
     928{
    904929        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. */
     969static void file_open(void)
    929970{
    930971        const char *old_fname = (doc.file_name != NULL) ? doc.file_name : "";
     
    934975
    935976        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. */
     990static 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. */
     1043static 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. */
     1070static 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);
    9361078        fdparams.caption = "Save As";
    9371079        fdparams.ifname = old_fname;
     
    9511093 * of the caret.
    9521094 */
    953 static errno_t file_insert(char *fname)
     1095static errno_t file_insert(const char *fname)
    9541096{
    9551097        FILE *f;
     
    9781120
    9791121                bcnt -= off;
    980                 memcpy(buf, buf + off, bcnt);
     1122                memmove(buf, buf + off, bcnt);
    9811123
    9821124                insert_char(c);
     
    12591401
    12601402        gfx_text_fmt_init(&fmt);
     1403        fmt.font = font;
    12611404        fmt.color = pane->color;
    12621405
     
    13181461                                        return rc;
    13191462
    1320                                 rc = gfx_puttext(font, &tpos, &fmt, cbuf);
     1463                                rc = gfx_puttext(&tpos, &fmt, cbuf);
    13211464                                if (rc != EOK)
    13221465                                        return rc;
     
    14081551         */
    14091552        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);
    14121555                if (rc < 0) {
    14131556                        n = 0;
     
    22192362}
    22202363
     2364/** Window focus event
     2365 *
     2366 * @param window Window
     2367 * @param arg Argument (edit_t *)
     2368 * @param focus Focus number
     2369 */
     2370static 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
    22212379/** Window keyboard event
    22222380 *
     
    22292387{
    22302388        pane.keymod = event->mods;
     2389
     2390        if (ui_window_def_kbd(window, event) == ui_claimed)
     2391                return;
    22312392
    22322393        if (event->type == KEY_PRESS) {
     
    22372398}
    22382399
     2400/** Window unfocus event
     2401 *
     2402 * @param window Window
     2403 * @param arg Argument (edit_t *)
     2404 * @param focus Focus number
     2405 */
     2406static 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 */
     2419static 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 */
     2432static 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 */
     2446static 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 */
     2460static 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
    22392468/** File / Save menu entry selected.
    22402469 *
     
    23922621}
    23932622
    2394 /** Save As dialog OK button press.
    2395  *
    2396  * @param dialog Save As dialog
     2623/** Open File dialog OK button press.
     2624 *
     2625 * @param dialog Open File dialog
    23972626 * @param arg Argument (ui_demo_t *)
    23982627 * @param fname File name
    23992628 */
    2400 static void save_as_dialog_bok(ui_file_dialog_t *dialog, void *arg,
     2629static void open_dialog_bok(ui_file_dialog_t *dialog, void *arg,
    24012630    const char *fname)
    24022631{
    24032632        edit_t *edit = (edit_t *)arg;
    2404         gfx_context_t *gc = ui_window_get_gc(edit->window);
    24052633        char *cname;
    24062634        errno_t rc;
    24072635
     2636        (void)edit;
    24082637        ui_file_dialog_destroy(dialog);
    2409         // TODO Smarter cursor management
    2410         pane.rflags |= REDRAW_CARET;
    2411         (void) pane_update(&pane);
    2412         gfx_cursor_set_visible(gc, true);
    24132638
    24142639        cname = str_dup(fname);
     
    24182643        }
    24192644
     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 */
     2661static 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 */
     2674static 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 */
     2688static 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
    24202704        rc = file_save(fname);
    24212705        if (rc != EOK)
     
    24362720{
    24372721        edit_t *edit = (edit_t *)arg;
    2438         gfx_context_t *gc = ui_window_get_gc(edit->window);
    2439 
     2722
     2723        (void)edit;
    24402724        ui_file_dialog_destroy(dialog);
    2441         // TODO Smarter cursor management
    2442         pane.rflags |= REDRAW_CARET;
    2443         (void) pane_update(&pane);
    2444         gfx_cursor_set_visible(gc, true);
    24452725}
    24462726
     
    24532733{
    24542734        edit_t *edit = (edit_t *)arg;
    2455         gfx_context_t *gc = ui_window_get_gc(edit->window);
    2456 
     2735
     2736        (void)edit;
    24572737        ui_file_dialog_destroy(dialog);
    2458         // TODO Smarter cursor management
    2459         pane.rflags |= REDRAW_CARET;
    2460         (void) pane_update(&pane);
    2461         gfx_cursor_set_visible(gc, true);
    24622738}
    24632739
     
    24722748{
    24732749        edit_t *edit = (edit_t *) arg;
    2474         gfx_context_t *gc = ui_window_get_gc(edit->window);
    24752750        char *endptr;
    24762751        int line;
     
    24842759
    24852760        caret_move_absolute(line, pane.ideal_column, dir_before, false);
    2486         // TODO Smarter cursor management
     2761        (void)edit;
    24872762        (void) pane_update(&pane);
    2488         gfx_cursor_set_visible(gc, true);
    2489         (void) gfx_update(gc);
    24902763}
    24912764
     
    24982771{
    24992772        edit_t *edit = (edit_t *) arg;
    2500         gfx_context_t *gc = ui_window_get_gc(edit->window);
    2501 
     2773
     2774        (void)edit;
    25022775        ui_prompt_dialog_destroy(dialog);
    2503         // TODO Smarter cursor management
    2504         pane.rflags |= REDRAW_CARET;
    2505         (void) pane_update(&pane);
    2506         gfx_cursor_set_visible(gc, true);
    25072776}
    25082777
     
    25152784{
    25162785        edit_t *edit = (edit_t *) arg;
    2517         gfx_context_t *gc = ui_window_get_gc(edit->window);
    2518 
     2786
     2787        (void)edit;
    25192788        ui_prompt_dialog_destroy(dialog);
    2520         // TODO Smarter cursor management
    2521         pane.rflags |= REDRAW_CARET;
    2522         (void) pane_update(&pane);
    2523         gfx_cursor_set_visible(gc, true);
    25242789}
    25252790
     
    25342799{
    25352800        edit_t *edit = (edit_t *) arg;
    2536         gfx_context_t *gc = ui_window_get_gc(edit->window);
    25372801        char *pattern;
    25382802        bool reverse;
    25392803
     2804        (void)edit;
    25402805        ui_prompt_dialog_destroy(dialog);
    25412806
     
    25542819        search(pattern, reverse);
    25552820
    2556         // TODO Smarter cursor management
    25572821        (void) pane_update(&pane);
    2558         gfx_cursor_set_visible(gc, true);
    2559         (void) gfx_update(gc);
    25602822}
    25612823
     
    25682830{
    25692831        edit_t *edit = (edit_t *) arg;
    2570         gfx_context_t *gc = ui_window_get_gc(edit->window);
    2571 
     2832
     2833        (void)edit;
    25722834        ui_prompt_dialog_destroy(dialog);
    2573         // TODO Smarter cursor management
    2574         pane.rflags |= REDRAW_CARET;
    2575         (void) pane_update(&pane);
    2576         gfx_cursor_set_visible(gc, true);
    25772835}
    25782836
     
    25852843{
    25862844        edit_t *edit = (edit_t *) arg;
    2587         gfx_context_t *gc = ui_window_get_gc(edit->window);
    2588 
     2845
     2846        (void)edit;
    25892847        ui_prompt_dialog_destroy(dialog);
    2590         // TODO Smarter cursor management
    2591         pane.rflags |= REDRAW_CARET;
    2592         (void) pane_update(&pane);
    2593         gfx_cursor_set_visible(gc, true);
    25942848}
    25952849
Note: See TracChangeset for help on using the changeset viewer.