1
1

Merge branch '2161_del_clear_dialog_field'

* 2161_del_clear_dialog_field:
  fixed man and help
  set default keys for Input* actions
  quick_input: don't force set cursor position to 0.
  clear 'first' flag by mouse click.
  initial step to do mark in inpun fields
  Ticket #2161 (del - clear input field)
Этот коммит содержится в:
Ilia Maslakov 2010-05-27 22:27:40 +03:00
родитель 12969b4974 d3469a33f5
Коммит 82cfa9b54c
23 изменённых файлов: 375 добавлений и 112 удалений

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

@ -3439,7 +3439,8 @@ The format for the color definition is:
.fi
.PP
The colors are optional, and the keywords are: normal, selected, marked,
markselect, errors, input, reverse, gauge. Menu colors are: menunormal,
markselect, errors, input, inputmark, inputunchanged, commandlinemark,
reverse, gauge. Menu colors are: menunormal,
menusel, menuhot, menuhotsel, menuinactive. Dialog colors are: dnormal, dfocus,
dhotnormal, dhotfocus. Help colors are: helpnormal, helpitalic,
helpbold, helplink, helpslink. Viewer color is: viewunderline. Editor
@ -3601,7 +3602,16 @@ cursor on selected data
color of the filled part of the progress bar
.TP
.I input
color of input lines used in query dialogs.
color of input lines used in query dialogs
.TP
.I inputmark
color of input selected text
.TP
.I inputunhanged
color of input text before first modification or cursor movement
.TP
.I commandlinemark
color of selected text in command line
.TP
.I reverse
reverse color

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

@ -3713,20 +3713,29 @@ xterm=menu=magenta:marked=,magenta:markselect=,red
.PP
Цвета не являются обязательными, а в качестве ключевых слов (keywords)
могут использоваться: для задания цветовой палитры в панелях: normal,
selected, marked, markselect, errors, input, reverse, gauge; Цвета
пунктов меню: menunormal, menusel, menuhot, menuhotsel, menuinactive; Цвета
в окне диалога: dnormal, dfocus, dhotnormal, dhotfocus; Цвета в окне подсказки:
helpnormal, helpitalic, helpbold, helplink, helpslink; в окне программы
просмотра: viewunderline; специальные подсветки: executable, directory,
link, device, special, core; в окне редактора: editnormal, editbold,
editmarked.
selected, marked, markselect, errors, input, inputmark, inputunchanged,
commandlinemark, reverse, gauge. Цвета пунктов меню: menunormal, menusel,
menuhot, menuhotsel, menuinactive. Цвета в окне диалога: dnormal, dfocus,
dhotnormal, dhotfocus. Цвета в окне подсказки: helpnormal, helpitalic,
helpbold, helplink, helpslink. Цвета в окне программы просмотра:
viewunderline. Специальные подсветки: executable, directory, link, device,
special, core. Цвета в редакторе: editnormal, editbold, editmarked.
.PP
Цвета задавать не обязательно. Цвет какого именно поля определяется
каждым ключевым словом, можно понять из перевода этого ключевого слова.
Некоторые случаи требуют пояснений.
.PP
.I input
определяет цвета в строке ввода в диалоговых окнах.
определяет цвета в строке ввода в диалоговых окнах;
.PP
.I inputmark
цвет выделенного текста в строке ввода в диалоговых окнах;
.PP
.I inputunchanged
цвет текста в строке ввода до первого изменения или до перемещения курсора;
.PP
.I commandlinemark
цвет выделенного текста в командной строке;
.PP
.I gauge
определяет цвет заполненной части полоски (progress bar), при

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

