Ticket #1791: a nice dark skin created by Lee Bigelow.
[kaloumi3.git] / src / screen.c
blobe158312c4710522d131acc0742938c7a65c737fd
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 "lib/global.h"
36 #include "lib/tty/tty.h"
37 #include "lib/skin.h"
38 #include "lib/strescape.h"
39 #include "lib/tty/mouse.h" /* For Gpm_Event */
40 #include "lib/tty/key.h" /* XCTRL and ALT macros */
41 #include "lib/filehighlight.h"
42 #include "lib/mcconfig.h"
43 #include "lib/vfs/mc-vfs/vfs.h"
44 #include "lib/unixcompat.h"
46 #include "dir.h"
47 #include "panel.h"
48 #include "boxes.h"
49 #include "tree.h"
50 #include "ext.h" /* regexp_command */
51 #include "layout.h" /* Most layout variables are here */
52 #include "wtools.h" /* for message (...) */
53 #include "cmd.h"
54 #include "command.h" /* cmdline */
55 #include "setup.h" /* For loading/saving panel options */
56 #include "user.h"
57 #include "execute.h"
58 #include "widget.h"
59 #include "menu.h" /* menubar_visible */
60 #include "main-widgets.h"
61 #include "main.h"
62 #include "mountlist.h" /* my_statfs */
63 #include "selcodepage.h" /* select_charset () */
64 #include "charsets.h" /* get_codepage_id () */
65 #include "cmddef.h" /* CK_ cmd name const */
66 #include "keybind.h" /* global_keymap_t */
68 #define ELEMENTS(arr) ( sizeof(arr) / sizeof((arr)[0]) )
70 #define NORMAL 0
71 #define SELECTED 1
72 #define MARKED 2
73 #define MARKED_SELECTED 3
74 #define STATUS 5
77 * This describes a format item. The parse_display_format routine parses
78 * the user specified format and creates a linked list of format_e structures.
80 typedef struct format_e
82 struct format_e *next;
83 int requested_field_len;
84 int field_len;
85 align_crt_t just_mode;
86 int expand;
87 const char *(*string_fn) (file_entry *, int len);
88 char *title;
89 const char *id;
90 } format_e;
92 /* If true, show the mini-info on the panel */
93 int show_mini_info = 1;
95 /* If true, then use stat() on the cwd to determine directory changes */
96 int fast_reload = 0;
98 /* If true, use some usability hacks by Torben */
99 int torben_fj_mode = 0;
101 /* If true, up/down keys scroll the pane listing by pages */
102 int panel_scroll_pages = 1;
104 /* If 1, we use permission hilighting */
105 int permission_mode = 0;
107 /* If 1 - then add per file type hilighting */
108 int filetype_mode = 1;
110 /* The hook list for the select file function */
111 Hook *select_file_hook = 0;
113 const global_keymap_t *panel_map;
115 static cb_ret_t panel_callback (Widget *, widget_msg_t msg, int parm);
116 static int panel_event (Gpm_Event * event, void *);
117 static void paint_frame (WPanel * panel);
118 static const char *panel_format (WPanel * panel);
119 static const char *mini_status_format (WPanel * panel);
121 static char *panel_sort_up_sign = NULL;
122 static char *panel_sort_down_sign = NULL;
124 static char *panel_hiddenfiles_sign_show = NULL;
125 static char *panel_hiddenfiles_sign_hide = NULL;
126 static char *panel_history_prev_item_sign = NULL;
127 static char *panel_history_next_item_sign = NULL;
128 static char *panel_history_show_list_sign = NULL;
130 /* This macro extracts the number of available lines in a panel */
131 #define llines(p) (p->widget.lines-3 - (show_mini_info ? 2 : 0))
133 static void
134 set_colors (WPanel * panel)
136 (void) panel;
137 tty_set_normal_attrs ();
138 tty_setcolor (NORMAL_COLOR);
141 /* Delete format string, it is a linked list */
142 static void
143 delete_format (format_e * format)
145 while (format != NULL)
147 format_e *next = format->next;
148 g_free (format->title);
149 g_free (format);
150 format = next;
154 /* This code relies on the default justification!!! */
155 static void
156 add_permission_string (char *dest, int width, file_entry * fe, int attr, int color, int is_octal)
158 int i, r, l;
160 l = get_user_permissions (&fe->st);
162 if (is_octal)
164 /* Place of the access bit in octal mode */
165 l = width + l - 3;
166 r = l + 1;
168 else
170 /* The same to the triplet in string mode */
171 l = l * 3 + 1;
172 r = l + 3;
175 for (i = 0; i < width; i++)
177 if (i >= l && i < r)
179 if (attr == SELECTED || attr == MARKED_SELECTED)
180 tty_setcolor (MARKED_SELECTED_COLOR);
181 else
182 tty_setcolor (MARKED_COLOR);
184 else if (color >= 0)
185 tty_setcolor (color);
186 else
187 tty_lowlevel_setcolor (-color);
189 tty_print_char (dest[i]);
193 /* String representations of various file attributes */
194 /* name */
195 static const char *
196 string_file_name (file_entry * fe, int len)
198 static char buffer[MC_MAXPATHLEN * MB_LEN_MAX + 1];
200 (void) len;
201 g_strlcpy (buffer, fe->fname, sizeof (buffer));
202 return buffer;
205 static unsigned int
206 ilog10 (dev_t n)
208 unsigned int digits = 0;
211 digits++, n /= 10;
213 while (n != 0);
214 return digits;
217 static void
218 format_device_number (char *buf, size_t bufsize, dev_t dev)
220 dev_t major_dev = major (dev);
221 dev_t minor_dev = minor (dev);
222 unsigned int major_digits = ilog10 (major_dev);
223 unsigned int minor_digits = ilog10 (minor_dev);
225 g_assert (bufsize >= 1);
226 if (major_digits + 1 + minor_digits + 1 <= bufsize)
228 g_snprintf (buf, bufsize, "%lu,%lu", (unsigned long) major_dev, (unsigned long) minor_dev);
230 else
232 g_strlcpy (buf, _("[dev]"), bufsize);
236 /* size */
237 static const char *
238 string_file_size (file_entry * fe, int len)
240 static char buffer[BUF_TINY];
242 /* Don't ever show size of ".." since we don't calculate it */
243 if (!strcmp (fe->fname, ".."))
245 return _("UP--DIR");
248 #ifdef HAVE_STRUCT_STAT_ST_RDEV
249 if (S_ISBLK (fe->st.st_mode) || S_ISCHR (fe->st.st_mode))
250 format_device_number (buffer, len + 1, fe->st.st_rdev);
251 else
252 #endif
254 size_trunc_len (buffer, (unsigned int) len, fe->st.st_size, 0);
256 return buffer;
259 /* bsize */
260 static const char *
261 string_file_size_brief (file_entry * fe, int len)
263 if (S_ISLNK (fe->st.st_mode) && !fe->f.link_to_dir)
265 return _("SYMLINK");
268 if ((S_ISDIR (fe->st.st_mode) || fe->f.link_to_dir) && strcmp (fe->fname, ".."))
270 return _("SUB-DIR");
273 return string_file_size (fe, len);
276 /* This functions return a string representation of a file entry */
277 /* type */
278 static const char *
279 string_file_type (file_entry * fe, int len)
281 static char buffer[2];
283 (void) len;
284 if (S_ISDIR (fe->st.st_mode))
285 buffer[0] = PATH_SEP;
286 else if (S_ISLNK (fe->st.st_mode))
288 if (fe->f.link_to_dir)
289 buffer[0] = '~';
290 else if (fe->f.stale_link)
291 buffer[0] = '!';
292 else
293 buffer[0] = '@';
295 else if (S_ISCHR (fe->st.st_mode))
296 buffer[0] = '-';
297 else if (S_ISSOCK (fe->st.st_mode))
298 buffer[0] = '=';
299 else if (S_ISDOOR (fe->st.st_mode))
300 buffer[0] = '>';
301 else if (S_ISBLK (fe->st.st_mode))
302 buffer[0] = '+';
303 else if (S_ISFIFO (fe->st.st_mode))
304 buffer[0] = '|';
305 else if (S_ISNAM (fe->st.st_mode))
306 buffer[0] = '#';
307 else if (!S_ISREG (fe->st.st_mode))
308 buffer[0] = '?'; /* non-regular of unknown kind */
309 else if (is_exe (fe->st.st_mode))
310 buffer[0] = '*';
311 else
312 buffer[0] = ' ';
313 buffer[1] = '\0';
314 return buffer;
317 /* mtime */
318 static const char *
319 string_file_mtime (file_entry * fe, int len)
321 (void) len;
322 return file_date (fe->st.st_mtime);
325 /* atime */
326 static const char *
327 string_file_atime (file_entry * fe, int len)
329 (void) len;
330 return file_date (fe->st.st_atime);
333 /* ctime */
334 static const char *
335 string_file_ctime (file_entry * fe, int len)
337 (void) len;
338 return file_date (fe->st.st_ctime);
341 /* perm */
342 static const char *
343 string_file_permission (file_entry * fe, int len)
345 (void) len;
346 return string_perm (fe->st.st_mode);
349 /* mode */
350 static const char *
351 string_file_perm_octal (file_entry * fe, int len)
353 static char buffer[10];
355 (void) len;
356 g_snprintf (buffer, sizeof (buffer), "0%06lo", (unsigned long) fe->st.st_mode);
357 return buffer;
360 /* nlink */
361 static const char *
362 string_file_nlinks (file_entry * fe, int len)
364 static char buffer[BUF_TINY];
366 (void) len;
367 g_snprintf (buffer, sizeof (buffer), "%16d", (int) fe->st.st_nlink);
368 return buffer;
371 /* inode */
372 static const char *
373 string_inode (file_entry * fe, int len)
375 static char buffer[10];
377 (void) len;
378 g_snprintf (buffer, sizeof (buffer), "%lu", (unsigned long) fe->st.st_ino);
379 return buffer;
382 /* nuid */
383 static const char *
384 string_file_nuid (file_entry * fe, int len)
386 static char buffer[10];
388 (void) len;
389 g_snprintf (buffer, sizeof (buffer), "%lu", (unsigned long) fe->st.st_uid);
390 return buffer;
393 /* ngid */
394 static const char *
395 string_file_ngid (file_entry * fe, int len)
397 static char buffer[10];
399 (void) len;
400 g_snprintf (buffer, sizeof (buffer), "%lu", (unsigned long) fe->st.st_gid);
401 return buffer;
404 /* owner */
405 static const char *
406 string_file_owner (file_entry * fe, int len)
408 (void) len;
409 return get_owner (fe->st.st_uid);
412 /* group */
413 static const char *
414 string_file_group (file_entry * fe, int len)
416 (void) len;
417 return get_group (fe->st.st_gid);
420 /* mark */
421 static const char *
422 string_marked (file_entry * fe, int len)
424 (void) len;
425 return fe->f.marked ? "*" : " ";
428 /* space */
429 static const char *
430 string_space (file_entry * fe, int len)
432 (void) fe;
433 (void) len;
434 return " ";
437 /* dot */
438 static const char *
439 string_dot (file_entry * fe, int len)
441 (void) fe;
442 (void) len;
443 return ".";
446 #define GT 1
448 /* *INDENT-OFF* */
449 panel_field_t panel_fields[] = {
451 "unsorted", 12, 1, J_LEFT_FIT,
452 /* TRANSLATORS: one single character to represent 'unsorted' sort mode */
453 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
454 N_("sort|u"),
455 N_("&Unsorted"), TRUE, FALSE,
456 string_file_name,
457 (sortfn *) unsorted
461 "name", 12, 1, J_LEFT_FIT,
462 /* TRANSLATORS: one single character to represent 'name' sort mode */
463 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
464 N_("sort|n"),
465 N_("&Name"), TRUE, TRUE,
466 string_file_name,
467 (sortfn *) sort_name
471 "version", 12, 1, J_LEFT_FIT,
472 /* TRANSLATORS: one single character to represent 'version' sort mode */
473 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
474 N_("sort|v"),
475 N_("&Version"), TRUE, FALSE,
476 string_file_name,
477 (sortfn *) sort_vers
481 "extension", 12, 1, J_LEFT_FIT,
482 /* TRANSLATORS: one single character to represent 'extension' sort mode */
483 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
484 N_("sort|e"),
485 N_("&Extension"), TRUE, FALSE,
486 string_file_name, /* TODO: string_file_ext */
487 (sortfn *) sort_ext
491 "size", 7, 0, J_RIGHT,
492 /* TRANSLATORS: one single character to represent 'size' sort mode */
493 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
494 N_("sort|s"),
495 N_("&Size"), TRUE, TRUE,
496 string_file_size,
497 (sortfn *) sort_size
501 "bsize", 7, 0, J_RIGHT,
503 N_("Block Size"), FALSE, FALSE,
504 string_file_size_brief,
505 (sortfn *) sort_size
509 "type", GT, 0, J_LEFT,
511 "", FALSE, TRUE,
512 string_file_type,
513 NULL
517 "mtime", 12, 0, J_RIGHT,
518 /* TRANSLATORS: one single character to represent 'Modify time' sort mode */
519 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
520 N_("sort|m"),
521 N_("&Modify time"), TRUE, TRUE,
522 string_file_mtime,
523 (sortfn *) sort_time
527 "atime", 12, 0, J_RIGHT,
528 /* TRANSLATORS: one single character to represent 'Access time' sort mode */
529 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
530 N_("sort|a"),
531 N_("&Access time"), TRUE, TRUE,
532 string_file_atime,
533 (sortfn *) sort_atime
537 "ctime", 12, 0, J_RIGHT,
538 /* TRANSLATORS: one single character to represent 'Change time' sort mode */
539 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
540 N_("sort|h"),
541 N_("C&Hange time"), TRUE, TRUE,
542 string_file_ctime,
543 (sortfn *) sort_ctime
547 "perm", 10, 0, J_LEFT,
549 N_("Permission"), FALSE, TRUE,
550 string_file_permission,
551 NULL
555 "mode", 6, 0, J_RIGHT,
557 N_("Perm"), FALSE, TRUE,
558 string_file_perm_octal,
559 NULL
563 "nlink", 2, 0, J_RIGHT,
565 N_("Nl"), FALSE, TRUE,
566 string_file_nlinks, NULL
570 "inode", 5, 0, J_RIGHT,
571 /* TRANSLATORS: one single character to represent 'inode' sort mode */
572 /* TRANSLATORS: no need to translate 'sort', it's just a context prefix */
573 N_("sort|i"),
574 N_("&Inode"), TRUE, TRUE,
575 string_inode,
576 (sortfn *) sort_inode
580 "nuid", 5, 0, J_RIGHT,
582 N_("UID"), FALSE, FALSE,
583 string_file_nuid,
584 NULL
588 "ngid", 5, 0, J_RIGHT,
590 N_("GID"), FALSE, FALSE,
591 string_file_ngid,
592 NULL
596 "owner", 8, 0, J_LEFT_FIT,
598 N_("Owner"), FALSE, TRUE,
599 string_file_owner,
600 NULL
604 "group", 8, 0, J_LEFT_FIT,
606 N_("Group"), FALSE, TRUE,
607 string_file_group,
608 NULL
612 "mark", 1, 0, J_RIGHT,
614 " ", FALSE, TRUE,
615 string_marked,
616 NULL
620 "|", 1, 0, J_RIGHT,
622 " ", FALSE, TRUE,
623 NULL,
624 NULL
628 "space", 1, 0, J_RIGHT,
630 " ", FALSE, TRUE,
631 string_space,
632 NULL
636 "dot", 1, 0, J_RIGHT,
638 " ", FALSE, FALSE,
639 string_dot,
640 NULL
644 NULL, 0, 0, J_RIGHT, NULL, NULL, FALSE, FALSE, NULL, NULL
647 /* *INDENT-ON* */
649 static int
650 file_compute_color (int attr, file_entry * fe)
652 switch (attr)
654 case SELECTED:
655 return (SELECTED_COLOR);
656 case MARKED:
657 return (MARKED_COLOR);
658 case MARKED_SELECTED:
659 return (MARKED_SELECTED_COLOR);
660 case STATUS:
661 return (NORMAL_COLOR);
662 case NORMAL:
663 default:
664 if (!filetype_mode)
665 return (NORMAL_COLOR);
668 return mc_fhl_get_color (mc_filehighlight, fe);
671 /* Formats the file number file_index of panel in the buffer dest */
672 static void
673 format_file (char *dest, int limit, WPanel * panel, int file_index, int width, int attr,
674 int isstatus)
676 int color, length, empty_line;
677 const char *txt;
678 format_e *format, *home;
679 file_entry *fe;
681 (void) dest;
682 (void) limit;
683 length = 0;
684 empty_line = (file_index >= panel->count);
685 home = (isstatus) ? panel->status_format : panel->format;
686 fe = &panel->dir.list[file_index];
688 if (!empty_line)
689 color = file_compute_color (attr, fe);
690 else
691 color = NORMAL_COLOR;
693 for (format = home; format; format = format->next)
695 if (length == width)
696 break;
698 if (format->string_fn)
700 int len, perm;
701 char *preperad_text;
703 if (empty_line)
704 txt = " ";
705 else
706 txt = (*format->string_fn) (fe, format->field_len);
708 len = format->field_len;
709 if (len + length > width)
710 len = width - length;
711 if (len <= 0)
712 break;
714 perm = 0;
715 if (permission_mode)
717 if (!strcmp (format->id, "perm"))
718 perm = 1;
719 else if (!strcmp (format->id, "mode"))
720 perm = 2;
723 if (color >= 0)
724 tty_setcolor (color);
725 else
726 tty_lowlevel_setcolor (-color);
728 preperad_text = (char *) str_fit_to_term (txt, len, format->just_mode);
729 if (perm)
730 add_permission_string (preperad_text, format->field_len, fe, attr, color, perm - 1);
731 else
732 tty_print_string (preperad_text);
734 length += len;
736 else
738 if (attr == SELECTED || attr == MARKED_SELECTED)
739 tty_setcolor (SELECTED_COLOR);
740 else
741 tty_setcolor (NORMAL_COLOR);
742 tty_print_one_vline ();
743 length++;
747 if (length < width)
748 tty_draw_hline (-1, -1, ' ', width - length);
751 static void
752 repaint_file (WPanel * panel, int file_index, int mv, int attr, int isstatus)
754 int second_column = 0;
755 int width;
756 int offset = 0;
757 char buffer[BUF_MEDIUM];
759 gboolean panel_is_split = !isstatus && panel->split;
761 width = panel->widget.cols - 2;
763 if (panel_is_split)
765 second_column = (file_index - panel->top_file) / llines (panel);
766 width = width / 2 - 1;
768 if (second_column != 0)
770 offset = 1 + width;
771 /*width = (panel->widget.cols-2) - (panel->widget.cols-2)/2 - 1; */
772 width = panel->widget.cols - offset - 2;
776 /* Nothing to paint */
777 if (width <= 0)
778 return;
780 if (mv)
782 if (panel_is_split)
783 widget_move (&panel->widget,
784 (file_index - panel->top_file) % llines (panel) + 2, offset + 1);
785 else
786 widget_move (&panel->widget, file_index - panel->top_file + 2, 1);
789 format_file (buffer, sizeof (buffer), panel, file_index, width, attr, isstatus);
791 if (panel_is_split)
793 if (second_column)
794 tty_print_char (' ');
795 else
797 tty_setcolor (NORMAL_COLOR);
798 tty_print_one_vline ();
803 static void
804 display_mini_info (WPanel * panel)
806 if (!show_mini_info)
807 return;
809 widget_move (&panel->widget, llines (panel) + 3, 1);
811 if (panel->searching)
813 tty_setcolor (INPUT_COLOR);
814 tty_print_char ('/');
815 tty_print_string (str_fit_to_term (panel->search_buffer, panel->widget.cols - 3, J_LEFT));
816 return;
819 /* Status resolves links and show them */
820 set_colors (panel);
822 if (S_ISLNK (panel->dir.list[panel->selected].st.st_mode))
824 char *lc_link, link_target[MC_MAXPATHLEN];
825 int len;
827 lc_link = concat_dir_and_file (panel->cwd, panel->dir.list[panel->selected].fname);
828 len = mc_readlink (lc_link, link_target, MC_MAXPATHLEN - 1);
829 g_free (lc_link);
830 if (len > 0)
832 link_target[len] = 0;
833 tty_print_string ("-> ");
834 tty_print_string (str_fit_to_term (link_target, panel->widget.cols - 5, J_LEFT_FIT));
836 else
837 tty_print_string (str_fit_to_term (_("<readlink failed>"),
838 panel->widget.cols - 2, J_LEFT));
840 else if (strcmp (panel->dir.list[panel->selected].fname, "..") == 0)
842 /* FIXME:
843 * while loading directory (do_load_dir() and do_reload_dir()),
844 * the actual stat info about ".." directory isn't got;
845 * so just don't display incorrect info about ".." directory */
846 tty_print_string (str_fit_to_term (_("UP--DIR"), panel->widget.cols - 2, J_LEFT));
848 else
849 /* Default behavior */
850 repaint_file (panel, panel->selected, 0, STATUS, 1);
853 static void
854 paint_dir (WPanel * panel)
856 int i;
857 int color; /* Color value of the line */
858 int items; /* Number of items */
860 items = llines (panel) * (panel->split ? 2 : 1);
862 for (i = 0; i < items; i++)
864 if (i + panel->top_file >= panel->count)
865 color = 0;
866 else
868 color = 2 * (panel->dir.list[i + panel->top_file].f.marked);
869 color += (panel->selected == i + panel->top_file && panel->active);
871 repaint_file (panel, i + panel->top_file, 1, color, 0);
873 tty_set_normal_attrs ();
876 static void
877 display_total_marked_size (WPanel * panel, int y, int x, gboolean size_only)
879 char buffer[BUF_SMALL], b_bytes[BUF_SMALL], *buf;
880 int cols;
882 if (panel->marked <= 0)
883 return;
885 buf = size_only ? b_bytes : buffer;
886 cols = panel->widget.cols - 2;
889 * This is a trick to use two ngettext() calls in one sentence.
890 * First make "N bytes", then insert it into "X in M files".
892 g_snprintf (b_bytes, sizeof (b_bytes),
893 ngettext ("%s byte", "%s bytes", (unsigned long) panel->total),
894 size_trunc_sep (panel->total));
895 if (!size_only)
896 g_snprintf (buffer, sizeof (buffer),
897 ngettext ("%s in %d file", "%s in %d files", panel->marked),
898 b_bytes, panel->marked);
900 /* don't forget spaces around buffer content */
901 buf = (char *) str_trunc (buf, cols - 4);
903 if (x < 0)
904 /* center in panel */
905 x = (panel->widget.cols - str_term_width1 (buf)) / 2 - 1;
908 * y == llines (panel) + 2 for mini_info_separator
909 * y == panel->widget.lines - 1 for panel bottom frame
911 widget_move (&panel->widget, y, x);
912 tty_setcolor (MARKED_COLOR);
913 tty_printf (" %s ", buf);
916 static void
917 mini_info_separator (WPanel * panel)
919 if (show_mini_info)
921 const int y = llines (panel) + 2;
923 tty_setcolor (NORMAL_COLOR);
924 tty_draw_hline (panel->widget.y + y, panel->widget.x + 1,
925 ACS_HLINE, panel->widget.cols - 2);
926 /* Status displays total marked size.
927 * Centered in panel, full format. */
928 display_total_marked_size (panel, y, -1, FALSE);
932 static void
933 show_free_space (WPanel * panel)
935 /* Used to figure out how many free space we have */
936 static struct my_statfs myfs_stats;
937 /* Old current working directory for displaying free space */
938 static char *old_cwd = NULL;
940 /* Don't try to stat non-local fs */
941 if (!vfs_file_is_local (panel->cwd) || !free_space)
942 return;
944 if (old_cwd == NULL || strcmp (old_cwd, panel->cwd) != 0)
946 char rpath[PATH_MAX];
948 init_my_statfs ();
949 g_free (old_cwd);
950 old_cwd = g_strdup (panel->cwd);
952 if (mc_realpath (panel->cwd, rpath) == NULL)
953 return;
955 my_statfs (&myfs_stats, rpath);
958 if (myfs_stats.avail > 0 || myfs_stats.total > 0)
960 char buffer1[6], buffer2[6], tmp[BUF_SMALL];
961 size_trunc_len (buffer1, sizeof (buffer1) - 1, myfs_stats.avail, 1);
962 size_trunc_len (buffer2, sizeof (buffer2) - 1, myfs_stats.total, 1);
963 g_snprintf (tmp, sizeof (tmp), " %s/%s (%d%%) ", buffer1, buffer2,
964 myfs_stats.total > 0 ?
965 (int) (100 * (double) myfs_stats.avail / myfs_stats.total) : 0);
966 widget_move (&panel->widget, panel->widget.lines - 1,
967 panel->widget.cols - 2 - (int) strlen (tmp));
968 tty_setcolor (NORMAL_COLOR);
969 tty_print_string (tmp);
973 static void
974 show_dir (WPanel * panel)
976 gchar *tmp;
977 set_colors (panel);
978 draw_box (panel->widget.parent,
979 panel->widget.y, panel->widget.x, panel->widget.lines, panel->widget.cols);
981 if (show_mini_info)
983 widget_move (&panel->widget, llines (panel) + 2, 0);
984 tty_print_alt_char (ACS_LTEE);
985 widget_move (&panel->widget, llines (panel) + 2, panel->widget.cols - 1);
986 tty_print_alt_char (ACS_RTEE);
989 widget_move (&panel->widget, 0, 1);
990 tty_print_string (panel_history_prev_item_sign);
992 tmp = (show_dot_files) ? panel_hiddenfiles_sign_show : panel_hiddenfiles_sign_hide;
993 tmp =
994 g_strdup_printf ("%s[%s]%s", tmp, panel_history_show_list_sign,
995 panel_history_next_item_sign);
997 widget_move (&panel->widget, 0, panel->widget.cols - 6);
998 tty_print_string (tmp);
1000 g_free (tmp);
1002 if (panel->active)
1003 tty_setcolor (REVERSE_COLOR);
1005 widget_move (&panel->widget, 0, 3);
1007 tty_printf (" %s ",
1008 str_term_trim (strip_home_and_password (panel->cwd),
1009 min (max (panel->widget.cols - 12, 0), panel->widget.cols)));
1011 if (!show_mini_info)
1013 if (panel->marked == 0)
1015 /* Show size of curret file in the bottom of panel */
1016 if (S_ISREG (panel->dir.list[panel->selected].st.st_mode))
1018 char buffer[BUF_SMALL];
1020 g_snprintf (buffer, sizeof (buffer), " %s ",
1021 size_trunc_sep (panel->dir.list[panel->selected].st.st_size));
1022 tty_setcolor (NORMAL_COLOR);
1023 widget_move (&panel->widget, panel->widget.lines - 1, 4);
1024 tty_print_string (buffer);
1027 else
1029 /* Show total size of marked files
1030 * In the bottom of panel, display size only. */
1031 display_total_marked_size (panel, panel->widget.lines - 1, 2, TRUE);
1035 show_free_space (panel);
1037 if (panel->active)
1038 tty_set_normal_attrs ();
1041 /* To be used only by long_frame and full_frame to adjust top_file */
1042 static void
1043 adjust_top_file (WPanel * panel)
1045 int old_top = panel->top_file;
1047 if (panel->selected - old_top > llines (panel))
1048 panel->top_file = panel->selected;
1049 if (old_top - panel->count > llines (panel))
1050 panel->top_file = panel->count - llines (panel);
1053 /* Repaint everything, including frame and separator */
1054 static void
1055 paint_panel (WPanel * panel)
1057 paint_frame (panel); /* including show_dir */
1058 paint_dir (panel);
1059 mini_info_separator (panel);
1060 display_mini_info (panel);
1061 panel->dirty = 0;
1064 /* add "#enc:encodning" to end of path */
1065 /* if path end width a previous #enc:, only encoding is changed no additional
1066 * #enc: is appended
1067 * retun new string
1069 static char *
1070 add_encoding_to_path (const char *path, const char *encoding)
1072 char *result;
1073 char *semi;
1074 char *slash;
1076 semi = g_strrstr (path, "#enc:");
1078 if (semi != NULL)
1080 slash = strchr (semi, PATH_SEP);
1081 if (slash != NULL)
1083 result = g_strconcat (path, "/#enc:", encoding, (char *) NULL);
1085 else
1087 *semi = 0;
1088 result = g_strconcat (path, "/#enc:", encoding, (char *) NULL);
1089 *semi = '#';
1092 else
1094 result = g_strconcat (path, "/#enc:", encoding, (char *) NULL);
1097 return result;
1100 char *
1101 remove_encoding_from_path (const char *path)
1103 GString *ret;
1104 GString *tmp_path, *tmp_conv;
1105 char *tmp, *tmp2;
1106 const char *enc;
1107 GIConv converter;
1109 ret = g_string_new ("");
1110 tmp_conv = g_string_new ("");
1112 tmp_path = g_string_new (path);
1114 while ((tmp = g_strrstr (tmp_path->str, "/#enc:")) != NULL)
1116 enc = vfs_get_encoding ((const char *) tmp);
1117 converter = enc ? str_crt_conv_to (enc) : str_cnv_to_term;
1118 if (converter == INVALID_CONV)
1119 converter = str_cnv_to_term;
1121 tmp2 = tmp + 1;
1122 while (*tmp2 && *tmp2 != '/')
1123 tmp2++;
1125 if (*tmp2)
1127 str_vfs_convert_from (converter, tmp2, tmp_conv);
1128 g_string_prepend (ret, tmp_conv->str);
1129 g_string_set_size (tmp_conv, 0);
1131 g_string_set_size (tmp_path, tmp - tmp_path->str);
1132 str_close_conv (converter);
1134 g_string_prepend (ret, tmp_path->str);
1135 g_string_free (tmp_path, TRUE);
1136 g_string_free (tmp_conv, TRUE);
1138 tmp = ret->str;
1139 g_string_free (ret, FALSE);
1140 return tmp;
1144 * Repaint the contents of the panels without frames. To schedule panel
1145 * for repainting, set panel->dirty to 1. There are many reasons why
1146 * the panels need to be repainted, and this is a costly operation, so
1147 * it's done once per event.
1149 void
1150 update_dirty_panels (void)
1152 if (current_panel->dirty)
1153 paint_panel (current_panel);
1155 if ((get_other_type () == view_listing) && other_panel->dirty)
1156 paint_panel (other_panel);
1159 static void
1160 do_select (WPanel * panel, int i)
1162 if (i != panel->selected)
1164 panel->dirty = 1;
1165 panel->selected = i;
1166 panel->top_file = panel->selected - (panel->widget.lines - 2) / 2;
1167 if (panel->top_file < 0)
1168 panel->top_file = 0;
1172 static void
1173 do_try_to_select (WPanel * panel, const char *name)
1175 int i;
1176 char *subdir;
1178 if (!name)
1180 do_select (panel, 0);
1181 return;
1184 /* We only want the last component of the directory,
1185 * and from this only the name without suffix. */
1186 subdir = vfs_strip_suffix_from_filename (x_basename (name));
1188 /* Search that subdirectory, if found select it */
1189 for (i = 0; i < panel->count; i++)
1191 if (strcmp (subdir, panel->dir.list[i].fname) == 0)
1193 do_select (panel, i);
1194 g_free (subdir);
1195 return;
1199 /* Try to select a file near the file that is missing */
1200 if (panel->selected >= panel->count)
1201 do_select (panel, panel->count - 1);
1202 g_free (subdir);
1205 void
1206 try_to_select (WPanel * panel, const char *name)
1208 do_try_to_select (panel, name);
1209 select_item (panel);
1212 void
1213 panel_update_cols (Widget * widget, int frame_size)
1215 int cols, origin;
1217 if (horizontal_split)
1219 widget->cols = COLS;
1220 return;
1223 if (frame_size == frame_full)
1225 cols = COLS;
1226 origin = 0;
1228 else
1230 if (widget == get_panel_widget (0))
1232 cols = first_panel_size;
1233 origin = 0;
1235 else
1237 cols = COLS - first_panel_size;
1238 origin = first_panel_size;
1242 widget->cols = cols;
1243 widget->x = origin;
1246 extern int saving_setup;
1247 static char *
1248 panel_save_name (WPanel * panel)
1250 /* If the program is shuting down */
1251 if ((midnight_shutdown && auto_save_setup) || saving_setup)
1252 return g_strdup (panel->panel_name);
1253 else
1254 return g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
1257 void
1258 panel_clean_dir (WPanel * panel)
1260 int count = panel->count;
1262 panel->count = 0;
1263 panel->top_file = 0;
1264 panel->selected = 0;
1265 panel->marked = 0;
1266 panel->dirs_marked = 0;
1267 panel->total = 0;
1268 panel->searching = 0;
1269 panel->is_panelized = 0;
1270 panel->dirty = 1;
1272 clean_dir (&panel->dir, count);
1275 static void
1276 panel_destroy (WPanel * p)
1278 size_t i;
1280 char *name = panel_save_name (p);
1282 panel_save_setup (p, name);
1283 panel_clean_dir (p);
1285 /* save and clean history */
1286 if (p->dir_history)
1288 history_put (p->hist_name, p->dir_history);
1290 p->dir_history = g_list_first (p->dir_history);
1291 g_list_foreach (p->dir_history, (GFunc) g_free, NULL);
1292 g_list_free (p->dir_history);
1295 g_free (p->hist_name);
1297 delete_format (p->format);
1298 delete_format (p->status_format);
1300 g_free (p->user_format);
1301 for (i = 0; i < LIST_TYPES; i++)
1302 g_free (p->user_status_format[i]);
1303 g_free (p->dir.list);
1304 g_free (p->panel_name);
1305 g_free (name);
1308 static void
1309 panel_format_modified (WPanel * panel)
1311 panel->format_modified = 1;
1314 /* Panel creation */
1315 /* The parameter specifies the name of the panel for setup retieving */
1316 WPanel *
1317 panel_new (const char *panel_name)
1319 return panel_new_with_dir (panel_name, NULL);
1322 /* Panel creation for specified directory */
1323 /* The parameter specifies the name of the panel for setup retieving */
1324 /* and the path of working panel directory. If path is NULL then */
1325 /* panel will be created for current directory */
1326 WPanel *
1327 panel_new_with_dir (const char *panel_name, const char *wpath)
1329 WPanel *panel;
1330 char *section;
1331 int i, err;
1332 char curdir[MC_MAXPATHLEN];
1334 panel = g_new0 (WPanel, 1);
1336 /* No know sizes of the panel at startup */
1337 init_widget (&panel->widget, 0, 0, 0, 0, panel_callback, panel_event);
1339 /* We do not want the cursor */
1340 widget_want_cursor (panel->widget, 0);
1342 if (wpath)
1344 g_strlcpy (panel->cwd, wpath, sizeof (panel->cwd));
1345 mc_get_current_wd (curdir, sizeof (curdir) - 2);
1347 else
1348 mc_get_current_wd (panel->cwd, sizeof (panel->cwd) - 2);
1350 strcpy (panel->lwd, ".");
1352 panel->hist_name = g_strconcat ("Dir Hist ", panel_name, (char *) NULL);
1353 panel->dir_history = history_get (panel->hist_name);
1354 directory_history_add (panel, panel->cwd);
1356 panel->dir.list = g_new (file_entry, MIN_FILES);
1357 panel->dir.size = MIN_FILES;
1358 panel->active = 0;
1359 panel->filter = 0;
1360 panel->split = 0;
1361 panel->top_file = 0;
1362 panel->selected = 0;
1363 panel->marked = 0;
1364 panel->total = 0;
1365 panel->reverse = 0;
1366 panel->dirty = 1;
1367 panel->searching = 0;
1368 panel->dirs_marked = 0;
1369 panel->is_panelized = 0;
1370 panel->format = 0;
1371 panel->status_format = 0;
1372 panel->format_modified = 1;
1374 panel->panel_name = g_strdup (panel_name);
1375 panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
1377 for (i = 0; i < LIST_TYPES; i++)
1378 panel->user_status_format[i] = g_strdup (DEFAULT_USER_FORMAT);
1380 panel->search_buffer[0] = 0;
1381 panel->frame_size = frame_half;
1382 section = g_strconcat ("Temporal:", panel->panel_name, (char *) NULL);
1383 if (!mc_config_has_group (mc_main_config, section))
1385 g_free (section);
1386 section = g_strdup (panel->panel_name);
1388 panel_load_setup (panel, section);
1389 g_free (section);
1391 /* Load format strings */
1392 err = set_panel_formats (panel);
1393 if (err != 0)
1394 set_panel_formats (panel);
1396 /* Because do_load_dir lists files in current directory */
1397 if (wpath)
1398 mc_chdir (wpath);
1400 /* Load the default format */
1401 panel->count =
1402 do_load_dir (panel->cwd, &panel->dir, panel->current_sort_field->sort_routine,
1403 panel->reverse, panel->case_sensitive, panel->exec_first, panel->filter);
1405 /* Restore old right path */
1406 if (wpath)
1407 mc_chdir (curdir);
1409 return panel;
1412 void
1413 panel_reload (WPanel * panel)
1415 struct stat current_stat;
1417 if (fast_reload && !stat (panel->cwd, &current_stat)
1418 && current_stat.st_ctime == panel->dir_stat.st_ctime
1419 && current_stat.st_mtime == panel->dir_stat.st_mtime)
1420 return;
1422 while (mc_chdir (panel->cwd) == -1)
1424 char *last_slash;
1426 if (panel->cwd[0] == PATH_SEP && panel->cwd[1] == 0)
1428 panel_clean_dir (panel);
1429 panel->count = set_zero_dir (&panel->dir) ? 1 : 0;
1430 return;
1432 last_slash = strrchr (panel->cwd, PATH_SEP);
1433 if (!last_slash || last_slash == panel->cwd)
1434 strcpy (panel->cwd, PATH_SEP_STR);
1435 else
1436 *last_slash = 0;
1437 memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
1438 show_dir (panel);
1441 panel->count =
1442 do_reload_dir (panel->cwd, &panel->dir, panel->current_sort_field->sort_routine,
1443 panel->count, panel->reverse, panel->case_sensitive,
1444 panel->exec_first, panel->filter);
1446 panel->dirty = 1;
1447 if (panel->selected >= panel->count)
1448 do_select (panel, panel->count - 1);
1450 recalculate_panel_summary (panel);
1453 static void
1454 panel_paint_sort_info (WPanel * panel)
1456 const char *sort_sign = (panel->reverse) ? panel_sort_down_sign : panel_sort_up_sign;
1457 char *str;
1459 if (*panel->current_sort_field->hotkey == '\0')
1460 return;
1462 str = g_strdup_printf ("%s%s", sort_sign, Q_ (panel->current_sort_field->hotkey));
1464 widget_move (&panel->widget, 1, 1);
1465 tty_print_string (str);
1466 g_free (str);
1469 static gchar *
1470 panel_get_title_without_hotkey (const char *title)
1472 char *translated_title;
1473 char *hkey;
1475 if (title == NULL)
1476 return NULL;
1477 if (title[0] == '\0')
1478 return g_strdup ("");
1480 translated_title = g_strdup (_(title));
1482 hkey = strchr (translated_title, '&');
1483 if ((hkey != NULL) && (hkey[1] != '\0'))
1484 memmove ((void *) hkey, (void *) hkey + 1, strlen (hkey));
1486 return translated_title;
1489 static void
1490 paint_frame (WPanel * panel)
1492 int side, width;
1493 GString *format_txt;
1495 if (!panel->split)
1496 adjust_top_file (panel);
1498 widget_erase (&panel->widget);
1499 show_dir (panel);
1501 widget_move (&panel->widget, 1, 1);
1503 for (side = 0; side <= panel->split; side++)
1505 format_e *format;
1507 if (side)
1509 tty_setcolor (NORMAL_COLOR);
1510 tty_print_one_vline ();
1511 width = panel->widget.cols - panel->widget.cols / 2 - 1;
1513 else if (panel->split)
1514 width = panel->widget.cols / 2 - 3;
1515 else
1516 width = panel->widget.cols - 2;
1518 format_txt = g_string_new ("");
1519 for (format = panel->format; format; format = format->next)
1521 if (format->string_fn)
1523 g_string_set_size (format_txt, 0);
1525 if (panel->list_type == list_long
1526 && strcmp (format->id, panel->current_sort_field->id) == 0)
1527 g_string_append (format_txt,
1528 (panel->reverse) ? panel_sort_down_sign : panel_sort_up_sign);
1530 g_string_append (format_txt, format->title);
1531 if (strcmp (format->id, "name") == 0 && panel->filter && *panel->filter)
1533 g_string_append (format_txt, " [");
1534 g_string_append (format_txt, panel->filter);
1535 g_string_append (format_txt, "]");
1538 tty_setcolor (MARKED_COLOR);
1539 tty_print_string (str_fit_to_term (format_txt->str, format->field_len,
1540 J_CENTER_LEFT));
1541 width -= format->field_len;
1543 else
1545 tty_setcolor (NORMAL_COLOR);
1546 tty_print_one_vline ();
1547 width--;
1550 g_string_free (format_txt, TRUE);
1552 if (width > 0)
1553 tty_draw_hline (-1, -1, ' ', width);
1556 if (panel->list_type != list_long)
1557 panel_paint_sort_info (panel);
1560 static const char *
1561 parse_panel_size (WPanel * panel, const char *format, int isstatus)
1563 int frame = frame_half;
1564 format = skip_separators (format);
1566 if (!strncmp (format, "full", 4))
1568 frame = frame_full;
1569 format += 4;
1571 else if (!strncmp (format, "half", 4))
1573 frame = frame_half;
1574 format += 4;
1577 if (!isstatus)
1579 panel->frame_size = frame;
1580 panel->split = 0;
1583 /* Now, the optional column specifier */
1584 format = skip_separators (format);
1586 if (*format == '1' || *format == '2')
1588 if (!isstatus)
1589 panel->split = *format == '2';
1590 format++;
1593 if (!isstatus)
1594 panel_update_cols (&(panel->widget), panel->frame_size);
1596 return skip_separators (format);
1599 /* Format is:
1601 all := panel_format? format
1602 panel_format := [full|half] [1|2]
1603 format := one_format_e
1604 | format , one_format_e
1606 one_format_e := just format.id [opt_size]
1607 just := [<=>]
1608 opt_size := : size [opt_expand]
1609 size := [0-9]+
1610 opt_expand := +
1614 static format_e *
1615 parse_display_format (WPanel * panel, const char *format, char **error, int isstatus,
1616 int *res_total_cols)
1618 format_e *darr, *old = 0, *home = 0; /* The formats we return */
1619 int total_cols = 0; /* Used columns by the format */
1620 int set_justify; /* flag: set justification mode? */
1621 align_crt_t justify = J_LEFT; /* Which mode. */
1622 size_t i;
1624 static size_t i18n_timelength = 0; /* flag: check ?Time length at startup */
1626 *error = 0;
1628 if (i18n_timelength == 0)
1630 i18n_timelength = i18n_checktimelength (); /* Musn't be 0 */
1632 for (i = 0; panel_fields[i].id != NULL; i++)
1633 if (strcmp ("time", panel_fields[i].id + 1) == 0)
1634 panel_fields[i].min_size = i18n_timelength;
1638 * This makes sure that the panel and mini status full/half mode
1639 * setting is equal
1641 format = parse_panel_size (panel, format, isstatus);
1643 while (*format)
1644 { /* format can be an empty string */
1645 int found = 0;
1647 darr = g_new0 (format_e, 1);
1649 /* I'm so ugly, don't look at me :-) */
1650 if (!home)
1651 home = old = darr;
1653 old->next = darr;
1654 darr->next = 0;
1655 old = darr;
1657 format = skip_separators (format);
1659 if (strchr ("<=>", *format))
1661 set_justify = 1;
1662 switch (*format)
1664 case '<':
1665 justify = J_LEFT;
1666 break;
1667 case '=':
1668 justify = J_CENTER;
1669 break;
1670 case '>':
1671 default:
1672 justify = J_RIGHT;
1673 break;
1675 format = skip_separators (format + 1);
1677 else
1678 set_justify = 0;
1680 for (i = 0; panel_fields[i].id != NULL; i++)
1682 size_t klen = strlen (panel_fields[i].id);
1684 if (strncmp (format, panel_fields[i].id, klen) != 0)
1685 continue;
1687 format += klen;
1689 darr->requested_field_len = panel_fields[i].min_size;
1690 darr->string_fn = panel_fields[i].string_fn;
1691 darr->title = panel_get_title_without_hotkey (panel_fields[i].title_hotkey);
1693 darr->id = panel_fields[i].id;
1694 darr->expand = panel_fields[i].expands;
1695 darr->just_mode = panel_fields[i].default_just;
1697 if (set_justify)
1699 if (IS_FIT (darr->just_mode))
1700 darr->just_mode = MAKE_FIT (justify);
1701 else
1702 darr->just_mode = justify;
1704 found = 1;
1706 format = skip_separators (format);
1708 /* If we have a size specifier */
1709 if (*format == ':')
1711 int req_length;
1713 /* If the size was specified, we don't want
1714 * auto-expansion by default
1716 darr->expand = 0;
1717 format++;
1718 req_length = atoi (format);
1719 darr->requested_field_len = req_length;
1721 format = skip_numbers (format);
1723 /* Now, if they insist on expansion */
1724 if (*format == '+')
1726 darr->expand = 1;
1727 format++;
1732 break;
1734 if (!found)
1736 char *tmp_format = g_strdup (format);
1738 int pos = min (8, strlen (format));
1739 delete_format (home);
1740 tmp_format[pos] = 0;
1741 *error = g_strconcat (_("Unknown tag on display format: "), tmp_format, (char *) NULL);
1742 g_free (tmp_format);
1743 return 0;
1745 total_cols += darr->requested_field_len;
1748 *res_total_cols = total_cols;
1749 return home;
1752 static format_e *
1753 use_display_format (WPanel * panel, const char *format, char **error, int isstatus)
1755 #define MAX_EXPAND 4
1756 int expand_top = 0; /* Max used element in expand */
1757 int usable_columns; /* Usable columns in the panel */
1758 int total_cols = 0;
1759 int i;
1760 format_e *darr, *home;
1762 if (!format)
1763 format = DEFAULT_USER_FORMAT;
1765 home = parse_display_format (panel, format, error, isstatus, &total_cols);
1767 if (*error)
1768 return 0;
1770 panel->dirty = 1;
1772 /* Status needn't to be split */
1773 usable_columns = ((panel->widget.cols - 2) / ((isstatus)
1775 : (panel->split + 1))) - (!isstatus
1776 && panel->split);
1778 /* Look for the expandable fields and set field_len based on the requested field len */
1779 for (darr = home; darr && expand_top < MAX_EXPAND; darr = darr->next)
1781 darr->field_len = darr->requested_field_len;
1782 if (darr->expand)
1783 expand_top++;
1786 /* If we used more columns than the available columns, adjust that */
1787 if (total_cols > usable_columns)
1789 int pdif, dif = total_cols - usable_columns;
1791 while (dif)
1793 pdif = dif;
1794 for (darr = home; darr; darr = darr->next)
1796 if (dif && darr->field_len - 1)
1798 darr->field_len--;
1799 dif--;
1803 /* avoid endless loop if num fields > 40 */
1804 if (pdif == dif)
1805 break;
1807 total_cols = usable_columns; /* give up, the rest should be truncated */
1810 /* Expand the available space */
1811 if ((usable_columns > total_cols) && expand_top)
1813 int spaces = (usable_columns - total_cols) / expand_top;
1814 int extra = (usable_columns - total_cols) % expand_top;
1816 for (i = 0, darr = home; darr && (i < expand_top); darr = darr->next)
1817 if (darr->expand)
1819 darr->field_len += (spaces + ((i == 0) ? extra : 0));
1820 i++;
1823 return home;
1826 /* Switches the panel to the mode specified in the format */
1827 /* Seting up both format and status string. Return: 0 - on success; */
1828 /* 1 - format error; 2 - status error; 3 - errors in both formats. */
1830 set_panel_formats (WPanel * p)
1832 format_e *form;
1833 char *err = NULL;
1834 int retcode = 0;
1836 form = use_display_format (p, panel_format (p), &err, 0);
1838 if (err != NULL)
1840 g_free (err);
1841 retcode = 1;
1843 else
1845 delete_format (p->format);
1846 p->format = form;
1849 if (show_mini_info)
1851 form = use_display_format (p, mini_status_format (p), &err, 1);
1853 if (err != NULL)
1855 g_free (err);
1856 retcode += 2;
1858 else
1860 delete_format (p->status_format);
1861 p->status_format = form;
1865 panel_format_modified (p);
1866 panel_update_cols (&(p->widget), p->frame_size);
1868 if (retcode)
1869 message (D_ERROR, _("Warning"),
1870 _("User supplied format looks invalid, reverting to default."));
1871 if (retcode & 0x01)
1873 g_free (p->user_format);
1874 p->user_format = g_strdup (DEFAULT_USER_FORMAT);
1876 if (retcode & 0x02)
1878 g_free (p->user_status_format[p->list_type]);
1879 p->user_status_format[p->list_type] = g_strdup (DEFAULT_USER_FORMAT);
1882 return retcode;
1885 /* Given the panel->view_type returns the format string to be parsed */
1886 static const char *
1887 panel_format (WPanel * panel)
1889 switch (panel->list_type)
1892 case list_long:
1893 return "full perm space nlink space owner space group space size space mtime space name";
1895 case list_brief:
1896 return "half 2 type name";
1898 case list_user:
1899 return panel->user_format;
1901 default:
1902 case list_full:
1903 return "half type name | size | mtime";
1907 static const char *
1908 mini_status_format (WPanel * panel)
1910 if (panel->user_mini_status)
1911 return panel->user_status_format[panel->list_type];
1913 switch (panel->list_type)
1916 case list_long:
1917 return "full perm space nlink space owner space group space size space mtime space name";
1919 case list_brief:
1920 return "half type name space bsize space perm space";
1922 case list_full:
1923 return "half type name";
1925 default:
1926 case list_user:
1927 return panel->user_format;
1931 /* */
1932 /* Panel operation commands */
1933 /* */
1935 /* Used to emulate Lynx's entering leaving a directory with the arrow keys */
1936 static cb_ret_t
1937 maybe_cd (int move_up_dir)
1939 if (navigate_with_arrows)
1941 if (!cmdline->buffer[0])
1943 if (move_up_dir)
1945 do_cd ("..", cd_exact);
1946 return MSG_HANDLED;
1948 if (S_ISDIR (selection (current_panel)->st.st_mode)
1949 || link_isdir (selection (current_panel)))
1951 do_cd (selection (current_panel)->fname, cd_exact);
1952 return MSG_HANDLED;
1956 return MSG_NOT_HANDLED;
1959 /* Returns the number of items in the given panel */
1960 static int
1961 ITEMS (WPanel * p)
1963 if (p->split)
1964 return llines (p) * 2;
1965 else
1966 return llines (p);
1969 /* Select current item and readjust the panel */
1970 void
1971 select_item (WPanel * panel)
1973 int items = ITEMS (panel);
1975 /* Although currently all over the code we set the selection and
1976 top file to decent values before calling select_item, I could
1977 forget it someday, so it's better to do the actual fitting here */
1979 if (panel->top_file < 0)
1980 panel->top_file = 0;
1982 if (panel->selected < 0)
1983 panel->selected = 0;
1985 if (panel->selected > panel->count - 1)
1986 panel->selected = panel->count - 1;
1988 if (panel->top_file > panel->count - 1)
1989 panel->top_file = panel->count - 1;
1991 if ((panel->count - panel->top_file) < items)
1993 panel->top_file = panel->count - items;
1994 if (panel->top_file < 0)
1995 panel->top_file = 0;
1998 if (panel->selected < panel->top_file)
1999 panel->top_file = panel->selected;
2001 if ((panel->selected - panel->top_file) >= items)
2002 panel->top_file = panel->selected - items + 1;
2004 panel->dirty = 1;
2006 execute_hooks (select_file_hook);
2009 /* Clears all files in the panel, used only when one file was marked */
2010 void
2011 unmark_files (WPanel * panel)
2013 int i;
2015 if (!panel->marked)
2016 return;
2017 for (i = 0; i < panel->count; i++)
2018 file_mark (panel, i, 0);
2020 panel->dirs_marked = 0;
2021 panel->marked = 0;
2022 panel->total = 0;
2025 static void
2026 unselect_item (WPanel * panel)
2028 repaint_file (panel, panel->selected, 1, 2 * selection (panel)->f.marked, 0);
2031 static void
2032 move_down (WPanel * panel)
2034 if (panel->selected + 1 == panel->count)
2035 return;
2037 unselect_item (panel);
2038 panel->selected++;
2039 if (panel->selected - panel->top_file == ITEMS (panel) && panel_scroll_pages)
2041 /* Scroll window half screen */
2042 panel->top_file += ITEMS (panel) / 2;
2043 if (panel->top_file > panel->count - ITEMS (panel))
2044 panel->top_file = panel->count - ITEMS (panel);
2045 paint_dir (panel);
2047 select_item (panel);
2050 static void
2051 move_up (WPanel * panel)
2053 if (panel->selected == 0)
2054 return;
2056 unselect_item (panel);
2057 panel->selected--;
2058 if (panel->selected < panel->top_file && panel_scroll_pages)
2060 /* Scroll window half screen */
2061 panel->top_file -= ITEMS (panel) / 2;
2062 if (panel->top_file < 0)
2063 panel->top_file = 0;
2064 paint_dir (panel);
2066 select_item (panel);
2069 /* Changes the selection by lines (may be negative) */
2070 static void
2071 move_selection (WPanel * panel, int lines)
2073 int new_pos;
2074 int adjust = 0;
2076 new_pos = panel->selected + lines;
2077 if (new_pos >= panel->count)
2078 new_pos = panel->count - 1;
2080 if (new_pos < 0)
2081 new_pos = 0;
2083 unselect_item (panel);
2084 panel->selected = new_pos;
2086 if (panel->selected - panel->top_file >= ITEMS (panel))
2088 panel->top_file += lines;
2089 adjust = 1;
2092 if (panel->selected - panel->top_file < 0)
2094 panel->top_file += lines;
2095 adjust = 1;
2098 if (adjust)
2100 if (panel->top_file > panel->selected)
2101 panel->top_file = panel->selected;
2102 if (panel->top_file < 0)
2103 panel->top_file = 0;
2104 paint_dir (panel);
2106 select_item (panel);
2109 static cb_ret_t
2110 move_left (WPanel * panel)
2112 if (panel->split)
2114 move_selection (panel, -llines (panel));
2115 return MSG_HANDLED;
2117 else
2118 return maybe_cd (1); /* cd .. */
2121 static int
2122 move_right (WPanel * panel)
2124 if (panel->split)
2126 move_selection (panel, llines (panel));
2127 return MSG_HANDLED;
2129 else
2130 return maybe_cd (0); /* cd (selection) */
2133 static void
2134 prev_page (WPanel * panel)
2136 int items;
2138 if (!panel->selected && !panel->top_file)
2139 return;
2140 unselect_item (panel);
2141 items = ITEMS (panel);
2142 if (panel->top_file < items)
2143 items = panel->top_file;
2144 if (!items)
2145 panel->selected = 0;
2146 else
2147 panel->selected -= items;
2148 panel->top_file -= items;
2150 select_item (panel);
2151 paint_dir (panel);
2154 static void
2155 ctrl_prev_page (WPanel * panel)
2157 (void) panel;
2158 do_cd ("..", cd_exact);
2161 static void
2162 next_page (WPanel * panel)
2164 int items;
2166 if (panel->selected == panel->count - 1)
2167 return;
2168 unselect_item (panel);
2169 items = ITEMS (panel);
2170 if (panel->top_file > panel->count - 2 * items)
2171 items = panel->count - items - panel->top_file;
2172 if (panel->top_file + items < 0)
2173 items = -panel->top_file;
2174 if (!items)
2175 panel->selected = panel->count - 1;
2176 else
2177 panel->selected += items;
2178 panel->top_file += items;
2180 select_item (panel);
2181 paint_dir (panel);
2184 static void
2185 ctrl_next_page (WPanel * panel)
2187 if ((S_ISDIR (selection (panel)->st.st_mode) || link_isdir (selection (panel))))
2189 do_cd (selection (panel)->fname, cd_exact);
2193 static void
2194 goto_top_file (WPanel * panel)
2196 unselect_item (panel);
2197 panel->selected = panel->top_file;
2198 select_item (panel);
2201 static void
2202 goto_middle_file (WPanel * panel)
2204 unselect_item (panel);
2205 panel->selected = panel->top_file + (ITEMS (panel) / 2);
2206 select_item (panel);
2209 static void
2210 goto_bottom_file (WPanel * panel)
2212 unselect_item (panel);
2213 panel->selected = panel->top_file + ITEMS (panel) - 1;
2214 select_item (panel);
2217 static void
2218 move_home (WPanel * panel)
2220 if (panel->selected == 0)
2221 return;
2222 unselect_item (panel);
2224 if (torben_fj_mode)
2226 int middle_pos = panel->top_file + (ITEMS (panel) / 2);
2228 if (panel->selected > middle_pos)
2230 goto_middle_file (panel);
2231 return;
2233 if (panel->selected != panel->top_file)
2235 goto_top_file (panel);
2236 return;
2240 panel->top_file = 0;
2241 panel->selected = 0;
2243 paint_dir (panel);
2244 select_item (panel);
2247 static void
2248 move_end (WPanel * panel)
2250 if (panel->selected == panel->count - 1)
2251 return;
2252 unselect_item (panel);
2253 if (torben_fj_mode)
2255 int middle_pos = panel->top_file + (ITEMS (panel) / 2);
2257 if (panel->selected < middle_pos)
2259 goto_middle_file (panel);
2260 return;
2262 if (panel->selected != (panel->top_file + ITEMS (panel) - 1))
2264 goto_bottom_file (panel);
2265 return;
2269 panel->selected = panel->count - 1;
2270 paint_dir (panel);
2271 select_item (panel);
2274 /* Recalculate the panels summary information, used e.g. when marked
2275 files might have been removed by an external command */
2276 void
2277 recalculate_panel_summary (WPanel * panel)
2279 int i;
2281 panel->marked = 0;
2282 panel->dirs_marked = 0;
2283 panel->total = 0;
2285 for (i = 0; i < panel->count; i++)
2286 if (panel->dir.list[i].f.marked)
2288 /* do_file_mark will return immediately if newmark == oldmark.
2289 So we have to first unmark it to get panel's summary information
2290 updated. (Norbert) */
2291 panel->dir.list[i].f.marked = 0;
2292 do_file_mark (panel, i, 1);
2296 /* This routine marks a file or a directory */
2297 void
2298 do_file_mark (WPanel * panel, int idx, int mark)
2300 if (panel->dir.list[idx].f.marked == mark)
2301 return;
2303 /* Only '..' can't be marked, '.' isn't visible */
2304 if (!strcmp (panel->dir.list[idx].fname, ".."))
2305 return;
2307 file_mark (panel, idx, mark);
2308 if (panel->dir.list[idx].f.marked)
2310 panel->marked++;
2311 if (S_ISDIR (panel->dir.list[idx].st.st_mode))
2313 if (panel->dir.list[idx].f.dir_size_computed)
2314 panel->total += panel->dir.list[idx].st.st_size;
2315 panel->dirs_marked++;
2317 else
2318 panel->total += panel->dir.list[idx].st.st_size;
2319 set_colors (panel);
2321 else
2323 if (S_ISDIR (panel->dir.list[idx].st.st_mode))
2325 if (panel->dir.list[idx].f.dir_size_computed)
2326 panel->total -= panel->dir.list[idx].st.st_size;
2327 panel->dirs_marked--;
2329 else
2330 panel->total -= panel->dir.list[idx].st.st_size;
2331 panel->marked--;
2335 static void
2336 do_mark_file (WPanel * panel, int do_move)
2338 do_file_mark (panel, panel->selected, selection (panel)->f.marked ? 0 : 1);
2339 if (mark_moves_down && do_move)
2340 move_down (panel);
2343 static void
2344 mark_file (WPanel * panel)
2346 do_mark_file (panel, 1);
2349 /* Incremental search of a file name in the panel */
2350 static void
2351 do_search (WPanel * panel, int c_code)
2353 size_t l;
2354 int i, sel;
2355 gboolean wrapped = FALSE;
2356 char *act;
2357 mc_search_t *search;
2358 char *reg_exp, *esc_str;
2359 gboolean is_found = FALSE;
2361 l = strlen (panel->search_buffer);
2362 if (c_code == KEY_BACKSPACE)
2364 if (l != 0)
2366 act = panel->search_buffer + l;
2367 str_prev_noncomb_char (&act, panel->search_buffer);
2368 act[0] = '\0';
2370 panel->search_chpoint = 0;
2372 else
2374 if (c_code != 0 && (gsize) panel->search_chpoint < sizeof (panel->search_char))
2376 panel->search_char[panel->search_chpoint] = c_code;
2377 panel->search_chpoint++;
2380 if (panel->search_chpoint > 0)
2382 switch (str_is_valid_char (panel->search_char, panel->search_chpoint))
2384 case -2:
2385 return;
2386 case -1:
2387 panel->search_chpoint = 0;
2388 return;
2389 default:
2390 if (l + panel->search_chpoint < sizeof (panel->search_buffer))
2392 memcpy (panel->search_buffer + l, panel->search_char, panel->search_chpoint);
2393 l += panel->search_chpoint;
2394 (panel->search_buffer + l)[0] = '\0';
2395 panel->search_chpoint = 0;
2401 reg_exp = g_strdup_printf ("%s*", panel->search_buffer);
2402 esc_str = strutils_escape (reg_exp, -1, ",|\\{}[]", TRUE);
2403 search = mc_search_new (esc_str, -1);
2404 search->search_type = MC_SEARCH_T_GLOB;
2405 search->is_entire_line = TRUE;
2406 search->is_case_sentitive = 0;
2408 sel = panel->selected;
2409 for (i = panel->selected; !wrapped || i != panel->selected; i++)
2411 if (i >= panel->count)
2413 i = 0;
2414 if (wrapped)
2415 break;
2416 wrapped = TRUE;
2418 if (mc_search_run (search, panel->dir.list[i].fname, 0, panel->dir.list[i].fnamelen, NULL))
2420 sel = i;
2421 is_found = TRUE;
2422 break;
2425 if (is_found)
2427 unselect_item (panel);
2428 panel->selected = sel;
2429 select_item (panel);
2430 paint_panel (panel);
2432 else if (c_code != KEY_BACKSPACE)
2434 act = panel->search_buffer + l;
2435 str_prev_noncomb_char (&act, panel->search_buffer);
2436 act[0] = '\0';
2438 mc_search_free (search);
2439 g_free (reg_exp);
2440 g_free (esc_str);
2443 static void
2444 start_search (WPanel * panel)
2446 if (panel->searching)
2448 if (panel->selected + 1 == panel->count)
2449 panel->selected = 0;
2450 else
2451 move_down (panel);
2452 do_search (panel, 0);
2454 else
2456 panel->searching = 1;
2457 panel->search_buffer[0] = '\0';
2458 panel->search_char[0] = '\0';
2459 panel->search_chpoint = 0;
2460 display_mini_info (panel);
2461 mc_refresh ();
2465 /* Return 1 if the Enter key has been processed, 0 otherwise */
2466 static int
2467 do_enter_on_file_entry (file_entry * fe)
2469 char *full_name;
2472 * Directory or link to directory - change directory.
2473 * Try the same for the entries on which mc_lstat() has failed.
2475 if (S_ISDIR (fe->st.st_mode) || link_isdir (fe) || (fe->st.st_mode == 0))
2477 if (!do_cd (fe->fname, cd_exact))
2478 message (D_ERROR, MSG_ERROR, _("Cannot change directory"));
2479 return 1;
2482 /* Try associated command */
2483 if (regex_command (fe->fname, "Open", 0) != 0)
2484 return 1;
2486 /* Check if the file is executable */
2487 full_name = concat_dir_and_file (current_panel->cwd, fe->fname);
2488 if (!is_exe (fe->st.st_mode) || !if_link_is_exe (full_name, fe))
2490 g_free (full_name);
2491 return 0;
2493 g_free (full_name);
2495 if (confirm_execute)
2497 if (query_dialog
2498 (_(" The Midnight Commander "),
2499 _(" Do you really want to execute? "), D_NORMAL, 2, _("&Yes"), _("&No")) != 0)
2500 return 1;
2502 #ifdef ENABLE_VFS
2503 if (!vfs_current_is_local ())
2505 char *tmp;
2506 int ret;
2508 tmp = concat_dir_and_file (vfs_get_current_dir (), fe->fname);
2509 ret = mc_setctl (tmp, VFS_SETCTL_RUN, NULL);
2510 g_free (tmp);
2511 /* We took action only if the dialog was shown or the execution
2512 * was successful */
2513 return confirm_execute || (ret == 0);
2515 #endif
2518 char *tmp = name_quote (fe->fname, 0);
2519 char *cmd = g_strconcat (".", PATH_SEP_STR, tmp, (char *) NULL);
2520 g_free (tmp);
2521 shell_execute (cmd, 0);
2522 g_free (cmd);
2525 #if HAVE_CHARSET
2526 source_codepage = default_source_codepage;
2527 #endif
2529 return 1;
2532 static int
2533 do_enter (WPanel * panel)
2535 return do_enter_on_file_entry (selection (panel));
2538 static void
2539 chdir_other_panel (WPanel * panel)
2541 char *new_dir;
2542 char *sel_entry = NULL;
2544 if (get_other_type () != view_listing)
2546 set_display_type (get_other_index (), view_listing);
2549 if (!S_ISDIR (panel->dir.list[panel->selected].st.st_mode))
2551 new_dir = concat_dir_and_file (panel->cwd, "..");
2552 sel_entry = strrchr (panel->cwd, PATH_SEP);
2554 else
2555 new_dir = concat_dir_and_file (panel->cwd, panel->dir.list[panel->selected].fname);
2557 change_panel ();
2558 do_cd (new_dir, cd_exact);
2559 if (sel_entry)
2560 try_to_select (current_panel, sel_entry);
2561 change_panel ();
2563 move_down (panel);
2565 g_free (new_dir);
2569 * Make the current directory of the current panel also the current
2570 * directory of the other panel. Put the other panel to the listing
2571 * mode if needed. If the current panel is panelized, the other panel
2572 * doesn't become panelized.
2574 static void
2575 sync_other_panel (WPanel * panel)
2577 if (get_other_type () != view_listing)
2579 set_display_type (get_other_index (), view_listing);
2582 do_panel_cd (other_panel, current_panel->cwd, cd_exact);
2584 /* try to select current filename on the other panel */
2585 if (!panel->is_panelized)
2587 try_to_select (other_panel, selection (panel)->fname);
2591 static void
2592 chdir_to_readlink (WPanel * panel)
2594 char *new_dir;
2596 if (get_other_type () != view_listing)
2597 return;
2599 if (S_ISLNK (panel->dir.list[panel->selected].st.st_mode))
2601 char buffer[MC_MAXPATHLEN], *p;
2602 int i;
2603 struct stat st;
2605 i = readlink (selection (panel)->fname, buffer, MC_MAXPATHLEN - 1);
2606 if (i < 0)
2607 return;
2608 if (mc_stat (selection (panel)->fname, &st) < 0)
2609 return;
2610 buffer[i] = 0;
2611 if (!S_ISDIR (st.st_mode))
2613 p = strrchr (buffer, PATH_SEP);
2614 if (p && !p[1])
2616 *p = 0;
2617 p = strrchr (buffer, PATH_SEP);
2619 if (!p)
2620 return;
2621 p[1] = 0;
2623 if (*buffer == PATH_SEP)
2624 new_dir = g_strdup (buffer);
2625 else
2626 new_dir = concat_dir_and_file (panel->cwd, buffer);
2628 change_panel ();
2629 do_cd (new_dir, cd_exact);
2630 change_panel ();
2632 move_down (panel);
2634 g_free (new_dir);
2638 static gsize
2639 panel_get_format_field_count (WPanel * panel)
2641 format_e *format;
2642 gsize lc_index;
2643 for (lc_index = 0, format = panel->format; format != NULL; format = format->next, lc_index++);
2644 return lc_index;
2648 function return 0 if not found and REAL_INDEX+1 if found
2650 static gsize
2651 panel_get_format_field_index_by_name (WPanel * panel, const char *name)
2653 format_e *format;
2654 gsize lc_index;
2656 for (lc_index = 1, format = panel->format;
2657 !(format == NULL || strcmp (format->title, name) == 0); format = format->next, lc_index++);
2658 if (format == NULL)
2659 lc_index = 0;
2661 return lc_index;
2664 static format_e *
2665 panel_get_format_field_by_index (WPanel * panel, gsize lc_index)
2667 format_e *format;
2668 for (format = panel->format;
2669 !(format == NULL || lc_index == 0); format = format->next, lc_index--);
2670 return format;
2673 static const panel_field_t *
2674 panel_get_sortable_field_by_format (WPanel * panel, gsize lc_index)
2676 const panel_field_t *pfield;
2677 format_e *format;
2679 format = panel_get_format_field_by_index (panel, lc_index);
2680 if (format == NULL)
2681 return NULL;
2682 pfield = panel_get_field_by_title (format->title);
2683 if (pfield == NULL)
2684 return NULL;
2685 if (pfield->sort_routine == NULL)
2686 return NULL;
2687 return pfield;
2690 static void
2691 panel_toggle_sort_order_prev (WPanel * panel)
2693 gsize lc_index, i;
2694 gchar *title;
2696 const panel_field_t *pfield = NULL;
2698 title = panel_get_title_without_hotkey (panel->current_sort_field->title_hotkey);
2699 lc_index = panel_get_format_field_index_by_name (panel, title);
2700 g_free (title);
2702 if (lc_index > 1)
2704 /* search for prev sortable column in panel format */
2705 for (i = lc_index - 1;
2706 i != 0 && (pfield = panel_get_sortable_field_by_format (panel, i - 1)) == NULL; i--);
2709 if (pfield == NULL)
2711 /* Sortable field not found. Try to search in each array */
2712 for (i = panel_get_format_field_count (panel);
2713 i != 0 && (pfield = panel_get_sortable_field_by_format (panel, i - 1)) == NULL; i--);
2715 if (pfield == NULL)
2716 return;
2717 panel->current_sort_field = pfield;
2718 panel_set_sort_order (panel, panel->current_sort_field);
2722 static void
2723 panel_toggle_sort_order_next (WPanel * panel)
2725 gsize lc_index, i;
2726 const panel_field_t *pfield = NULL;
2727 gsize format_field_count = panel_get_format_field_count (panel);
2728 gchar *title;
2730 title = panel_get_title_without_hotkey (panel->current_sort_field->title_hotkey);
2731 lc_index = panel_get_format_field_index_by_name (panel, title);
2732 g_free (title);
2734 if (lc_index != 0 && lc_index != format_field_count)
2736 /* search for prev sortable column in panel format */
2737 for (i = lc_index;
2738 i != format_field_count
2739 && (pfield = panel_get_sortable_field_by_format (panel, i)) == NULL; i++);
2742 if (pfield == NULL)
2744 /* Sortable field not found. Try to search in each array */
2745 for (i = 0;
2746 i != format_field_count
2747 && (pfield = panel_get_sortable_field_by_format (panel, i)) == NULL; i++);
2749 if (pfield == NULL)
2750 return;
2751 panel->current_sort_field = pfield;
2752 panel_set_sort_order (panel, panel->current_sort_field);
2755 static void
2756 panel_select_sort_order (WPanel * panel)
2758 const panel_field_t *sort_order;
2759 sort_order = sort_box (panel->current_sort_field, &panel->reverse,
2760 &panel->case_sensitive, &panel->exec_first);
2761 if (sort_order == NULL)
2762 return;
2763 panel->current_sort_field = sort_order;
2764 panel_set_sort_order (panel, panel->current_sort_field);
2768 static void
2769 panel_set_sort_type_by_id (WPanel * panel, const char *name)
2771 const panel_field_t *sort_order;
2773 if (strcmp (panel->current_sort_field->id, name) != 0)
2775 sort_order = panel_get_field_by_id (name);
2776 if (sort_order == NULL)
2777 return;
2778 panel->current_sort_field = sort_order;
2780 else
2782 panel->reverse = !panel->reverse;
2784 panel_set_sort_order (panel, panel->current_sort_field);
2787 typedef void (*panel_key_callback) (WPanel *);
2789 static void
2790 cmd_do_enter (WPanel * wp)
2792 (void) do_enter (wp);
2794 static void
2795 cmd_view_simple (WPanel * wp)
2797 (void) wp;
2798 view_simple_cmd ();
2800 static void
2801 cmd_edit_new (WPanel * wp)
2803 (void) wp;
2804 edit_cmd_new ();
2806 static void
2807 cmd_copy_local (WPanel * wp)
2809 (void) wp;
2810 copy_cmd_local ();
2812 static void
2813 cmd_rename_local (WPanel * wp)
2815 (void) wp;
2816 rename_cmd_local ();
2818 static void
2819 cmd_delete_local (WPanel * wp)
2821 (void) wp;
2822 delete_cmd_local ();
2824 static void
2825 cmd_select (WPanel * wp)
2827 (void) wp;
2828 select_cmd ();
2830 static void
2831 cmd_unselect (WPanel * wp)
2833 (void) wp;
2834 unselect_cmd ();
2836 static void
2837 cmd_reverse_selection (WPanel * wp)
2839 (void) wp;
2840 reverse_selection_cmd ();
2843 static cb_ret_t
2844 panel_execute_cmd (WPanel * panel, unsigned long command)
2846 int res = MSG_HANDLED;
2848 switch (command)
2850 case CK_PanelChdirOtherPanel:
2851 chdir_other_panel (panel);
2852 break;
2853 case CK_PanelChdirToReadlink:
2854 chdir_to_readlink (panel);
2855 break;
2856 case CK_PanelCmdCopyLocal:
2857 cmd_copy_local (panel);
2858 break;
2859 case CK_PanelCmdDeleteLocal:
2860 cmd_delete_local (panel);
2861 break;
2862 case CK_PanelCmdDoEnter:
2863 cmd_do_enter (panel);
2864 break;
2865 case CK_PanelCmdViewSimple:
2866 cmd_view_simple (panel);
2867 break;
2868 case CK_PanelCmdEditNew:
2869 cmd_edit_new (panel);
2870 break;
2871 case CK_PanelCmdRenameLocal:
2872 cmd_rename_local (panel);
2873 break;
2874 case CK_PanelCmdReverseSelection:
2875 cmd_reverse_selection (panel);
2876 break;
2877 case CK_PanelCmdSelect:
2878 cmd_select (panel);
2879 break;
2880 case CK_PanelCmdUnselect:
2881 cmd_unselect (panel);
2882 break;
2883 case CK_PanelNextPage:
2884 next_page (panel);
2885 break;
2886 case CK_PanelPrevPage:
2887 prev_page (panel);
2888 break;
2889 case CK_PanelCtrlNextPage:
2890 ctrl_next_page (panel);
2891 break;
2892 case CK_PanelCtrlPrevPage:
2893 ctrl_prev_page (panel);
2894 break;
2895 case CK_PanelDirectoryHistoryList:
2896 directory_history_list (panel);
2897 break;
2898 case CK_PanelDirectoryHistoryNext:
2899 directory_history_next (panel);
2900 break;
2901 case CK_PanelDirectoryHistoryPrev:
2902 directory_history_prev (panel);
2903 break;
2904 case CK_PanelGotoBottomFile:
2905 goto_bottom_file (panel);
2906 break;
2907 case CK_PanelGotoMiddleFile:
2908 goto_middle_file (panel);
2909 break;
2910 case CK_PanelGotoTopFile:
2911 goto_top_file (panel);
2912 break;
2913 case CK_PanelMarkFile:
2914 mark_file (panel);
2915 break;
2916 case CK_PanelMoveUp:
2917 move_up (panel);
2918 break;
2919 case CK_PanelMoveDown:
2920 move_down (panel);
2921 break;
2922 case CK_PanelMoveLeft:
2923 res = move_left (panel);
2924 break;
2925 case CK_PanelMoveRight:
2926 res = move_right (panel);
2927 break;
2928 case CK_PanelMoveEnd:
2929 move_end (panel);
2930 break;
2931 case CK_PanelMoveHome:
2932 move_home (panel);
2933 break;
2934 case CK_PanelSetPanelEncoding:
2935 set_panel_encoding (panel);
2936 break;
2937 case CK_PanelStartSearch:
2938 start_search (panel);
2939 break;
2940 case CK_PanelSyncOtherPanel:
2941 sync_other_panel (panel);
2942 break;
2943 case CK_PanelSelectSortOrder:
2944 panel_select_sort_order (panel);
2945 break;
2946 case CK_PanelToggleSortOrderPrev:
2947 panel_toggle_sort_order_prev (panel);
2948 break;
2949 case CK_PanelToggleSortOrderNext:
2950 panel_toggle_sort_order_next (panel);
2951 break;
2952 case CK_PanelReverseSort:
2953 panel->reverse = !panel->reverse;
2954 panel_set_sort_order (panel, panel->current_sort_field);
2955 break;
2956 case CK_PanelSortOrderByName:
2957 panel_set_sort_type_by_id (panel, "name");
2958 break;
2959 case CK_PanelSortOrderByExt:
2960 panel_set_sort_type_by_id (panel, "extension");
2961 break;
2962 case CK_PanelSortOrderBySize:
2963 panel_set_sort_type_by_id (panel, "size");
2964 break;
2965 case CK_PanelSortOrderByMTime:
2966 panel_set_sort_type_by_id (panel, "mtime");
2967 break;
2969 return res;
2972 static cb_ret_t
2973 panel_key (WPanel * panel, int key)
2975 size_t i;
2976 unsigned long res, command;
2978 for (i = 0; panel_map[i].key != 0; i++)
2980 if (key == panel_map[i].key)
2982 int old_searching = panel->searching;
2984 if (panel_map[i].command != CK_PanelStartSearch)
2985 panel->searching = 0;
2987 command = panel_map[i].command;
2988 res = panel_execute_cmd (panel, command);
2990 if (res == MSG_NOT_HANDLED)
2991 return res;
2993 if (panel->searching != old_searching)
2994 display_mini_info (panel);
2995 return MSG_HANDLED;
2999 if (torben_fj_mode && key == ALT ('h'))
3001 goto_middle_file (panel);
3002 return MSG_HANDLED;
3005 if (is_abort_char (key))
3007 panel->searching = 0;
3008 display_mini_info (panel);
3009 return MSG_HANDLED;
3012 /* Do not eat characters not meant for the panel below ' ' (e.g. C-l). */
3013 if ((key >= ' ' && key <= 255) || key == KEY_BACKSPACE)
3015 if (panel->searching)
3017 do_search (panel, key);
3018 return MSG_HANDLED;
3021 if (!command_prompt)
3023 start_search (panel);
3024 do_search (panel, key);
3025 return MSG_HANDLED;
3029 return MSG_NOT_HANDLED;
3032 static cb_ret_t
3033 panel_callback (Widget * w, widget_msg_t msg, int parm)
3035 WPanel *panel = (WPanel *) w;
3036 WButtonBar *bb;
3038 switch (msg)
3040 case WIDGET_DRAW:
3041 paint_panel (panel);
3042 return MSG_HANDLED;
3044 case WIDGET_FOCUS:
3045 current_panel = panel;
3046 panel->active = 1;
3047 if (mc_chdir (panel->cwd) != 0)
3049 char *cwd = strip_password (g_strdup (panel->cwd), 1);
3050 message (D_ERROR, MSG_ERROR, _(" Cannot chdir to \"%s\" \n %s "),
3051 cwd, unix_error_string (errno));
3052 g_free (cwd);
3054 else
3055 subshell_chdir (panel->cwd);
3057 update_xterm_title_path ();
3058 select_item (panel);
3059 show_dir (panel);
3060 paint_dir (panel);
3061 panel->dirty = 0;
3063 bb = find_buttonbar (panel->widget.parent);
3064 midnight_set_buttonbar (bb);
3065 buttonbar_redraw (bb);
3066 return MSG_HANDLED;
3068 case WIDGET_UNFOCUS:
3069 /* Janne: look at this for the multiple panel options */
3070 if (panel->searching)
3072 panel->searching = 0;
3073 display_mini_info (panel);
3075 panel->active = 0;
3076 show_dir (panel);
3077 unselect_item (panel);
3078 return MSG_HANDLED;
3080 case WIDGET_KEY:
3081 return panel_key (panel, parm);
3083 case WIDGET_DESTROY:
3084 panel_destroy (panel);
3085 return MSG_HANDLED;
3087 default:
3088 return default_proc (msg, parm);
3092 void
3093 file_mark (WPanel * panel, int lc_index, int val)
3095 if (panel->dir.list[lc_index].f.marked != val)
3097 panel->dir.list[lc_index].f.marked = val;
3098 panel->dirty = 1;
3102 /* */
3103 /* Panel mouse events support routines */
3104 /* */
3105 static int mouse_marking = 0;
3107 static void
3108 mouse_toggle_mark (WPanel * panel)
3110 do_mark_file (panel, 0);
3111 mouse_marking = selection (panel)->f.marked;
3114 static void
3115 mouse_set_mark (WPanel * panel)
3117 if (mouse_marking && !(selection (panel)->f.marked))
3118 do_mark_file (panel, 0);
3119 else if (!mouse_marking && (selection (panel)->f.marked))
3120 do_mark_file (panel, 0);
3123 static int
3124 mark_if_marking (WPanel * panel, Gpm_Event * event)
3126 if (event->buttons & GPM_B_RIGHT)
3128 if (event->type & GPM_DOWN)
3129 mouse_toggle_mark (panel);
3130 else
3131 mouse_set_mark (panel);
3132 return 1;
3134 return 0;
3137 /* Determine which column was clicked, and sort the panel on
3138 * that column, or reverse sort on that column if already
3139 * sorted on that column.
3141 static void
3142 mouse_sort_col (Gpm_Event * event, WPanel * panel)
3144 int i;
3145 const char *lc_sort_name = NULL;
3146 panel_field_t *col_sort_format = NULL;
3147 format_e *format;
3148 gchar *title;
3150 for (i = 0, format = panel->format; format != NULL; format = format->next)
3152 i += format->field_len;
3153 if (event->x < i + 1)
3155 /* found column */
3156 lc_sort_name = format->title;
3157 break;
3161 if (lc_sort_name == NULL)
3162 return;
3164 for (i = 0; panel_fields[i].id != NULL; i++)
3166 title = panel_get_title_without_hotkey (panel_fields[i].title_hotkey);
3167 if (!strcmp (lc_sort_name, title) && panel_fields[i].sort_routine)
3169 col_sort_format = &panel_fields[i];
3170 g_free (title);
3171 break;
3173 g_free (title);
3176 if (!col_sort_format)
3177 return;
3179 if (panel->current_sort_field == col_sort_format)
3181 /* reverse the sort if clicked column is already the sorted column */
3182 panel->reverse = !panel->reverse;
3184 else
3186 /* new sort is forced to be ascending */
3187 panel->reverse = 0;
3189 panel_set_sort_order (panel, col_sort_format);
3194 * Mouse callback of the panel minus repainting.
3195 * If the event is redirected to the menu, *redir is set to 1.
3197 static int
3198 do_panel_event (Gpm_Event * event, WPanel * panel, int *redir)
3200 const int lines = llines (panel);
3201 const gboolean is_active = dlg_widget_active (panel);
3202 const gboolean mouse_down = (event->type & GPM_DOWN) != 0;
3204 /* "." button show/hide hidden files */
3205 if (event->type & GPM_DOWN && event->x == panel->widget.cols - 5 && event->y == 1)
3207 toggle_show_hidden ();
3208 repaint_screen ();
3209 return MOU_NORMAL;
3212 /* "<" button */
3213 if (mouse_down && event->y == 1 && event->x == 2)
3215 directory_history_prev (panel);
3216 return MOU_NORMAL;
3219 /* ">" button */
3220 if (mouse_down && event->y == 1 && event->x == panel->widget.cols - 1)
3222 directory_history_next (panel);
3223 return MOU_NORMAL;
3226 /* "^" button */
3227 if (mouse_down && event->y == 1 && event->x >= panel->widget.cols - 4
3228 && event->x <= panel->widget.cols - 2)
3230 directory_history_list (panel);
3231 return MOU_NORMAL;
3234 /* sort on clicked column */
3235 if (event->type & GPM_DOWN && event->y == 2)
3237 mouse_sort_col (event, panel);
3238 return MOU_NORMAL;
3241 /* rest of the upper frame, the menu is invisible - call menu */
3242 if (mouse_down && event->y == 1 && !menubar_visible)
3244 *redir = 1;
3245 event->x += panel->widget.x;
3246 return the_menubar->widget.mouse (event, the_menubar);
3249 /* Mouse wheel events */
3250 if (mouse_down && (event->buttons & GPM_B_UP))
3252 if (is_active)
3254 if (panel->top_file > 0)
3255 prev_page (panel);
3256 else /* We are in first page */
3257 move_up (panel);
3259 return MOU_NORMAL;
3262 if (mouse_down && (event->buttons & GPM_B_DOWN))
3264 if (is_active)
3266 if (panel->top_file + ITEMS (panel) < panel->count)
3267 next_page (panel);
3268 else /* We are in last page */
3269 move_down (panel);
3271 return MOU_NORMAL;
3274 event->y -= 2;
3275 if ((event->type & (GPM_DOWN | GPM_DRAG)))
3277 int my_index;
3279 if (!is_active)
3280 change_panel ();
3282 if (event->y <= 0)
3284 mark_if_marking (panel, event);
3285 if (mouse_move_pages)
3286 prev_page (panel);
3287 else
3288 move_up (panel);
3289 return MOU_REPEAT;
3292 if (!((panel->top_file + event->y <= panel->count) && event->y <= lines))
3294 mark_if_marking (panel, event);
3295 if (mouse_move_pages)
3296 next_page (panel);
3297 else
3298 move_down (panel);
3299 return MOU_REPEAT;
3302 my_index = panel->top_file + event->y - 1;
3303 if (panel->split && (event->x > ((panel->widget.cols - 2) / 2)))
3304 my_index += llines (panel);
3306 if (my_index >= panel->count)
3307 my_index = panel->count - 1;
3309 if (my_index != panel->selected)
3311 unselect_item (panel);
3312 panel->selected = my_index;
3313 select_item (panel);
3316 /* This one is new */
3317 mark_if_marking (panel, event);
3319 else if ((event->type & (GPM_UP | GPM_DOUBLE)) == (GPM_UP | GPM_DOUBLE))
3321 if (event->y > 0 && event->y <= lines)
3322 do_enter (panel);
3324 return MOU_NORMAL;
3327 /* Mouse callback of the panel */
3328 static int
3329 panel_event (Gpm_Event * event, void *data)
3331 WPanel *panel = data;
3332 int ret;
3333 int redir = MOU_NORMAL;
3335 ret = do_panel_event (event, panel, &redir);
3336 if (!redir)
3337 paint_panel (panel);
3339 return ret;
3342 void
3343 panel_re_sort (WPanel * panel)
3345 char *filename;
3346 int i;
3348 if (panel == NULL)
3349 return;
3351 filename = g_strdup (selection (panel)->fname);
3352 unselect_item (panel);
3353 do_sort (&panel->dir, panel->current_sort_field->sort_routine, panel->count - 1, panel->reverse,
3354 panel->case_sensitive, panel->exec_first);
3355 panel->selected = -1;
3356 for (i = panel->count; i; i--)
3358 if (!strcmp (panel->dir.list[i - 1].fname, filename))
3360 panel->selected = i - 1;
3361 break;
3364 g_free (filename);
3365 panel->top_file = panel->selected - ITEMS (panel) / 2;
3366 select_item (panel);
3367 panel->dirty = 1;
3370 void
3371 panel_set_sort_order (WPanel * panel, const panel_field_t * sort_order)
3373 if (sort_order == 0)
3374 return;
3376 panel->current_sort_field = sort_order;
3378 /* The directory is already sorted, we have to load the unsorted stuff */
3379 if (sort_order->sort_routine == (sortfn *) unsorted)
3381 char *current_file;
3383 current_file = g_strdup (panel->dir.list[panel->selected].fname);
3384 panel_reload (panel);
3385 try_to_select (panel, current_file);
3386 g_free (current_file);
3388 panel_re_sort (panel);
3391 void
3392 set_panel_encoding (WPanel * panel)
3394 const char *encoding = NULL;
3395 char *cd_path;
3396 #ifdef HAVE_CHARSET
3397 const char *errmsg;
3398 int r;
3400 r = select_charset (-1, -1, default_source_codepage, FALSE);
3402 if (r == SELECT_CHARSET_CANCEL)
3403 return; /* Cancel */
3405 if (r == SELECT_CHARSET_NO_TRANSLATE)
3407 /* No translation */
3408 errmsg = init_translation_table (display_codepage, display_codepage);
3409 cd_path = remove_encoding_from_path (panel->cwd);
3410 do_panel_cd (panel, cd_path, 0);
3411 g_free (cd_path);
3412 return;
3415 source_codepage = r;
3417 errmsg = init_translation_table (source_codepage, display_codepage);
3418 if (errmsg)
3420 message (D_ERROR, MSG_ERROR, "%s", errmsg);
3421 return;
3424 encoding = get_codepage_id (source_codepage);
3425 #endif
3426 if (encoding != NULL)
3428 cd_path = add_encoding_to_path (panel->cwd, encoding);
3429 if (!do_panel_cd (panel, cd_path, 0))
3430 message (D_ERROR, MSG_ERROR, _(" Cannot chdir to %s "), cd_path);
3431 g_free (cd_path);
3435 static void
3436 reload_panelized (WPanel * panel)
3438 int i, j;
3439 dir_list *list = &panel->dir;
3441 if (panel != current_panel)
3442 mc_chdir (panel->cwd);
3444 for (i = 0, j = 0; i < panel->count; i++)
3446 if (list->list[i].f.marked)
3448 /* Unmark the file in advance. In case the following mc_lstat
3449 * fails we are done, else we have to mark the file again
3450 * (Note: do_file_mark depends on a valid "list->list [i].buf").
3451 * IMO that's the best way to update the panel's summary status
3452 * -- Norbert
3454 do_file_mark (panel, i, 0);
3456 if (mc_lstat (list->list[i].fname, &list->list[i].st))
3458 g_free (list->list[i].fname);
3459 continue;
3461 if (list->list[i].f.marked)
3462 do_file_mark (panel, i, 1);
3463 if (j != i)
3464 list->list[j] = list->list[i];
3465 j++;
3467 if (j == 0)
3468 panel->count = set_zero_dir (list) ? 1 : 0;
3469 else
3470 panel->count = j;
3472 if (panel != current_panel)
3473 mc_chdir (current_panel->cwd);
3476 static void
3477 update_one_panel_widget (WPanel * panel, int force_update, const char *current_file)
3479 int free_pointer;
3480 char *my_current_file = NULL;
3482 if (force_update & UP_RELOAD)
3484 panel->is_panelized = 0;
3485 mc_setctl (panel->cwd, VFS_SETCTL_FLUSH, 0);
3486 memset (&(panel->dir_stat), 0, sizeof (panel->dir_stat));
3489 /* If current_file == -1 (an invalid pointer) then preserve selection */
3490 if (current_file == UP_KEEPSEL)
3492 free_pointer = 1;
3493 my_current_file = g_strdup (panel->dir.list[panel->selected].fname);
3494 current_file = my_current_file;
3496 else
3497 free_pointer = 0;
3499 if (panel->is_panelized)
3500 reload_panelized (panel);
3501 else
3502 panel_reload (panel);
3504 try_to_select (panel, current_file);
3505 panel->dirty = 1;
3507 if (free_pointer)
3508 g_free (my_current_file);
3511 static void
3512 update_one_panel (int which, int force_update, const char *current_file)
3514 if (get_display_type (which) == view_listing)
3516 WPanel *panel;
3517 panel = (WPanel *) get_panel_widget (which);
3518 update_one_panel_widget (panel, force_update, current_file);
3522 /* This routine reloads the directory in both panels. It tries to
3523 * select current_file in current_panel and other_file in other_panel.
3524 * If current_file == -1 then it automatically sets current_file and
3525 * other_file to the currently selected files in the panels.
3527 * if force_update has the UP_ONLY_CURRENT bit toggled on, then it
3528 * will not reload the other panel.
3530 void
3531 update_panels (int force_update, const char *current_file)
3533 int reload_other = !(force_update & UP_ONLY_CURRENT);
3534 WPanel *panel;
3536 update_one_panel (get_current_index (), force_update, current_file);
3537 if (reload_other)
3538 update_one_panel (get_other_index (), force_update, UP_KEEPSEL);
3540 if (get_current_type () == view_listing)
3541 panel = (WPanel *) get_panel_widget (get_current_index ());
3542 else
3543 panel = (WPanel *) get_panel_widget (get_other_index ());
3545 mc_chdir (panel->cwd);
3548 gsize
3549 panel_get_num_of_sortable_fields (void)
3551 gsize ret = 0, lc_index;
3553 for (lc_index = 0; panel_fields[lc_index].id != NULL; lc_index++)
3554 if (panel_fields[lc_index].is_user_choice)
3555 ret++;
3556 return ret;
3560 const char **
3561 panel_get_sortable_fields (gsize * array_size)
3563 char **ret;
3564 gsize lc_index, i;
3566 lc_index = panel_get_num_of_sortable_fields ();
3568 ret = g_try_new0 (char *, lc_index + 1);
3569 if (ret == NULL)
3570 return NULL;
3572 if (array_size != NULL)
3573 *array_size = lc_index;
3575 lc_index = 0;
3577 for (i = 0; panel_fields[i].id != NULL; i++)
3578 if (panel_fields[i].is_user_choice)
3579 ret[lc_index++] = g_strdup (_(panel_fields[i].title_hotkey));
3580 return (const char **) ret;
3583 const panel_field_t *
3584 panel_get_field_by_id (const char *name)
3586 gsize lc_index;
3587 for (lc_index = 0; panel_fields[lc_index].id != NULL; lc_index++)
3588 if (panel_fields[lc_index].id != NULL && strcmp (name, panel_fields[lc_index].id) == 0)
3589 return &panel_fields[lc_index];
3590 return NULL;
3593 const panel_field_t *
3594 panel_get_field_by_title_hotkey (const char *name)
3596 gsize lc_index;
3597 for (lc_index = 0; panel_fields[lc_index].id != NULL; lc_index++)
3598 if (panel_fields[lc_index].title_hotkey != NULL &&
3599 strcmp (name, _(panel_fields[lc_index].title_hotkey)) == 0)
3600 return &panel_fields[lc_index];
3601 return NULL;
3604 const panel_field_t *
3605 panel_get_field_by_title (const char *name)
3607 gsize lc_index;
3608 gchar *title = NULL;
3610 for (lc_index = 0; panel_fields[lc_index].id != NULL; lc_index++)
3612 title = panel_get_title_without_hotkey (panel_fields[lc_index].title_hotkey);
3613 if (panel_fields[lc_index].title_hotkey != NULL && strcmp (name, title) == 0)
3615 g_free (title);
3616 return &panel_fields[lc_index];
3619 g_free (title);
3620 return NULL;
3623 gsize
3624 panel_get_num_of_user_possible_fields (void)
3626 gsize ret = 0, lc_index;
3628 for (lc_index = 0; panel_fields[lc_index].id != NULL; lc_index++)
3629 if (panel_fields[lc_index].use_in_user_format)
3630 ret++;
3631 return ret;
3634 const char **
3635 panel_get_user_possible_fields (gsize * array_size)
3637 char **ret;
3638 gsize lc_index, i;
3640 lc_index = panel_get_num_of_user_possible_fields ();
3642 ret = g_try_new0 (char *, lc_index + 1);
3643 if (ret == NULL)
3644 return NULL;
3646 if (array_size != NULL)
3647 *array_size = lc_index;
3649 lc_index = 0;
3651 for (i = 0; panel_fields[i].id != NULL; i++)
3652 if (panel_fields[i].use_in_user_format)
3653 ret[lc_index++] = g_strdup (_(panel_fields[i].title_hotkey));
3654 return (const char **) ret;
3657 void
3658 panel_init (void)
3660 panel_sort_up_sign = mc_skin_get ("widget-common", "sort-sign-up", "'");
3661 panel_sort_down_sign = mc_skin_get ("widget-common", "sort-sign-down", ",");
3663 panel_hiddenfiles_sign_show = mc_skin_get ("widget-panel", "hiddenfiles-sign-show", ".");
3664 panel_hiddenfiles_sign_hide = mc_skin_get ("widget-panel", "hiddenfiles-sign-hide", ".");
3665 panel_history_prev_item_sign = mc_skin_get ("widget-panel", "history-prev-item-sign", "<");
3666 panel_history_next_item_sign = mc_skin_get ("widget-panel", "history-next-item-sign", ">");
3667 panel_history_show_list_sign = mc_skin_get ("widget-panel", "history-show-list-sign", "^");
3671 void
3672 panel_deinit (void)
3674 g_free (panel_sort_up_sign);
3675 g_free (panel_sort_down_sign);
3677 g_free (panel_hiddenfiles_sign_show);
3678 g_free (panel_hiddenfiles_sign_hide);
3679 g_free (panel_history_prev_item_sign);
3680 g_free (panel_history_next_item_sign);
3681 g_free (panel_history_show_list_sign);