Changes in uspace/app/nav/nav.c [54ddb59:accdf882] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nav/nav.c
r54ddb59 raccdf882 1 1 /* 2 * Copyright (c) 202 2Jiri Svoboda2 * Copyright (c) 2025 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 39 39 #include <stdlib.h> 40 40 #include <str.h> 41 #include <task.h> 41 42 #include <ui/fixed.h> 42 43 #include <ui/filelist.h> … … 48 49 #include "panel.h" 49 50 51 #define EDITOR_CMD "/app/edit" 52 50 53 static void wnd_close(ui_window_t *, void *); 51 54 static void wnd_kbd(ui_window_t *, void *, kbd_event_t *); … … 57 60 58 61 static void navigator_file_open(void *); 62 static void navigator_file_edit(void *); 59 63 static void navigator_file_exit(void *); 60 64 61 65 static nav_menu_cb_t navigator_menu_cb = { 62 66 .file_open = navigator_file_open, 67 .file_edit = navigator_file_edit, 63 68 .file_exit = navigator_file_exit 64 69 }; … … 97 102 (event->mods & KM_CTRL) != 0) { 98 103 switch (event->key) { 104 case KC_E: 105 navigator_file_edit((void *)navigator); 106 break; 99 107 case KC_Q: 100 108 ui_quit(navigator->ui); … … 318 326 } 319 327 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 320 384 /** File / Exit menu entry selected */ 321 385 static void navigator_file_exit(void *arg)
Note:
See TracChangeset
for help on using the changeset viewer.