mirror of
https://github.com/weechat/weechat.git
synced 2026-06-30 23:06:38 +02:00
core: add infolist "layout" and hdata "layout", "layout_buffer" and "layout_window" (thanks to Nils Görs)
This commit is contained in:
@@ -14,6 +14,8 @@ http://weechat.org/files/releasenotes/ReleaseNotes-devel.html[release notes]
|
||||
Version 0.4.1 (under dev!)
|
||||
--------------------------
|
||||
|
||||
* core: add infolist "layout" and hdata "layout", "layout_buffer" and
|
||||
"layout_window"
|
||||
* core: fix display of long lines without time (message beginning with two tabs)
|
||||
* core: make nick prefix/suffix dynamic (not stored in the line): move options
|
||||
irc.look.nick_{prefix|suffix} to weechat.look.nick_{prefix|suffix} and options
|
||||
|
||||
+117
-1
@@ -24,12 +24,14 @@
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../core/weechat.h"
|
||||
#include "../core/wee-log.h"
|
||||
#include "../core/wee-config.h"
|
||||
#include "../core/wee-hdata.h"
|
||||
#include "../core/wee-infolist.h"
|
||||
#include "../core/wee-log.h"
|
||||
#include "../core/wee-string.h"
|
||||
#include "../plugins/plugin.h"
|
||||
#include "gui-layout.h"
|
||||
@@ -868,6 +870,89 @@ gui_layout_remove_all ()
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for buffer layout.
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
gui_layout_hdata_layout_buffer_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_layout", "next_layout",
|
||||
0, 0, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
HDATA_VAR(struct t_gui_layout_buffer, plugin_name, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_buffer, buffer_name, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_buffer, number, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_buffer, prev_layout, POINTER, 0, NULL, hdata_name);
|
||||
HDATA_VAR(struct t_gui_layout_buffer, next_layout, POINTER, 0, NULL, hdata_name);
|
||||
}
|
||||
return hdata;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for window layout.
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
gui_layout_hdata_layout_window_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, NULL, NULL, 0, 0, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
HDATA_VAR(struct t_gui_layout_window, internal_id, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_window, parent_node, POINTER, 0, NULL, hdata_name);
|
||||
HDATA_VAR(struct t_gui_layout_window, split_pct, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_window, split_horiz, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_window, child1, POINTER, 0, NULL, hdata_name);
|
||||
HDATA_VAR(struct t_gui_layout_window, child2, POINTER, 0, NULL, hdata_name);
|
||||
HDATA_VAR(struct t_gui_layout_window, plugin_name, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout_window, buffer_name, STRING, 0, NULL, NULL);
|
||||
}
|
||||
return hdata;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns hdata for layout.
|
||||
*/
|
||||
|
||||
struct t_hdata *
|
||||
gui_layout_hdata_layout_cb (void *data, const char *hdata_name)
|
||||
{
|
||||
struct t_hdata *hdata;
|
||||
|
||||
/* make C compiler happy */
|
||||
(void) data;
|
||||
|
||||
hdata = hdata_new (NULL, hdata_name, "prev_layout", "next_layout",
|
||||
0, 0, NULL, NULL);
|
||||
if (hdata)
|
||||
{
|
||||
HDATA_VAR(struct t_gui_layout, name, STRING, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout, layout_buffers, POINTER, 0, NULL, "layout_buffer");
|
||||
HDATA_VAR(struct t_gui_layout, last_layout_buffer, POINTER, 0, NULL, "layout_buffer");
|
||||
HDATA_VAR(struct t_gui_layout, layout_windows, POINTER, 0, NULL, "layout_window");
|
||||
HDATA_VAR(struct t_gui_layout, internal_id, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout, internal_id_current_window, INTEGER, 0, NULL, NULL);
|
||||
HDATA_VAR(struct t_gui_layout, prev_layout, POINTER, 0, NULL, hdata_name);
|
||||
HDATA_VAR(struct t_gui_layout, next_layout, POINTER, 0, NULL, hdata_name);
|
||||
HDATA_LIST(gui_layouts);
|
||||
HDATA_LIST(last_gui_layout);
|
||||
HDATA_LIST(gui_layout_current);
|
||||
}
|
||||
return hdata;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a buffer layout in an infolist.
|
||||
*
|
||||
@@ -944,6 +1029,37 @@ gui_layout_window_add_to_infolist (struct t_infolist *infolist,
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Adds a layout in an infolist.
|
||||
*
|
||||
* Returns:
|
||||
* 1: OK
|
||||
* 0: error
|
||||
*/
|
||||
|
||||
int
|
||||
gui_layout_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_layout *layout)
|
||||
{
|
||||
struct t_infolist_item *ptr_item;
|
||||
|
||||
if (!infolist || !layout)
|
||||
return 0;
|
||||
|
||||
ptr_item = infolist_new_item (infolist);
|
||||
if (!ptr_item)
|
||||
return 0;
|
||||
|
||||
if (!infolist_new_var_string (ptr_item, "name", layout->name))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "internal_id", layout->internal_id))
|
||||
return 0;
|
||||
if (!infolist_new_var_integer (ptr_item, "internal_id_current_window", layout->internal_id_current_window))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints windows layout infos in WeeChat log file (usually for crash dump).
|
||||
*/
|
||||
|
||||
@@ -112,10 +112,18 @@ extern void gui_layout_save_on_exit ();
|
||||
extern void gui_layout_free (struct t_gui_layout *layout);
|
||||
extern void gui_layout_remove (struct t_gui_layout *layout);
|
||||
extern void gui_layout_remove_all ();
|
||||
extern struct t_hdata *gui_layout_hdata_layout_buffer_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern struct t_hdata *gui_layout_hdata_layout_window_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern struct t_hdata *gui_layout_hdata_layout_cb (void *data,
|
||||
const char *hdata_name);
|
||||
extern int gui_layout_buffer_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_layout_buffer *layout_buffer);
|
||||
extern int gui_layout_window_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_layout_window *layout_window);
|
||||
extern int gui_layout_add_to_infolist (struct t_infolist *infolist,
|
||||
struct t_gui_layout *layout);
|
||||
extern void gui_layout_print_log ();
|
||||
extern void gui_layout_init ();
|
||||
extern void gui_layout_end ();
|
||||
|
||||
@@ -56,6 +56,7 @@
|
||||
#include "../gui/gui-history.h"
|
||||
#include "../gui/gui-hotlist.h"
|
||||
#include "../gui/gui-key.h"
|
||||
#include "../gui/gui-layout.h"
|
||||
#include "../gui/gui-line.h"
|
||||
#include "../gui/gui-nicklist.h"
|
||||
#include "../gui/gui-window.h"
|
||||
@@ -412,6 +413,7 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
struct t_gui_hotlist *ptr_hotlist;
|
||||
struct t_gui_key *ptr_key;
|
||||
struct t_weechat_plugin *ptr_plugin;
|
||||
struct t_gui_layout *ptr_layout;
|
||||
int context, number, i;
|
||||
char *error;
|
||||
|
||||
@@ -713,6 +715,23 @@ plugin_api_infolist_get_internal (void *data, const char *infolist_name,
|
||||
return ptr_infolist;
|
||||
}
|
||||
}
|
||||
else if (string_strcasecmp (infolist_name, "layout") == 0)
|
||||
{
|
||||
ptr_infolist = infolist_new ();
|
||||
if (ptr_infolist)
|
||||
{
|
||||
for (ptr_layout = gui_layouts; ptr_layout;
|
||||
ptr_layout = ptr_layout->next_layout)
|
||||
{
|
||||
if (!gui_layout_add_to_infolist (ptr_infolist,ptr_layout))
|
||||
{
|
||||
infolist_free (ptr_infolist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
return ptr_infolist;
|
||||
}
|
||||
}
|
||||
else if (string_strcasecmp (infolist_name, "nicklist") == 0)
|
||||
{
|
||||
/* invalid buffer pointer ? */
|
||||
@@ -1108,6 +1127,10 @@ plugin_api_init ()
|
||||
N_("context (\"default\", \"search\", \"cursor\" or "
|
||||
"\"mouse\") (optional)"),
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "layout", N_("list of layouts"),
|
||||
NULL,
|
||||
NULL,
|
||||
&plugin_api_infolist_get_internal, NULL);
|
||||
hook_infolist (NULL, "nicklist", N_("nicks in nicklist for a buffer"),
|
||||
N_("buffer pointer"),
|
||||
N_("nick_xxx or group_xxx to get only nick/group xxx "
|
||||
@@ -1159,6 +1182,12 @@ plugin_api_init ()
|
||||
&gui_buffer_hdata_input_undo_cb, NULL);
|
||||
hook_hdata (NULL, "key", N_("a key (keyboard shortcut)"),
|
||||
&gui_key_hdata_key_cb, NULL);
|
||||
hook_hdata (NULL, "layout", N_("layout"),
|
||||
&gui_layout_hdata_layout_cb, NULL);
|
||||
hook_hdata (NULL, "layout_buffer", N_("buffer layout"),
|
||||
&gui_layout_hdata_layout_buffer_cb, NULL);
|
||||
hook_hdata (NULL, "layout_window", N_("window layout"),
|
||||
&gui_layout_hdata_layout_window_cb, NULL);
|
||||
hook_hdata (NULL, "lines", N_("structure with lines"),
|
||||
&gui_line_hdata_lines_cb, NULL);
|
||||
hook_hdata (NULL, "line", N_("structure with one line"),
|
||||
|
||||
Reference in New Issue
Block a user