mirror of
https://github.com/weechat/weechat.git
synced 2026-07-04 16:53:14 +02:00
core: fix buffer returned in focus info for bar items with a forced buffer
This commit is contained in:
+19
-4
@@ -1636,8 +1636,9 @@ gui_bar_item_focus_buffer_nicklist (void *data,
|
||||
struct t_gui_nick *ptr_nick;
|
||||
int i, rc, bar_item_line;
|
||||
unsigned long int value;
|
||||
const char *str_window, *str_bar_item_line;
|
||||
const char *str_window, *str_buffer, *str_bar_item_line;
|
||||
struct t_gui_window *window;
|
||||
struct t_gui_buffer *buffer;
|
||||
char *error;
|
||||
|
||||
/* make C compiler happy */
|
||||
@@ -1647,6 +1648,7 @@ gui_bar_item_focus_buffer_nicklist (void *data,
|
||||
if (!str_bar_item_line || !str_bar_item_line[0])
|
||||
return NULL;
|
||||
|
||||
/* get window */
|
||||
str_window = hashtable_get (info, "_window");
|
||||
if (str_window && str_window[0])
|
||||
{
|
||||
@@ -1663,6 +1665,19 @@ gui_bar_item_focus_buffer_nicklist (void *data,
|
||||
if (!window)
|
||||
return NULL;
|
||||
|
||||
/* get buffer */
|
||||
buffer = window->buffer;
|
||||
str_buffer = hashtable_get (info, "_buffer");
|
||||
if (str_buffer && str_buffer[0])
|
||||
{
|
||||
rc = sscanf (str_buffer, "%lx", &value);
|
||||
if ((rc == EOF) || (rc == 0))
|
||||
return NULL;
|
||||
buffer = (struct t_gui_buffer *)value;
|
||||
}
|
||||
if (!buffer)
|
||||
return NULL;
|
||||
|
||||
error = NULL;
|
||||
bar_item_line = (int) strtol (str_bar_item_line, &error, 10);
|
||||
if (!error || error[0])
|
||||
@@ -1671,19 +1686,19 @@ gui_bar_item_focus_buffer_nicklist (void *data,
|
||||
i = 0;
|
||||
ptr_group = NULL;
|
||||
ptr_nick = NULL;
|
||||
gui_nicklist_get_next_item (window->buffer, &ptr_group, &ptr_nick);
|
||||
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
|
||||
while (ptr_group || ptr_nick)
|
||||
{
|
||||
if ((ptr_nick && ptr_nick->visible)
|
||||
|| (ptr_group && !ptr_nick
|
||||
&& window->buffer->nicklist_display_groups
|
||||
&& buffer->nicklist_display_groups
|
||||
&& ptr_group->visible))
|
||||
{
|
||||
if (i == bar_item_line)
|
||||
break;
|
||||
i++;
|
||||
}
|
||||
gui_nicklist_get_next_item (window->buffer, &ptr_group, &ptr_nick);
|
||||
gui_nicklist_get_next_item (buffer, &ptr_group, &ptr_nick);
|
||||
}
|
||||
|
||||
if (i != bar_item_line)
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "gui-bar-window.h"
|
||||
#include "gui-bar.h"
|
||||
#include "gui-bar-item.h"
|
||||
#include "gui-buffer.h"
|
||||
#include "gui-chat.h"
|
||||
#include "gui-color.h"
|
||||
#include "gui-window.h"
|
||||
@@ -117,7 +118,8 @@ void
|
||||
gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
struct t_gui_bar_window **bar_window,
|
||||
char **bar_item,
|
||||
int *bar_item_line, int *bar_item_col)
|
||||
int *bar_item_line, int *bar_item_col,
|
||||
struct t_gui_buffer **buffer)
|
||||
{
|
||||
struct t_gui_bar *ptr_bar;
|
||||
struct t_gui_bar_window *ptr_bar_window;
|
||||
@@ -231,6 +233,8 @@ gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
*bar_item = (*bar_window)->bar->items_name[item][subitem];
|
||||
*bar_item_line = (*bar_window)->coords[i]->line;
|
||||
*bar_item_col = x - (*bar_window)->coords[i]->x;
|
||||
if ((*bar_window)->bar->items_buffer[item][subitem])
|
||||
*buffer = gui_buffer_search_by_full_name ((*bar_window)->bar->items_buffer[item][subitem]);
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
@@ -249,6 +253,8 @@ gui_bar_window_search_by_xy (struct t_gui_window *window, int x, int y,
|
||||
if (*bar_item_line < lines)
|
||||
{
|
||||
*bar_item = (*bar_window)->bar->items_name[i][j];
|
||||
if ((*bar_window)->bar->items_buffer[i][j])
|
||||
*buffer = gui_buffer_search_by_full_name ((*bar_window)->bar->items_buffer[i][j]);
|
||||
break;
|
||||
}
|
||||
j++;
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#define __WEECHAT_GUI_BAR_WINDOW_H 1
|
||||
|
||||
struct t_infolist;
|
||||
struct t_gui_buffer;
|
||||
struct t_gui_window;
|
||||
enum t_gui_bar_position;
|
||||
|
||||
@@ -67,9 +68,9 @@ extern int gui_bar_window_valid (struct t_gui_bar_window *bar_window);
|
||||
extern void gui_bar_window_search_by_xy (struct t_gui_window *window,
|
||||
int x, int y,
|
||||
struct t_gui_bar_window **bar_window,
|
||||
char **bar_item,
|
||||
int *bar_item_line,
|
||||
int *bar_item_col);
|
||||
char **bar_item, int *bar_item_line,
|
||||
int *bar_item_col,
|
||||
struct t_gui_buffer **buffer);
|
||||
extern void gui_bar_window_calculate_pos_size (struct t_gui_bar_window *bar_window,
|
||||
struct t_gui_window *window);
|
||||
extern void gui_bar_window_content_build (struct t_gui_bar_window *bar_window,
|
||||
|
||||
@@ -109,13 +109,14 @@ gui_cursor_display_debug_info ()
|
||||
if (focus_info)
|
||||
{
|
||||
snprintf (str_info, sizeof (str_info),
|
||||
"%s(%d,%d) window:0x%lx (buffer: %s), "
|
||||
"%s(%d,%d) window:0x%lx, buffer:0x%lx (%s), "
|
||||
"bar_window:0x%lx (bar: %s, item: %s, line: %d, col: %d), "
|
||||
"chat: %d, word: \"%s\"",
|
||||
gui_color_get_custom ("yellow,red"),
|
||||
focus_info->x, focus_info->y,
|
||||
(long unsigned int)focus_info->window,
|
||||
(focus_info->window) ? (focus_info->window)->buffer->name : "-",
|
||||
(long unsigned int)focus_info->buffer,
|
||||
(focus_info->buffer) ? (focus_info->buffer)->full_name : "-",
|
||||
(long unsigned int)focus_info->bar_window,
|
||||
(focus_info->bar_window) ? ((focus_info->bar_window)->bar)->name : "-",
|
||||
(focus_info->bar_item) ? focus_info->bar_item : "-",
|
||||
|
||||
+23
-9
@@ -84,6 +84,7 @@ gui_focus_get_info (int x, int y)
|
||||
|
||||
/* search window */
|
||||
focus_info->window = gui_window_search_by_xy (x, y);
|
||||
focus_info->buffer = (focus_info->window) ? (focus_info->window)->buffer : NULL;
|
||||
|
||||
/* fill info about chat area */
|
||||
gui_window_get_context_at_xy (focus_info->window,
|
||||
@@ -101,7 +102,12 @@ gui_focus_get_info (int x, int y)
|
||||
&focus_info->bar_window,
|
||||
&focus_info->bar_item,
|
||||
&focus_info->bar_item_line,
|
||||
&focus_info->bar_item_col);
|
||||
&focus_info->bar_item_col,
|
||||
&focus_info->buffer);
|
||||
|
||||
/* force current buffer if not buffer at all was found */
|
||||
if (!focus_info->buffer && gui_current_window)
|
||||
focus_info->buffer = gui_current_window->buffer;
|
||||
|
||||
return focus_info;
|
||||
}
|
||||
@@ -177,22 +183,30 @@ gui_focus_to_hashtable (struct t_gui_focus_info *focus_info, const char *key)
|
||||
FOCUS_INT("_x", focus_info->x);
|
||||
FOCUS_INT("_y", focus_info->y);
|
||||
|
||||
/* window/buffer */
|
||||
/* window */
|
||||
FOCUS_PTR("_window", focus_info->window);
|
||||
if (focus_info->window)
|
||||
{
|
||||
FOCUS_INT("_window_number", (focus_info->window)->number);
|
||||
FOCUS_PTR("_buffer", focus_info->window->buffer);
|
||||
FOCUS_INT("_buffer_number", ((focus_info->window)->buffer)->number);
|
||||
FOCUS_STR("_buffer_plugin", plugin_get_name (((focus_info->window)->buffer)->plugin));
|
||||
FOCUS_STR("_buffer_name", ((focus_info->window)->buffer)->name);
|
||||
FOCUS_STR("_buffer_full_name", ((focus_info->window)->buffer)->full_name);
|
||||
hashtable_map (focus_info->window->buffer->local_variables,
|
||||
&gui_focus_buffer_localvar_map_cb, hashtable);
|
||||
}
|
||||
else
|
||||
{
|
||||
FOCUS_STR("_window_number", "*");
|
||||
}
|
||||
|
||||
/* buffer */
|
||||
FOCUS_PTR("_buffer", focus_info->buffer);
|
||||
if (focus_info->buffer)
|
||||
{
|
||||
FOCUS_INT("_buffer_number", (focus_info->buffer)->number);
|
||||
FOCUS_STR("_buffer_plugin", plugin_get_name ((focus_info->buffer)->plugin));
|
||||
FOCUS_STR("_buffer_name", (focus_info->buffer)->name);
|
||||
FOCUS_STR("_buffer_full_name", (focus_info->buffer)->full_name);
|
||||
hashtable_map ((focus_info->buffer)->local_variables,
|
||||
&gui_focus_buffer_localvar_map_cb, hashtable);
|
||||
}
|
||||
else
|
||||
{
|
||||
FOCUS_PTR("_buffer", NULL);
|
||||
FOCUS_STR("_buffer_number", "-1");
|
||||
FOCUS_STR("_buffer_plugin", "");
|
||||
|
||||
@@ -26,6 +26,7 @@ struct t_gui_focus_info
|
||||
{
|
||||
int x, y; /* (x,y) on screen */
|
||||
struct t_gui_window *window; /* window found */
|
||||
struct t_gui_buffer *buffer; /* buffer found */
|
||||
int chat; /* 1 for chat area, otherwise 0 */
|
||||
struct t_gui_line *chat_line; /* line in chat area */
|
||||
int chat_line_x; /* x in line */
|
||||
|
||||
+21
-4
@@ -1040,11 +1040,14 @@ gui_key_focus_command (const char *key, int context,
|
||||
struct t_hashtable **hashtable_focus)
|
||||
{
|
||||
struct t_gui_key *ptr_key;
|
||||
int i, errors, matching, debug;
|
||||
int i, errors, matching, debug, rc;
|
||||
long unsigned int value;
|
||||
char *command, **commands;
|
||||
const char *str_buffer;
|
||||
struct t_hashtable *hashtable;
|
||||
struct t_weelist *list_keys;
|
||||
struct t_weelist_item *ptr_item;
|
||||
struct t_gui_buffer *ptr_buffer;
|
||||
|
||||
debug = 0;
|
||||
if (gui_cursor_debug && (context == GUI_KEY_CONTEXT_CURSOR))
|
||||
@@ -1082,6 +1085,18 @@ gui_key_focus_command (const char *key, int context,
|
||||
if (!hashtable)
|
||||
continue;
|
||||
|
||||
/* get buffer */
|
||||
ptr_buffer = gui_current_window->buffer;
|
||||
str_buffer = hashtable_get (hashtable, "_buffer");
|
||||
if (str_buffer && str_buffer[0])
|
||||
{
|
||||
rc = sscanf (str_buffer, "%lx", &value);
|
||||
if ((rc != EOF) && (rc != 0))
|
||||
ptr_buffer = (struct t_gui_buffer *)value;
|
||||
}
|
||||
if (!ptr_buffer)
|
||||
continue;
|
||||
|
||||
if ((context == GUI_KEY_CONTEXT_CURSOR) && gui_cursor_debug)
|
||||
{
|
||||
gui_input_delete_line (gui_current_window->buffer);
|
||||
@@ -1136,10 +1151,12 @@ gui_key_focus_command (const char *key, int context,
|
||||
if (debug)
|
||||
{
|
||||
gui_chat_printf (NULL,
|
||||
_("Executing command: \"%s\""),
|
||||
command);
|
||||
_("Executing command: \"%s\" "
|
||||
"on buffer \"%s\""),
|
||||
command,
|
||||
ptr_buffer->full_name);
|
||||
}
|
||||
input_data (gui_current_window->buffer, command);
|
||||
input_data (ptr_buffer, command);
|
||||
}
|
||||
free (command);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user