@ -19,71 +19,71 @@
#define SELECTED_COLOR mc_skin_color__cache[3]
#define MARKED_SELECTED_COLOR mc_skin_color__cache[4]
#define REVERSE_COLOR mc_skin_color__cache[5]
#define COMMAND_MARK_COLOR mc_skin_color__cache[6]
/* Dialog colors */
#define COLOR_NORMAL mc_skin_color__cache[6]
#define COLOR_FOCUS mc_skin_color__cache[7]
#define COLOR_HOT_NORMAL mc_skin_color__cache[8]
#define COLOR_HOT_FOCUS mc_skin_color__cache[9]
#define COLOR_NORMAL mc_skin_color__cache[7]
#define COLOR_FOCUS mc_skin_color__cache[8]
#define COLOR_HOT_NORMAL mc_skin_color__cache[9]
#define COLOR_HOT_FOCUS mc_skin_color__cache[10]
/* Error dialog colors */
#define ERROR_COLOR mc_skin_color__cache[10]
#define ERROR_HOT_NORMAL mc_skin_color__cache[11]
#define ERROR_HOT_FOCUS mc_skin_color__cache[12]
#define ERROR_COLOR mc_skin_color__cache[11]
#define ERROR_HOT_NORMAL mc_skin_color__cache[12]
#define ERROR_HOT_FOCUS mc_skin_color__cache[13]
/* Menu colors */
#define MENU_ENTRY_COLOR mc_skin_color__cache[13]
#define MENU_SELECTED_COLOR mc_skin_color__cache[14]
#define MENU_HOT_COLOR mc_skin_color__cache[15]
#define MENU_HOTSEL_COLOR mc_skin_color__cache[16]
#define MENU_INACTIVE_COLOR mc_skin_color__cache[17]
#define MENU_ENTRY_COLOR mc_skin_color__cache[14]
#define MENU_SELECTED_COLOR mc_skin_color__cache[15]
#define MENU_HOT_COLOR mc_skin_color__cache[16]
#define MENU_HOTSEL_COLOR mc_skin_color__cache[17]
#define MENU_INACTIVE_COLOR mc_skin_color__cache[18]
/*
* This should be selectable independently. Default has to be black background
* foreground does not matter at all.
*/
#define GAUGE_COLOR mc_skin_color__cache[18]
#define INPUT_COLOR mc_skin_color__cache[19]
#define GAUGE_COLOR mc_skin_color__cache[19]
#define INPUT_COLOR mc_skin_color__cache[20]
#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[20]
#define HELP_ITALIC_COLOR mc_skin_color__cache[21]
#define HELP_BOLD_COLOR mc_skin_color__cache[22]
#define HELP_LINK_COLOR mc_skin_color__cache[23]
#define HELP_SLINK_COLOR mc_skin_color__cache[24]
#define HELP_NORMAL_COLOR mc_skin_color__cache[23]
#define HELP_ITALIC_COLOR mc_skin_color__cache[24]
#define HELP_BOLD_COLOR mc_skin_color__cache[25]
#define HELP_LINK_COLOR mc_skin_color__cache[26]
#define HELP_SLINK_COLOR mc_skin_color__cache[27]
#define VIEW_UNDERLINED_COLOR mc_skin_color__cache[25]
#define VIEW_UNDERLINED_COLOR mc_skin_color__cache[28]
/*
* editor colors - only 4 for normal, search->found, select, and whitespace
* respectively
* Last is defined to view color.
*/
#define EDITOR_NORMAL_COLOR mc_skin_color__cache[26]
#define EDITOR_BOLD_COLOR mc_skin_color__cache[27]
#define EDITOR_MARKED_COLOR mc_skin_color__cache[28]
#define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[29]
#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[30]
#define EDITOR_NORMAL_COLOR mc_skin_color__cache[29]
#define EDITOR_BOLD_COLOR mc_skin_color__cache[30]
#define EDITOR_MARKED_COLOR mc_skin_color__cache[31]
#define EDITOR_WHITESPACE_COLOR mc_skin_color__cache[32]
#define EDITOR_RIGHT_MARGIN_COLOR mc_skin_color__cache[33]
/* color of left 8 char status per line */
#define LINE_STATE_COLOR mc_skin_color__cache[31]
#define BOOK_MARK_COLOR mc_skin_color__cache[32]
#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[33]
#define LINE_STATE_COLOR mc_skin_color__cache[34]
#define BOOK_MARK_COLOR mc_skin_color__cache[35]
#define BOOK_MARK_FOUND_COLOR mc_skin_color__cache[36]
#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[34]
#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[35]
#define BUTTONBAR_HOTKEY_COLOR mc_skin_color__cache[37]
#define BUTTONBAR_BUTTON_COLOR mc_skin_color__cache[38]
/* Diff colors */
#define DFF_ADD_COLOR mc_skin_color__cache[36]
#define DFF_CHG_COLOR mc_skin_color__cache[37]
#define DFF_CHH_COLOR mc_skin_color__cache[38]
#define DFF_CHD_COLOR mc_skin_color__cache[39]
#define DFF_DEL_COLOR mc_skin_color__cache[40]
#define DFF_FOLDER_COLOR mc_skin_color__cache[41]
#define DFF_ERROR_COLOR mc_skin_color__cache[42]
#define MC_SKIN_COLOR_CACHE_COUNT 43
#define DFF_ADD_COLOR mc_skin_color__cache[39]
#define DFF_CHG_COLOR mc_skin_color__cache[40]
#define DFF_CHH_COLOR mc_skin_color__cache[41]
#define DFF_CHD_COLOR mc_skin_color__cache[42]
#define DFF_DEL_COLOR mc_skin_color__cache[43]
#define DFF_FOLDER_COLOR mc_skin_color__cache[44]
#define DFF_ERROR_COLOR mc_skin_color__cache[45]
#define MC_SKIN_COLOR_CACHE_COUNT 46
/*** enums ***************************************************************************************/

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

