added a new parameter for completion flags to input_new
Этот коммит содержится в:
родитель
c825c379c4
Коммит
7639b364af
@ -626,7 +626,7 @@ edit_raw_key_query (const char *heading, const char *query, int cancel)
|
|||||||
NULL, heading,
|
NULL, heading,
|
||||||
DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
|
DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
|
||||||
add_widget (raw_dlg,
|
add_widget (raw_dlg,
|
||||||
input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0));
|
input_new (3 - cancel, w - 5, INPUT_COLOR, 2, "", 0, INPUT_COMPLETE_DEFAULT));
|
||||||
add_widget (raw_dlg, label_new (3 - cancel, 2, query));
|
add_widget (raw_dlg, label_new (3 - cancel, 2, query));
|
||||||
if (cancel)
|
if (cancel)
|
||||||
add_widget (raw_dlg,
|
add_widget (raw_dlg,
|
||||||
|
@ -45,7 +45,7 @@ CHARSET_SRC = charsets.c charsets.h selcodepage.c selcodepage.h
|
|||||||
|
|
||||||
SRCS = achown.c achown.h background.c background.h boxes.c boxes.h \
|
SRCS = achown.c achown.h background.c background.h boxes.c boxes.h \
|
||||||
chmod.c chmod.h chown.c chown.h cmd.c cmd.h color.c color.h \
|
chmod.c chmod.h chown.c chown.h cmd.c cmd.h color.c color.h \
|
||||||
command.c command.h complete.c complete.h cons.handler.c \
|
command.c command.h complete.c cons.handler.c \
|
||||||
cons.saver.h dialog.c dialog.h dir.c dir.h \
|
cons.saver.h dialog.c dialog.h dir.c dir.h \
|
||||||
eregex.h execute.c execute.h ext.c ext.h file.c filegui.c \
|
eregex.h execute.c execute.h ext.c ext.h file.c filegui.c \
|
||||||
filegui.h file.h filenot.c fileopctx.c fileopctx.h find.c \
|
filegui.h file.h filenot.c fileopctx.c fileopctx.h find.c \
|
||||||
|
10
src/boxes.c
10
src/boxes.c
@ -197,7 +197,7 @@ display_init (int radio_sel, char *init_text, int _check_status,
|
|||||||
|
|
||||||
status =
|
status =
|
||||||
input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
|
input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
|
||||||
"mini-input");
|
"mini-input", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (dd, status);
|
add_widget (dd, status);
|
||||||
input_set_point (status, 0);
|
input_set_point (status, 0);
|
||||||
|
|
||||||
@ -207,7 +207,7 @@ display_init (int radio_sel, char *init_text, int _check_status,
|
|||||||
|
|
||||||
user =
|
user =
|
||||||
input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
|
input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
|
||||||
"user-fmt-input");
|
"user-fmt-input", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (dd, user);
|
add_widget (dd, user);
|
||||||
input_set_point (user, 0);
|
input_set_point (user, 0);
|
||||||
|
|
||||||
@ -1085,17 +1085,17 @@ vfs_smb_get_authinfo (const char *host, const char *share, const char *domain,
|
|||||||
|
|
||||||
g_free (title);
|
g_free (title);
|
||||||
|
|
||||||
in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name");
|
in_user = input_new (5, istart, INPUT_COLOR, ilen, user, "auth_name", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (auth_dlg, in_user);
|
add_widget (auth_dlg, in_user);
|
||||||
|
|
||||||
in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain");
|
in_domain = input_new (3, istart, INPUT_COLOR, ilen, domain, "auth_domain", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (auth_dlg, in_domain);
|
add_widget (auth_dlg, in_domain);
|
||||||
add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON,
|
add_widget (auth_dlg, button_new (9, b2, B_CANCEL, NORMAL_BUTTON,
|
||||||
buts[1], 0));
|
buts[1], 0));
|
||||||
add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON,
|
add_widget (auth_dlg, button_new (9, b0, B_ENTER, DEFPUSH_BUTTON,
|
||||||
buts[0], 0));
|
buts[0], 0));
|
||||||
|
|
||||||
in_password = input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password");
|
in_password = input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT);
|
||||||
in_password->completion_flags = 0;
|
in_password->completion_flags = 0;
|
||||||
in_password->is_password = 1;
|
in_password->is_password = 1;
|
||||||
add_widget (auth_dlg, in_password);
|
add_widget (auth_dlg, in_password);
|
||||||
|
@ -34,7 +34,6 @@
|
|||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
#include "widget.h" /* WInput */
|
#include "widget.h" /* WInput */
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "complete.h" /* completion constants */
|
|
||||||
#include "wtools.h" /* message () */
|
#include "wtools.h" /* message () */
|
||||||
#include "panel.h" /* view_tree enum. Also, needed by main.h */
|
#include "panel.h" /* view_tree enum. Also, needed by main.h */
|
||||||
#include "main.h" /* do_cd */
|
#include "main.h" /* do_cd */
|
||||||
@ -295,7 +294,7 @@ command_new (int y, int x, int cols)
|
|||||||
{
|
{
|
||||||
WInput *cmd;
|
WInput *cmd;
|
||||||
|
|
||||||
cmd = input_new (y, x, DEFAULT_COLOR, cols, "", "cmdline");
|
cmd = input_new (y, x, DEFAULT_COLOR, cols, "", "cmdline", INPUT_COMPLETE_DEFAULT);
|
||||||
|
|
||||||
/* Add our hooks */
|
/* Add our hooks */
|
||||||
cmd->widget.callback = command_callback;
|
cmd->widget.callback = command_callback;
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "wtools.h"
|
#include "wtools.h"
|
||||||
#include "complete.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "key.h" /* XCTRL and ALT macros */
|
#include "key.h" /* XCTRL and ALT macros */
|
||||||
@ -58,6 +57,7 @@ static int look_for_executables = 0;
|
|||||||
static char *
|
static char *
|
||||||
filename_completion_function (char *text, int state)
|
filename_completion_function (char *text, int state)
|
||||||
{
|
{
|
||||||
|
fprintf(stderr, "filename_completion_function: text=\"%s\" state=%d\n", text, state);
|
||||||
static DIR *directory;
|
static DIR *directory;
|
||||||
static char *filename = NULL;
|
static char *filename = NULL;
|
||||||
static char *dirname = NULL;
|
static char *dirname = NULL;
|
||||||
@ -89,6 +89,7 @@ filename_completion_function (char *text, int state)
|
|||||||
/* Save the version of the directory that the user typed. */
|
/* Save the version of the directory that the user typed. */
|
||||||
users_dirname = dirname;
|
users_dirname = dirname;
|
||||||
{
|
{
|
||||||
|
// FIXME: memleak ?
|
||||||
dirname = tilde_expand (dirname);
|
dirname = tilde_expand (dirname);
|
||||||
canonicalize_pathname (dirname);
|
canonicalize_pathname (dirname);
|
||||||
/* Here we should do something with variable expansion
|
/* Here we should do something with variable expansion
|
||||||
@ -630,13 +631,15 @@ check_is_cd (const char *text, int start, int flags)
|
|||||||
static char **
|
static char **
|
||||||
try_complete (char *text, int *start, int *end, int flags)
|
try_complete (char *text, int *start, int *end, int flags)
|
||||||
{
|
{
|
||||||
int in_command_position = 0, i;
|
int in_command_position = 0;
|
||||||
char *word, c;
|
char *word, c;
|
||||||
char **matches = NULL;
|
char **matches = NULL;
|
||||||
const char *command_separator_chars = ";|&{(`";
|
const char *command_separator_chars = ";|&{(`";
|
||||||
char *p = NULL, *q = NULL, *r = NULL;
|
char *p = NULL, *q = NULL, *r = NULL;
|
||||||
int is_cd = check_is_cd (text, *start, flags);
|
int is_cd = check_is_cd (text, *start, flags);
|
||||||
|
|
||||||
|
fprintf(stderr, "try_complete() text=\"%s\" start=%d end=%d flags=%d\n", text, *start, *end, flags);
|
||||||
|
|
||||||
ignore_filenames = 0;
|
ignore_filenames = 0;
|
||||||
c = text [*end];
|
c = text [*end];
|
||||||
text [*end] = 0;
|
text [*end] = 0;
|
||||||
@ -648,7 +651,7 @@ try_complete (char *text, int *start, int *end, int flags)
|
|||||||
appears after a character that separates commands. And we have to
|
appears after a character that separates commands. And we have to
|
||||||
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
|
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
|
||||||
if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS)){
|
if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS)){
|
||||||
i = *start - 1;
|
int i = *start - 1;
|
||||||
for (i = *start - 1; i > -1; i--) {
|
for (i = *start - 1; i > -1; i--) {
|
||||||
if (text[i] == ' ' || text[i] == '\t'){
|
if (text[i] == ' ' || text[i] == '\t'){
|
||||||
if (i == 0 ) continue;
|
if (i == 0 ) continue;
|
||||||
@ -691,7 +694,7 @@ try_complete (char *text, int *start, int *end, int flags)
|
|||||||
p = q + 1;
|
p = q + 1;
|
||||||
q = NULL;
|
q = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Command substitution? */
|
/* Command substitution? */
|
||||||
if (p > q && p > r){
|
if (p > q && p > r){
|
||||||
matches = completion_matches (p + 1, command_completion_function);
|
matches = completion_matches (p + 1, command_completion_function);
|
||||||
@ -1035,6 +1038,7 @@ complete_engine (WInput *in, int what_to_do)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//void complete (WInput *in, COMPLETION_STYLE style)
|
||||||
void complete (WInput *in)
|
void complete (WInput *in)
|
||||||
{
|
{
|
||||||
int engine_flags;
|
int engine_flags;
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
#ifndef MC_COMPLETE_H
|
|
||||||
#define MC_COMPLETE_H
|
|
||||||
|
|
||||||
#define INPUT_COMPLETE_FILENAMES 1
|
|
||||||
#define INPUT_COMPLETE_HOSTNAMES 2
|
|
||||||
#define INPUT_COMPLETE_COMMANDS 4
|
|
||||||
#define INPUT_COMPLETE_VARIABLES 8
|
|
||||||
#define INPUT_COMPLETE_USERNAMES 16
|
|
||||||
#define INPUT_COMPLETE_CD 32
|
|
||||||
|
|
||||||
#include "widget.h"
|
|
||||||
|
|
||||||
void free_completions (WInput *);
|
|
||||||
void complete (WInput *);
|
|
||||||
|
|
||||||
#endif
|
|
@ -275,16 +275,16 @@ find_parameters (char **start_dir, char **pattern, char **content)
|
|||||||
add_widget (find_dlg, case_sense);
|
add_widget (find_dlg, case_sense);
|
||||||
|
|
||||||
in_with =
|
in_with =
|
||||||
input_new (8, istart, INPUT_COLOR, ilen, in_contents, "content");
|
input_new (8, istart, INPUT_COLOR, ilen, in_contents, "content", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (find_dlg, in_with);
|
add_widget (find_dlg, in_with);
|
||||||
|
|
||||||
add_widget (find_dlg, recursively_cbox);
|
add_widget (find_dlg, recursively_cbox);
|
||||||
in_name =
|
in_name =
|
||||||
input_new (5, istart, INPUT_COLOR, ilen, in_start_name, "name");
|
input_new (5, istart, INPUT_COLOR, ilen, in_start_name, "name", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (find_dlg, in_name);
|
add_widget (find_dlg, in_name);
|
||||||
|
|
||||||
in_start =
|
in_start =
|
||||||
input_new (3, istart, INPUT_COLOR, ilen, in_start_dir, "start");
|
input_new (3, istart, INPUT_COLOR, ilen, in_start_dir, "start", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (find_dlg, in_start);
|
add_widget (find_dlg, in_start);
|
||||||
|
|
||||||
add_widget (find_dlg, label_new (8, 3, labs[2]));
|
add_widget (find_dlg, label_new (8, 3, labs[2]));
|
||||||
|
@ -66,7 +66,6 @@
|
|||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "command.h"
|
#include "command.h"
|
||||||
#include "wtools.h"
|
#include "wtools.h"
|
||||||
#include "complete.h" /* For the free_completion */
|
|
||||||
|
|
||||||
#include "chmod.h"
|
#include "chmod.h"
|
||||||
#include "chown.h"
|
#include "chown.h"
|
||||||
|
@ -165,7 +165,7 @@ init_panelize (void)
|
|||||||
|
|
||||||
pname =
|
pname =
|
||||||
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",
|
input_new (UY + 14, UX, INPUT_COLOR, panelize_dlg->cols - 10, "",
|
||||||
"in");
|
"in", INPUT_COMPLETE_DEFAULT);
|
||||||
add_widget (panelize_dlg, pname);
|
add_widget (panelize_dlg, pname);
|
||||||
|
|
||||||
add_widget (panelize_dlg, label_new (UY + 13, UX, _("Command")));
|
add_widget (panelize_dlg, label_new (UY + 13, UX, _("Command")));
|
||||||
|
@ -42,7 +42,6 @@
|
|||||||
#include "dialog.h"
|
#include "dialog.h"
|
||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "win.h"
|
#include "win.h"
|
||||||
#include "complete.h"
|
|
||||||
#include "key.h" /* XCTRL and ALT macros */
|
#include "key.h" /* XCTRL and ALT macros */
|
||||||
#include "profile.h" /* for history loading and saving */
|
#include "profile.h" /* for history loading and saving */
|
||||||
#include "wtools.h" /* For common_dialog_repaint() */
|
#include "wtools.h" /* For common_dialog_repaint() */
|
||||||
@ -1659,7 +1658,7 @@ input_event (Gpm_Event * event, void *data)
|
|||||||
|
|
||||||
WInput *
|
WInput *
|
||||||
input_new (int y, int x, int color, int len, const char *def_text,
|
input_new (int y, int x, int color, int len, const char *def_text,
|
||||||
const char *histname)
|
const char *histname, int completion_flags)
|
||||||
{
|
{
|
||||||
WInput *in = g_new (WInput, 1);
|
WInput *in = g_new (WInput, 1);
|
||||||
int initial_buffer_len;
|
int initial_buffer_len;
|
||||||
@ -1688,9 +1687,7 @@ input_new (int y, int x, int color, int len, const char *def_text,
|
|||||||
initial_buffer_len = 1 + max ((size_t) len, strlen (def_text));
|
initial_buffer_len = 1 + max ((size_t) len, strlen (def_text));
|
||||||
in->widget.options |= W_IS_INPUT;
|
in->widget.options |= W_IS_INPUT;
|
||||||
in->completions = NULL;
|
in->completions = NULL;
|
||||||
in->completion_flags =
|
in->completion_flags = completion_flags;
|
||||||
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_HOSTNAMES |
|
|
||||||
INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES;
|
|
||||||
in->current_max_len = initial_buffer_len;
|
in->current_max_len = initial_buffer_len;
|
||||||
in->buffer = g_malloc (initial_buffer_len);
|
in->buffer = g_malloc (initial_buffer_len);
|
||||||
in->color = color;
|
in->color = color;
|
||||||
|
20
src/widget.h
20
src/widget.h
@ -122,12 +122,14 @@ typedef struct WGroupbox {
|
|||||||
char *title;
|
char *title;
|
||||||
} WGroupbox;
|
} WGroupbox;
|
||||||
|
|
||||||
|
/* default completion flags for input widgets */
|
||||||
|
|
||||||
/* Constructors */
|
/* Constructors */
|
||||||
WButton *button_new (int y, int x, int action, int flags, const char *text,
|
WButton *button_new (int y, int x, int action, int flags, const char *text,
|
||||||
bcback callback);
|
bcback callback);
|
||||||
WRadio *radio_new (int y, int x, int count, const char **text);
|
WRadio *radio_new (int y, int x, int count, const char **text);
|
||||||
WCheck *check_new (int y, int x, int state, 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);
|
WInput *input_new (int y, int x, int color, int len, const char *text, const char *histname, int completion_flags);
|
||||||
WLabel *label_new (int y, int x, const char *text);
|
WLabel *label_new (int y, int x, const char *text);
|
||||||
WGauge *gauge_new (int y, int x, int shown, int max, int current);
|
WGauge *gauge_new (int y, int x, int shown, int max, int current);
|
||||||
WListbox *listbox_new (int x, int y, int width, int height, lcback callback);
|
WListbox *listbox_new (int x, int y, int width, int height, lcback callback);
|
||||||
@ -200,4 +202,20 @@ void buttonbar_set_label_data (Dlg_head *h, int idx, const char *text,
|
|||||||
void buttonbar_set_visible (WButtonBar *, gboolean);
|
void buttonbar_set_visible (WButtonBar *, gboolean);
|
||||||
void buttonbar_redraw (Dlg_head *h);
|
void buttonbar_redraw (Dlg_head *h);
|
||||||
|
|
||||||
|
/* Completion stuff */
|
||||||
|
|
||||||
|
#define INPUT_COMPLETE_FILENAMES 1
|
||||||
|
#define INPUT_COMPLETE_HOSTNAMES 2
|
||||||
|
#define INPUT_COMPLETE_COMMANDS 4
|
||||||
|
#define INPUT_COMPLETE_VARIABLES 8
|
||||||
|
#define INPUT_COMPLETE_USERNAMES 16
|
||||||
|
#define INPUT_COMPLETE_CD 32
|
||||||
|
|
||||||
|
#define INPUT_COMPLETE_DEFAULT \
|
||||||
|
( INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_HOSTNAMES | \
|
||||||
|
INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES )
|
||||||
|
|
||||||
|
void free_completions (WInput *);
|
||||||
|
void complete (WInput *);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "widget.h"
|
#include "widget.h"
|
||||||
#include "wtools.h"
|
#include "wtools.h"
|
||||||
#include "key.h" /* mi_getch() */
|
#include "key.h" /* mi_getch() */
|
||||||
#include "complete.h" /* INPUT_COMPLETE_CD */
|
|
||||||
#include "background.h" /* parent_call */
|
#include "background.h" /* parent_call */
|
||||||
|
|
||||||
|
|
||||||
@ -361,7 +360,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
|||||||
case quick_input:
|
case quick_input:
|
||||||
input =
|
input =
|
||||||
input_new (ypos, xpos, INPUT_COLOR, qw->hotkey_pos,
|
input_new (ypos, xpos, INPUT_COLOR, qw->hotkey_pos,
|
||||||
qw->text, qw->histname);
|
qw->text, qw->histname, INPUT_COMPLETE_DEFAULT);
|
||||||
input->is_password = qw->value == 1;
|
input->is_password = qw->value == 1;
|
||||||
input->point = 0;
|
input->point = 0;
|
||||||
if (qw->value & 2)
|
if (qw->value & 2)
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user