1
1

initial step to do mark in inpun fields

added selection with mouse

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>

    Code cleanup: make visibility of some functions as static

Signed-off-by: Slava Zanko <slavazanko@gmail.com>
Signed-off-by: Ilia Maslakov <il.smind@gmail.com>

fixed skins

Signed-off-by: Ilia Maslakov <il.smind@gmail.com>
Этот коммит содержится в:
Ilia Maslakov 2010-05-02 22:33:08 +00:00
родитель 72bb075828
Коммит a4e4378861
20 изменённых файлов: 216 добавлений и 36 удалений

Просмотреть файл

@ -45,7 +45,7 @@
*/
#define GAUGE_COLOR mc_skin_color__cache[19]
#define INPUT_COLOR mc_skin_color__cache[20]
#define INPUT_INACTIVE_COLOR mc_skin_color__cache[21]
#define INPUT_UNCHANGED_COLOR mc_skin_color__cache[21]
#define INPUT_MARK_COLOR mc_skin_color__cache[22]
#define HELP_NORMAL_COLOR mc_skin_color__cache[23]

Просмотреть файл

@ -70,6 +70,9 @@ static const mc_skin_colors_old_t old_colors[] = {
{"menuinactive", "menu", "menuinactive"},
{"gauge", "core", "gauge"},
{"input", "core", "input"},
{"inputmark", "core", "inputmark"},
{"inputunchanged", "core", "inputunchanged"},
{"commandlinemark", "core", "commandlinemark"},
{"helpnormal", "help", "_default_"},
{"helpitalic", "help", "helpitalic"},
{"helpbold", "help", "helpbold"},

Просмотреть файл

@ -222,7 +222,7 @@ mc_skin_color_cache_init (void)
GAUGE_COLOR = mc_skin_color_get ("core", "gauge");
INPUT_COLOR = mc_skin_color_get ("core", "input");
INPUT_MARK_COLOR = mc_skin_color_get ("core", "inputmark");
INPUT_INACTIVE_COLOR = mc_skin_color_get ("core", "inputinactive");
INPUT_UNCHANGED_COLOR = mc_skin_color_get ("core", "inputunchanged");
HELP_NORMAL_COLOR = mc_skin_color_get ("help", "_default_");
HELP_ITALIC_COLOR = mc_skin_color_get ("help", "helpitalic");

Просмотреть файл

@ -330,6 +330,12 @@ InputHistoryNext = alt-n; ctrl-up
InputHistoryShow = alt-h
InputComplete = alt-tab
InputClearLine =
InputLeftHighlight =
InputRightHighlight =
InputWordLeftHighlight =
InputWordRightHighlight =
InputBolHighlight =
InputEolHighlight =
[tree]
TreeHelp = f1

Просмотреть файл

@ -334,6 +334,12 @@ InputHistoryNext = alt-n; ctrl-up
InputHistoryShow = alt-h
InputComplete = alt-tab
InputClearLine =
InputLeftHighlight =
InputRightHighlight =
InputWordLeftHighlight =
InputWordRightHighlight =
InputBolHighlight =
InputEolHighlight =
[tree]
TreeHelp = f1

Просмотреть файл

@ -31,7 +31,10 @@
markselect=yellow;cyan
gauge=white;black
input=black;cyan
inputunchanged=gray;cyan
inputmark=cyan;black
reverse=black;lightgray
commandlinemark=black;lightgray
[dialog]
_default_=brightcyan;blue

Просмотреть файл

@ -31,7 +31,10 @@
markselect=yellow;cyan
gauge=white;black
input=black;cyan
inputunchanged=gray;cyan
inputmark=cyan;black
reverse=black;lightgray
commandlinemark=black;lightgray
[dialog]
_default_=black;lightgray

Просмотреть файл

@ -32,6 +32,9 @@
gauge=white;black
input=black;cyan
reverse=black;lightgray
inputunchanged=gray;cyan
inputmark=cyan;black
commandlinemark=black;lightgray
[dialog]
_default_=black;lightgray

Просмотреть файл

@ -33,7 +33,10 @@
markselect=yellow;cyan
gauge=white;black
input=black;cyan
inputunchanged=gray;cyan
inputmark=cyan;black
reverse=black;lightgray
commandlinemark=black;lightgray
[dialog]
_default_=black;lightgray

Просмотреть файл

@ -326,7 +326,8 @@ mc_args_new_color_group (void)
_("--colors KEYWORD={FORE},{BACK}\n\n"
"{FORE} and {BACK} can be omitted, and the default will be used\n"
"\n" "Keywords:\n"
" Global: errors, reverse, gauge, input, viewunderline\n"
" Global: errors, reverse, gauge, viewunderline\n"
" input, inputmark, inputunchanged, commandlinemark\n"
" File display: normal, selected, marked, markselect\n"
" Dialog boxes: dnormal, dfocus, dhotnormal, dhotfocus, errdhotnormal,\n"
" errdhotfocus\n"

Просмотреть файл

@ -139,7 +139,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_INACTIVE_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
@ -1025,7 +1025,7 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_INACTIVE_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};

Просмотреть файл

@ -255,6 +255,13 @@
#define CK_InputPaste 4025
#define CK_InputClearLine 4026
#define CK_InputLeftHighlight 4027
#define CK_InputRightHighlight 4028
#define CK_InputWordLeftHighlight 4029
#define CK_InputWordRightHighlight 4030
#define CK_InputBolHighlight 4031
#define CK_InputEolHighlight 4032
/* Viewer */
#define CK_ViewHelp 5001
#define CK_ViewToggleWrapMode 5002

Просмотреть файл

@ -31,6 +31,7 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/wait.h>
#include "lib/global.h"
#include "lib/tty/tty.h"

Просмотреть файл

@ -315,7 +315,7 @@ editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_INACTIVE_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};

