Merge branch 'master' of ssh://git.sv.gnu.org/srv/git/weechat
This commit is contained in:
commit
fdcbc8e585
@ -483,6 +483,7 @@ hook_command_build_completion (struct t_hook_command *hook_command)
|
||||
}
|
||||
}
|
||||
}
|
||||
weelist_free (list);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2176,8 +2177,22 @@ unhook (struct t_hook *hook)
|
||||
}
|
||||
free (HOOK_COMMAND(hook, cplt_templates));
|
||||
}
|
||||
if (HOOK_COMMAND(hook, cplt_templates_static))
|
||||
free (HOOK_COMMAND(hook, cplt_templates_static));
|
||||
if (HOOK_COMMAND(hook, cplt_template_num_args))
|
||||
free (HOOK_COMMAND(hook, cplt_template_num_args));
|
||||
if (HOOK_COMMAND(hook, cplt_template_args))
|
||||
free (HOOK_COMMAND(hook, cplt_template_args));
|
||||
if (HOOK_COMMAND(hook, cplt_template_args_concat))
|
||||
{
|
||||
for (i = 0;
|
||||
i < HOOK_COMMAND(hook, cplt_template_num_args_concat);
|
||||
i++)
|
||||
{
|
||||
free (HOOK_COMMAND(hook, cplt_template_args_concat[i]));
|
||||
}
|
||||
free (HOOK_COMMAND(hook, cplt_template_args_concat));
|
||||
}
|
||||
break;
|
||||
case HOOK_TYPE_COMMAND_RUN:
|
||||
if (HOOK_COMMAND_RUN(hook, command))
|
||||
|
@ -1044,11 +1044,17 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
(void) item;
|
||||
(void) window;
|
||||
|
||||
if (!window)
|
||||
window = gui_current_window;
|
||||
|
||||
if (!window->buffer->completion
|
||||
|| !window->buffer->completion->partial_completion_list)
|
||||
return NULL;
|
||||
|
||||
length = 1;
|
||||
for (ptr_item = gui_completion_partial_list; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
for (ptr_item = window->buffer->completion->partial_completion_list;
|
||||
ptr_item; ptr_item = ptr_item->next_item)
|
||||
{
|
||||
length += strlen (ptr_item->word) + 32;
|
||||
}
|
||||
@ -1057,8 +1063,8 @@ gui_bar_item_default_completion (void *data, struct t_gui_bar_item *item,
|
||||
if (buf)
|
||||
{
|
||||
buf[0] = '\0';
|
||||
for (ptr_item = gui_completion_partial_list; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
for (ptr_item = window->buffer->completion->partial_completion_list;
|
||||
ptr_item; ptr_item = ptr_item->next_item)
|
||||
{
|
||||
strcat (buf, GUI_COLOR_CUSTOM_BAR_FG);
|
||||
strcat (buf, ptr_item->word);
|
||||
|
@ -1515,6 +1515,10 @@ gui_buffer_close (struct t_gui_buffer *buffer)
|
||||
|
||||
/* free all lines */
|
||||
gui_line_free_all (buffer);
|
||||
if (buffer->own_lines)
|
||||
free (buffer->own_lines);
|
||||
if (buffer->mixed_lines)
|
||||
free (buffer->mixed_lines);
|
||||
|
||||
/* free some data */
|
||||
if (buffer->title)
|
||||
|
@ -49,10 +49,6 @@
|
||||
#include "gui-nicklist.h"
|
||||
|
||||
|
||||
struct t_gui_completion_partial *gui_completion_partial_list = NULL;
|
||||
struct t_gui_completion_partial *last_gui_completion_partial = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* gui_completion_buffer_init: init completion for a buffer
|
||||
*/
|
||||
@ -80,6 +76,75 @@ gui_completion_buffer_init (struct t_gui_completion *completion,
|
||||
completion->position_replace = 0;
|
||||
completion->diff_size = 0;
|
||||
completion->diff_length = 0;
|
||||
|
||||
completion->partial_completion_list = NULL;
|
||||
completion->last_partial_completion = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_partial_list_add: add an item to partial completions list
|
||||
*/
|
||||
|
||||
struct t_gui_completion_partial *
|
||||
gui_completion_partial_list_add (struct t_gui_completion *completion,
|
||||
const char *word, int count)
|
||||
{
|
||||
struct t_gui_completion_partial *new_item;
|
||||
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (new_item)
|
||||
{
|
||||
new_item->word = strdup (word);
|
||||
new_item->count = count;
|
||||
|
||||
new_item->prev_item = completion->last_partial_completion;
|
||||
if (completion->partial_completion_list)
|
||||
(completion->last_partial_completion)->next_item = new_item;
|
||||
else
|
||||
completion->partial_completion_list = new_item;
|
||||
completion->last_partial_completion = new_item;
|
||||
new_item->next_item = NULL;
|
||||
}
|
||||
return new_item;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_partial_free: remove an item from partial completions list
|
||||
*/
|
||||
|
||||
void
|
||||
gui_completion_partial_list_free (struct t_gui_completion *completion,
|
||||
struct t_gui_completion_partial *item)
|
||||
{
|
||||
/* remove partial completion item from list */
|
||||
if (item->prev_item)
|
||||
(item->prev_item)->next_item = item->next_item;
|
||||
if (item->next_item)
|
||||
(item->next_item)->prev_item = item->prev_item;
|
||||
if (completion->partial_completion_list == item)
|
||||
completion->partial_completion_list = item->next_item;
|
||||
if (completion->last_partial_completion == item)
|
||||
completion->last_partial_completion = item->prev_item;
|
||||
|
||||
/* free data */
|
||||
if (item->word)
|
||||
free (item->word);
|
||||
|
||||
free (item);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_partial_free: remove partial completions list
|
||||
*/
|
||||
|
||||
void
|
||||
gui_completion_partial_list_free_all (struct t_gui_completion *completion)
|
||||
{
|
||||
while (completion->partial_completion_list)
|
||||
{
|
||||
gui_completion_partial_list_free (completion,
|
||||
completion->partial_completion_list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -110,6 +175,8 @@ gui_completion_free_data (struct t_gui_completion *completion)
|
||||
if (completion->word_found)
|
||||
free (completion->word_found);
|
||||
completion->word_found = NULL;
|
||||
|
||||
gui_completion_partial_list_free_all (completion);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -123,68 +190,6 @@ gui_completion_free (struct t_gui_completion *completion)
|
||||
free (completion);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_partial_list_add: add an item to partial completions list
|
||||
*/
|
||||
|
||||
struct t_gui_completion_partial *
|
||||
gui_completion_partial_list_add (const char *word, int count)
|
||||
{
|
||||
struct t_gui_completion_partial *new_item;
|
||||
|
||||
new_item = malloc (sizeof (*new_item));
|
||||
if (new_item)
|
||||
{
|
||||
new_item->word = strdup (word);
|
||||
new_item->count = count;
|
||||
|
||||
new_item->prev_item = last_gui_completion_partial;
|
||||
if (gui_completion_partial_list)
|
||||
last_gui_completion_partial->next_item = new_item;
|
||||
else
|
||||
gui_completion_partial_list = new_item;
|
||||
last_gui_completion_partial = new_item;
|
||||
new_item->next_item = NULL;
|
||||
}
|
||||
return new_item;
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_partial_free: remove an item from partial completions list
|
||||
*/
|
||||
|
||||
void
|
||||
gui_completion_partial_list_free (struct t_gui_completion_partial *item)
|
||||
{
|
||||
/* remove partial completion item from list */
|
||||
if (item->prev_item)
|
||||
(item->prev_item)->next_item = item->next_item;
|
||||
if (item->next_item)
|
||||
(item->next_item)->prev_item = item->prev_item;
|
||||
if (gui_completion_partial_list == item)
|
||||
gui_completion_partial_list = item->next_item;
|
||||
if (last_gui_completion_partial == item)
|
||||
last_gui_completion_partial = item->prev_item;
|
||||
|
||||
/* free data */
|
||||
if (item->word)
|
||||
free (item->word);
|
||||
free (item);
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_partial_free: remove partial completions list
|
||||
*/
|
||||
|
||||
void
|
||||
gui_completion_partial_list_free_all ()
|
||||
{
|
||||
while (gui_completion_partial_list)
|
||||
{
|
||||
gui_completion_partial_list_free (gui_completion_partial_list);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_completion_stop: stop completion (for example after 1 arg of command
|
||||
* with 1 arg)
|
||||
@ -198,7 +203,7 @@ gui_completion_stop (struct t_gui_completion *completion,
|
||||
completion->position = -1;
|
||||
if (remove_partial_completion_list)
|
||||
{
|
||||
gui_completion_partial_list_free_all ();
|
||||
gui_completion_partial_list_free_all (completion);
|
||||
hook_signal_send ("partial_completion",
|
||||
WEECHAT_HOOK_SIGNAL_STRING, NULL);
|
||||
}
|
||||
@ -1699,10 +1704,10 @@ gui_completion_partial_build_list (struct t_gui_completion *completion,
|
||||
{
|
||||
int char_size, items_count;
|
||||
char utf_char[16], *word;
|
||||
struct t_weelist *weelist_temp, *weelist_words;
|
||||
struct t_weelist *weelist_temp;
|
||||
struct t_weelist_item *ptr_item, *next_item;
|
||||
|
||||
gui_completion_partial_list_free_all ();
|
||||
gui_completion_partial_list_free_all (completion);
|
||||
|
||||
if (!completion->completion_list || !completion->completion_list->items)
|
||||
return;
|
||||
@ -1711,13 +1716,6 @@ gui_completion_partial_build_list (struct t_gui_completion *completion,
|
||||
if (!weelist_temp)
|
||||
return;
|
||||
|
||||
weelist_words = weelist_new ();
|
||||
if (!weelist_words)
|
||||
{
|
||||
weelist_free (weelist_temp);
|
||||
return;
|
||||
}
|
||||
|
||||
for (ptr_item = completion->completion_list->items; ptr_item;
|
||||
ptr_item = ptr_item->next_item)
|
||||
{
|
||||
@ -1754,7 +1752,8 @@ gui_completion_partial_build_list (struct t_gui_completion *completion,
|
||||
}
|
||||
if (word)
|
||||
{
|
||||
gui_completion_partial_list_add (word,
|
||||
gui_completion_partial_list_add (completion,
|
||||
word,
|
||||
CONFIG_BOOLEAN(config_completion_partial_completion_count) ?
|
||||
items_count : -1);
|
||||
free (word);
|
||||
@ -1900,7 +1899,7 @@ gui_completion_complete (struct t_gui_completion *completion)
|
||||
return;
|
||||
}
|
||||
|
||||
gui_completion_partial_list_free_all ();
|
||||
gui_completion_partial_list_free_all (completion);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -2057,6 +2056,8 @@ gui_completion_search (struct t_gui_completion *completion, int direction,
|
||||
void
|
||||
gui_completion_print_log (struct t_gui_completion *completion)
|
||||
{
|
||||
struct t_gui_completion_partial *ptr_item;
|
||||
|
||||
log_printf ("[completion (addr:0x%lx)]", completion);
|
||||
log_printf (" buffer. . . . . . . . . : 0x%lx", completion->buffer);
|
||||
log_printf (" context . . . . . . . . : %d", completion->context);
|
||||
@ -2081,6 +2082,19 @@ gui_completion_print_log (struct t_gui_completion *completion)
|
||||
weelist_print_log (completion->completion_list,
|
||||
"completion list element");
|
||||
}
|
||||
if (completion->partial_completion_list)
|
||||
{
|
||||
log_printf ("");
|
||||
for (ptr_item = completion->partial_completion_list;
|
||||
ptr_item; ptr_item = ptr_item->next_item)
|
||||
{
|
||||
log_printf ("[partial completion item (addr:0x%lx)]", ptr_item);
|
||||
log_printf (" word. . . . . . . . . . : '%s'", ptr_item->word);
|
||||
log_printf (" count . . . . . . . . . : %d", ptr_item->count);
|
||||
log_printf (" prev_item . . . . . . . : 0x%lx", ptr_item->prev_item);
|
||||
log_printf (" next_item . . . . . . . : 0x%lx", ptr_item->next_item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -25,6 +25,14 @@
|
||||
#define GUI_COMPLETION_COMMAND_ARG 2
|
||||
#define GUI_COMPLETION_AUTO 3
|
||||
|
||||
struct t_gui_completion_partial
|
||||
{
|
||||
char *word; /* (partial) word matching completion */
|
||||
int count; /* number of matching items with this word */
|
||||
struct t_gui_completion_partial *prev_item;
|
||||
struct t_gui_completion_partial *next_item;
|
||||
};
|
||||
|
||||
struct t_gui_completion
|
||||
{
|
||||
/* completion context */
|
||||
@ -49,18 +57,12 @@ struct t_gui_completion
|
||||
int position_replace; /* position where word has to be replaced */
|
||||
int diff_size; /* size difference (< 0 = char(s) deleted) */
|
||||
int diff_length; /* length difference (<= diff_size) */
|
||||
};
|
||||
|
||||
struct t_gui_completion_partial
|
||||
{
|
||||
char *word; /* (partial) word matching completion */
|
||||
int count; /* number of matching items with this word */
|
||||
struct t_gui_completion_partial *prev_item;
|
||||
struct t_gui_completion_partial *next_item;
|
||||
/* partial completion */
|
||||
struct t_gui_completion_partial *partial_completion_list;
|
||||
struct t_gui_completion_partial *last_partial_completion;
|
||||
};
|
||||
|
||||
extern struct t_gui_completion_partial *gui_completion_partial_list;
|
||||
|
||||
/* completion functions */
|
||||
|
||||
extern void gui_completion_buffer_init (struct t_gui_completion *completion,
|
||||
|
Loading…
x
Reference in New Issue
Block a user