Changes in uspace/app/nav/nav.c [accdf882:54ddb59] in mainline


Ignore:
File:
1 edited

Legend:

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

    raccdf882 r54ddb59  
    11/*
    2  * Copyright (c) 2025 Jiri Svoboda
     2 * Copyright (c) 2022 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    3939#include <stdlib.h>
    4040#include <str.h>
    41 #include <task.h>
    4241#include <ui/fixed.h>
    4342#include <ui/filelist.h>
     
    4948#include "panel.h"
    5049
    51 #define EDITOR_CMD "/app/edit"
    52 
    5350static void wnd_close(ui_window_t *, void *);
    5451static void wnd_kbd(ui_window_t *, void *, kbd_event_t *);
     
    6057
    6158static void navigator_file_open(void *);
    62 static void navigator_file_edit(void *);
    6359static void navigator_file_exit(void *);
    6460
    6561static nav_menu_cb_t navigator_menu_cb = {
    6662        .file_open = navigator_file_open,
    67         .file_edit = navigator_file_edit,
    6863        .file_exit = navigator_file_exit
    6964};
     
    10297            (event->mods & KM_CTRL) != 0) {
    10398                switch (event->key) {
    104                 case KC_E:
    105                         navigator_file_edit((void *)navigator);
    106                         break;
    10799                case KC_Q:
    108100                        ui_quit(navigator->ui);
     
    326318}
    327319
    328 /** Open file in text editor.
    329  *
    330  * @param panel Panel
    331  * @param fname File name
    332  *
    333  * @return EOK on success or an error code
    334  */
    335 static errno_t navigator_edit_file(navigator_t *navigator, const char *fname)
    336 {
    337         task_id_t id;
    338         task_wait_t wait;
    339         task_exit_t texit;
    340         int retval;
    341         errno_t rc;
    342 
    343         /* Free up and clean console for the child task. */
    344         rc = ui_suspend(navigator->ui);
    345         if (rc != EOK)
    346                 return rc;
    347 
    348         rc = task_spawnl(&id, &wait, EDITOR_CMD, EDITOR_CMD, fname, NULL);
    349         if (rc != EOK)
    350                 goto error;
    351 
    352         rc = task_wait(&wait, &texit, &retval);
    353         if ((rc != EOK) || (texit != TASK_EXIT_NORMAL))
    354                 goto error;
    355 
    356         /* Resume UI operation */
    357         rc = ui_resume(navigator->ui);
    358         if (rc != EOK)
    359                 return rc;
    360 
    361         (void) ui_paint(navigator->ui);
    362         return EOK;
    363 error:
    364         (void) ui_resume(navigator->ui);
    365         (void) ui_paint(navigator->ui);
    366         return rc;
    367 }
    368 
    369 /** File / Edit menu entry selected */
    370 static void navigator_file_edit(void *arg)
    371 {
    372         navigator_t *navigator = (navigator_t *)arg;
    373         ui_file_list_entry_t *entry;
    374         ui_file_list_entry_attr_t attr;
    375         panel_t *panel;
    376 
    377         panel = navigator_get_active_panel(navigator);
    378         entry = ui_file_list_get_cursor(panel->flist);
    379         ui_file_list_entry_get_attr(entry, &attr);
    380 
    381         (void)navigator_edit_file(navigator, attr.name);
    382 }
    383 
    384320/** File / Exit menu entry selected */
    385321static void navigator_file_exit(void *arg)
Note: See TracChangeset for help on using the changeset viewer.