@ -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"},

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

@ -202,6 +202,7 @@ mc_skin_color_cache_init (void)
SELECTED_COLOR = mc_skin_color_get ("core", "selected");
MARKED_SELECTED_COLOR = mc_skin_color_get ("core", "markselect");
REVERSE_COLOR = mc_skin_color_get ("core", "reverse");
COMMAND_MARK_COLOR = mc_skin_color_get ("core", "commandlinemark");
COLOR_NORMAL = mc_skin_color_get ("dialog", "_default_");
COLOR_FOCUS = mc_skin_color_get ("dialog", "dfocus");
@ -220,6 +221,8 @@ 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_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 = shift-left
InputRightHighlight = shift-right
InputWordLeftHighlight = ctrl-shift-left
InputWordRightHighlight = ctrl-shift-right
InputBolHighlight = shift-home
InputEolHighlight = shift-end
[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

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

@ -320,13 +320,13 @@ mc_args_new_color_group (void)
* FIXME: undocumented keywords: viewunderline, editnormal, editbold,
* and editmarked. To preserve translations, lines should be split.
*/
mc_args__loc__colors_string = g_strdup_printf ("%s%s",
/* TRANSLATORS: don't translate keywords and names of colors */
_("--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"

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

@ -136,6 +136,13 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
int dlg_width = 48, dlg_height = 15;
Dlg_head *dd;
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
/* Controls whether the array strings have been translated */
const char *displays[LIST_TYPES] = {
N_("&Full file list"),
@ -202,7 +209,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
add_widget (dd, cancel_button);
add_widget (dd, ok_button);
display_mini_status = input_new (10, 8, INPUT_COLOR, dlg_width - 12, _status[radio_sel],
display_mini_status = input_new (10, 8, (int *) input_colors, dlg_width - 12, _status[radio_sel],
"mini-input", INPUT_COMPLETE_DEFAULT);
add_widget (dd, display_mini_status);
input_set_point (display_mini_status, 0);
@ -210,7 +217,7 @@ display_init (int radio_sel, char *init_text, int _check_status, char **_status)
display_check_status = check_new (9, 4, _check_status, user_mini_status);
add_widget (dd, display_check_status);
display_user_format = input_new (7, 8, INPUT_COLOR, dlg_width - 12, init_text,
display_user_format = input_new (7, 8, (int *) input_colors, dlg_width - 12, init_text,
"user-fmt-input", INPUT_COMPLETE_DEFAULT);
add_widget (dd, display_user_format);
input_set_point (display_user_format, 0);
@ -1015,6 +1022,13 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
WInput *in_domain;
Dlg_head *auth_dlg;
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
#ifdef ENABLE_NLS
static int i18n_flag = 0;
@ -1063,17 +1077,17 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain, c
g_free (title);
in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT);
in_user = input_new (5, istart, (int *) input_colors, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT);
add_widget (auth_dlg, in_user);
in_domain =
input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT);
in_domain = input_new (3, istart, (int *) input_colors, ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT);
add_widget (auth_dlg, in_domain);
add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON, buts[1], 0));
add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON, buts[0], 0));
in_password =
input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT);
in_password = input_new (7, istart, (int *) input_colors, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT);
in_password->completion_flags = 0;
in_password->is_password = 1;
add_widget (auth_dlg, in_password);

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

@ -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

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