Просмотреть файл

@ -387,7 +387,7 @@ find_parameters (char **start_dir, char **pattern, char **content)
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_INACTIVE_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};

Просмотреть файл

@ -477,6 +477,12 @@ static name_keymap_t command_names[] = {
{ "InputXStore", CK_InputKillSave },
{ "InputXPaste", CK_InputPaste },
{ "InputClearLine", CK_InputClearLine },
{ "InputLeftHighlight", CK_InputLeftHighlight },
{ "InputRightHighlight", CK_InputRightHighlight},
{ "InputWordLeftHighlight", CK_InputWordLeftHighlight},
{ "InputWordRightHighlight", CK_InputWordRightHighlight},
{ "InputBolHighlight", CK_InputBolHighlight},
{ "InputEolHighlight", CK_InputEolHighlight},
/* common */
{ "ExtMap1", CK_StartExtMap1 },

Просмотреть файл

@ -142,7 +142,7 @@ init_panelize (void)
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_INACTIVE_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};

Просмотреть файл

@ -1046,6 +1046,60 @@ draw_history_button (WInput * in)
/* Pointer to killed data */
static char *kill_buffer = NULL;
static void
input_set_markers (WInput * in, long m1)
{
in->mark = m1;
}
static void
input_mark_cmd (WInput * in, gboolean mark)
{
if (!mark)
{
in->highlight = FALSE;
input_set_markers (in, 0);
}
else
{
in->highlight = TRUE;
input_set_markers (in, in->point);
}
}
static gboolean
input_eval_marks (WInput * in, long *start_mark, long *end_mark)
{
if (in->highlight)
{
*start_mark = min (in->mark, in->point);
*end_mark = max (in->mark, in->point);
return TRUE;
}
else
{
*start_mark = *end_mark = 0;
return FALSE;
}
}
static void
delete_region (WInput * in, int x_first, int x_last)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
size_t len;
input_mark_cmd (in, FALSE);
in->point = first;
last = str_offset_to_pos (in->buffer, last);
first = str_offset_to_pos (in->buffer, first);
len = strlen (&in->buffer[last]) + 1;
memmove (&in->buffer[first], &in->buffer[last], len);
in->charpoint = 0;
in->need_push = 1;
}
void
update_input (WInput * in, int clear_first)
{
@ -1080,7 +1134,7 @@ update_input (WInput * in, int clear_first)
draw_history_button (in);
if (in->first)
tty_setcolor (in->inactive_color);
tty_setcolor (in->unchanged_color);
else
tty_setcolor (in->color);
@ -1088,16 +1142,43 @@ update_input (WInput * in, int clear_first)
if (!in->is_password)
{
tty_print_string (str_term_substring (in->buffer, in->term_first_shown,
in->field_width - has_history));
if (!in->highlight)
{
tty_print_string (str_term_substring (in->buffer, in->term_first_shown,
in->field_width - has_history));
}
else
{
long m1, m2;
if (input_eval_marks (in, &m1, &m2))
{
tty_setcolor (in->color);
cp = str_term_substring (in->buffer, in->term_first_shown, in->field_width - has_history);
tty_print_string (cp);
tty_setcolor (in->mark_color);
if (m1 < in->term_first_shown)
{
widget_move (&in->widget, 0, 0);
tty_print_string (str_term_substring (in->buffer, in->term_first_shown, m2 - in->term_first_shown));
}
else
{
int sel_width;
widget_move (&in->widget, 0, m1 - in->term_first_shown);
sel_width = min (m2 - m1, (in->field_width - has_history) - (str_term_width2 (in->buffer, m1) - in->term_first_shown));
tty_print_string (str_term_substring (in->buffer, m1, sel_width));
}
}
}
}
else
{
cp = in->buffer;
for (i = -in->term_first_shown; i < in->field_width - has_history; i++)
cp = str_term_substring (in->buffer, in->term_first_shown, in->field_width - has_history);
for (i = 0; i < in->field_width - has_history; i++)
{
if (i >= 0)
{
tty_setcolor (in->color);
tty_print_char ((cp[0] != '\0') ? '*' : ' ');
}
if (cp[0] != '\0')
@ -1515,6 +1596,7 @@ new_input (WInput * in)
in->point = 0;
in->charpoint = 0;
in->mark = 0;
in->highlight = FALSE;
free_completions (in);
update_input (in, 0);
}
@ -1540,6 +1622,12 @@ insert_char (WInput * in, int c_code)
size_t i;
int res;
if (in->highlight)
{
long m1, m2;
if (input_eval_marks (in, &m1, &m2))
delete_region (in, m1, m2);
}
if (c_code == -1)
return MSG_NOT_HANDLED;
@ -1746,24 +1834,6 @@ copy_region (WInput * in, int x_first, int x_last)
save_text_to_clip_file (kill_buffer);
}
static void
delete_region (WInput * in, int x_first, int x_last)
{
int first = min (x_first, x_last);
int last = max (x_first, x_last);
size_t len;
in->point = first;
if (in->mark > first)
in->mark = first;
last = str_offset_to_pos (in->buffer, last);
first = str_offset_to_pos (in->buffer, first);
len = strlen (&in->buffer[last]) + 1;
memmove (&in->buffer[first], &in->buffer[last], len);
in->charpoint = 0;
in->need_push = 1;
}
static void
kill_word (WInput * in)
{
@ -1799,7 +1869,7 @@ back_kill_word (WInput * in)
static void
set_mark (WInput * in)
{
in->mark = in->point;
input_mark_cmd (in, TRUE);
}
static void
@ -1932,24 +2002,55 @@ input_execute_cmd (WInput * in, unsigned long command)
{
cb_ret_t res = MSG_HANDLED;
/* a highlight command like shift-arrow */
if (command == CK_InputLeftHighlight ||
command == CK_InputRightHighlight ||
command == CK_InputWordLeftHighlight ||
command == CK_InputWordRightHighlight ||
command == CK_InputBolHighlight ||
command == CK_InputEolHighlight)
{
if (!in->highlight)
{
input_mark_cmd (in, FALSE); /* clear */
input_mark_cmd (in, TRUE); /* marking on */
}
}
switch (command)
{
case CK_InputForwardWord:
case CK_InputBackwardWord:
case CK_InputForwardChar:
case CK_InputBackwardChar:
if (in->highlight)
input_mark_cmd (in, FALSE);
}
switch (command)
{
case CK_InputBol:
case CK_InputBolHighlight:
beginning_of_line (in);
break;
case CK_InputEol:
case CK_InputEolHighlight:
end_of_line (in);
break;
case CK_InputMoveLeft:
case CK_InputLeftHighlight:
key_left (in);
break;
case CK_InputWordLeft:
case CK_InputWordLeftHighlight:
key_ctrl_left (in);
break;
case CK_InputMoveRight:
case CK_InputRightHighlight:
key_right (in);
break;
case CK_InputWordRight:
case CK_InputWordRightHighlight:
key_ctrl_right (in);
break;
case CK_InputBackwardChar:
@ -1965,11 +2066,26 @@ input_execute_cmd (WInput * in, unsigned long command)
forward_word (in);
break;
case CK_InputBackwardDelete:
backward_delete (in);
if (in->highlight)
{
long m1, m2;
if (input_eval_marks (in, &m1, &m2))
delete_region (in, m1, m2);
}
else
{
backward_delete (in);
}
break;
case CK_InputDeleteChar:
if (in->first)
port_region_marked_for_delete (in);
else if (in->highlight)
{
long m1, m2;
if (input_eval_marks (in, &m1, &m2))
delete_region (in, m1, m2);
}
else
delete_char (in);
break;
@ -2016,6 +2132,16 @@ input_execute_cmd (WInput * in, unsigned long command)
res = MSG_NOT_HANDLED;
}
if (command != CK_InputLeftHighlight &&
command != CK_InputRightHighlight &&
command != CK_InputWordLeftHighlight &&
command != CK_InputWordRightHighlight &&
command != CK_InputBolHighlight &&
command != CK_InputEolHighlight)
{
in->highlight = FALSE;
}
return res;
}
@ -2164,6 +2290,9 @@ input_event (Gpm_Event * event, void *data)
{
WInput *in = data;
if (event->type & GPM_DOWN)
input_mark_cmd (in, FALSE);
if (event->type & (GPM_DOWN | GPM_DRAG))
{
dlg_select_widget (in);
@ -2181,6 +2310,13 @@ input_event (Gpm_Event * event, void *data)
}
update_input (in, 1);
}
/* A lone up mustn't do anything */
if (in->highlight && event->type & (GPM_UP | GPM_DRAG))
return MOU_NORMAL;
if (!(event->type & GPM_DRAG))
input_mark_cmd (in, TRUE);
return MOU_NORMAL;
}
@ -2219,10 +2355,11 @@ input_new (int y, int x, int *input_colors, int width, const char *def_text,
in->current_max_size = initial_buffer_len;
in->buffer = g_new (char, initial_buffer_len);
in->color = input_colors[0];
in->unchanged_color = input_colors[1];
in->mark_color = input_colors[2];
in->inactive_color = input_colors[1];
in->field_width = width;
in->first = TRUE;
in->highlight = FALSE;
in->term_first_shown = 0;
in->disable_update = 0;
in->mark = 0;

Просмотреть файл

@ -102,12 +102,13 @@ typedef struct {
Widget widget;
int point; /* cursor position in the input line in characters */
int mark; /* The mark position in characters */
gboolean highlight; /* There is a selected block */
int term_first_shown; /* column of the first shown character */
size_t current_max_size; /* Maximum length of input line (bytes) */
int field_width; /* width of the editing field */
int color; /* color used */
int mark_color; /* color for marked text */
int inactive_color; /* color for inactive text (Is first keystroke) */
int unchanged_color; /* color for inactive text (Is first keystroke) */
gboolean first; /* Is first keystroke? */
int disable_update; /* Do we want to skip updates? */
int is_password; /* Is this a password input line? */

Просмотреть файл

@ -370,7 +370,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_INACTIVE_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};