summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/fe-text/module-formats.c13
-rw-r--r--src/fe-text/module-formats.h11
-rw-r--r--src/fe-text/statusbar-config.c111
3 files changed, 134 insertions, 1 deletions
diff --git a/src/fe-text/module-formats.c b/src/fe-text/module-formats.c
index e9e0b6e2..7584a8c0 100644
--- a/src/fe-text/module-formats.c
+++ b/src/fe-text/module-formats.c
@@ -51,6 +51,19 @@ FORMAT_REC gui_text_formats[] =
/* ---- */
{ NULL, "Statusbars", 0 },
+
+ { "statusbar_list_header", "Name Type Placement Position Visible", 0 },
+ { "statusbar_list_footer", "", 0 },
+ { "statusbar_list", "$[30]0 $[6]1 $[9]2 $[8]3 $4", 5, { 0, 0, 0, 1, 0 } },
+ { "statusbar_info_name", "Statusbar: {hilight $0}", 1, { 0 } },
+ { "statusbar_info_type", "Type : $0", 1, { 0 } },
+ { "statusbar_info_placement", "Placement: $0", 1, { 0 } },
+ { "statusbar_info_position", "Position : $0", 1, { 1 } },
+ { "statusbar_info_visible", "Visible : $0", 1, { 0 } },
+ { "statusbar_info_item_header", "Items : Name Priority Alignment", 0 },
+ { "statusbar_info_item_footer", "", 0 },
+ { "statusbar_info_item_name", " : $[35]0 $[9]1 $2", 3, { 0, 1, 0 } },
+ { "statusbar_not_found", "Statusbar doesn't exist: $0", 1, { 0 } },
{ "statusbar_not_found", "Statusbar doesn't exist: $0", 1, { 0 } },
{ "statusbar_item_not_found", "Statusbar item doesn't exist: $0", 1, { 0 } },
{ "statusbar_unknown_command", "Unknown statusbar command: $0", 1, { 0 } },
diff --git a/src/fe-text/module-formats.h b/src/fe-text/module-formats.h
index 391dfd6e..88c67000 100644
--- a/src/fe-text/module-formats.h
+++ b/src/fe-text/module-formats.h
@@ -27,6 +27,17 @@ enum {
TXT_FILL_3,
+ TXT_STATUSBAR_LIST_HEADER,
+ TXT_STATUSBAR_LIST_FOOTER,
+ TXT_STATUSBAR_LIST,
+ TXT_STATUSBAR_INFO_NAME,
+ TXT_STATUSBAR_INFO_TYPE,
+ TXT_STATUSBAR_INFO_PLACEMENT,
+ TXT_STATUSBAR_INFO_POSITION,
+ TXT_STATUSBAR_INFO_VISIBLE,
+ TXT_STATUSBAR_INFO_ITEM_HEADER,
+ TXT_STATUSBAR_INFO_ITEM_FOOTER,
+ TXT_STATUSBAR_INFO_ITEM_NAME,
TXT_STATUSBAR_NOT_FOUND,
TXT_STATUSBAR_ITEM_NOT_FOUND,
TXT_STATUSBAR_UNKNOWN_COMMAND,
diff --git a/src/fe-text/statusbar-config.c b/src/fe-text/statusbar-config.c
index cff3e068..715f8c38 100644
--- a/src/fe-text/statusbar-config.c
+++ b/src/fe-text/statusbar-config.c
@@ -251,6 +251,102 @@ static void read_statusbar_config(void)
statusbars_create_window_bars();
}
+static const char *sbar_get_type(STATUSBAR_CONFIG_REC *rec)
+{
+ return rec->type == STATUSBAR_TYPE_ROOT ? "root" :
+ rec->type == STATUSBAR_TYPE_WINDOW ? "window" : "??";
+}
+
+static const char *sbar_get_placement(STATUSBAR_CONFIG_REC *rec)
+{
+ return rec->placement == STATUSBAR_TOP ? "top" :
+ rec->placement == STATUSBAR_BOTTOM ? "bottom" : "??";
+}
+
+static const char *sbar_get_visibility(STATUSBAR_CONFIG_REC *rec)
+{
+ return rec->visible == STATUSBAR_VISIBLE_ALWAYS ? "always" :
+ rec->visible == STATUSBAR_VISIBLE_ACTIVE ? "active" :
+ rec->visible == STATUSBAR_VISIBLE_INACTIVE ? "inactive" : "??";
+}
+
+static void statusbar_list_items(STATUSBAR_CONFIG_REC *bar)
+{
+ GSList *tmp;
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_ITEM_HEADER);
+
+ for (tmp = bar->items; tmp != NULL; tmp = tmp->next) {
+ SBAR_ITEM_CONFIG_REC *rec = tmp->data;
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_ITEM_NAME,
+ rec->name, rec->priority,
+ rec->right_alignment ? "right" : "left");
+ }
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_ITEM_FOOTER);
+}
+
+static void statusbar_print(STATUSBAR_CONFIG_REC *rec)
+{
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_NAME, rec->name);
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_TYPE, sbar_get_type(rec));
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_PLACEMENT,
+ sbar_get_placement(rec));
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_POSITION, rec->position);
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_INFO_VISIBLE,
+ sbar_get_visibility(rec));
+
+ if (rec->items != NULL)
+ statusbar_list_items(rec);
+}
+
+static void cmd_statusbar_list(void)
+{
+ GSList *tmp;
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_STATUSBAR_LIST_HEADER);
+
+ tmp = active_statusbar_group->config_bars;
+ for (; tmp != NULL; tmp = tmp->next) {
+ STATUSBAR_CONFIG_REC *rec = tmp->data;
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP,
+ TXT_STATUSBAR_LIST, rec->name, sbar_get_type(rec),
+ sbar_get_placement(rec), rec->position,
+ sbar_get_visibility(rec));
+ }
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTCRAP, TXT_STATUSBAR_LIST_FOOTER);
+}
+
+static void cmd_statusbar_print_info(const char *name)
+{
+ GSList *tmp;
+
+ tmp = active_statusbar_group->config_bars;
+ for (; tmp != NULL; tmp = tmp->next) {
+ STATUSBAR_CONFIG_REC *rec = tmp->data;
+
+ if (g_strcasecmp(rec->name, name) == 0) {
+ statusbar_print(rec);
+ return;
+ }
+ }
+
+ printformat(NULL, NULL, MSGLEVEL_CLIENTERROR,
+ TXT_STATUSBAR_NOT_FOUND, name);
+}
+
/* SYNTAX: STATUSBAR <name> ENABLE */
static void cmd_statusbar_enable(const char *data, void *server,
void *item, CONFIG_NODE *node)
@@ -418,7 +514,20 @@ static void cmd_statusbar(const char *data)
if (!cmd_get_params(data, &free_arg, 3 | PARAM_FLAG_GETREST,
&name, &cmd, &params))
return;
- if (*cmd == '\0') cmd_param_error(CMDERR_NOT_ENOUGH_PARAMS);
+
+ if (*name == '\0') {
+ /* list all statusbars */
+ cmd_statusbar_list();
+ cmd_params_free(free_arg);
+ return;
+ }
+
+ if (*cmd == '\0') {
+ /* print statusbar info */
+ cmd_statusbar_print_info(name);
+ cmd_params_free(free_arg);
+ return;
+ }
/* lookup/create the statusbar node */
node = iconfig_node_traverse("statusbar", TRUE);