mirror of
https://github.com/MidnightCommander/mc
synced 2025-03-11 18:32:53 +03:00
Input complete: refactoring.
* (complete): rename to input_complete() and move declaration to input.h. * input_complete.h: remove. * (input_free_completions): rename to input_complete_free() and move definition to input_complete.c. * lib/widget/input_complete.c: rename variables and function from query_* to complete_*. Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
parent
178f88bdd9
commit
c9e2a4400e
@ -15,7 +15,7 @@ libmcwidget_la_SOURCES = \
|
||||
hline.c hline.h \
|
||||
history.c history.h \
|
||||
input.c input.h \
|
||||
input_complete.c input_complete.h \
|
||||
input_complete.c \
|
||||
listbox-window.c listbox-window.h \
|
||||
listbox.c listbox.h \
|
||||
label.c label.h \
|
||||
|
@ -50,8 +50,6 @@
|
||||
#include "lib/event.h" /* mc_event_raise() */
|
||||
#include "lib/mcconfig.h" /* mc_config_history_*() */
|
||||
|
||||
#include "input_complete.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
gboolean quote = FALSE;
|
||||
@ -808,7 +806,7 @@ input_execute_cmd (WInput * in, long command)
|
||||
do_show_hist (in);
|
||||
break;
|
||||
case CK_Complete:
|
||||
complete (in);
|
||||
input_complete (in);
|
||||
break;
|
||||
default:
|
||||
res = MSG_NOT_HANDLED;
|
||||
@ -897,7 +895,7 @@ input_destroy (WInput * in)
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
|
||||
/* clean history */
|
||||
if (in->history.list != NULL)
|
||||
@ -1132,7 +1130,7 @@ input_handle_char (WInput * in, int key)
|
||||
|
||||
if (quote)
|
||||
{
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
v = insert_char (in, key);
|
||||
input_update (in, TRUE);
|
||||
quote = FALSE;
|
||||
@ -1146,13 +1144,13 @@ input_handle_char (WInput * in, int key)
|
||||
return MSG_NOT_HANDLED;
|
||||
if (in->first)
|
||||
port_region_marked_for_delete (in);
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
v = insert_char (in, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (command != CK_Complete)
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
input_execute_cmd (in, command);
|
||||
v = MSG_HANDLED;
|
||||
if (in->first)
|
||||
@ -1174,7 +1172,7 @@ input_assign_text (WInput * in, const char *text)
|
||||
if (text == NULL)
|
||||
text = "";
|
||||
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
in->mark = -1;
|
||||
in->need_push = TRUE;
|
||||
in->charpoint = 0;
|
||||
@ -1222,7 +1220,7 @@ input_set_point (WInput * in, int pos)
|
||||
max_pos = str_length (in->buffer);
|
||||
pos = MIN (pos, max_pos);
|
||||
if (pos != in->point)
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
in->point = pos;
|
||||
in->charpoint = 0;
|
||||
input_update (in, TRUE);
|
||||
@ -1365,17 +1363,8 @@ input_clean (WInput * in)
|
||||
in->point = 0;
|
||||
in->charpoint = 0;
|
||||
in->mark = -1;
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
input_update (in, FALSE);
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
input_free_completions (WInput * in)
|
||||
{
|
||||
g_strfreev (in->completions);
|
||||
in->completions = NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -98,7 +98,10 @@ void input_update (WInput * in, gboolean clear_first);
|
||||
void input_enable_update (WInput * in);
|
||||
void input_disable_update (WInput * in);
|
||||
void input_clean (WInput * in);
|
||||
void input_free_completions (WInput * in);
|
||||
|
||||
/* input_complete.c */
|
||||
void input_complete (WInput * in);
|
||||
void input_complete_free (WInput * in);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
|
@ -53,8 +53,6 @@
|
||||
#include "lib/util.h"
|
||||
#include "lib/widget.h"
|
||||
|
||||
#include "input_complete.h"
|
||||
|
||||
/*** global variables ****************************************************************************/
|
||||
|
||||
/* Linux declares environ in <unistd.h>, so don't repeat it here. */
|
||||
@ -95,7 +93,7 @@ static char **hosts = NULL;
|
||||
static char **hosts_p = NULL;
|
||||
static int hosts_alloclen = 0;
|
||||
|
||||
static int query_height, query_width;
|
||||
static int complete_height, complete_width;
|
||||
static WInput *input;
|
||||
static int min_end;
|
||||
static int start = 0;
|
||||
@ -1015,7 +1013,7 @@ insert_text (WInput * in, char *text, ssize_t size)
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
static cb_ret_t
|
||||
query_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
complete_callback (Widget * w, Widget * sender, widget_msg_t msg, int parm, void *data)
|
||||
{
|
||||
static int bl = 0;
|
||||
|
||||
@ -1198,7 +1196,7 @@ static gboolean
|
||||
complete_engine (WInput * in, int what_to_do)
|
||||
{
|
||||
if (in->completions != NULL && str_offset_to_pos (in->buffer, in->point) != end)
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
|
||||
if (in->completions == NULL)
|
||||
complete_engine_fill_completions (in);
|
||||
@ -1215,7 +1213,7 @@ complete_engine (WInput * in, int what_to_do)
|
||||
if (!insert_text (in, lc_complete, strlen (lc_complete)) || in->completions[1] != NULL)
|
||||
tty_beep ();
|
||||
else
|
||||
input_free_completions (in);
|
||||
input_complete_free (in);
|
||||
}
|
||||
|
||||
if ((what_to_do & DO_QUERY) != 0 && in->completions != NULL && in->completions[1] != NULL)
|
||||
@ -1224,8 +1222,8 @@ complete_engine (WInput * in, int what_to_do)
|
||||
int x, y, w, h;
|
||||
int start_x, start_y;
|
||||
char **p, *q;
|
||||
WDialog *query_dlg;
|
||||
WListbox *query_list;
|
||||
WDialog *complete_dlg;
|
||||
WListbox *complete_list;
|
||||
|
||||
for (p = in->completions + 1; *p != NULL; count++, p++)
|
||||
{
|
||||
@ -1262,28 +1260,29 @@ complete_engine (WInput * in, int what_to_do)
|
||||
|
||||
input = in;
|
||||
min_end = end;
|
||||
query_height = h;
|
||||
query_width = w;
|
||||
complete_height = h;
|
||||
complete_width = w;
|
||||
|
||||
query_dlg = dlg_create (TRUE, y, x, query_height, query_width, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, query_callback, NULL, "[Completion]", NULL);
|
||||
query_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
|
||||
group_add_widget (GROUP (query_dlg), query_list);
|
||||
complete_dlg =
|
||||
dlg_create (TRUE, y, x, complete_height, complete_width, WPOS_KEEP_DEFAULT, TRUE,
|
||||
dialog_colors, complete_callback, NULL, "[Completion]", NULL);
|
||||
complete_list = listbox_new (1, 1, h - 2, w - 2, FALSE, NULL);
|
||||
group_add_widget (GROUP (complete_dlg), complete_list);
|
||||
|
||||
for (p = in->completions + 1; *p != NULL; p++)
|
||||
listbox_add_item (query_list, LISTBOX_APPEND_AT_END, 0, *p, NULL, FALSE);
|
||||
listbox_add_item (complete_list, LISTBOX_APPEND_AT_END, 0, *p, NULL, FALSE);
|
||||
|
||||
i = dlg_run (query_dlg);
|
||||
i = dlg_run (complete_dlg);
|
||||
q = NULL;
|
||||
if (i == B_ENTER)
|
||||
{
|
||||
listbox_get_current (query_list, &q, NULL);
|
||||
listbox_get_current (complete_list, &q, NULL);
|
||||
if (q != NULL)
|
||||
insert_text (in, q, strlen (q));
|
||||
}
|
||||
if (q != NULL || end != min_end)
|
||||
input_free_completions (in);
|
||||
dlg_destroy (query_dlg);
|
||||
input_complete_free (in);
|
||||
dlg_destroy (complete_dlg);
|
||||
|
||||
/* B_USER if user wants to start over again */
|
||||
return (i == B_USER);
|
||||
@ -1437,7 +1436,7 @@ complete_engine_fill_completions (WInput * in)
|
||||
|
||||
/* declared in lib/widget/input.h */
|
||||
void
|
||||
complete (WInput * in)
|
||||
input_complete (WInput * in)
|
||||
{
|
||||
int engine_flags;
|
||||
|
||||
@ -1459,3 +1458,12 @@ complete (WInput * in)
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
||||
void
|
||||
input_complete_free (WInput * in)
|
||||
{
|
||||
g_strfreev (in->completions);
|
||||
in->completions = NULL;
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------------------------------------------- */
|
||||
|
@ -1,18 +0,0 @@
|
||||
#ifndef MC__WIDGET_INPUT_COMPLETE_H
|
||||
#define MC__WIDGET_INPUT_COMPLETE_H
|
||||
|
||||
/*** typedefs(not structures) and defined constants **********************************************/
|
||||
|
||||
/*** enums ***************************************************************************************/
|
||||
|
||||
/*** structures declarations (and typedefs of structures)*****************************************/
|
||||
|
||||
/*** global variables defined in .c file *********************************************************/
|
||||
|
||||
/*** declarations of public functions ************************************************************/
|
||||
|
||||
void complete (WInput * in);
|
||||
|
||||
/*** inline functions ****************************************************************************/
|
||||
|
||||
#endif /* MC__WIDGET_INPUT_COMPLETE_H */
|
@ -1776,7 +1776,7 @@ load_hint (gboolean force)
|
||||
void
|
||||
change_panel (void)
|
||||
{
|
||||
input_free_completions (cmdline);
|
||||
input_complete_free (cmdline);
|
||||
group_select_next_widget (GROUP (midnight_dlg));
|
||||
}
|
||||
|
||||
|
@ -3268,7 +3268,7 @@ _do_panel_cd (WPanel * panel, const vfs_path_t * new_dir_vpath, enum cd_enum cd_
|
||||
/* Success: save previous directory, shutdown status of previous dir */
|
||||
olddir_vpath = vfs_path_clone (panel->cwd_vpath);
|
||||
panel_set_lwd (panel, panel->cwd_vpath);
|
||||
input_free_completions (cmdline);
|
||||
input_complete_free (cmdline);
|
||||
|
||||
vfs_path_free (panel->cwd_vpath);
|
||||
vfs_setup_cwd ();
|
||||
|
Loading…
x
Reference in New Issue
Block a user