mirror of
https://github.com/weechat/weechat.git
synced 2026-07-05 09:13:14 +02:00
ctrl-up/ctrl-down keys added to call previous/next command in global history (common to all buffers)
This commit is contained in:
+32
-32
@@ -17,7 +17,7 @@
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* history.c: memorize and call again commands or text */
|
||||
/* history.c: memorize commands or text */
|
||||
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
@@ -33,10 +33,10 @@
|
||||
#include "../gui/gui.h"
|
||||
|
||||
|
||||
t_history *history_general = NULL;
|
||||
t_history *history_general_last = NULL;
|
||||
t_history *history_general_ptr = NULL;
|
||||
int num_history_general = 0;
|
||||
t_history *history_global = NULL;
|
||||
t_history *history_global_last = NULL;
|
||||
t_history *history_global_ptr = NULL;
|
||||
int num_history_global = 0;
|
||||
|
||||
|
||||
/*
|
||||
@@ -74,7 +74,7 @@ history_add (void *buffer, char *string)
|
||||
{
|
||||
t_history *new_history, *ptr_history;
|
||||
|
||||
/* add history to general history */
|
||||
/* add history to global history */
|
||||
new_history = (t_history *)malloc (sizeof (t_history));
|
||||
if (new_history)
|
||||
{
|
||||
@@ -82,26 +82,26 @@ history_add (void *buffer, char *string)
|
||||
if (cfg_log_hide_nickserv_pwd)
|
||||
history_hide_password (new_history->text);
|
||||
|
||||
if (history_general)
|
||||
history_general->prev_history = new_history;
|
||||
if (history_global)
|
||||
history_global->prev_history = new_history;
|
||||
else
|
||||
history_general_last = new_history;
|
||||
new_history->next_history = history_general;
|
||||
history_global_last = new_history;
|
||||
new_history->next_history = history_global;
|
||||
new_history->prev_history = NULL;
|
||||
history_general = new_history;
|
||||
num_history_general++;
|
||||
history_global = new_history;
|
||||
num_history_global++;
|
||||
|
||||
/* remove one command if necessary */
|
||||
if ((cfg_history_max_commands > 0)
|
||||
&& (num_history_general > cfg_history_max_commands))
|
||||
&& (num_history_global > cfg_history_max_commands))
|
||||
{
|
||||
ptr_history = history_general_last->prev_history;
|
||||
history_general_last->prev_history->next_history = NULL;
|
||||
if (history_general_last->text)
|
||||
free (history_general_last->text);
|
||||
free (history_general_last);
|
||||
history_general_last = ptr_history;
|
||||
num_history_general--;
|
||||
ptr_history = history_global_last->prev_history;
|
||||
history_global_last->prev_history->next_history = NULL;
|
||||
if (history_global_last->text)
|
||||
free (history_global_last->text);
|
||||
free (history_global_last);
|
||||
history_global_last = ptr_history;
|
||||
num_history_global--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,26 +138,26 @@ history_add (void *buffer, char *string)
|
||||
}
|
||||
|
||||
/*
|
||||
* history_general_free: free general history
|
||||
* history_global_free: free global history
|
||||
*/
|
||||
|
||||
void
|
||||
history_general_free ()
|
||||
history_global_free ()
|
||||
{
|
||||
t_history *ptr_history;
|
||||
|
||||
while (history_general)
|
||||
while (history_global)
|
||||
{
|
||||
ptr_history = history_general->next_history;
|
||||
if (history_general->text)
|
||||
free (history_general->text);
|
||||
free (history_general);
|
||||
history_general = ptr_history;
|
||||
ptr_history = history_global->next_history;
|
||||
if (history_global->text)
|
||||
free (history_global->text);
|
||||
free (history_global);
|
||||
history_global = ptr_history;
|
||||
}
|
||||
history_general = NULL;
|
||||
history_general_last = NULL;
|
||||
history_general_ptr = NULL;
|
||||
num_history_general = 0;
|
||||
history_global = NULL;
|
||||
history_global_last = NULL;
|
||||
history_global_ptr = NULL;
|
||||
num_history_global = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -30,8 +30,12 @@ struct t_history
|
||||
t_history *prev_history; /* link to previous text/command */
|
||||
};
|
||||
|
||||
extern t_history *history_global;
|
||||
extern t_history *history_global_last;
|
||||
extern t_history *history_global_ptr;
|
||||
|
||||
extern void history_add (void *, char *);
|
||||
extern void history_general_free ();
|
||||
extern void history_global_free ();
|
||||
extern void history_buffer_free (void *);
|
||||
|
||||
#endif /* history.h */
|
||||
|
||||
@@ -2465,8 +2465,8 @@ gui_end ()
|
||||
while (gui_windows)
|
||||
gui_window_free (gui_windows);
|
||||
|
||||
/* delete general history */
|
||||
history_general_free ();
|
||||
/* delete global history */
|
||||
history_global_free ();
|
||||
|
||||
/* delete infobar messages */
|
||||
while (gui_infobar)
|
||||
|
||||
@@ -75,7 +75,9 @@ gui_input_default_key_bindings ()
|
||||
gui_key_bind ( /* left */ "meta2-D", "left");
|
||||
gui_key_bind ( /* right */ "meta2-C", "right");
|
||||
gui_key_bind ( /* up */ "meta2-A", "up");
|
||||
gui_key_bind ( /* ^up */ "meta-Oa", "up_global");
|
||||
gui_key_bind ( /* down */ "meta2-B", "down");
|
||||
gui_key_bind ( /* ^down */ "meta-Ob", "down_global");
|
||||
gui_key_bind ( /* pgup */ "meta2-5~", "page_up");
|
||||
gui_key_bind ( /* pgdn */ "meta2-6~", "page_down");
|
||||
gui_key_bind ( /* F10 */ "meta2-21~", "infobar_clear");
|
||||
|
||||
@@ -36,6 +36,7 @@
|
||||
#include "gui.h"
|
||||
#include "../common/command.h"
|
||||
#include "../common/weeconfig.h"
|
||||
#include "../common/history.h"
|
||||
#include "../common/hotlist.h"
|
||||
#include "../common/log.h"
|
||||
#include "../irc/irc.h"
|
||||
@@ -1327,6 +1328,37 @@ gui_input_up ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_up_global: recall last command in global history
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_up_global ()
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
if (history_global_ptr)
|
||||
{
|
||||
history_global_ptr = history_global_ptr->next_history;
|
||||
if (!history_global_ptr)
|
||||
history_global_ptr = history_global;
|
||||
}
|
||||
else
|
||||
history_global_ptr = history_global;
|
||||
if (history_global_ptr)
|
||||
{
|
||||
gui_current_window->buffer->input_buffer_size =
|
||||
strlen (history_global_ptr->text);
|
||||
gui_input_optimize_buffer_size (gui_current_window->buffer);
|
||||
gui_current_window->buffer->input_buffer_pos =
|
||||
gui_current_window->buffer->input_buffer_size;
|
||||
strcpy (gui_current_window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_down: recall next command or move to next DCC in list
|
||||
*/
|
||||
@@ -1385,6 +1417,34 @@ gui_input_down ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_down_global: recall next command in global history
|
||||
*/
|
||||
|
||||
void
|
||||
gui_input_down_global ()
|
||||
{
|
||||
if (gui_current_window->buffer->has_input)
|
||||
{
|
||||
if (history_global_ptr)
|
||||
{
|
||||
history_global_ptr = history_global_ptr->prev_history;
|
||||
if (history_global_ptr)
|
||||
gui_current_window->buffer->input_buffer_size =
|
||||
strlen (history_global_ptr->text);
|
||||
else
|
||||
gui_current_window->buffer->input_buffer_size = 0;
|
||||
gui_input_optimize_buffer_size (gui_current_window->buffer);
|
||||
gui_current_window->buffer->input_buffer_pos =
|
||||
gui_current_window->buffer->input_buffer_size;
|
||||
if (history_global_ptr)
|
||||
strcpy (gui_current_window->buffer->input_buffer,
|
||||
history_global_ptr->text);
|
||||
gui_draw_buffer_input (gui_current_window->buffer, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* gui_input_jump_smart: jump to buffer with activity (alt-A by default)
|
||||
*/
|
||||
|
||||
@@ -77,8 +77,12 @@ t_gui_key_function gui_key_functions[] =
|
||||
N_("move to next word") },
|
||||
{ "up", gui_input_up,
|
||||
N_("call previous command in history") },
|
||||
{ "up_global", gui_input_up_global,
|
||||
N_("call previous command in global history") },
|
||||
{ "down", gui_input_down,
|
||||
N_("call next command in history") },
|
||||
{ "down_global", gui_input_down_global,
|
||||
N_("call next command in global history") },
|
||||
{ "page_up", gui_input_page_up,
|
||||
N_("scroll one page up") },
|
||||
{ "page_down", gui_input_page_down,
|
||||
|
||||
@@ -336,7 +336,9 @@ extern void gui_input_previous_word ();
|
||||
extern void gui_input_right ();
|
||||
extern void gui_input_next_word ();
|
||||
extern void gui_input_up ();
|
||||
extern void gui_input_up_global ();
|
||||
extern void gui_input_down ();
|
||||
extern void gui_input_down_global ();
|
||||
extern void gui_input_jump_smart ();
|
||||
extern void gui_input_jump_dcc ();
|
||||
extern void gui_input_jump_last_buffer ();
|
||||
|
||||
Reference in New Issue
Block a user