mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-03 18:14:25 +03:00
Ticket #2731 (scroll long filenames in panel)
added bindings 'ScrollLeft', 'ScrollRight' for scroll long filenames in panel Signed-off-by: Ilia Maslakov <il.smind@gmail.com> some code & typo fixes. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
678120dd9e
commit
d94da7d5c3
@ -205,6 +205,8 @@ static name_keymap_t command_names[] = {
|
|||||||
{"Unselect", CK_Unselect},
|
{"Unselect", CK_Unselect},
|
||||||
|
|
||||||
/* panel */
|
/* panel */
|
||||||
|
{"ScrollLeft", CK_ScrollLeft},
|
||||||
|
{"ScrollRight", CK_ScrollRight},
|
||||||
{"PanelOtherCd", CK_PanelOtherCd},
|
{"PanelOtherCd", CK_PanelOtherCd},
|
||||||
{"PanelOtherCdLink", CK_PanelOtherCdLink},
|
{"PanelOtherCdLink", CK_PanelOtherCdLink},
|
||||||
{"CopySingle", CK_CopySingle},
|
{"CopySingle", CK_CopySingle},
|
||||||
|
@ -196,6 +196,8 @@ enum
|
|||||||
CK_SortByExt,
|
CK_SortByExt,
|
||||||
CK_SortBySize,
|
CK_SortBySize,
|
||||||
CK_SortByMTime,
|
CK_SortByMTime,
|
||||||
|
CK_ScrollLeft,
|
||||||
|
CK_ScrollRight,
|
||||||
|
|
||||||
/* dialog */
|
/* dialog */
|
||||||
CK_Ok = 300,
|
CK_Ok = 300,
|
||||||
|
@ -121,6 +121,8 @@ SortByName =
|
|||||||
SortByExt =
|
SortByExt =
|
||||||
SortBySize =
|
SortBySize =
|
||||||
SortByMTime =
|
SortByMTime =
|
||||||
|
ScrollLeft =
|
||||||
|
ScrollRight =
|
||||||
|
|
||||||
[dialog]
|
[dialog]
|
||||||
Ok = enter
|
Ok = enter
|
||||||
|
@ -122,6 +122,8 @@ SortByName =
|
|||||||
SortByExt =
|
SortByExt =
|
||||||
SortBySize =
|
SortBySize =
|
||||||
SortByMTime =
|
SortByMTime =
|
||||||
|
ScrollLeft =
|
||||||
|
ScrollRight =
|
||||||
|
|
||||||
[dialog]
|
[dialog]
|
||||||
Ok = enter
|
Ok = enter
|
||||||
|
@ -389,7 +389,8 @@ delete_format (format_e * format)
|
|||||||
/** This code relies on the default justification!!! */
|
/** This code relies on the default justification!!! */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
add_permission_string (char *dest, int width, file_entry * fe, int attr, int color, int is_octal)
|
add_permission_string (const char *dest, int width, file_entry * fe, int attr, int color,
|
||||||
|
int is_octal)
|
||||||
{
|
{
|
||||||
int i, r, l;
|
int i, r, l;
|
||||||
|
|
||||||
@ -764,7 +765,6 @@ format_file (char *dest, int limit, WPanel * panel, int file_index, int width, i
|
|||||||
color = file_compute_color (attr, fe);
|
color = file_compute_color (attr, fe);
|
||||||
else
|
else
|
||||||
color = NORMAL_COLOR;
|
color = NORMAL_COLOR;
|
||||||
|
|
||||||
for (format = home; format; format = format->next)
|
for (format = home; format; format = format->next)
|
||||||
{
|
{
|
||||||
if (length == width)
|
if (length == width)
|
||||||
@ -773,7 +773,8 @@ format_file (char *dest, int limit, WPanel * panel, int file_index, int width, i
|
|||||||
if (format->string_fn)
|
if (format->string_fn)
|
||||||
{
|
{
|
||||||
int len, perm;
|
int len, perm;
|
||||||
char *preperad_text;
|
const char *prepared_text;
|
||||||
|
int name_offset = 0;
|
||||||
|
|
||||||
if (empty_line)
|
if (empty_line)
|
||||||
txt = " ";
|
txt = " ";
|
||||||
@ -786,6 +787,20 @@ format_file (char *dest, int limit, WPanel * panel, int file_index, int width, i
|
|||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
if (!isstatus && panel->content_shift > -1 && strcmp (format->id, "name") == 0)
|
||||||
|
{
|
||||||
|
int str_len;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
str_len = str_length (txt);
|
||||||
|
i = max (0, str_len - len);
|
||||||
|
panel->max_shift = max (panel->max_shift, i);
|
||||||
|
i = min (panel->content_shift, i);
|
||||||
|
|
||||||
|
if (i > -1)
|
||||||
|
name_offset = str_offset_to_pos (txt, i);
|
||||||
|
}
|
||||||
|
|
||||||
perm = 0;
|
perm = 0;
|
||||||
if (panels_options.permission_mode)
|
if (panels_options.permission_mode)
|
||||||
{
|
{
|
||||||
@ -800,12 +815,15 @@ format_file (char *dest, int limit, WPanel * panel, int file_index, int width, i
|
|||||||
else
|
else
|
||||||
tty_lowlevel_setcolor (-color);
|
tty_lowlevel_setcolor (-color);
|
||||||
|
|
||||||
preperad_text = (char *) str_fit_to_term (txt, len, format->just_mode);
|
if (!isstatus && panel->content_shift > -1)
|
||||||
|
prepared_text = str_fit_to_term (txt + name_offset, len, HIDE_FIT (format->just_mode));
|
||||||
|
else
|
||||||
|
prepared_text = str_fit_to_term (txt, len, format->just_mode);
|
||||||
|
|
||||||
if (perm)
|
if (perm)
|
||||||
add_permission_string (preperad_text, format->field_len, fe, attr, color, perm - 1);
|
add_permission_string (prepared_text, format->field_len, fe, attr, color, perm - 1);
|
||||||
else
|
else
|
||||||
tty_print_string (preperad_text);
|
tty_print_string (prepared_text);
|
||||||
|
|
||||||
length += len;
|
length += len;
|
||||||
}
|
}
|
||||||
@ -940,7 +958,8 @@ paint_dir (WPanel * panel)
|
|||||||
int items; /* Number of items */
|
int items; /* Number of items */
|
||||||
|
|
||||||
items = llines (panel) * (panel->split ? 2 : 1);
|
items = llines (panel) * (panel->split ? 2 : 1);
|
||||||
|
/* reset max len of filename because we have the new max length for the new file list */
|
||||||
|
panel->max_shift = -1;
|
||||||
for (i = 0; i < items; i++)
|
for (i = 0; i < items; i++)
|
||||||
{
|
{
|
||||||
if (i + panel->top_file >= panel->count)
|
if (i + panel->top_file >= panel->count)
|
||||||
@ -952,6 +971,7 @@ paint_dir (WPanel * panel)
|
|||||||
}
|
}
|
||||||
repaint_file (panel, i + panel->top_file, 1, color, 0);
|
repaint_file (panel, i + panel->top_file, 1, color, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
tty_set_normal_attrs ();
|
tty_set_normal_attrs ();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2628,6 +2648,49 @@ panel_select_sort_order (WPanel * panel)
|
|||||||
|
|
||||||
/* --------------------------------------------------------------------------------------------- */
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn panel_content_scroll_left (panel)
|
||||||
|
* \input:
|
||||||
|
* panel: pointer to the panel on which we operate
|
||||||
|
* \brief: scroll long filename to the left (decrement scroll pointer)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
panel_content_scroll_left (WPanel * panel)
|
||||||
|
{
|
||||||
|
if (panel->content_shift > -1)
|
||||||
|
{
|
||||||
|
if (panel->content_shift > panel->max_shift)
|
||||||
|
panel->content_shift = panel->max_shift;
|
||||||
|
|
||||||
|
panel->content_shift--;
|
||||||
|
show_dir (panel);
|
||||||
|
paint_dir (panel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \fn panel_content_scroll_right (panel)
|
||||||
|
* \input:
|
||||||
|
* panel: pointer to the panel on which we operate
|
||||||
|
* \brief: scroll long filename to the right (increment scroll pointer)
|
||||||
|
*/
|
||||||
|
|
||||||
|
static void
|
||||||
|
panel_content_scroll_right (WPanel * panel)
|
||||||
|
{
|
||||||
|
if (panel->content_shift < 0 || panel->content_shift < panel->max_shift)
|
||||||
|
{
|
||||||
|
panel->content_shift++;
|
||||||
|
show_dir (panel);
|
||||||
|
paint_dir (panel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
panel_set_sort_type_by_id (WPanel * panel, const char *name)
|
panel_set_sort_type_by_id (WPanel * panel, const char *name)
|
||||||
{
|
{
|
||||||
@ -2941,6 +3004,12 @@ panel_execute_cmd (WPanel * panel, unsigned long command)
|
|||||||
panel_change_encoding (panel);
|
panel_change_encoding (panel);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case CK_ScrollLeft:
|
||||||
|
panel_content_scroll_left (panel);
|
||||||
|
break;
|
||||||
|
case CK_ScrollRight:
|
||||||
|
panel_content_scroll_right (panel);
|
||||||
|
break;
|
||||||
case CK_Search:
|
case CK_Search:
|
||||||
start_search (panel);
|
start_search (panel);
|
||||||
break;
|
break;
|
||||||
@ -3639,6 +3708,8 @@ panel_clean_dir (WPanel * panel)
|
|||||||
panel->searching = FALSE;
|
panel->searching = FALSE;
|
||||||
panel->is_panelized = FALSE;
|
panel->is_panelized = FALSE;
|
||||||
panel->dirty = 1;
|
panel->dirty = 1;
|
||||||
|
panel->content_shift = -1;
|
||||||
|
panel->max_shift = -1;
|
||||||
|
|
||||||
clean_dir (&panel->dir, count);
|
clean_dir (&panel->dir, count);
|
||||||
}
|
}
|
||||||
@ -3707,6 +3778,8 @@ panel_new_with_dir (const char *panel_name, const char *wpath)
|
|||||||
panel->format = 0;
|
panel->format = 0;
|
||||||
panel->status_format = 0;
|
panel->status_format = 0;
|
||||||
panel->format_modified = 1;
|
panel->format_modified = 1;
|
||||||
|
panel->content_shift = -1;
|
||||||
|
panel->max_shift = -1;
|
||||||
|
|
||||||
panel->panel_name = g_strdup (panel_name);
|
panel->panel_name = g_strdup (panel_name);
|
||||||
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
|
panel->user_format = g_strdup (DEFAULT_USER_FORMAT);
|
||||||
|
@ -125,6 +125,8 @@ typedef struct WPanel
|
|||||||
char prev_search_buffer[MC_MAXFILENAMELEN];
|
char prev_search_buffer[MC_MAXFILENAMELEN];
|
||||||
char search_char[MB_LEN_MAX]; /*buffer for multibytes characters */
|
char search_char[MB_LEN_MAX]; /*buffer for multibytes characters */
|
||||||
int search_chpoint; /*point after last characters in search_char */
|
int search_chpoint; /*point after last characters in search_char */
|
||||||
|
int content_shift; /* Number of characters of filename need to skip from left side. */
|
||||||
|
int max_shift; /* Max shift for visible part of current panel */
|
||||||
} WPanel;
|
} WPanel;
|
||||||
|
|
||||||
/*** global variables defined in .c file *********************************************************/
|
/*** global variables defined in .c file *********************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user