@ -305,8 +305,14 @@ WInput *
command_new (int y, int x, int cols)
{
WInput *cmd;
const int command_colors[3] =
{
DEFAULT_COLOR,
DEFAULT_COLOR,
COMMAND_MARK_COLOR
};
cmd = input_new (y, x, DEFAULT_COLOR, cols, "", "cmdline",
cmd = input_new (y, x, (int *) command_colors, cols, "", "cmdline",
INPUT_COMPLETE_DEFAULT | INPUT_COMPLETE_CD | INPUT_COMPLETE_COMMANDS | INPUT_COMPLETE_SHELL_ESC);
/* Add our hooks */

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

@ -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"

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

@ -312,11 +312,18 @@ int
editcmd_dialog_raw_key_query (const char *heading, const char *query, int cancel)
{
int w = str_term_width1 (query) + 7;
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
struct Dlg_head *raw_dlg =
create_dlg (0, 0, 7, w, dialog_colors, editcmd_dialog_raw_key_query_cb,
NULL, heading, DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
add_widget (raw_dlg,
input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0, INPUT_COMPLETE_DEFAULT));
add_widget (raw_dlg, input_new (3 - cancel, w - 5, (int *) input_colors,
2, "", 0, INPUT_COMPLETE_DEFAULT));
add_widget (raw_dlg, label_new (3 - cancel, 2, query));
if (cancel)
add_widget (raw_dlg, button_new (4, w / 2 - 5, B_CANCEL, NORMAL_BUTTON, _("Cancel"), 0));

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

@ -384,6 +384,13 @@ find_parameters (char **start_dir, char **pattern, char **content)
const char *buts[] = { N_("&OK"), N_("&Cancel"), N_("&Tree") };
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
int b0, b1, b2;
#ifdef ENABLE_NLS
@ -467,20 +474,20 @@ find_parameters (char **start_dir, char **pattern, char **content)
file_case_sens_cbox = check_new (7, 3, options.file_case_sens, file_case_label);
add_widget (find_dlg, file_case_sens_cbox);
in_with = input_new (6, FIND_X / 2 + 1, INPUT_COLOR, FIND_X / 2 - 4, INPUT_LAST_TEXT,
in_with = input_new (6, FIND_X / 2 + 1, (int *) input_colors, FIND_X / 2 - 4, INPUT_LAST_TEXT,
MC_HISTORY_SHARED_SEARCH, INPUT_COMPLETE_DEFAULT);
add_widget (find_dlg, in_with);
add_widget (find_dlg, label_new (5, FIND_X / 2 + 1, _("Content:")));
in_name = input_new (6, 3, INPUT_COLOR, FIND_X / 2 - 4, INPUT_LAST_TEXT, "name",
INPUT_COMPLETE_DEFAULT);
in_name = input_new (6, 3, (int *) input_colors,
FIND_X / 2 - 4, INPUT_LAST_TEXT, "name", INPUT_COMPLETE_DEFAULT);
add_widget (find_dlg, in_name);
add_widget (find_dlg, label_new (5, 3, _("File name:")));
add_widget (find_dlg, button_new (3, FIND_X - b2 - 2, B_TREE, NORMAL_BUTTON, buts[2], 0));
in_start = input_new (3, 3, INPUT_COLOR, FIND_X - b2 - 6, in_start_dir, "start",
INPUT_COMPLETE_DEFAULT);
in_start = input_new (3, 3, (int *) input_colors,
FIND_X - b2 - 6, in_start_dir, "start", INPUT_COMPLETE_DEFAULT);
add_widget (find_dlg, in_start);
add_widget (find_dlg, label_new (2, 3, _("Start at:")));

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

@ -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 },

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

@ -139,6 +139,13 @@ init_panelize (void)
static int i18n_flag = 0;
static int maxlen = 0;
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
if (!i18n_flag)
{
i = sizeof (panelize_but) / sizeof (panelize_but[0]);
@ -176,8 +183,8 @@ init_panelize (void)
panelize_but[i].flags, panelize_but[i].text, 0));
pname =
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",
"in", INPUT_COMPLETE_DEFAULT);
input_new (UY + 14, UX, (int *) input_colors,
panelize_dlg->cols - 10, "", "in", INPUT_COMPLETE_DEFAULT);
add_widget (panelize_dlg, pname);
add_widget (panelize_dlg, label_new (UY + 13, UX, _("Command")));

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

@ -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)
{
@ -1079,22 +1133,52 @@ update_input (WInput * in, int clear_first)
if (has_history)
draw_history_button (in);
if (in->first)
tty_setcolor (in->unchanged_color);
else
tty_setcolor (in->color);
widget_move (&in->widget, 0, 0);
if (!in->is_password)
{
if (!in->highlight)
{
tty_print_string (str_term_substring (in->buffer, in->term_first_shown,
in->field_width - has_history));
}
else
{
cp = in->buffer;
for (i = -in->term_first_shown; i < in->field_width - has_history; i++)
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 = 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')
@ -1103,7 +1187,7 @@ update_input (WInput * in, int clear_first)
}
if (clear_first)
in->first = 0;
in->first = FALSE;
}
void
@ -1512,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);
}
@ -1537,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;
@ -1743,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)
{
@ -1796,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
@ -1920,7 +1993,7 @@ port_region_marked_for_delete (WInput * in)
{
in->buffer[0] = '\0';
in->point = 0;
in->first = 0;
in->first = FALSE;
in->charpoint = 0;
}
@ -1929,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:
@ -1962,9 +2066,27 @@ input_execute_cmd (WInput * in, unsigned long command)
forward_word (in);
break;
case CK_InputBackwardDelete:
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;
case CK_InputKillWord:
@ -2010,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;
}
@ -2158,6 +2290,11 @@ input_event (Gpm_Event * event, void *data)
{
WInput *in = data;
if (event->type & GPM_DOWN)
{
in->first = FALSE;
input_mark_cmd (in, FALSE);
}
if (event->type & (GPM_DOWN | GPM_DRAG))
{
dlg_select_widget (in);
@ -2175,11 +2312,18 @@ 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;
}
WInput *
input_new (int y, int x, int color, int width, const char *def_text,
input_new (int y, int x, int *input_colors, int width, const char *def_text,
const char *histname, INPUT_COMPLETE_FLAGS completion_flags)
{
WInput *in = g_new (WInput, 1);
@ -2212,9 +2356,12 @@ input_new (int y, int x, int color, int width, const char *def_text,
in->completion_flags = completion_flags;
in->current_max_size = initial_buffer_len;
in->buffer = g_new (char, initial_buffer_len);
in->color = color;
in->color = input_colors[0];
in->unchanged_color = input_colors[1];
in->mark_color = input_colors[2];
in->field_width = width;
in->first = 1;
in->first = TRUE;
in->highlight = FALSE;
in->term_first_shown = 0;
in->disable_update = 0;
in->mark = 0;

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

@ -102,11 +102,14 @@ 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 first; /* Is first keystroke? */
int mark_color; /* color for marked text */
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? */
char *buffer; /* pointer to editing buffer */
@ -192,7 +195,9 @@ WButton *button_new (int y, int x, int action, int flags, const char *text,
bcback callback);
WRadio *radio_new (int y, int x, int count, const char **text);
WCheck *check_new (int y, int x, int state, const char *text);
WInput *input_new (int y, int x, int color, int len, const char *text, const char *histname, INPUT_COMPLETE_FLAGS completion_flags);
WInput *input_new (int y, int x, int *input_colors,
int len, const char *text, const char *histname,
INPUT_COMPLETE_FLAGS completion_flags);
WLabel *label_new (int y, int x, const char *text);
WHLine *hline_new (int y, int x, int width);

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

@ -367,6 +367,13 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
WRadio *r;
int return_val;
const int input_colors[3] =
{
INPUT_COLOR,
INPUT_UNCHANGED_COLOR,
INPUT_MARK_COLOR
};
I18N (qd->title);
if ((qd->xpos == -1) || (qd->ypos == -1))
@ -397,10 +404,10 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
break;
case quick_input:
in = input_new (ypos, xpos, INPUT_COLOR, qw->u.input.len,
qw->u.input.text, qw->u.input.histname, INPUT_COMPLETE_DEFAULT);
in = input_new (ypos, xpos, (int *) input_colors,
qw->u.input.len, qw->u.input.text, qw->u.input.histname,
INPUT_COMPLETE_DEFAULT);
in->is_password = (qw->u.input.flags == 1);
in->point = 0;
if ((qw->u.input.flags & 2) != 0)
in->completion_flags |= INPUT_COMPLETE_CD;
qw->widget = (Widget *) in;