summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTimo Sirainen <cras@irssi.org>2001-08-03 20:04:39 +0000
committercras <cras@dbcabf3a-b0e7-0310-adc4-f8d773084564>2001-08-03 20:04:39 +0000
commit79ae6fceb33de787ff65527cdab636af276ccb95 (patch)
tree89ecf93cd9ce06a28cf2ba3c90cf0e6eb9cff829 /src
parentaf7eb94043a6f71950b91729f095238f91f4c88b (diff)
downloadirssi-79ae6fceb33de787ff65527cdab636af276ccb95.zip
/WINDOW command now prints all information related to window.
git-svn-id: http://svn.irssi.org/repos/irssi/trunk@1699 dbcabf3a-b0e7-0310-adc4-f8d773084564
Diffstat (limited to 'src')
-rw-r--r--src/fe-common/core/module-formats.c16
-rw-r--r--src/fe-common/core/module-formats.h16
-rw-r--r--src/fe-common/core/window-commands.c122
3 files changed, 149 insertions, 5 deletions
diff --git a/src/fe-common/core/module-formats.c b/src/fe-common/core/module-formats.c
index db20cd35..b9d13d6f 100644
--- a/src/fe-common/core/module-formats.c
+++ b/src/fe-common/core/module-formats.c
@@ -43,6 +43,22 @@ FORMAT_REC fecommon_core_formats[] = {
{ "windowlist_footer", "", 0 },
{ "windows_layout_saved", "Layout of windows is now remembered next time you start irssi", 0 },
{ "windows_layout_reset", "Layout of windows reset to defaults", 0 },
+ { "window_info_header", "", 0 },
+ { "window_info_footer", "", 0 },
+ { "window_info_refnum", "Window : {hilight #$0}", 1, { 1 } },
+ { "window_info_refnum_sticky", "Window : {hilight #$0 (sticky)}", 1, { 1 } },
+ { "window_info_name", "Name : $0", 1, { 0 } },
+ { "window_info_size", "Size : $0x$1", 2, { 1, 1 } },
+ { "window_info_level", "Level : $0", 1, { 0 } },
+ { "window_info_server", "Server : $0", 1, { 0 } },
+ { "window_info_server_sticky", "Server : $0 (sticky)", 1, { 0 } },
+ { "window_info_theme", "Theme : $0$1", 2, { 0, 0 } },
+ { "window_info_bound_items_header", "Bounds : {hilight Name Server tag}", 0 },
+ { "window_info_bound_item", " : $[!30]0 $[!15]1 $2", 3, { 0, 0, 0 } },
+ { "window_info_bound_items_footer", "", 0 },
+ { "window_info_items_header", "Items : {hilight Name Server tag}", 0 },
+ { "window_info_item", " $[7]0: $[!30]1 $2", 3, { 0, 0, 0 } },
+ { "window_info_items_footer", "", 0 },
/* ---- */
{ NULL, "Server", 0 },
diff --git a/src/fe-common/core/module-formats.h b/src/fe-common/core/module-formats.h
index ab88bcf8..eacbc8aa 100644
--- a/src/fe-common/core/module-formats.h
+++ b/src/fe-common/core/module-formats.h
@@ -21,6 +21,22 @@ enum {
TXT_WINDOWLIST_FOOTER,
TXT_WINDOWS_LAYOUT_SAVED,
TXT_WINDOWS_LAYOUT_RESET,
+ TXT_WINDOW_INFO_HEADER,
+ TXT_WINDOW_INFO_FOOTER,
+ TXT_WINDOW_INFO_REFNUM,
+ TXT_WINDOW_INFO_REFNUM_STICKY,
+ TXT_WINDOW_INFO_NAME,
+ TXT_WINDOW_INFO_SIZE,
+ TXT_WINDOW_INFO_LEVEL,
+ TXT_WINDOW_INFO_SERVER,
+ TXT_WINDOW_INFO_SERVER_STICKY,
+ TXT_WINDOW_INFO_THEME,
+ TXT_WINDOW_INFO_BOUND_ITEMS_HEADER,
+ TXT_WINDOW_INFO_BOUND_ITEM,
+ TXT_WINDOW_INFO_BOUND_ITEMS_FOOTER,
+ TXT_WINDOW_INFO_ITEMS_HEADER,
+ TXT_WINDOW_INFO_ITEM,
+ TXT_WINDOW_INFO_ITEMS_FOOTER,
TXT_FILL_2,
diff --git a/src/fe-common/core/window-commands.c b/src/fe-common/core/window-commands.c
index c158ba39..8648087b 100644
--- a/src/fe-common/core/window-commands.c
+++ b/src/fe-common/core/window-commands.c
@@ -33,14 +33,126 @@
#include "windows-layout.h"
#include "printtext.h"
-static void cmd_window(const char *data, void *server, WI_ITEM_REC *item)
+static void window_print_binds(WINDOW_REC *win)
{
- if (is_numeric(data, 0)) {
- signal_emit("command window refnum", 3, data, server, item);
- return;
+ GSList *tmp;
+
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_BOUND_ITEMS_HEADER);
+ for (tmp = win->bound_items; tmp != NULL; tmp = tmp->next) {
+ WINDOW_BIND_REC *bind = tmp->data;
+
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_BOUND_ITEM,
+ bind->name, bind->servertag,
+ bind->sticky ? "sticky" : "");
+ }
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_BOUND_ITEMS_FOOTER);
+}
+
+static void window_print_items(WINDOW_REC *win)
+{
+ GSList *tmp;
+ const char *type;
+
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_ITEMS_HEADER);
+ for (tmp = win->items; tmp != NULL; tmp = tmp->next) {
+ WI_ITEM_REC *item = tmp->data;
+
+ type = module_find_id_str("WINDOW ITEM TYPE", item->type);
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_ITEM,
+ type == NULL ? "??" : type, item->name,
+ item->server == NULL ? "" :
+ item->server->tag);
+ }
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_ITEMS_FOOTER);
+}
+
+static void cmd_window_info(void)
+{
+ WINDOW_REC *win;
+ char *levelstr;
+
+ win = active_win;
+
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_HEADER);
+
+ /* Window reference number + sticky status */
+ if (!win->sticky_refnum) {
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_REFNUM, win->refnum);
+ } else {
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_REFNUM_STICKY, win->refnum);
+ }
+
+ /* Window name */
+ if (win->name != NULL) {
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_NAME, win->name);
+ }
+
+ /* Window width / height */
+ printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_SIZE,
+ win->width, win->height);
+
+ /* Window level */
+ levelstr = win->level == 0 ?
+ g_strdup("NONE") : bits2level(win->level);
+ printformat_window(win, MSGLEVEL_CLIENTCRAP, TXT_WINDOW_INFO_LEVEL,
+ levelstr);
+ g_free(levelstr);
+
+ /* Active window server + sticky status */
+ if (win->servertag == NULL) {
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_SERVER,
+ win->active_server != NULL ?
+ win->active_server->tag : "NONE");
+ } else {
+ if (win->active_server != NULL &&
+ strcmp(win->active_server->tag, win->servertag) != 0)
+ g_warning("Active server isn't the sticky server!");
+
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_SERVER_STICKY,
+ win->servertag);
+ }
+
+ /* Window theme + error status */
+ if (win->theme_name != NULL) {
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_THEME, win->theme_name,
+ win->theme != NULL ? "" : "(not loaded)");
}
- command_runsub("window", data, server, item);
+ /* Bound items in window */
+ if (win->bound_items != NULL)
+ window_print_binds(win);
+
+ /* Item */
+ if (win->items != NULL)
+ window_print_items(win);
+
+ printformat_window(win, MSGLEVEL_CLIENTCRAP,
+ TXT_WINDOW_INFO_FOOTER);
+}
+
+static void cmd_window(const char *data, void *server, WI_ITEM_REC *item)
+{
+ while (*data == ' ') data++;
+
+ if (*data == '\0')
+ cmd_window_info();
+ else if (is_numeric(data, 0))
+ signal_emit("command window refnum", 3, data, server, item);
+ else
+ command_runsub("window", data, server, item);
}
/* SYNTAX: WINDOW NEW [hide] */