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,
|
||||
DLG_CENTER | DLG_TRYUP | DLG_WANT_TAB);
|
||||
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));
|
||||
if (cancel)
|
||||
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 \
|
||||
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 \
|
||||
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 \
|
||||
|
10
src/boxes.c
10
src/boxes.c
@ -197,7 +197,7 @@ display_init (int radio_sel, char *init_text, int _check_status,
|
||||
|
||||
status =
|
||||
input_new (10, 9, INPUT_COLOR, DISPLAY_X - 14, _status[radio_sel],
|
||||
"mini-input");
|
||||
"mini-input", INPUT_COMPLETE_DEFAULT);
|
||||
add_widget (dd, status);
|
||||
input_set_point (status, 0);
|
||||
|
||||
@ -207,7 +207,7 @@ display_init (int radio_sel, char *init_text, int _check_status,
|
||||
|
||||
user =
|
||||
input_new (7, 9, INPUT_COLOR, DISPLAY_X - 14, init_text,
|
||||
"user-fmt-input");
|
||||
"user-fmt-input", INPUT_COMPLETE_DEFAULT);
|
||||
add_widget (dd, user);
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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, 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");
|
||||
in_password = input_new (7, istart, INPUT_COLOR, ilen, "", "auth_password", INPUT_COMPLETE_DEFAULT);
|
||||
in_password->completion_flags = 0;
|
||||
in_password->is_password = 1;
|
||||
add_widget (auth_dlg, in_password);
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "tty.h"
|
||||
#include "widget.h" /* WInput */
|
||||
#include "command.h"
|
||||
#include "complete.h" /* completion constants */
|
||||
#include "wtools.h" /* message () */
|
||||
#include "panel.h" /* view_tree enum. Also, needed by main.h */
|
||||
#include "main.h" /* do_cd */
|
||||
@ -295,7 +294,7 @@ command_new (int y, int x, int cols)
|
||||
{
|
||||
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 */
|
||||
cmd->widget.callback = command_callback;
|
||||
|
@ -41,7 +41,6 @@
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
#include "wtools.h"
|
||||
#include "complete.h"
|
||||
#include "main.h"
|
||||
#include "util.h"
|
||||
#include "key.h" /* XCTRL and ALT macros */
|
||||
@ -58,6 +57,7 @@ static int look_for_executables = 0;
|
||||
static char *
|
||||
filename_completion_function (char *text, int state)
|
||||
{
|
||||
fprintf(stderr, "filename_completion_function: text=\"%s\" state=%d\n", text, state);
|
||||
static DIR *directory;
|
||||
static char *filename = 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. */
|
||||
users_dirname = dirname;
|
||||
{
|
||||
// FIXME: memleak ?
|
||||
dirname = tilde_expand (dirname);
|
||||
canonicalize_pathname (dirname);
|
||||
/* Here we should do something with variable expansion
|
||||
@ -630,13 +631,15 @@ check_is_cd (const char *text, int start, int flags)
|
||||
static char **
|
||||
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 **matches = NULL;
|
||||
const char *command_separator_chars = ";|&{(`";
|
||||
char *p = NULL, *q = NULL, *r = NULL;
|
||||
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;
|
||||
c = text [*end];
|
||||
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
|
||||
be in a INPUT_COMPLETE_COMMANDS flagged Input line. */
|
||||
if (!is_cd && (flags & INPUT_COMPLETE_COMMANDS)){
|
||||
i = *start - 1;
|
||||
int i = *start - 1;
|
||||
for (i = *start - 1; i > -1; i--) {
|
||||
if (text[i] == ' ' || text[i] == '\t'){
|
||||
if (i == 0 ) continue;
|
||||
@ -691,7 +694,7 @@ try_complete (char *text, int *start, int *end, int flags)
|
||||
p = q + 1;
|
||||
q = NULL;
|
||||
}
|
||||
|
||||
|
||||
/* Command substitution? */
|
||||
if (p > q && p > r){
|
||||
matches = completion_matches (p + 1, command_completion_function);
|
||||
@ -1035,6 +1038,7 @@ complete_engine (WInput *in, int what_to_do)
|
||||
return 0;
|
||||
}
|
||||
|
||||
//void complete (WInput *in, COMPLETION_STYLE style)
|
||||
void complete (WInput *in)
|
||||
{
|
||||
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);
|
||||
|
||||
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, recursively_cbox);
|
||||
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);
|
||||
|
||||
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, label_new (8, 3, labs[2]));
|
||||
|
@ -66,7 +66,6 @@
|
||||
#include "widget.h"
|
||||
#include "command.h"
|
||||
#include "wtools.h"
|
||||
#include "complete.h" /* For the free_completion */
|
||||
|
||||
#include "chmod.h"
|
||||
#include "chown.h"
|
||||
|
@ -165,7 +165,7 @@ init_panelize (void)
|
||||
|
||||
pname =
|
||||
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, label_new (UY + 13, UX, _("Command")));
|
||||
|
@ -42,7 +42,6 @@
|
||||
#include "dialog.h"
|
||||
#include "widget.h"
|
||||
#include "win.h"
|
||||
#include "complete.h"
|
||||
#include "key.h" /* XCTRL and ALT macros */
|
||||
#include "profile.h" /* for history loading and saving */
|
||||
#include "wtools.h" /* For common_dialog_repaint() */
|
||||
@ -1659,7 +1658,7 @@ input_event (Gpm_Event * event, void *data)
|
||||
|
||||
WInput *
|
||||
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);
|
||||
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));
|
||||
in->widget.options |= W_IS_INPUT;
|
||||
in->completions = NULL;
|
||||
in->completion_flags =
|
||||
INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_HOSTNAMES |
|
||||
INPUT_COMPLETE_VARIABLES | INPUT_COMPLETE_USERNAMES;
|
||||
in->completion_flags = completion_flags;
|
||||
in->current_max_len = initial_buffer_len;
|
||||
in->buffer = g_malloc (initial_buffer_len);
|
||||
in->color = color;
|
||||
|
20
src/widget.h
20
src/widget.h
@ -122,12 +122,14 @@ typedef struct WGroupbox {
|
||||
char *title;
|
||||
} WGroupbox;
|
||||
|
||||
/* default completion flags for input widgets */
|
||||
|
||||
/* Constructors */
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
@ -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_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
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "widget.h"
|
||||
#include "wtools.h"
|
||||
#include "key.h" /* mi_getch() */
|
||||
#include "complete.h" /* INPUT_COMPLETE_CD */
|
||||
#include "background.h" /* parent_call */
|
||||
|
||||
|
||||
@ -361,7 +360,7 @@ quick_dialog_skip (QuickDialog *qd, int nskip)
|
||||
case quick_input:
|
||||
input =
|
||||
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->point = 0;
|
||||
if (qw->value & 2)
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user