Ticket #1787: remove obsolete checks for <stdlib.h>
[free-mc.git] / src / screen.c
bloba5ad4149c1b504197233394274213fbc396c9133
1 /* Panel managing.
2 Copyright (C) 1994, 1995, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
3 2005, 2006, 2007, 2009 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 Written by: 1995 Miguel de Icaza
16 1997, 1999 Timur Bakeyev
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
22 /** \file screen.c
23 * \brief Source: panel managin module
26 #include <config.h>
28 #include <errno.h>
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
34 #include "global.h"
36 #include "../src/tty/tty.h"
37 #include "../src/skin/skin.h"
38 #include "../src/tty/mouse.h" /* For Gpm_Event */
39 #include "../src/tty/key.h" /* XCTRL and ALT macros */
40 #include "../src/filehighlight/fhl.h"
42 #include "dir.h"
43 #include "panel.h"
44 #include "boxes.h"
45 #include "tree.h"
46 #include "ext.h" /* regexp_command */
47 #include "layout.h" /* Most layout variables are here */
48 #include "wtools.h" /* for message (...) */
49 #include "cmd.h"
50 #include "command.h" /* cmdline */
51 #include "setup.h" /* For loading/saving panel options */
52 #include "user.h"
53 #include "../src/mcconfig/mcconfig.h"
54 #include "execute.h"
55 #include "widget.h"
56 #include "menu.h" /* menubar_visible */
57 #include "main-widgets.h"
58 #include "main.h"
59 #include "unixcompat.h"
60 #include "mountlist.h" /* my_statfs */
61 #include "selcodepage.h" /* select_charset () */
62 #include "charsets.h" /* get_codepage_id () */
63 #include "cmddef.h" /* CK_ cmd name const */
64 #include "keybind.h" /* global_keymap_t */
66 #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
68 #define NORMAL 0
69 #define SELECTED 1
70 #define MARKED 2
71 #define MARKED_SELECTED 3
72 #define STATUS 5
75 * This describes a format item. The parse_display_format routine parses
76 * the user specified format and creates a linked list of format_e structures.
78 typedef struct format_e {
79 struct format_e *next;
80 int requested_field_len;
81 int field_len;
82 align_crt_t just_mode;
83 int expand;
84 const char *(*string_fn)(file_entry *, int len);
85 char *title;
86 const char *id;
87 } format_e;
89 /* If true, show the mini-info on the panel */
90 int show_mini_info = 1;
92 /* If true, then use stat() on the cwd to determine directory changes */
93 int fast_reload = 0;
95 /* If true, use some usability hacks by Torben */
96 int torben_fj_mode = 0;
98 /* If true, up/down keys scroll the pane listing by pages */
99 int panel_scroll_pages = 1;
101 /* If 1, we use permission hilighting */
102 int permission_mode = 0;
104 /* If 1 - then add per file type hilighting */
105 int filetype_mode = 1;
107 /* The hook list for the select file function */
108 Hook *select_file_hook = 0;
110 const global_keymap_t *panel_map;
112 static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
113 static int panel_event (Gpm_Event *event, void *);
114 static void paint_frame (WPanel *panel);
115 static const char *panel_format (WPanel *panel);
116 static const char *mini_status_format (WPanel *panel);
118 static char *panel_sort_up_sign = NULL;
119 static char *panel_sort_down_sign = NULL;
121 static char *panel_hiddenfiles_sign_show = NULL;
122 static char *panel_hiddenfiles_sign_hide = NULL;
123 static char *panel_history_prev_item_sign = NULL;
124 static char *panel_history_next_item_sign = NULL;
125 static char *panel_history_show_list_sign = NULL;
127 /* This macro extracts the number of available lines in a panel */
128 #define llines(p) (p->widget.lines-3 - (show_mini_info ? 2 : 0))
130 static void
131 set_colors (WPanel *panel)
133 (void) panel;
134 tty_set_normal_attrs ();
135 tty_setcolor (NORMAL_COLOR);
138 /* Delete format string, it is a linked list */
139 static void
140 delete_format (format_e *format)
142 format_e *next;
144 while (format){
145 next = format->next;
146 g_free(format->title);
147 g_free (format);
148 format = next;
152 /* This code relies on the default justification!!! */
153 static void
154 add_permission_string (char *dest, int width, file_entry *fe, int attr, int color, int is_octal)
156 int i, r, l;
158 l = get_user_permissions (&fe->st);
160 if (is_octal){
161 /* Place of the access bit in octal mode */
162 l = width + l - 3;
163 r = l + 1;
164 } else {
165 /* The same to the triplet in string mode */
166 l = l * 3 + 1;
167 r = l + 3;
170 for(i = 0; i < width; i++){
171 if (i >= l && i < r){
172 if (attr == SELECTED || attr == MARKED_SELECTED)
173 tty_setcolor (MARKED_SELECTED_COLOR);
174 else
175 tty_setcolor (MARKED_COLOR);
176 } else if (color >= 0)
177 tty_setcolor (color);
178 else
179 tty_lowlevel_setcolor (-color);
181 tty_print_char (dest[i]);
185 /* String representations of various file attributes */
186 /* name */
187 static const char *
188 string_file_name (file_entry *fe, int len)
190 static char buffer [MC_MAXPATHLEN * MB_LEN_MAX + 1];
192 (void) len;
193 g_strlcpy (buffer, fe->fname, sizeof(buffer));
194 return buffer;
197 static unsigned int ilog10(dev_t n)
199 unsigned int digits = 0;
200 do {
201 digits++, n /= 10;
202 } while (n != 0);
203 return digits;
206 static void format_device_number (char *buf, size_t bufsize, dev_t dev)
208 dev_t major_dev = major(dev);
209 dev_t minor_dev = minor(dev);
210 unsigned int major_digits = ilog10(major_dev);
211 unsigned int minor_digits = ilog10(minor_dev);
213 g_assert(bufsize >= 1);
214 if (major_digits + 1 + minor_digits + 1 <= bufsize) {
215 g_snprintf(buf, bufsize, "%lu,%lu", (unsigned long) major_dev,
216 (unsigned long) minor_dev);
217 } else {
218 g_strlcpy(buf, _("[dev]"), bufsize);
222 /* size */
223 static const char *
224 string_file_size (file_entry *fe, int len)
226 static char buffer [BUF_TINY];
228 /* Don't ever show size of ".." since we don't calculate it */
229 if (!strcmp (fe->fname, "..")) {
230 return _("UP--DIR");
233 #ifdef HAVE_STRUCT_STAT_ST_RDEV
234 if (S_ISBLK (fe->st.st_mode) || S_ISCHR (fe->st.st_mode))
235 format_device_number (buffer, len + 1, fe->st.st_rdev);
236 else
237 #endif
239 size_trunc_len (buffer, (unsigned int) len, fe->st.st_size, 0);
241 return buffer;
244 /* bsize */
245 static const char *
246 string_file_size_brief (file_entry *fe, int len)
248 if (S_ISLNK (fe->st.st_mode) && !fe->f.link_to_dir) {
249 return _("SYMLINK");
252 if ((S_ISDIR (fe->st.st_mode) || fe->f.link_to_dir) && strcmp (fe->fname, "..")) {
253 return _("SUB-DIR");
256 return string_file_size (fe, len);
259 /* This functions return a string representation of a file entry */
260 /* type */
261 static const char *
262 string_file_type (file_entry *fe, int len)
264 static char buffer[2];
266 (void) len;
267 if (S_ISDIR (fe->st.st_mode))
268 buffer[0] = PATH_SEP;
269 else if (S_ISLNK (fe->st.st_mode)) {
270 if (fe->f.link_to_dir)
271 buffer[0] = '~';
272 else if (fe->f.stale_link)
273 buffer[0] = '!';
274 else
275 buffer[0] = '@';
276 } else if (S_ISCHR (fe->st.st_mode))
277 buffer[0] = '-';
278 else if (S_ISSOCK (fe->st.st_mode))
279 buffer[0] = '=';
280 else if (S_ISDOOR (fe->st.st_mode))
281 buffer[0] = '>';
282 else if (S_ISBLK (fe->st.st_mode))
283 buffer[0] = '+';
284 else if (S_ISFIFO (fe->st.st_mode))
285 buffer[0] = '|';
286 else if (S_ISNAM (fe->st.st_mode))
287 buffer[0] = '#';
288 else if (!S_ISREG (fe->st.st_mode))
289 buffer[0] = '?'; /* non-regular of unknown kind */
290 else if (is_exe (fe->st.st_mode))
291 buffer[0] = '*';
292 else
293 buffer[0] = ' ';
294 buffer[1] = '\0';
295 return buffer;
298 /* mtime */
299 static const char *
300 string_file_mtime (file_entry *fe, int len)
302 (void) len;
303 return file_date (fe->st.st_mtime);
306 /* atime */
307 static const char *
308 string_file_atime (file_entry *fe, int len)
310 (void) len;
311 return file_date (fe->st.st_atime);
314 /* ctime */
315 static const char *
316 string_file_ctime (file_entry *fe, int len)
318 (void) len;
319 return file_date (fe->st.st_ctime);
322 /* perm */
323 static const char *
324 string_file_permission (file_entry *fe, int len)
326 (void) len;
327 return string_perm (fe->st.st_mode);
330 /* mode */
331 static const char *
332 string_file_perm_octal (file_entry *fe, int len)
334 static char buffer [10];
336 (void) len;
337 g_snprintf (buffer, sizeof (buffer), "0%06lo", (unsigned long) fe->st.st_mode);
338 return buffer;
341 /* nlink */
342 static const char *
343 string_file_nlinks (file_entry *fe, int len)
345 static char buffer[BUF_TINY];
347 (void) len;
348 g_snprintf (buffer, sizeof (buffer), "%16d", (int) fe->st.st_nlink);
349 return buffer;
352 /* inode */
353 static const char *
354 string_inode (file_entry *fe, int len)
356 static char buffer [10];
358 (void) len;
359 g_snprintf (buffer, sizeof (buffer), "%lu",
360 (unsigned long) fe->st.st_ino);
361 return buffer;
364 /* nuid */
365 static const char *
366 string_file_nuid (file_entry *fe, int len)
368 static char buffer [10];
370 (void) len;
371 g_snprintf (buffer, sizeof (buffer), "%lu",
372 (unsigned long) fe->st.st_uid);
373 return buffer;
376 /* ngid */
377 static const char *
378 string_file_ngid (file_entry *fe, int len)
380 static char buffer [10];
382 (void) len;
383 g_snprintf (buffer, sizeof (buffer), "%lu",
384 (unsigned long) fe->st.st_gid);
385 return buffer;
388 /* owner */
389 static const char *
390 string_file_owner (file_entry *fe, int len)
392 (void) len;
393 return get_owner (fe->st.st_uid);
396 /* group */
397 static const char *
398 string_file_group (file_entry *fe, int len)
400 (void) len;
401 return get_group (fe->st.st_gid);
404 /* mark */
405 static const char *
406 string_marked (file_entry *fe, int len)
408 (void) len;
409 return fe->f.marked ? "*" : " ";
412 /* space */
413 static const char *
414 string_space (file_entry *fe, int len)
416 (void) fe;
417 (void) len;
418 return " ";
421 /* dot */
422 static const char *
423 string_dot (file_entry *fe, int len)
425 (void) fe;
426 (void) len;
427 return ".";
430 #define GT 1
432 panel_field_t panel_fields [] = {
434 "unsorted", 12, 1, J_LEFT_FIT,
435 /* TRANSLATORS: one single character to represent 'unsorted' sort mode */
436 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
437 N_("sort|u"),
438 N_("&Unsorted"), TRUE, FALSE,
439 string_file_name,
440 (sortfn *) unsorted
443 "name", 12, 1, J_LEFT_FIT,
444 /* TRANSLATORS: one single character to represent 'name' sort mode */
445 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
446 N_("sort|n"),
447 N_("&Name"), TRUE, TRUE,
448 string_file_name,
449 (sortfn *) sort_name
452 "extension", 12, 1, J_LEFT_FIT,
453 /* TRANSLATORS: one single character to represent 'extension' sort mode */
454 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
455 N_("sort|e"),
456 N_("&Extension"), TRUE, FALSE,
457 string_file_name, /* TODO: string_file_ext*/
458 (sortfn *) sort_ext
461 "size", 7, 0, J_RIGHT,
462 /* TRANSLATORS: one single character to represent 'size' sort mode */
463 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
464 N_("sort|s"),
465 N_("&Size"), TRUE,TRUE,
466 string_file_size,
467 (sortfn *) sort_size
470 "bsize", 7, 0, J_RIGHT,
472 N_("Block Size"), FALSE, FALSE,
473 string_file_size_brief,
474 (sortfn *) sort_size
477 "type", GT, 0, J_LEFT,
479 "", FALSE, TRUE,
480 string_file_type,
481 NULL
484 "mtime", 12, 0, J_RIGHT,
485 /* TRANSLATORS: one single character to represent 'Modify time' sort mode */
486 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
487 N_("sort|m"),
488 N_("&Modify time"), TRUE,TRUE,
489 string_file_mtime,
490 (sortfn *) sort_time
493 "atime", 12, 0, J_RIGHT,
494 /* TRANSLATORS: one single character to represent 'Access time' sort mode */
495 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
496 N_("sort|a"),
497 N_("&Access time"), TRUE,TRUE,
498 string_file_atime,
499 (sortfn *) sort_atime
502 "ctime", 12, 0, J_RIGHT,
503 /* TRANSLATORS: one single character to represent 'Change time' sort mode */
504 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
505 N_("sort|h"),
506 N_("C&Hange time"), TRUE,TRUE,
507 string_file_ctime,
508 (sortfn *) sort_ctime
511 "perm", 10, 0, J_LEFT,
513 N_("Permission"), FALSE,TRUE,
514 string_file_permission,
515 NULL
518 "mode", 6, 0, J_RIGHT,
520 N_("Perm"), FALSE,TRUE,
521 string_file_perm_octal,
522 NULL
525 "nlink", 2, 0, J_RIGHT,
527 N_("Nl"), FALSE,TRUE,
528 string_file_nlinks, NULL
531 "inode", 5, 0, J_RIGHT,
532 /* TRANSLATORS: one single character to represent 'inode' sort mode */
533 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
534 N_("sort|i"),
535 N_("&Inode"), TRUE,TRUE,
536 string_inode,
537 (sortfn *) sort_inode
540 "nuid", 5, 0, J_RIGHT,
542 N_("UID"), FALSE,FALSE,
543 string_file_nuid,
544 NULL
547 "ngid", 5, 0, J_RIGHT,
549 N_("GID"), FALSE,FALSE,
550 string_file_ngid,
551 NULL
554 "owner", 8, 0, J_LEFT_FIT,
556 N_("Owner"), FALSE,TRUE,
557 string_file_owner,
558 NULL
561 "group", 8,0, J_LEFT_FIT,
563 N_("Group"), FALSE,TRUE,
564 string_file_group,
565 NULL
568 "mark", 1, 0, J_RIGHT,
570 " ", FALSE,TRUE,
571 string_marked,
572 NULL
575 "|", 1, 0, J_RIGHT,
577 " ", FALSE,TRUE,
578 NULL,
579 NULL
582 "space", 1, 0, J_RIGHT,
584 " ", FALSE,TRUE,
585 string_space,
586 NULL
589 "dot", 1, 0, J_RIGHT,
591 " ", FALSE,FALSE,
592 string_dot,
593 NULL
596 NULL, 0, 0, J_RIGHT, NULL, NULL, FALSE, FALSE, NULL, NULL
600 static int
601 file_compute_color (int attr, file_entry *fe)
603 switch (attr) {
604 case SELECTED:
605 return (SELECTED_COLOR);
606 case MARKED:
607 return (MARKED_COLOR);
608 case MARKED_SELECTED:
609 return (MARKED_SELECTED_COLOR);
610 case STATUS:
611 return (NORMAL_COLOR);
612 case NORMAL:
613 default:
614 if (!filetype_mode)
615 return (NORMAL_COLOR);
618 return mc_fhl_get_color (mc_filehighlight, fe);
621 /* Formats the file number file_index of panel in the buffer dest */
622 static void
623 format_file (char *dest, int limit, WPanel *panel, int file_index, int width, int attr, int isstatus)
625 int color, length, empty_line;
626 const char *txt;
627 format_e *format, *home;
628 file_entry *fe;
630 (void) dest;
631 (void) limit;
632 length = 0;
633 empty_line = (file_index >= panel->count);
634 home = (isstatus) ? panel->status_format : panel->format;
635 fe = &panel->dir.list [file_index];
637 if (!empty_line)
638 color = file_compute_color (attr, fe);
639 else
640 color = NORMAL_COLOR;
642 for (format = home; format; format = format->next){
643 if (length == width)
644 break;
646 if (format->string_fn){
647 int len, perm;
648 char *preperad_text;
650 if (empty_line)
651 txt = " ";
652 else
653 txt = (*format->string_fn)(fe, format->field_len);
655 len = format->field_len;
656 if (len + length > width)
657 len = width - length;
658 if (len <= 0)
659 break;
661 perm = 0;
662 if (permission_mode) {
663 if (!strcmp(format->id, "perm"))
664 perm = 1;
665 else if (!strcmp(format->id, "mode"))
666 perm = 2;
669 if (color >= 0)
670 tty_setcolor (color);
671 else
672 tty_lowlevel_setcolor (-color);
674 preperad_text = (char*) str_fit_to_term(txt, len, format->just_mode);
675 if (perm)
676 add_permission_string (preperad_text, format->field_len, fe,
677 attr, color, perm - 1);
678 else
679 tty_print_string (preperad_text);
681 length+= len;
682 } else {
683 if (attr == SELECTED || attr == MARKED_SELECTED)
684 tty_setcolor (SELECTED_COLOR);
685 else
686 tty_setcolor (NORMAL_COLOR);
687 tty_print_one_vline ();
688 length++;
692 if (length < width)
693 tty_draw_hline (-1, -1, ' ', width - length);
696 static void
697 repaint_file (WPanel *panel, int file_index, int mv, int attr, int isstatus)
699 int second_column = 0;
700 int width;
701 int offset = 0;
702 char buffer [BUF_MEDIUM];
704 gboolean panel_is_split = !isstatus && panel->split;
706 width = panel->widget.cols - 2;
708 if (panel_is_split) {
709 second_column = (file_index - panel->top_file) / llines (panel);
710 width = width/2 - 1;
712 if (second_column != 0) {
713 offset = 1 + width;
714 /*width = (panel->widget.cols-2) - (panel->widget.cols-2)/2 - 1;*/
715 width = panel->widget.cols - offset - 2;
719 /* Nothing to paint */
720 if (width <= 0)
721 return;
723 if (mv){
724 if (panel_is_split)
725 widget_move (&panel->widget,
726 (file_index - panel->top_file) % llines (panel) + 2,
727 offset + 1);
728 else
729 widget_move (&panel->widget, file_index - panel->top_file + 2, 1);
732 format_file (buffer, sizeof(buffer), panel, file_index, width, attr, isstatus);
734 if (panel_is_split) {
735 if (second_column)
736 tty_print_char (' ');
737 else {
738 tty_setcolor (NORMAL_COLOR);
739 tty_print_one_vline ();
744 static void
745 display_mini_info (WPanel *panel)
747 if (!show_mini_info)
748 return;
750 widget_move (&panel->widget, llines (panel) + 3, 1);
752 if (panel->searching) {
753 tty_setcolor (INPUT_COLOR);
754 tty_print_char ('/');
755 tty_print_string (str_fit_to_term (panel->search_buffer,
756 panel->widget.cols - 3, J_LEFT));
757 return;
760 /* Status resolves links and show them */
761 set_colors (panel);
763 if (S_ISLNK (panel->dir.list [panel->selected].st.st_mode)){
764 char *lc_link, link_target [MC_MAXPATHLEN];
765 int len;
767 lc_link = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
768 len = mc_readlink (lc_link, link_target, MC_MAXPATHLEN - 1);
769 g_free (lc_link);
770 if (len > 0){
771 link_target[len] = 0;
772 tty_print_string ("-> ");
773 tty_print_string (str_fit_to_term (link_target, panel->widget.cols - 5,
774 J_LEFT_FIT));
775 } else
776 tty_print_string (str_fit_to_term (_("<readlink failed>"),
777 panel->widget.cols - 2, J_LEFT));
778 } else if (strcmp (panel->dir.list [panel->selected].fname, "..") == 0) {
779 /* FIXME:
780 * while loading directory (do_load_dir() and do_reload_dir()),
781 * the actual stat info about ".." directory isn't got;
782 * so just don't display incorrect info about ".." directory */
783 tty_print_string (str_fit_to_term (_("UP--DIR"), panel->widget.cols - 2, J_LEFT));
784 } else
785 /* Default behavior */
786 repaint_file (panel, panel->selected, 0, STATUS, 1);
789 static void
790 paint_dir (WPanel *panel)
792 int i;
793 int color; /* Color value of the line */
794 int items; /* Number of items */
796 items = llines (panel) * (panel->split ? 2 : 1);
798 for (i = 0; i < items; i++){
799 if (i+panel->top_file >= panel->count)
800 color = 0;
801 else {
802 color = 2 * (panel->dir.list [i+panel->top_file].f.marked);
803 color += (panel->selected==i+panel->top_file && panel->active);
805 repaint_file (panel, i+panel->top_file, 1, color, 0);
807 tty_set_normal_attrs ();
810 static void
811 display_total_marked_size (WPanel *panel, int y, int x, gboolean size_only)
813 char buffer[BUF_SMALL], b_bytes[BUF_SMALL], *buf;
814 int cols;
816 if (panel->marked <= 0)
817 return;
819 buf = size_only ? b_bytes : buffer;
820 cols = panel->widget.cols - 2;
823 * This is a trick to use two ngettext() calls in one sentence.
824 * First make "N bytes", then insert it into "X in M files".
826 g_snprintf (b_bytes, sizeof (b_bytes),
827 ngettext("%s byte", "%s bytes", (unsigned long) panel->total),
828 size_trunc_sep (panel->total));
829 if (!size_only)
830 g_snprintf (buffer, sizeof (buffer),
831 ngettext("%s in %d file", "%s in %d files", panel->marked),
832 b_bytes, panel->marked);
834 /* don't forget spaces around buffer content */
835 buf = (char *) str_trunc (buf, cols - 4);
837 if (x < 0)
838 /* center in panel */
839 x = (panel->widget.cols - str_term_width1 (buf)) / 2 - 1;
842 * y == llines (panel) + 2 for mini_info_separator
843 * y == panel->widget.lines - 1 for panel bottom frame
845 widget_move (&panel->widget, y, x);
846 tty_setcolor (MARKED_COLOR);
847 tty_printf (" %s ", buf);
850 static void
851 mini_info_separator (WPanel *panel)
853 if (show_mini_info) {
854 const int y = llines (panel) + 2;
856 tty_setcolor (NORMAL_COLOR);
857 tty_draw_hline (panel->widget.y + y, panel->widget.x + 1,
858 ACS_HLINE, panel->widget.cols - 2);
859 /* Status displays total marked size.
860 * Centered in panel, full format. */
861 display_total_marked_size (panel, y, -1, FALSE);
865 static void
866 show_free_space (WPanel *panel)
868 /* Used to figure out how many free space we have */
869 static struct my_statfs myfs_stats;
870 /* Old current working directory for displaying free space */
871 static char *old_cwd = NULL;
873 /* Don't try to stat non-local fs */
874 if (!vfs_file_is_local (panel->cwd) || !free_space)
875 return;
877 if (old_cwd == NULL || strcmp (old_cwd, panel->cwd) != 0) {
878 char rpath[PATH_MAX];
880 init_my_statfs ();
881 g_free (old_cwd);
882 old_cwd = g_strdup (panel->cwd);
884 if (mc_realpath (panel->cwd, rpath) == NULL)
885 return;
887 my_statfs (&myfs_stats, rpath);
890 if (myfs_stats.avail > 0 || myfs_stats.total > 0) {
891 char buffer1[6], buffer2[6], tmp[BUF_SMALL];
892 size_trunc_len (buffer1, sizeof(buffer1) - 1, myfs_stats.avail, 1);
893 size_trunc_len (buffer2, sizeof(buffer2) - 1, myfs_stats.total, 1);
894 g_snprintf (tmp, sizeof(tmp), " %s/%s (%d%%) ", buffer1, buffer2,
895 myfs_stats.total > 0 ?
896 (int)(100 * (double)myfs_stats.avail / myfs_stats.total) : 0);
897 widget_move (&panel->widget, panel->widget.lines - 1,
898 panel->widget.cols - 2 - (int) strlen (tmp));
899 tty_setcolor (NORMAL_COLOR);
900 tty_print_string (tmp);
904 static void
905 show_dir (WPanel *panel)
907 gchar *tmp;
908 set_colors (panel);
909 draw_box (panel->widget.parent,
910 panel->widget.y, panel->widget.x,
911 panel->widget.lines, panel->widget.cols);
913 if (show_mini_info) {
914 widget_move (&panel->widget, llines (panel) + 2, 0);
915 tty_print_alt_char (ACS_LTEE);
916 widget_move (&panel->widget, llines (panel) + 2,
917 panel->widget.cols - 1);
918 tty_print_alt_char (ACS_RTEE);
921 widget_move (&panel->widget, 0, 1);
922 tty_print_string (panel_history_prev_item_sign);
924 tmp = (show_dot_files) ? panel_hiddenfiles_sign_show : panel_hiddenfiles_sign_hide;
925 tmp = g_strdup_printf("%s[%s]%s",tmp,panel_history_show_list_sign,panel_history_next_item_sign);
927 widget_move (&panel->widget, 0, panel->widget.cols - 6);
928 tty_print_string (tmp);
930 g_free(tmp);
932 if (panel->active)
933 tty_setcolor (REVERSE_COLOR);
935 widget_move (&panel->widget, 0, 3);
937 tty_printf (" %s ",
938 str_term_trim (strip_home_and_password (panel->cwd),
939 min (max (panel->widget.cols - 12, 0),
940 panel->widget.cols)));
942 if (!show_mini_info) {
943 if (panel->marked == 0) {
944 /* Show size of curret file in the bottom of panel */
945 if (S_ISREG (panel->dir.list [panel->selected].st.st_mode)) {
946 char buffer[BUF_SMALL];
948 g_snprintf (buffer, sizeof (buffer), " %s ",
949 size_trunc_sep (panel->dir.list [panel->selected].st.st_size));
950 tty_setcolor (NORMAL_COLOR);
951 widget_move (&panel->widget, panel->widget.lines - 1, 4);
952 tty_print_string (buffer);
954 } else {
955 /* Show total size of marked files
956 * In the bottom of panel, display size only. */
957 display_total_marked_size (panel, panel->widget.lines - 1, 2, TRUE);
961 show_free_space (panel);
963 if (panel->active)
964 tty_set_normal_attrs ();
967 /* To be used only by long_frame and full_frame to adjust top_file */
968 static void
969 adjust_top_file (WPanel *panel)
971 int old_top = panel->top_file;
973 if (panel->selected - old_top > llines (panel))
974 panel->top_file = panel->selected;
975 if (old_top - panel->count > llines (panel))
976 panel->top_file = panel->count - llines (panel);
979 /* Repaint everything, including frame and separator */
980 static void
981 paint_panel (WPanel *panel)
983 paint_frame (panel); /* including show_dir */
984 paint_dir (panel);
985 mini_info_separator (panel);
986 display_mini_info (panel);
987 panel->dirty = 0;
990 /* add "#enc:encodning" to end of path */
991 /* if path end width a previous #enc:, only encoding is changed no additional
992 * #enc: is appended
993 * retun new string
995 static char
996 *add_encoding_to_path (const char *path, const char *encoding)
998 char *result;
999 char *semi;
1000 char *slash;
1002 semi = g_strrstr (path, "#enc:");
1004 if (semi != NULL) {
1005 slash = strchr (semi, PATH_SEP);
1006 if (slash != NULL) {
1007 result = g_strconcat (path, "/#enc:", encoding, NULL);
1008 } else {
1009 *semi = 0;
1010 result = g_strconcat (path, "/#enc:", encoding, NULL);
1011 *semi = '#';
1013 } else {
1014 result = g_strconcat (path, "/#enc:", encoding, NULL);
1017 return result;
1020 char *
1021 remove_encoding_from_path (const char *path)
1023 GString *ret;
1024 GString *tmp_path, *tmp_conv;
1025 char *tmp, *tmp2;
1026 const char *enc;
1027 GIConv converter;
1029 ret = g_string_new("");
1030 tmp_conv = g_string_new("");
1032 tmp_path = g_string_new(path);
1034 while ((tmp = g_strrstr (tmp_path->str, "/#enc:")) != NULL){
1035 enc = vfs_get_encoding ((const char *) tmp);
1036 converter = enc ? str_crt_conv_to (enc): str_cnv_to_term;
1037 if (converter == INVALID_CONV) converter = str_cnv_to_term;
1039 tmp2=tmp+1;
1040 while (*tmp2 && *tmp2 != '/')
1041 tmp2++;
1043 if (*tmp2){
1044 str_vfs_convert_from (converter, tmp2, tmp_conv);
1045 g_string_prepend(ret, tmp_conv->str);
1046 g_string_set_size(tmp_conv,0);
1048 g_string_set_size(tmp_path,tmp - tmp_path->str);
1049 str_close_conv (converter);
1051 g_string_prepend(ret, tmp_path->str);
1052 g_string_free(tmp_path,TRUE);
1053 g_string_free(tmp_conv,TRUE);
1055 tmp = ret->str;
1056 g_string_free(ret, FALSE);
1057 return tmp;
1061 * Repaint the contents of the panels without frames. To schedule panel
1062 * for repainting, set panel->dirty to 1. There are many reasons why
1063 * the panels need to be repainted, and this is a costly operation, so
1064 * it's done once per event.
1066 void
1067 update_dirty_panels (void)
1069 if (current_panel->dirty)
1070 paint_panel (current_panel);
1072 if ((get_other_type () == view_listing) && other_panel->dirty)
1073 paint_panel (other_panel);
1076 static void
1077 do_select (WPanel *panel, int i)
1079 if (i != panel->selected) {
1080 panel->dirty = 1;
1081 panel->selected = i;
1082 panel->top_file = panel->selected - (panel->widget.lines - 2) / 2;
1083 if (panel->top_file < 0)
1084 panel->top_file = 0;
1088 static void
1089 do_try_to_select (WPanel *panel, const char *name)
1091 int i;
1092 char *subdir;
1094 if (!name) {
1095 do_select(panel, 0);
1096 return;
1099 /* We only want the last component of the directory,
1100 * and from this only the name without suffix. */
1101 subdir = vfs_strip_suffix_from_filename (x_basename(name));
1103 /* Search that subdirectory, if found select it */
1104 for (i = 0; i < panel->count; i++){
1105 if (strcmp (subdir, panel->dir.list [i].fname) == 0) {
1106 do_select (panel, i);
1107 g_free (subdir);
1108 return;
1112 /* Try to select a file near the file that is missing */
1113 if (panel->selected >= panel->count)
1114 do_select (panel, panel->count-1);
1115 g_free (subdir);
1118 void
1119 try_to_select (WPanel *panel, const char *name)
1121 do_try_to_select (panel, name);
1122 select_item (panel);
1125 void
1126 panel_update_cols (Widget *widget, int frame_size)
1128 int cols, origin;
1130 if (horizontal_split){
1131 widget->cols = COLS;
1132 return;
1135 if (frame_size == frame_full){
1136 cols = COLS;
1137 origin = 0;
1138 } else {
1139 if (widget == get_panel_widget (0)){
1140 cols = first_panel_size;
1141 origin = 0;
1142 } else {
1143 cols = COLS-first_panel_size;
1144 origin = first_panel_size;
1148 widget->cols = cols;
1149 widget->x = origin;
1152 extern int saving_setup;
1153 static char *
1154 panel_save_name (WPanel *panel)
1156 /* If the program is shuting down */
1157 if ((midnight_shutdown && auto_save_setup) || saving_setup)
1158 return g_strdup (panel->panel_name);
1159 else
1160 return g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
1163 void
1164 panel_clean_dir (WPanel *panel)
1166 int count = panel->count;
1168 panel->count = 0;
1169 panel->top_file = 0;
1170 panel->selected = 0;
1171 panel->marked = 0;
1172 panel->dirs_marked = 0;
1173 panel->total = 0;
1174 panel->searching = 0;
1175 panel->is_panelized = 0;
1176 panel->dirty = 1;
1178 clean_dir (&panel->dir, count);
1181 static void
1182 panel_destroy (WPanel *p)
1184 int i;
1186 char *name = panel_save_name (p);
1188 panel_save_setup (p, name);
1189 panel_clean_dir (p);
1191 /* save and clean history */
1192 if (p->dir_history) {
1193 history_put (p->hist_name, p->dir_history);
1195 p->dir_history = g_list_first (p->dir_history);
1196 g_list_foreach (p->dir_history, (GFunc) g_free, NULL);
1197 g_list_free (p->dir_history);
1200 g_free (p->hist_name);
1202 delete_format (p->format);
1203 delete_format (p->status_format);
1205 g_free (p->user_format);
1206 for (i = 0; i < LIST_TYPES; i++)
1207 g_free (p->user_status_format[i]);
1208 g_free (p->dir.list);
1209 g_free (p->panel_name);
1210 g_free (name);
1213 static void
1214 panel_format_modified (WPanel *panel)
1216 panel->format_modified = 1;
1219 /* Panel creation */
1220 /* The parameter specifies the name of the panel for setup retieving */
1221 WPanel *
1222 panel_new (const char *panel_name)
1224 return panel_new_with_dir(panel_name, NULL);
1227 /* Panel creation for specified directory */
1228 /* The parameter specifies the name of the panel for setup retieving */
1229 /* and the path of working panel directory. If path is NULL then */
1230 /* panel will be created for current directory */
1231 WPanel *
1232 panel_new_with_dir (const char *panel_name, const char *wpath)
1234 WPanel *panel;
1235 char *section;
1236 int i, err;
1237 char curdir[MC_MAXPATHLEN];
1239 panel = g_new0 (WPanel, 1);
1241 /* No know sizes of the panel at startup */
1242 init_widget (&panel->widget, 0, 0, 0, 0, panel_callback, panel_event);
1244 /* We do not want the cursor */
1245 widget_want_cursor (panel->widget, 0);
1247 if (wpath) {
1248 g_strlcpy(panel->cwd, wpath, sizeof (panel->cwd));
1249 mc_get_current_wd (curdir, sizeof (curdir) - 2);
1250 } else
1251 mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
1253 strcpy (panel->lwd, ".");
1255 panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL);
1256 panel->dir_history = history_get (panel->hist_name);
1257 directory_history_add (panel, panel->cwd);
1259 panel->dir.list = g_new (file_entry, MIN_FILES);
1260 panel->dir.size = MIN_FILES;
1261 panel->active = 0;
1262 panel->filter = 0;
1263 panel->split = 0;
1264 panel->top_file = 0;
1265 panel->selected = 0;
1266 panel->marked = 0;
1267 panel->total = 0;
1268 panel->reverse = 0;
1269 panel->dirty = 1;
1270 panel->searching = 0;
1271 panel->dirs_marked = 0;
1272 panel->is_panelized = 0;
1273 panel->format = 0;
1274 panel->status_format = 0;
1275 panel->format_modified = 1;
1277 panel->panel_name = g_strdup (panel_name);
1278 panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
1280 for (i = 0; i < LIST_TYPES; i++)
1281 panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
1283 panel->search_buffer[0] = 0;
1284 panel->frame_size = frame_half;
1285 section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
1286 if (!mc_config_has_group (mc_main_config, section)) {
1287 g_free (section);
1288 section = g_strdup (panel->panel_name);
1290 panel_load_setup (panel, section);
1291 g_free (section);
1293 /* Load format strings */
1294 err = set_panel_formats (panel);
1295 if (err) {
1296 set_panel_formats (panel);
1300 /* Because do_load_dir lists files in current directory */
1301 if (wpath)
1302 mc_chdir(wpath);
1304 /* Load the default format */
1305 panel->count =
1306 do_load_dir (panel->cwd, &panel->dir, panel->current_sort_field->sort_routine,
1307 panel->reverse, panel->case_sensitive,
1308 panel->exec_first, panel->filter);
1310 /* Restore old right path */
1311 if (wpath)
1312 mc_chdir(curdir);
1314 return panel;
1317 void
1318 panel_reload (WPanel *panel)
1320 struct stat current_stat;
1322 if (fast_reload && !stat (panel->cwd, &current_stat)
1323 && current_stat.st_ctime == panel->dir_stat.st_ctime
1324 && current_stat.st_mtime == panel->dir_stat.st_mtime)
1325 return;
1327 while (mc_chdir (panel->cwd) == -1) {
1328 char *last_slash;
1330 if (panel->cwd[0] == PATH_SEP && panel->cwd[1] == 0) {
1331 panel_clean_dir (panel);
1332 panel->count = set_zero_dir (&panel->dir) ? 1 : 0;
1333 return;
1335 last_slash = strrchr (panel->cwd, PATH_SEP);
1336 if (!last_slash || last_slash == panel->cwd)
1337 strcpy (panel->cwd, PATH_SEP_STR);
1338 else
1339 *last_slash = 0;
1340 memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
1341 show_dir (panel);
1344 panel->count =
1345 do_reload_dir (panel->cwd, &panel->dir, panel->current_sort_field->sort_routine,
1346 panel->count, panel->reverse, panel->case_sensitive,
1347 panel->exec_first, panel->filter);
1349 panel->dirty = 1;
1350 if (panel->selected >= panel->count)
1351 do_select (panel, panel->count - 1);
1353 recalculate_panel_summary (panel);
1356 static void
1357 panel_paint_sort_info(WPanel *panel)
1359 const char *sort_sign = (panel->reverse) ? panel_sort_down_sign : panel_sort_up_sign;
1360 char *str;
1362 if (*panel->current_sort_field->hotkey == '\0')
1363 return;
1365 str = g_strdup_printf("%s%s",sort_sign, Q_(panel->current_sort_field->hotkey));
1367 widget_move (&panel->widget, 1, 1);
1368 tty_print_string (str);
1369 g_free(str);
1372 static gchar*
1373 panel_get_title_without_hotkey(const char *title)
1375 char *translated_title;
1376 char *hkey;
1378 if (title == NULL)
1379 return NULL;
1380 if (title[0] == '\0')
1381 return g_strdup("");
1383 translated_title = g_strdup(_(title));
1385 hkey = strchr(translated_title, '&');
1386 if ((hkey != NULL) && (hkey[1] != '\0'))
1387 memmove((void *) hkey, (void *) hkey+1,strlen(hkey));
1389 return translated_title;
1392 static void
1393 paint_frame (WPanel *panel)
1395 int side, width;
1396 GString *format_txt;
1398 if (!panel->split)
1399 adjust_top_file (panel);
1401 widget_erase (&panel->widget);
1402 show_dir (panel);
1404 widget_move (&panel->widget, 1, 1);
1406 for (side = 0; side <= panel->split; side++){
1407 format_e *format;
1409 if (side){
1410 tty_setcolor (NORMAL_COLOR);
1411 tty_print_one_vline ();
1412 width = panel->widget.cols - panel->widget.cols/2 - 1;
1413 } else if (panel->split)
1414 width = panel->widget.cols/2 - 3;
1415 else
1416 width = panel->widget.cols - 2;
1418 format_txt = g_string_new("");
1419 for (format = panel->format; format; format = format->next){
1420 if (format->string_fn){
1421 g_string_set_size(format_txt, 0);
1423 if (panel->list_type == list_long && strcmp (format->id, panel->current_sort_field->id) == 0)
1424 g_string_append (format_txt, (panel->reverse) ? panel_sort_down_sign : panel_sort_up_sign);
1426 g_string_append (format_txt, format->title);
1427 if (strcmp (format->id, "name") == 0 && panel->filter && *panel->filter) {
1428 g_string_append (format_txt, " [");
1429 g_string_append (format_txt, panel->filter);
1430 g_string_append (format_txt, "]");
1433 tty_setcolor (MARKED_COLOR);
1434 tty_print_string (str_fit_to_term (format_txt->str, format->field_len,
1435 J_CENTER_LEFT));
1436 width -= format->field_len;
1437 } else {
1438 tty_setcolor (NORMAL_COLOR);
1439 tty_print_one_vline ();
1440 width--;
1443 g_string_free(format_txt, TRUE);
1445 if (width > 0)
1446 tty_draw_hline (-1, -1, ' ', width);
1449 if (panel->list_type != list_long)
1450 panel_paint_sort_info(panel);
1453 static const char *
1454 parse_panel_size (WPanel *panel, const char *format, int isstatus)
1456 int frame = frame_half;
1457 format = skip_separators (format);
1459 if (!strncmp (format, "full", 4)){
1460 frame = frame_full;
1461 format += 4;
1462 } else if (!strncmp (format, "half", 4)){
1463 frame = frame_half;
1464 format += 4;
1467 if (!isstatus){
1468 panel->frame_size = frame;
1469 panel->split = 0;
1472 /* Now, the optional column specifier */
1473 format = skip_separators (format);
1475 if (*format == '1' || *format == '2'){
1476 if (!isstatus)
1477 panel->split = *format == '2';
1478 format++;
1481 if (!isstatus)
1482 panel_update_cols (&(panel->widget), panel->frame_size);
1484 return skip_separators (format);
1487 /* Format is:
1489 all := panel_format? format
1490 panel_format := [full|half] [1|2]
1491 format := one_format_e
1492 | format , one_format_e
1494 one_format_e := just format.id [opt_size]
1495 just := [<=>]
1496 opt_size := : size [opt_expand]
1497 size := [0-9]+
1498 opt_expand := +
1502 static format_e *
1503 parse_display_format (WPanel *panel, const char *format, char **error, int isstatus, int *res_total_cols)
1505 format_e *darr, *old = 0, *home = 0; /* The formats we return */
1506 int total_cols = 0; /* Used columns by the format */
1507 int set_justify; /* flag: set justification mode? */
1508 align_crt_t justify = J_LEFT; /* Which mode. */
1509 size_t i;
1511 static size_t i18n_timelength = 0; /* flag: check ?Time length at startup */
1513 *error = 0;
1515 if (i18n_timelength == 0) {
1516 i18n_timelength = i18n_checktimelength (); /* Musn't be 0 */
1518 for (i = 0; panel_fields[i].id != NULL; i++)
1519 if (strcmp ("time", panel_fields[i].id + 1) == 0)
1520 panel_fields [i].min_size = i18n_timelength;
1524 * This makes sure that the panel and mini status full/half mode
1525 * setting is equal
1527 format = parse_panel_size (panel, format, isstatus);
1529 while (*format){ /* format can be an empty string */
1530 int found = 0;
1532 darr = g_new (format_e, 1);
1534 /* I'm so ugly, don't look at me :-) */
1535 if (!home)
1536 home = old = darr;
1538 old->next = darr;
1539 darr->next = 0;
1540 old = darr;
1542 format = skip_separators (format);
1544 if (strchr ("<=>", *format)){
1545 set_justify = 1;
1546 switch (*format)
1548 case '<':
1549 justify = J_LEFT;
1550 break;
1551 case '=':
1552 justify = J_CENTER;
1553 break;
1554 case '>':
1555 default:
1556 justify = J_RIGHT;
1557 break;
1559 format = skip_separators (format+1);
1560 } else
1561 set_justify = 0;
1563 for (i = 0; panel_fields[i].id != NULL; i++) {
1564 size_t klen = strlen (panel_fields [i].id);
1566 if (strncmp (format, panel_fields [i].id, klen) != 0)
1567 continue;
1569 format += klen;
1571 darr->requested_field_len = panel_fields [i].min_size;
1572 darr->string_fn = panel_fields [i].string_fn;
1573 darr->title = panel_get_title_without_hotkey(panel_fields [i].title_hotkey);
1575 darr->id = panel_fields [i].id;
1576 darr->expand = panel_fields [i].expands;
1577 darr->just_mode = panel_fields [i].default_just;
1579 if (set_justify) {
1580 if (IS_FIT(darr->just_mode))
1581 darr->just_mode = MAKE_FIT(justify);
1582 else
1583 darr->just_mode = justify;
1585 found = 1;
1587 format = skip_separators (format);
1589 /* If we have a size specifier */
1590 if (*format == ':'){
1591 int req_length;
1593 /* If the size was specified, we don't want
1594 * auto-expansion by default
1596 darr->expand = 0;
1597 format++;
1598 req_length = atoi (format);
1599 darr->requested_field_len = req_length;
1601 format = skip_numbers (format);
1603 /* Now, if they insist on expansion */
1604 if (*format == '+'){
1605 darr->expand = 1;
1606 format++;
1611 break;
1613 if (!found){
1614 char *tmp_format = g_strdup (format);
1616 int pos = min (8, strlen (format));
1617 delete_format (home);
1618 tmp_format [pos] = 0;
1619 *error = g_strconcat (_("Unknown tag on display format: "), tmp_format, (char *) NULL);
1620 g_free (tmp_format);
1621 return 0;
1623 total_cols += darr->requested_field_len;
1626 *res_total_cols = total_cols;
1627 return home;
1630 static format_e *
1631 use_display_format (WPanel *panel, const char *format, char **error, int isstatus)
1633 #define MAX_EXPAND 4
1634 int expand_top = 0; /* Max used element in expand */
1635 int usable_columns; /* Usable columns in the panel */
1636 int total_cols = 0;
1637 int i;
1638 format_e *darr, *home;
1640 if (!format)
1641 format = DEFAULT_USER_FORMAT;
1643 home = parse_display_format (panel, format, error, isstatus, &total_cols);
1645 if (*error)
1646 return 0;
1648 panel->dirty = 1;
1650 /* Status needn't to be split */
1651 usable_columns = ((panel->widget.cols-2)/((isstatus)
1653 : (panel->split+1))) - (!isstatus && panel->split);
1655 /* Look for the expandable fields and set field_len based on the requested field len */
1656 for (darr = home; darr && expand_top < MAX_EXPAND; darr = darr->next){
1657 darr->field_len = darr->requested_field_len;
1658 if (darr->expand)
1659 expand_top++;
1662 /* If we used more columns than the available columns, adjust that */
1663 if (total_cols > usable_columns){
1664 int pdif, dif = total_cols - usable_columns;
1666 while (dif){
1667 pdif = dif;
1668 for (darr = home; darr; darr = darr->next){
1669 if (dif && darr->field_len - 1){
1670 darr->field_len--;
1671 dif--;
1675 /* avoid endless loop if num fields > 40 */
1676 if (pdif == dif)
1677 break;
1679 total_cols = usable_columns; /* give up, the rest should be truncated */
1682 /* Expand the available space */
1683 if ((usable_columns > total_cols) && expand_top){
1684 int spaces = (usable_columns - total_cols) / expand_top;
1685 int extra = (usable_columns - total_cols) % expand_top;
1687 for (i = 0, darr = home; darr && (i < expand_top); darr = darr->next)
1688 if (darr->expand){
1689 darr->field_len += (spaces + ((i == 0) ? extra : 0));
1690 i++;
1693 return home;
1696 /* Switches the panel to the mode specified in the format */
1697 /* Seting up both format and status string. Return: 0 - on success; */
1698 /* 1 - format error; 2 - status error; 3 - errors in both formats. */
1700 set_panel_formats (WPanel *p)
1702 format_e *form;
1703 char *err;
1704 int retcode = 0;
1706 form = use_display_format (p, panel_format (p), &err, 0);
1708 if (err){
1709 g_free (err);
1710 retcode = 1;
1712 else {
1713 if (p->format)
1714 delete_format (p->format);
1716 p->format = form;
1719 if (show_mini_info){
1721 form = use_display_format (p, mini_status_format (p), &err, 1);
1723 if (err){
1724 g_free (err);
1725 retcode += 2;
1727 else {
1728 if (p->status_format)
1729 delete_format (p->status_format);
1731 p->status_format = form;
1735 panel_format_modified (p);
1736 panel_update_cols (&(p->widget), p->frame_size);
1738 if (retcode)
1739 message (D_ERROR, _("Warning" ), _( "User supplied format looks invalid, reverting to default." ) );
1740 if (retcode & 0x01){
1741 g_free (p->user_format);
1742 p->user_format = g_strdup (DEFAULT_USER_FORMAT);
1744 if (retcode & 0x02){
1745 g_free (p->user_status_format [p->list_type]);
1746 p->user_status_format [p->list_type] = g_strdup (DEFAULT_USER_FORMAT);
1749 return retcode;
1752 /* Given the panel->view_type returns the format string to be parsed */
1753 static const char *
1754 panel_format (WPanel *panel)
1756 switch (panel->list_type){
1758 case list_long:
1759 return "full perm space nlink space owner space group space size space mtime space name";
1761 case list_brief:
1762 return "half 2 type name";
1764 case list_user:
1765 return panel->user_format;
1767 default:
1768 case list_full:
1769 return "half type name | size | mtime";
1773 static const char *
1774 mini_status_format (WPanel *panel)
1776 if (panel->user_mini_status)
1777 return panel->user_status_format [panel->list_type];
1779 switch (panel->list_type){
1781 case list_long:
1782 return "full perm space nlink space owner space group space size space mtime space name";
1784 case list_brief:
1785 return "half type name space bsize space perm space";
1787 case list_full:
1788 return "half type name";
1790 default:
1791 case list_user:
1792 return panel->user_format;
1796 /* */
1797 /* Panel operation commands */
1798 /* */
1800 /* Used to emulate Lynx's entering leaving a directory with the arrow keys */
1801 static cb_ret_t
1802 maybe_cd (int move_up_dir)
1804 if (navigate_with_arrows) {
1805 if (!cmdline->buffer[0]) {
1806 if (move_up_dir) {
1807 do_cd ("..", cd_exact);
1808 return MSG_HANDLED;
1810 if (S_ISDIR (selection (current_panel)->st.st_mode)
1811 || link_isdir (selection (current_panel))) {
1812 do_cd (selection (current_panel)->fname, cd_exact);
1813 return MSG_HANDLED;
1817 return MSG_NOT_HANDLED;
1820 /* Returns the number of items in the given panel */
1821 static int
1822 ITEMS (WPanel *p)
1824 if (p->split)
1825 return llines (p) * 2;
1826 else
1827 return llines (p);
1830 /* Select current item and readjust the panel */
1831 void
1832 select_item (WPanel *panel)
1834 int items = ITEMS (panel);
1836 /* Although currently all over the code we set the selection and
1837 top file to decent values before calling select_item, I could
1838 forget it someday, so it's better to do the actual fitting here */
1840 if (panel->top_file < 0)
1841 panel->top_file = 0;
1843 if (panel->selected < 0)
1844 panel->selected = 0;
1846 if (panel->selected > panel->count - 1)
1847 panel->selected = panel->count - 1;
1849 if (panel->top_file > panel->count - 1)
1850 panel->top_file = panel->count - 1;
1852 if ((panel->count - panel->top_file) < items) {
1853 panel->top_file = panel->count - items;
1854 if (panel->top_file < 0)
1855 panel->top_file = 0;
1858 if (panel->selected < panel->top_file)
1859 panel->top_file = panel->selected;
1861 if ((panel->selected - panel->top_file) >= items)
1862 panel->top_file = panel->selected - items + 1;
1864 panel->dirty = 1;
1866 execute_hooks (select_file_hook);
1869 /* Clears all files in the panel, used only when one file was marked */
1870 void
1871 unmark_files (WPanel *panel)
1873 int i;
1875 if (!panel->marked)
1876 return;
1877 for (i = 0; i < panel->count; i++)
1878 file_mark (panel, i, 0);
1880 panel->dirs_marked = 0;
1881 panel->marked = 0;
1882 panel->total = 0;
1885 static void
1886 unselect_item (WPanel *panel)
1888 repaint_file (panel, panel->selected, 1, 2*selection (panel)->f.marked, 0);
1891 static void
1892 move_down (WPanel *panel)
1894 if (panel->selected+1 == panel->count)
1895 return;
1897 unselect_item (panel);
1898 panel->selected++;
1899 if (panel->selected - panel->top_file == ITEMS (panel) &&
1900 panel_scroll_pages) {
1901 /* Scroll window half screen */
1902 panel->top_file += ITEMS (panel)/2;
1903 if (panel->top_file > panel->count - ITEMS (panel))
1904 panel->top_file = panel->count - ITEMS (panel);
1905 paint_dir (panel);
1907 select_item (panel);
1910 static void
1911 move_up (WPanel *panel)
1913 if (panel->selected == 0)
1914 return;
1916 unselect_item (panel);
1917 panel->selected--;
1918 if (panel->selected < panel->top_file && panel_scroll_pages) {
1919 /* Scroll window half screen */
1920 panel->top_file -= ITEMS (panel)/2;
1921 if (panel->top_file < 0)
1922 panel->top_file = 0;
1923 paint_dir (panel);
1925 select_item (panel);
1928 /* Changes the selection by lines (may be negative) */
1929 static void
1930 move_selection (WPanel *panel, int lines)
1932 int new_pos;
1933 int adjust = 0;
1935 new_pos = panel->selected + lines;
1936 if (new_pos >= panel->count)
1937 new_pos = panel->count-1;
1939 if (new_pos < 0)
1940 new_pos = 0;
1942 unselect_item (panel);
1943 panel->selected = new_pos;
1945 if (panel->selected - panel->top_file >= ITEMS (panel)){
1946 panel->top_file += lines;
1947 adjust = 1;
1950 if (panel->selected - panel->top_file < 0){
1951 panel->top_file += lines;
1952 adjust = 1;
1955 if (adjust){
1956 if (panel->top_file > panel->selected)
1957 panel->top_file = panel->selected;
1958 if (panel->top_file < 0)
1959 panel->top_file = 0;
1960 paint_dir (panel);
1962 select_item (panel);
1965 static cb_ret_t
1966 move_left (WPanel *panel)
1968 if (panel->split) {
1969 move_selection (panel, -llines (panel));
1970 return MSG_HANDLED;
1971 } else
1972 return maybe_cd (1); /* cd .. */
1975 static int
1976 move_right (WPanel *panel)
1978 if (panel->split) {
1979 move_selection (panel, llines (panel));
1980 return MSG_HANDLED;
1981 } else
1982 return maybe_cd (0); /* cd (selection) */
1985 static void
1986 prev_page (WPanel *panel)
1988 int items;
1990 if (!panel->selected && !panel->top_file)
1991 return;
1992 unselect_item (panel);
1993 items = ITEMS (panel);
1994 if (panel->top_file < items)
1995 items = panel->top_file;
1996 if (!items)
1997 panel->selected = 0;
1998 else
1999 panel->selected -= items;
2000 panel->top_file -= items;
2002 /* This keeps the selection in a reasonable place */
2003 if (panel->selected < 0)
2004 panel->selected = 0;
2005 if (panel->top_file < 0)
2006 panel->top_file = 0;
2007 select_item (panel);
2008 paint_dir (panel);
2011 static void
2012 ctrl_prev_page (WPanel *panel)
2014 (void) panel;
2015 do_cd ("..", cd_exact);
2018 static void
2019 next_page (WPanel *panel)
2021 int items;
2023 if (panel->selected == panel->count - 1)
2024 return;
2025 unselect_item (panel);
2026 items = ITEMS (panel);
2027 if (panel->top_file > panel->count - 2 * items)
2028 items = panel->count - items - panel->top_file;
2029 if (panel->top_file + items < 0)
2030 items = -panel->top_file;
2031 if (!items)
2032 panel->selected = panel->count - 1;
2033 else
2034 panel->selected += items;
2035 panel->top_file += items;
2037 /* This keeps the selection in it's relative position */
2038 if (panel->selected >= panel->count)
2039 panel->selected = panel->count - 1;
2040 if (panel->top_file >= panel->count)
2041 panel->top_file = panel->count - 1;
2042 select_item (panel);
2043 paint_dir (panel);
2046 static void
2047 ctrl_next_page (WPanel *panel)
2049 if ((S_ISDIR (selection (panel)->st.st_mode)
2050 || link_isdir (selection (panel)))) {
2051 do_cd (selection (panel)->fname, cd_exact);
2055 static void
2056 goto_top_file (WPanel *panel)
2058 unselect_item (panel);
2059 panel->selected = panel->top_file;
2060 select_item (panel);
2063 static void
2064 goto_middle_file (WPanel *panel)
2066 unselect_item (panel);
2067 panel->selected = panel->top_file + (ITEMS (panel)/2);
2068 if (panel->selected >= panel->count)
2069 panel->selected = panel->count - 1;
2070 select_item (panel);
2073 static void
2074 goto_bottom_file (WPanel *panel)
2076 unselect_item (panel);
2077 panel->selected = panel->top_file + ITEMS (panel)-1;
2078 if (panel->selected >= panel->count)
2079 panel->selected = panel->count - 1;
2080 select_item (panel);
2083 static void
2084 move_home (WPanel *panel)
2086 if (panel->selected == 0)
2087 return;
2088 unselect_item (panel);
2090 if (torben_fj_mode){
2091 int middle_pos = panel->top_file + (ITEMS (panel)/2);
2093 if (panel->selected > middle_pos){
2094 goto_middle_file (panel);
2095 return;
2097 if (panel->selected != panel->top_file){
2098 goto_top_file (panel);
2099 return;
2103 panel->top_file = 0;
2104 panel->selected = 0;
2106 paint_dir (panel);
2107 select_item (panel);
2110 static void
2111 move_end (WPanel *panel)
2113 if (panel->selected == panel->count-1)
2114 return;
2115 unselect_item (panel);
2116 if (torben_fj_mode){
2117 int middle_pos = panel->top_file + (ITEMS (panel)/2);
2119 if (panel->selected < middle_pos){
2120 goto_middle_file (panel);
2121 return;
2123 if (panel->selected != (panel->top_file + ITEMS(panel)-1)){
2124 goto_bottom_file (panel);
2125 return;
2129 panel->selected = panel->count-1;
2130 paint_dir (panel);
2131 select_item (panel);
2134 /* Recalculate the panels summary information, used e.g. when marked
2135 files might have been removed by an external command */
2136 void
2137 recalculate_panel_summary (WPanel *panel)
2139 int i;
2141 panel->marked = 0;
2142 panel->dirs_marked = 0;
2143 panel->total = 0;
2145 for (i = 0; i < panel->count; i++)
2146 if (panel->dir.list [i].f.marked){
2147 /* do_file_mark will return immediately if newmark == oldmark.
2148 So we have to first unmark it to get panel's summary information
2149 updated. (Norbert) */
2150 panel->dir.list [i].f.marked = 0;
2151 do_file_mark (panel, i, 1);
2155 /* This routine marks a file or a directory */
2156 void
2157 do_file_mark (WPanel *panel, int idx, int mark)
2159 if (panel->dir.list[idx].f.marked == mark)
2160 return;
2162 /* Only '..' can't be marked, '.' isn't visible */
2163 if (!strcmp (panel->dir.list[idx].fname, ".."))
2164 return;
2166 file_mark (panel, idx, mark);
2167 if (panel->dir.list[idx].f.marked) {
2168 panel->marked++;
2169 if (S_ISDIR (panel->dir.list[idx].st.st_mode)) {
2170 if (panel->dir.list[idx].f.dir_size_computed)
2171 panel->total += panel->dir.list[idx].st.st_size;
2172 panel->dirs_marked++;
2173 } else
2174 panel->total += panel->dir.list[idx].st.st_size;
2175 set_colors (panel);
2176 } else {
2177 if (S_ISDIR (panel->dir.list[idx].st.st_mode)) {
2178 if (panel->dir.list[idx].f.dir_size_computed)
2179 panel->total -= panel->dir.list[idx].st.st_size;
2180 panel->dirs_marked--;
2181 } else
2182 panel->total -= panel->dir.list[idx].st.st_size;
2183 panel->marked--;
2187 static void
2188 do_mark_file (WPanel *panel, int do_move)
2190 do_file_mark (panel, panel->selected,
2191 selection (panel)->f.marked ? 0 : 1);
2192 if (mark_moves_down && do_move)
2193 move_down (panel);
2196 static void
2197 mark_file (WPanel *panel)
2199 do_mark_file (panel, 1);
2202 /* Incremental search of a file name in the panel */
2203 static void
2204 do_search (WPanel *panel, int c_code)
2206 size_t l, max, buf_max;
2207 int i, sel;
2208 int wrapped = 0;
2209 char *act;
2211 l = strlen (panel->search_buffer);
2212 if (c_code == KEY_BACKSPACE) {
2213 if (l != 0) {
2214 act = panel->search_buffer + l;
2215 str_prev_noncomb_char (&act, panel->search_buffer);
2216 act[0] = '\0';
2218 panel->search_chpoint = 0;
2219 } else {
2220 if (c_code && (gsize) panel->search_chpoint < sizeof (panel->search_char)) {
2221 panel->search_char[panel->search_chpoint] = c_code;
2222 panel->search_chpoint++;
2225 if (panel->search_chpoint > 0) {
2226 switch (str_is_valid_char (panel->search_char, panel->search_chpoint)) {
2227 case -2:
2228 return;
2229 case -1:
2230 panel->search_chpoint = 0;
2231 return;
2232 default:
2233 if (l + panel->search_chpoint < sizeof (panel->search_buffer)) {
2234 memcpy (panel->search_buffer + l, panel->search_char,
2235 panel->search_chpoint);
2236 l+= panel->search_chpoint;
2237 (panel->search_buffer + l)[0] = '\0';
2238 panel->search_chpoint = 0;
2244 buf_max = panel->case_sensitive ?
2245 str_prefix (panel->search_buffer, panel->search_buffer) :
2246 str_caseprefix (panel->search_buffer, panel->search_buffer);
2247 max = 0;
2248 sel = panel->selected;
2249 for (i = panel->selected; !wrapped || i != panel->selected; i++) {
2250 if (i >= panel->count) {
2251 i = 0;
2252 if (wrapped)
2253 break;
2254 wrapped = 1;
2256 l = panel->case_sensitive ?
2257 str_prefix (panel->dir.list[i].fname, panel->search_buffer) :
2258 str_caseprefix (panel->dir.list[i].fname, panel->search_buffer);
2259 if (l > max) {
2260 max = l;
2261 sel = i;
2262 if (max == buf_max) break;
2266 unselect_item (panel);
2267 panel->selected = sel;
2268 select_item (panel);
2270 act = panel->search_buffer + strlen (panel->search_buffer);
2271 while (max < buf_max) {
2272 str_prev_char_safe (&act);
2273 act[0] = '\0';
2274 buf_max = panel->case_sensitive ?
2275 str_prefix (panel->search_buffer, panel->search_buffer) :
2276 str_caseprefix (panel->search_buffer, panel->search_buffer);
2279 paint_panel (panel);
2282 static void
2283 start_search (WPanel *panel)
2285 if (panel->searching){
2286 if (panel->selected+1 == panel->count)
2287 panel->selected = 0;
2288 else
2289 move_down (panel);
2290 do_search (panel, 0);
2291 } else {
2292 panel->searching = 1;
2293 panel->search_buffer[0] = '\0';
2294 panel->search_char[0] = '\0';
2295 panel->search_chpoint = 0;
2296 display_mini_info (panel);
2297 mc_refresh ();
2301 /* Return 1 if the Enter key has been processed, 0 otherwise */
2302 static int
2303 do_enter_on_file_entry (file_entry *fe)
2305 char *full_name;
2308 * Directory or link to directory - change directory.
2309 * Try the same for the entries on which mc_lstat() has failed.
2311 if (S_ISDIR (fe->st.st_mode) || link_isdir (fe)
2312 || (fe->st.st_mode == 0)) {
2313 if (!do_cd (fe->fname, cd_exact))
2314 message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
2315 return 1;
2318 /* Try associated command */
2319 if (regex_command (fe->fname, "Open", 0) != 0)
2320 return 1;
2322 /* Check if the file is executable */
2323 full_name = concat_dir_and_file (current_panel->cwd, fe->fname);
2324 if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe)) {
2325 g_free (full_name);
2326 return 0;
2328 g_free (full_name);
2330 if (confirm_execute) {
2331 if (query_dialog
2332 (_(" The Midnight Commander "),
2333 _(" Do you really want to execute? "), D_NORMAL, 2, _("&Yes"),
2334 _("&No")) != 0)
2335 return 1;
2337 #ifdef USE_VFS
2338 if (!vfs_current_is_local ()) {
2339 char *tmp;
2340 int ret;
2342 tmp = concat_dir_and_file (vfs_get_current_dir (), fe->fname);
2343 ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL);
2344 g_free (tmp);
2345 /* We took action only if the dialog was shown or the execution
2346 * was successful */
2347 return confirm_execute || (ret == 0);
2349 #endif
2352 char *tmp = name_quote (fe->fname, 0);
2353 char *cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL);
2354 g_free (tmp);
2355 shell_execute (cmd, 0);
2356 g_free (cmd);
2359 return 1;
2362 static int
2363 do_enter (WPanel *panel)
2365 return do_enter_on_file_entry (selection (panel));
2368 static void
2369 chdir_other_panel (WPanel *panel)
2371 char *new_dir;
2372 char *sel_entry = NULL;
2374 if (get_other_type () != view_listing) {
2375 set_display_type (get_other_index (), view_listing);
2378 if (!S_ISDIR (panel->dir.list [panel->selected].st.st_mode)) {
2379 new_dir = concat_dir_and_file (panel->cwd, "..");
2380 sel_entry = strrchr(panel->cwd, PATH_SEP);
2381 } else
2382 new_dir = concat_dir_and_file (panel->cwd, panel->dir.list [panel->selected].fname);
2384 change_panel ();
2385 do_cd (new_dir, cd_exact);
2386 if (sel_entry)
2387 try_to_select (current_panel, sel_entry);
2388 change_panel ();
2390 move_down (panel);
2392 g_free (new_dir);
2396 * Make the current directory of the current panel also the current
2397 * directory of the other panel. Put the other panel to the listing
2398 * mode if needed. If the current panel is panelized, the other panel
2399 * doesn't become panelized.
2401 static void
2402 sync_other_panel (WPanel *panel)
2404 if (get_other_type () != view_listing) {
2405 set_display_type (get_other_index (), view_listing);
2408 do_panel_cd (other_panel, current_panel->cwd, cd_exact);
2410 /* try to select current filename on the other panel */
2411 if (!panel->is_panelized) {
2412 try_to_select (other_panel, selection (panel)->fname);
2416 static void
2417 chdir_to_readlink (WPanel *panel)
2419 char *new_dir;
2421 if (get_other_type () != view_listing)
2422 return;
2424 if (S_ISLNK (panel->dir.list [panel->selected].st.st_mode)) {
2425 char buffer [MC_MAXPATHLEN], *p;
2426 int i;
2427 struct stat st;
2429 i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN - 1);
2430 if (i < 0)
2431 return;
2432 if (mc_stat (selection (panel)->fname, &st) < 0)
2433 return;
2434 buffer [i] = 0;
2435 if (!S_ISDIR (st.st_mode)) {
2436 p = strrchr (buffer, PATH_SEP);
2437 if (p && !p[1]) {
2438 *p = 0;
2439 p = strrchr (buffer, PATH_SEP);
2441 if (!p)
2442 return;
2443 p[1] = 0;
2445 if (*buffer == PATH_SEP)
2446 new_dir = g_strdup (buffer);
2447 else
2448 new_dir = concat_dir_and_file (panel->cwd, buffer);
2450 change_panel ();
2451 do_cd (new_dir, cd_exact);
2452 change_panel ();
2454 move_down (panel);
2456 g_free (new_dir);
2460 static gsize
2461 panel_get_format_field_count(WPanel *panel)
2463 format_e *format;
2464 gsize lc_index;
2465 for (
2466 lc_index=0, format = panel->format;
2467 format != NULL;
2468 format = format->next, lc_index++
2470 return lc_index;
2474 function return 0 if not found and REAL_INDEX+1 if found
2476 static gsize
2477 panel_get_format_field_index_by_name(WPanel *panel, const char *name)
2479 format_e *format;
2480 gsize lc_index;
2482 for (
2483 lc_index=1, format = panel->format;
2484 ! ( format == NULL || strcmp(format->title, name) == 0 );
2485 format = format->next, lc_index++
2487 if (format == NULL)
2488 lc_index = 0;
2490 return lc_index;
2493 static format_e *
2494 panel_get_format_field_by_index(WPanel *panel, gsize lc_index)
2496 format_e *format;
2497 for (
2498 format = panel->format;
2499 ! ( format == NULL || lc_index == 0 );
2500 format = format->next, lc_index--
2502 return format;
2505 static const panel_field_t *
2506 panel_get_sortable_field_by_format(WPanel *panel, gsize lc_index)
2508 const panel_field_t *pfield;
2509 format_e *format;
2511 format = panel_get_format_field_by_index(panel, lc_index);
2512 if (format == NULL)
2513 return NULL;
2514 pfield = panel_get_field_by_title(format->title);
2515 if (pfield == NULL)
2516 return NULL;
2517 if (pfield->sort_routine == NULL)
2518 return NULL;
2519 return pfield;
2522 static void
2523 panel_toggle_sort_order_prev(WPanel *panel)
2525 gsize lc_index, i;
2526 gchar *title;
2528 const panel_field_t *pfield = NULL;
2530 title = panel_get_title_without_hotkey(panel->current_sort_field->title_hotkey);
2531 lc_index = panel_get_format_field_index_by_name(panel, title);
2532 g_free(title);
2534 if (lc_index > 1){
2535 /* search for prev sortable column in panel format */
2536 for (
2537 i = lc_index-1 ;
2538 i != 0 && (pfield = panel_get_sortable_field_by_format(panel, i-1)) == NULL ;
2543 if ( pfield == NULL) {
2544 /* Sortable field not found. Try to search in each array */
2545 for (
2546 i = panel_get_format_field_count(panel) ;
2547 i != 0 && (pfield = panel_get_sortable_field_by_format(panel, i-1)) == NULL ;
2551 if ( pfield == NULL)
2552 return;
2553 panel->current_sort_field = pfield;
2554 panel_set_sort_order(panel, panel->current_sort_field);
2558 static void
2559 panel_toggle_sort_order_next(WPanel *panel)
2561 gsize lc_index, i;
2562 const panel_field_t *pfield = NULL;
2563 gsize format_field_count = panel_get_format_field_count(panel);
2564 gchar *title;
2566 title = panel_get_title_without_hotkey(panel->current_sort_field->title_hotkey);
2567 lc_index = panel_get_format_field_index_by_name(panel, title);
2568 g_free(title);
2570 if (lc_index != 0 && lc_index != format_field_count){
2571 /* search for prev sortable column in panel format */
2572 for (
2573 i = lc_index;
2574 i != format_field_count && (pfield = panel_get_sortable_field_by_format(panel, i)) == NULL ;
2579 if ( pfield == NULL) {
2580 /* Sortable field not found. Try to search in each array */
2581 for (
2582 i = 0 ;
2583 i != format_field_count && (pfield = panel_get_sortable_field_by_format(panel, i)) == NULL ;
2587 if ( pfield == NULL)
2588 return;
2589 panel->current_sort_field = pfield;
2590 panel_set_sort_order(panel, panel->current_sort_field);
2593 static void
2594 panel_select_sort_order(WPanel *panel)
2596 const panel_field_t *sort_order;
2597 sort_order = sort_box (panel->current_sort_field, &panel->reverse,
2598 &panel->case_sensitive,
2599 &panel->exec_first);
2600 if (sort_order == NULL)
2601 return;
2602 panel->current_sort_field = sort_order;
2603 panel_set_sort_order (panel, panel->current_sort_field);
2607 static void
2608 panel_set_sort_type_by_id(WPanel *panel, const char *name)
2610 const panel_field_t *sort_order;
2612 if (strcmp(panel->current_sort_field->id, name) != 0) {
2613 sort_order = panel_get_field_by_id (name);
2614 if (sort_order == NULL)
2615 return;
2616 panel->current_sort_field = sort_order;
2617 } else {
2618 panel->reverse = ! panel->reverse;
2620 panel_set_sort_order (panel, panel->current_sort_field);
2623 typedef void (*panel_key_callback) (WPanel *);
2625 static void cmd_do_enter(WPanel *wp) { (void) do_enter(wp); }
2626 static void cmd_view_simple(WPanel *wp) { (void) wp; view_simple_cmd(); }
2627 static void cmd_edit_new(WPanel *wp) { (void) wp; edit_cmd_new(); }
2628 static void cmd_copy_local(WPanel *wp) { (void) wp; copy_cmd_local(); }
2629 static void cmd_rename_local(WPanel *wp) { (void) wp; rename_cmd_local(); }
2630 static void cmd_delete_local(WPanel *wp) { (void) wp; delete_cmd_local(); }
2631 static void cmd_select(WPanel *wp) { (void) wp; select_cmd(); }
2632 static void cmd_unselect(WPanel *wp) { (void) wp; unselect_cmd(); }
2633 static void cmd_reverse_selection(WPanel *wp) { (void) wp; reverse_selection_cmd(); }
2635 static cb_ret_t
2636 panel_execute_cmd (WPanel *panel, unsigned long command)
2638 int res = MSG_HANDLED;
2640 switch (command) {
2641 case CK_PanelChdirOtherPanel:
2642 chdir_other_panel (panel);
2643 break;
2644 case CK_PanelChdirToReadlink:
2645 chdir_to_readlink (panel);
2646 break;
2647 case CK_PanelCmdCopyLocal:
2648 cmd_copy_local (panel);
2649 break;
2650 case CK_PanelCmdDeleteLocal:
2651 cmd_delete_local (panel);
2652 break;
2653 case CK_PanelCmdDoEnter:
2654 cmd_do_enter (panel);
2655 break;
2656 case CK_PanelCmdViewSimple:
2657 cmd_view_simple (panel);
2658 break;
2659 case CK_PanelCmdEditNew:
2660 cmd_edit_new (panel);
2661 break;
2662 case CK_PanelCmdRenameLocal:
2663 cmd_rename_local (panel);
2664 break;
2665 case CK_PanelCmdReverseSelection:
2666 cmd_reverse_selection (panel);
2667 break;
2668 case CK_PanelCmdSelect:
2669 cmd_select (panel);
2670 break;
2671 case CK_PanelCmdUnselect:
2672 cmd_unselect (panel);
2673 break;
2674 case CK_PanelNextPage:
2675 next_page (panel);
2676 break;
2677 case CK_PanelPrevPage:
2678 prev_page (panel);
2679 break;
2680 case CK_PanelCtrlNextPage:
2681 ctrl_next_page (panel);
2682 break;
2683 case CK_PanelCtrlPrevPage:
2684 ctrl_prev_page (panel);
2685 break;
2686 case CK_PanelDirectoryHistoryList:
2687 directory_history_list (panel);
2688 break;
2689 case CK_PanelDirectoryHistoryNext:
2690 directory_history_next (panel);
2691 break;
2692 case CK_PanelDirectoryHistoryPrev:
2693 directory_history_prev (panel);
2694 break;
2695 case CK_PanelGotoBottomFile:
2696 goto_bottom_file (panel);
2697 break;
2698 case CK_PanelGotoMiddleFile:
2699 goto_middle_file (panel);
2700 break;
2701 case CK_PanelGotoTopFile:
2702 goto_top_file (panel);
2703 break;
2704 case CK_PanelMarkFile:
2705 mark_file (panel);
2706 break;
2707 case CK_PanelMoveUp:
2708 move_up (panel);
2709 break;
2710 case CK_PanelMoveDown:
2711 move_down (panel);
2712 break;
2713 case CK_PanelMoveLeft:
2714 res = move_left (panel);
2715 break;
2716 case CK_PanelMoveRight:
2717 res = move_right (panel);
2718 break;
2719 case CK_PanelMoveEnd:
2720 move_end (panel);
2721 break;
2722 case CK_PanelMoveHome:
2723 move_home (panel);
2724 break;
2725 case CK_PanelSetPanelEncoding:
2726 set_panel_encoding (panel);
2727 break;
2728 case CK_PanelStartSearch:
2729 start_search (panel);
2730 break;
2731 case CK_PanelSyncOtherPanel:
2732 sync_other_panel (panel);
2733 break;
2734 case CK_PanelSelectSortOrder:
2735 panel_select_sort_order(panel);
2736 break;
2737 case CK_PanelToggleSortOrderPrev:
2738 panel_toggle_sort_order_prev(panel);
2739 break;
2740 case CK_PanelToggleSortOrderNext:
2741 panel_toggle_sort_order_next(panel);
2742 break;
2743 case CK_PanelReverseSort:
2744 panel->reverse = ! panel->reverse;
2745 panel_set_sort_order (panel, panel->current_sort_field);
2746 break;
2747 case CK_PanelSortOrderByName:
2748 panel_set_sort_type_by_id(panel, "name");
2749 break;
2750 case CK_PanelSortOrderByExt:
2751 panel_set_sort_type_by_id(panel, "extension");
2752 break;
2753 case CK_PanelSortOrderBySize:
2754 panel_set_sort_type_by_id(panel, "size");
2755 break;
2756 case CK_PanelSortOrderByMTime:
2757 panel_set_sort_type_by_id(panel, "mtime");
2758 break;
2760 return res;
2763 static cb_ret_t
2764 panel_key (WPanel *panel, int key)
2766 size_t i;
2767 unsigned long res, command;
2769 for (i = 0; panel_map[i].key != 0; i++) {
2770 if (key == panel_map[i].key) {
2771 int old_searching = panel->searching;
2773 if (panel_map[i].command != CK_PanelStartSearch)
2774 panel->searching = 0;
2776 command = panel_map[i].command;
2777 res = panel_execute_cmd (panel, command);
2779 if (res == MSG_NOT_HANDLED)
2780 return res;
2782 if (panel->searching != old_searching)
2783 display_mini_info (panel);
2784 return MSG_HANDLED;
2788 if (torben_fj_mode && key == ALT ('h')) {
2789 goto_middle_file (panel);
2790 return MSG_HANDLED;
2793 if (is_abort_char (key)) {
2794 panel->searching = 0;
2795 display_mini_info (panel);
2796 return MSG_HANDLED;
2799 /* Do not eat characters not meant for the panel below ' ' (e.g. C-l). */
2800 if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE) {
2801 if (panel->searching) {
2802 do_search (panel, key);
2803 return MSG_HANDLED;
2806 if (!command_prompt) {
2807 start_search (panel);
2808 do_search (panel, key);
2809 return MSG_HANDLED;
2813 return MSG_NOT_HANDLED;
2816 static cb_ret_t
2817 panel_callback (Widget *w, widget_msg_t msg, int parm)
2819 WPanel *panel = (WPanel *) w;
2820 WButtonBar *bb;
2822 switch (msg) {
2823 case WIDGET_DRAW:
2824 paint_panel (panel);
2825 return MSG_HANDLED;
2827 case WIDGET_FOCUS:
2828 current_panel = panel;
2829 panel->active = 1;
2830 if (mc_chdir (panel->cwd) != 0) {
2831 char *cwd = strip_password (g_strdup (panel->cwd), 1);
2832 message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
2833 cwd, unix_error_string (errno));
2834 g_free(cwd);
2835 } else
2836 subshell_chdir (panel->cwd);
2838 update_xterm_title_path ();
2839 select_item (panel);
2840 show_dir (panel);
2841 paint_dir (panel);
2842 panel->dirty = 0;
2844 bb = find_buttonbar (panel->widget.parent);
2845 midnight_set_buttonbar (bb);
2846 buttonbar_redraw (bb);
2847 return MSG_HANDLED;
2849 case WIDGET_UNFOCUS:
2850 /* Janne: look at this for the multiple panel options */
2851 if (panel->searching){
2852 panel->searching = 0;
2853 display_mini_info (panel);
2855 panel->active = 0;
2856 show_dir (panel);
2857 unselect_item (panel);
2858 return MSG_HANDLED;
2860 case WIDGET_KEY:
2861 return panel_key (panel, parm);
2863 case WIDGET_DESTROY:
2864 panel_destroy (panel);
2865 return MSG_HANDLED;
2867 default:
2868 return default_proc (msg, parm);
2872 void
2873 file_mark (WPanel *panel, int lc_index, int val)
2875 if (panel->dir.list[lc_index].f.marked != val) {
2876 panel->dir.list[lc_index].f.marked = val;
2877 panel->dirty = 1;
2881 /* */
2882 /* Panel mouse events support routines */
2883 /* */
2884 static int mouse_marking = 0;
2886 static void
2887 mouse_toggle_mark (WPanel *panel)
2889 do_mark_file (panel, 0);
2890 mouse_marking = selection (panel)->f.marked;
2893 static void
2894 mouse_set_mark (WPanel *panel)
2896 if (mouse_marking && !(selection (panel)->f.marked))
2897 do_mark_file (panel, 0);
2898 else if (!mouse_marking && (selection (panel)->f.marked))
2899 do_mark_file (panel, 0);
2902 static int
2903 mark_if_marking (WPanel *panel, Gpm_Event *event)
2905 if (event->buttons & GPM_B_RIGHT){
2906 if (event->type & GPM_DOWN)
2907 mouse_toggle_mark (panel);
2908 else
2909 mouse_set_mark (panel);
2910 return 1;
2912 return 0;
2915 /* Determine which column was clicked, and sort the panel on
2916 * that column, or reverse sort on that column if already
2917 * sorted on that column.
2919 static void
2920 mouse_sort_col(Gpm_Event *event, WPanel *panel)
2922 int i;
2923 const char *lc_sort_name = NULL;
2924 panel_field_t *col_sort_format = NULL;
2925 format_e *format;
2926 gchar *title;
2928 for (i = 0, format = panel->format; format != NULL; format = format->next) {
2929 i += format->field_len;
2930 if (event->x < i + 1) {
2931 /* found column */
2932 lc_sort_name = format->title;
2933 break;
2937 if (lc_sort_name == NULL)
2938 return;
2940 for(i = 0; panel_fields[i].id != NULL; i++) {
2941 title = panel_get_title_without_hotkey(panel_fields[i].title_hotkey);
2942 if (!strcmp (lc_sort_name, title) && panel_fields[i].sort_routine) {
2943 col_sort_format = &panel_fields[i];
2944 g_free(title);
2945 break;
2947 g_free(title);
2950 if (!col_sort_format)
2951 return;
2953 if (panel->current_sort_field == col_sort_format) {
2954 /* reverse the sort if clicked column is already the sorted column */
2955 panel->reverse = !panel->reverse;
2956 } else {
2957 /* new sort is forced to be ascending */
2958 panel->reverse = 0;
2960 panel_set_sort_order (panel, col_sort_format);
2965 * Mouse callback of the panel minus repainting.
2966 * If the event is redirected to the menu, *redir is set to 1.
2968 static int
2969 do_panel_event (Gpm_Event *event, WPanel *panel, int *redir)
2971 const int lines = llines (panel);
2972 const gboolean is_active = dlg_widget_active (panel);
2973 const gboolean mouse_down = (event->type & GPM_DOWN) != 0;
2975 /* "." button show/hide hidden files */
2976 if (event->type & GPM_DOWN && event->x == panel->widget.cols - 5 && event->y == 1) {
2977 toggle_show_hidden();
2978 repaint_screen ();
2979 return MOU_NORMAL;
2982 /* "<" button */
2983 if (mouse_down && event->y == 1 && event->x == 2) {
2984 directory_history_prev (panel);
2985 return MOU_NORMAL;
2988 /* ">" button */
2989 if (mouse_down && event->y == 1 && event->x == panel->widget.cols - 1) {
2990 directory_history_next (panel);
2991 return MOU_NORMAL;
2994 /* "^" button */
2995 if (mouse_down && event->y == 1 && event->x >= panel->widget.cols - 4 && event->x <= panel->widget.cols - 2) {
2996 directory_history_list (panel);
2997 return MOU_NORMAL;
3000 /* sort on clicked column */
3001 if (event->type & GPM_DOWN && event->y == 2) {
3002 mouse_sort_col(event,panel);
3003 return MOU_NORMAL;
3006 /* rest of the upper frame, the menu is invisible - call menu */
3007 if (mouse_down && event->y == 1 && !menubar_visible) {
3008 *redir = 1;
3009 event->x += panel->widget.x;
3010 return the_menubar->widget.mouse (event, the_menubar);
3013 /* Mouse wheel events */
3014 if (mouse_down && (event->buttons & GPM_B_UP)) {
3015 if (is_active) {
3016 if (panel->top_file > 0)
3017 prev_page (panel);
3018 else /* We are in first page */
3019 move_up (panel);
3021 return MOU_NORMAL;
3024 if (mouse_down && (event->buttons & GPM_B_DOWN)) {
3025 if (is_active) {
3026 if (panel->top_file + ITEMS (panel) < panel->count)
3027 next_page (panel);
3028 else /* We are in last page */
3029 move_down (panel);
3031 return MOU_NORMAL;
3034 event->y -= 2;
3035 if ((event->type & (GPM_DOWN | GPM_DRAG))) {
3036 int my_index;
3038 if (!is_active)
3039 change_panel ();
3041 if (event->y <= 0) {
3042 mark_if_marking (panel, event);
3043 if (mouse_move_pages)
3044 prev_page (panel);
3045 else
3046 move_up (panel);
3047 return MOU_REPEAT;
3050 if (!((panel->top_file + event->y <= panel->count) && event->y <= lines)) {
3051 mark_if_marking (panel, event);
3052 if (mouse_move_pages)
3053 next_page (panel);
3054 else
3055 move_down (panel);
3056 return MOU_REPEAT;
3059 my_index = panel->top_file + event->y - 1;
3060 if (panel->split && (event->x > ((panel->widget.cols - 2) / 2)))
3061 my_index += llines (panel);
3063 if (my_index >= panel->count)
3064 my_index = panel->count - 1;
3066 if (my_index != panel->selected) {
3067 unselect_item (panel);
3068 panel->selected = my_index;
3069 select_item (panel);
3072 /* This one is new */
3073 mark_if_marking (panel, event);
3074 } else if ((event->type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE)) {
3075 if (event->y > 0 && event->y <= lines)
3076 do_enter (panel);
3078 return MOU_NORMAL;
3081 /* Mouse callback of the panel */
3082 static int
3083 panel_event (Gpm_Event *event, void *data)
3085 WPanel *panel = data;
3086 int ret;
3087 int redir = MOU_NORMAL;
3089 ret = do_panel_event (event, panel, &redir);
3090 if (!redir)
3091 paint_panel (panel);
3093 return ret;
3096 void
3097 panel_re_sort (WPanel *panel)
3099 char *filename;
3100 int i;
3102 if (panel == NULL)
3103 return;
3105 filename = g_strdup (selection (panel)->fname);
3106 unselect_item (panel);
3107 do_sort (&panel->dir, panel->current_sort_field->sort_routine, panel->count-1, panel->reverse,
3108 panel->case_sensitive, panel->exec_first);
3109 panel->selected = -1;
3110 for (i = panel->count; i; i--){
3111 if (!strcmp (panel->dir.list [i-1].fname, filename)){
3112 panel->selected = i-1;
3113 break;
3116 g_free (filename);
3117 panel->top_file = panel->selected - ITEMS (panel)/2;
3118 if (panel->top_file < 0)
3119 panel->top_file = 0;
3120 select_item (panel);
3121 panel->dirty = 1;
3124 void
3125 panel_set_sort_order (WPanel *panel, const panel_field_t *sort_order)
3127 if (sort_order == 0)
3128 return;
3130 panel->current_sort_field = sort_order;
3132 /* The directory is already sorted, we have to load the unsorted stuff */
3133 if (sort_order->sort_routine == (sortfn *) unsorted){
3134 char *current_file;
3136 current_file = g_strdup (panel->dir.list [panel->selected].fname);
3137 panel_reload (panel);
3138 try_to_select (panel, current_file);
3139 g_free (current_file);
3141 panel_re_sort (panel);
3144 void
3145 set_panel_encoding (WPanel *panel)
3147 const char *encoding = NULL;
3148 char *cd_path;
3149 #ifdef HAVE_CHARSET
3150 const char *errmsg;
3151 int r;
3153 r = select_charset (-1, -1, source_codepage, FALSE);
3155 if (r == SELECT_CHARSET_CANCEL)
3156 return; /* Cancel */
3158 if (r == SELECT_CHARSET_NO_TRANSLATE) {
3159 /* No translation */
3160 errmsg = init_translation_table (display_codepage, display_codepage);
3161 cd_path = remove_encoding_from_path (panel->cwd);
3162 do_panel_cd (panel, cd_path, 0);
3163 g_free (cd_path);
3164 return;
3167 source_codepage = r;
3169 errmsg = init_translation_table (source_codepage, display_codepage);
3170 if (errmsg) {
3171 message (D_ERROR, MSG_ERROR, "%s", errmsg);
3172 return;
3175 encoding = get_codepage_id (source_codepage);
3176 #endif
3177 if (encoding != NULL) {
3178 cd_path = add_encoding_to_path (panel->cwd, encoding);
3179 if (!do_panel_cd (panel, cd_path, 0))
3180 message (D_ERROR, MSG_ERROR, _(" Cannot chdir to %s "), cd_path);
3181 g_free (cd_path);
3185 static void
3186 reload_panelized (WPanel *panel)
3188 int i, j;
3189 dir_list *list = &panel->dir;
3191 if (panel != current_panel)
3192 mc_chdir (panel->cwd);
3194 for (i = 0, j = 0; i < panel->count; i++) {
3195 if (list->list[i].f.marked) {
3196 /* Unmark the file in advance. In case the following mc_lstat
3197 * fails we are done, else we have to mark the file again
3198 * (Note: do_file_mark depends on a valid "list->list [i].buf").
3199 * IMO that's the best way to update the panel's summary status
3200 * -- Norbert
3202 do_file_mark (panel, i, 0);
3204 if (mc_lstat (list->list[i].fname, &list->list[i].st)) {
3205 g_free (list->list[i].fname);
3206 continue;
3208 if (list->list[i].f.marked)
3209 do_file_mark (panel, i, 1);
3210 if (j != i)
3211 list->list[j] = list->list[i];
3212 j++;
3214 if (j == 0)
3215 panel->count = set_zero_dir (list) ? 1 : 0;
3216 else
3217 panel->count = j;
3219 if (panel != current_panel)
3220 mc_chdir (current_panel->cwd);
3223 static void
3224 update_one_panel_widget (WPanel *panel, int force_update,
3225 const char *current_file)
3227 int free_pointer;
3228 char *my_current_file = NULL;
3230 if (force_update & UP_RELOAD) {
3231 panel->is_panelized = 0;
3232 mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0);
3233 memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
3236 /* If current_file == -1 (an invalid pointer) then preserve selection */
3237 if (current_file == UP_KEEPSEL) {
3238 free_pointer = 1;
3239 my_current_file = g_strdup (panel->dir.list[panel->selected].fname);
3240 current_file = my_current_file;
3241 } else
3242 free_pointer = 0;
3244 if (panel->is_panelized)
3245 reload_panelized (panel);
3246 else
3247 panel_reload (panel);
3249 try_to_select (panel, current_file);
3250 panel->dirty = 1;
3252 if (free_pointer)
3253 g_free (my_current_file);
3256 static void
3257 update_one_panel (int which, int force_update, const char *current_file)
3259 WPanel *panel;
3261 if (get_display_type (which) != view_listing)
3262 return;
3264 panel = (WPanel *) get_panel_widget (which);
3265 update_one_panel_widget (panel, force_update, current_file);
3268 /* This routine reloads the directory in both panels. It tries to
3269 * select current_file in current_panel and other_file in other_panel.
3270 * If current_file == -1 then it automatically sets current_file and
3271 * other_file to the currently selected files in the panels.
3273 * if force_update has the UP_ONLY_CURRENT bit toggled on, then it
3274 * will not reload the other panel.
3276 void
3277 update_panels (int force_update, const char *current_file)
3279 int reload_other = !(force_update & UP_ONLY_CURRENT);
3280 WPanel *panel;
3282 update_one_panel (get_current_index (), force_update, current_file);
3283 if (reload_other)
3284 update_one_panel (get_other_index (), force_update, UP_KEEPSEL);
3286 if (get_current_type () == view_listing)
3287 panel = (WPanel *) get_panel_widget (get_current_index ());
3288 else
3289 panel = (WPanel *) get_panel_widget (get_other_index ());
3291 mc_chdir (panel->cwd);
3294 gsize
3295 panel_get_num_of_sortable_fields(void)
3297 gsize ret = 0, lc_index;
3299 for(lc_index=0; panel_fields[lc_index].id != NULL; lc_index ++)
3300 if (panel_fields[lc_index].is_user_choice)
3301 ret++;
3302 return ret;
3306 const char **
3307 panel_get_sortable_fields(gsize *array_size)
3309 char **ret;
3310 gsize lc_index, i;
3312 lc_index = panel_get_num_of_sortable_fields();
3314 ret = g_new0 (char *, lc_index + 1);
3315 if (ret == NULL)
3316 return NULL;
3318 if (array_size != NULL)
3319 *array_size = lc_index;
3321 lc_index=0;
3323 for(i=0; panel_fields[i].id != NULL; i ++)
3324 if (panel_fields[i].is_user_choice)
3325 ret[lc_index++] = g_strdup(_(panel_fields[i].title_hotkey));
3326 return (const char**) ret;
3329 const panel_field_t *
3330 panel_get_field_by_id(const char *name)
3332 gsize lc_index;
3333 for(lc_index=0; panel_fields[lc_index].id != NULL; lc_index ++)
3334 if (
3335 panel_fields[lc_index].id != NULL &&
3336 strcmp(name, panel_fields[lc_index].id) == 0
3338 return &panel_fields[lc_index];
3339 return NULL;
3342 const panel_field_t *
3343 panel_get_field_by_title_hotkey(const char *name)
3345 gsize lc_index;
3346 for(lc_index=0; panel_fields[lc_index].id != NULL; lc_index ++)
3347 if (
3348 panel_fields[lc_index].title_hotkey != NULL &&
3349 strcmp(name, _(panel_fields[lc_index].title_hotkey)) == 0
3351 return &panel_fields[lc_index];
3352 return NULL;
3355 const panel_field_t *
3356 panel_get_field_by_title(const char *name)
3358 gsize lc_index;
3359 gchar *title = NULL;
3361 for(lc_index=0; panel_fields[lc_index].id != NULL; lc_index ++) {
3362 title = panel_get_title_without_hotkey(panel_fields[lc_index].title_hotkey);
3363 if (
3364 panel_fields[lc_index].title_hotkey != NULL &&
3365 strcmp(name, title) == 0
3367 g_free(title);
3368 return &panel_fields[lc_index];
3371 g_free(title);
3372 return NULL;
3375 gsize
3376 panel_get_num_of_user_possible_fields(void)
3378 gsize ret = 0, lc_index;
3380 for(lc_index=0; panel_fields[lc_index].id != NULL; lc_index ++)
3381 if (panel_fields[lc_index].use_in_user_format)
3382 ret++;
3383 return ret;
3386 const char **
3387 panel_get_user_possible_fields(gsize *array_size)
3389 char **ret;
3390 gsize lc_index, i;
3392 lc_index = panel_get_num_of_user_possible_fields();
3394 ret = g_new0 (char *, lc_index + 1);
3395 if (ret == NULL)
3396 return NULL;
3398 if (array_size != NULL)
3399 *array_size = lc_index;
3401 lc_index=0;
3403 for(i=0; panel_fields[i].id != NULL; i ++)
3404 if (panel_fields[i].use_in_user_format)
3405 ret[lc_index++] = g_strdup(_(panel_fields[i].title_hotkey));
3406 return (const char**) ret;
3409 void
3410 panel_init(void)
3412 panel_sort_up_sign = mc_skin_get("widget-common","sort-sign-up","'");
3413 panel_sort_down_sign = mc_skin_get("widget-common","sort-sign-down",",");
3415 panel_hiddenfiles_sign_show = mc_skin_get("widget-panel", "hiddenfiles-sign-show", ".");
3416 panel_hiddenfiles_sign_hide = mc_skin_get("widget-panel", "hiddenfiles-sign-hide", ".");
3417 panel_history_prev_item_sign = mc_skin_get("widget-panel", "history-prev-item-sign", "<");
3418 panel_history_next_item_sign = mc_skin_get("widget-panel", "history-next-item-sign", ">");
3419 panel_history_show_list_sign = mc_skin_get("widget-panel", "history-show-list-sign", "^");
3423 void
3424 panel_deinit(void)
3426 g_free(panel_sort_up_sign);
3427 g_free(panel_sort_down_sign);
3429 g_free(panel_hiddenfiles_sign_show);
3430 g_free(panel_hiddenfiles_sign_hide);
3431 g_free(panel_history_prev_item_sign);
3432 g_free(panel_history_next_item_sign);
3433 g_free(panel_history_show_list_sign);