Ticket #2733: 2733-file-edit-history.patch
File 2733-file-edit-history.patch, 7.2 KB (added by filipsef, 8 years ago) |
---|
-
lib/keybind.c
diff --git a/lib/keybind.c b/lib/keybind.c index 89fa9a0..2c7510a 100644
a b static name_keymap_t command_names[] = { 231 231 {"SortBySize", CK_SortBySize}, 232 232 {"SortByMTime", CK_SortByMTime}, 233 233 {"CdParentSmart", CK_CdParentSmart}, 234 {"FileEditHistory", CK_FileEditHistory}, 234 235 235 236 /* dialog */ 236 237 {"Ok", CK_Ok}, -
lib/keybind.h
diff --git a/lib/keybind.h b/lib/keybind.h index a88efbc..19e539b 100644
a b enum 205 205 CK_SortByMTime, 206 206 CK_ScrollLeft, 207 207 CK_ScrollRight, 208 CK_FileEditHistory, 208 209 209 210 /* dialog */ 210 211 CK_Ok = 300L, -
lib/widget/history.c
diff --git a/lib/widget/history.c b/lib/widget/history.c index 67aff69..768c203 100644
a b int num_history_items_recorded = 60; 57 57 58 58 /*** file scope macro definitions ****************************************************************/ 59 59 60 #define B_VIEW (B_USER + 1) 61 #define B_EDIT (B_USER + 2) 62 60 63 /*** file scope type declarations ****************************************************************/ 61 64 62 65 typedef struct … … history_dlg_reposition (WDialog * dlg_head) 114 117 115 118 /* --------------------------------------------------------------------------------------------- */ 116 119 120 static inline cb_ret_t 121 history_handle_key (WDialog * h, int key) 122 { 123 switch (key) 124 { 125 case KEY_F (3): 126 h->ret_value = B_VIEW; 127 dlg_stop (h); 128 return MSG_HANDLED; 129 130 case KEY_F (4): 131 h->ret_value = B_EDIT; 132 dlg_stop (h); 133 return MSG_HANDLED; 134 default: 135 return MSG_NOT_HANDLED; 136 } 137 } 138 139 /* --------------------------------------------------------------------------------------------- */ 140 117 141 static cb_ret_t 118 142 history_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data) 119 143 { … … history_dlg_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, v 122 146 case MSG_RESIZE: 123 147 return history_dlg_reposition (DIALOG (w)); 124 148 149 case MSG_UNHANDLED_KEY: 150 return history_handle_key (DIALOG (w), parm); 151 125 152 default: 126 153 return dlg_default_callback (w, sender, msg, parm, data); 127 154 } … … history_save (mc_config_t * cfg, const char *name, GList * h) 285 312 /* --------------------------------------------------------------------------------------------- */ 286 313 287 314 char * 288 history_show (GList ** history, Widget * widget, int current )315 history_show (GList ** history, Widget * widget, int current, int *param) 289 316 { 290 317 GList *z, *hlist = NULL, *hi; 291 318 size_t maxlen, count = 0; … … history_show (GList ** history, Widget * widget, int current) 293 320 WDialog *query_dlg; 294 321 WListbox *query_list; 295 322 history_dlg_data hist_data; 323 int dlg_ret; 296 324 297 325 if (*history == NULL) 298 326 return NULL; … … history_show (GList ** history, Widget * widget, int current) 356 384 listbox_select_entry (query_list, current); 357 385 } 358 386 359 if (dlg_run (query_dlg) != B_CANCEL) 387 dlg_ret = dlg_run (query_dlg); 388 if (dlg_ret != B_CANCEL) 360 389 { 361 390 char *q; 362 391 392 if (param != NULL) 393 { 394 switch (dlg_ret) 395 { 396 case B_EDIT: 397 *param = CK_Edit; 398 break; 399 case B_VIEW: 400 *param = CK_View; 401 break; 402 default: 403 *param = CK_CdChild; 404 } 405 } 406 363 407 listbox_get_current (query_list, &q, NULL); 364 408 r = g_strdup (q); 365 409 } -
lib/widget/history.h
diff --git a/lib/widget/history.h b/lib/widget/history.h index 101ffd4..48038de 100644
a b GList *history_load (mc_config_t * cfg, const char *name); 28 28 void history_save (mc_config_t * cfg, const char *name, GList * h); 29 29 /* for repositioning of history dialog we should pass widget to this 30 30 * function, as position of history dialog depends on widget's position */ 31 char *history_show (GList ** history, Widget * widget, int current );31 char *history_show (GList ** history, Widget * widget, int current, int *action); 32 32 33 33 /*** inline functions ****************************************************************************/ 34 34 -
lib/widget/input.c
diff --git a/lib/widget/input.c b/lib/widget/input.c index d0dc1cb..df11de5 100644
a b do_show_hist (WInput * in) 178 178 len = get_history_length (in->history.list); 179 179 180 180 r = history_show (&in->history.list, WIDGET (in), 181 g_list_position (in->history.list, in->history.list) );181 g_list_position (in->history.list, in->history.list), NULL); 182 182 if (r != NULL) 183 183 { 184 184 input_assign_text (in, r); -
src/filemanager/panel.c
diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index 30d2706..54be0c0 100644
a b directory_history_list (WPanel * panel) 3344 3344 3345 3345 pos = g_list_position (panel->dir_history_current, panel->dir_history); 3346 3346 3347 s = history_show (&panel->dir_history, WIDGET (panel), pos );3347 s = history_show (&panel->dir_history, WIDGET (panel), pos, NULL); 3348 3348 if (s != NULL) 3349 3349 { 3350 3350 vfs_path_t *s_vpath; … … directory_history_list (WPanel * panel) 3381 3381 } 3382 3382 } 3383 3383 3384 static void 3385 file_edit_history_list (WPanel * panel) 3386 { 3387 3388 char *fn; 3389 FILE *f; 3390 char buf[MC_MAXPATHLEN + 100]; 3391 GList *file_list = NULL; 3392 char *s; 3393 int action; 3394 3395 /* open file with positions */ 3396 fn = mc_config_get_full_path (MC_FILEPOS_FILE); 3397 f = fopen (fn, "r"); 3398 g_free (fn); 3399 if (f == NULL) 3400 return; 3401 3402 while (fgets (buf, sizeof (buf), f) != NULL) 3403 { 3404 s = strrchr(buf, ' '); 3405 if (s) 3406 { 3407 *s = 0; 3408 } 3409 s = g_strdup (buf); 3410 3411 file_list = g_list_prepend (file_list, s); 3412 file_list = g_list_first(file_list); 3413 } 3414 fclose(f); 3415 3416 file_list = g_list_last(file_list); 3417 3418 s = history_show (&file_list, WIDGET(panel), 0, &action); 3419 3420 if (s != NULL) 3421 { 3422 vfs_path_t *vpath; 3423 3424 switch (action) 3425 { 3426 case CK_Edit: 3427 vpath = vfs_path_from_str (s); 3428 edit_file_at_line (vpath, use_internal_edit, 0); 3429 break; 3430 case CK_View: 3431 vpath = vfs_path_from_str (s); 3432 view_file (vpath, TRUE, use_internal_view); 3433 break; 3434 default: 3435 { 3436 char *dirname = g_path_get_dirname(s); 3437 vpath = vfs_path_from_str (dirname); 3438 g_free (dirname); 3439 3440 do_cd (vpath, cd_exact); 3441 try_to_select (panel, basename(s)); 3442 } 3443 } 3444 vfs_path_free(vpath); 3445 g_free (s); 3446 } 3447 3448 file_list = g_list_first (file_list); 3449 g_list_foreach (file_list, (GFunc) g_free, NULL); 3450 g_list_free (file_list); 3451 } 3452 3384 3453 /* --------------------------------------------------------------------------------------------- */ 3385 3454 3386 3455 static cb_ret_t … … panel_execute_cmd (WPanel * panel, long command) 3458 3527 case CK_CdParent: 3459 3528 goto_parent_dir (panel); 3460 3529 break; 3530 case CK_FileEditHistory: 3531 file_edit_history_list (panel); 3532 break; 3461 3533 case CK_History: 3462 3534 directory_history_list (panel); 3463 3535 break;