summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-04-26 18:39:38 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-04-26 18:39:38 +0200
commit224073d3b2059ca5eea46d78235ab6476ecc1889 (patch)
treec9edf73dd42c62f0da2d1c17ae9d60a880572479
parent950d64d229e6740a2e25c8aa7d8bdd770b30054b (diff)
downloadxK-224073d3b2059ca5eea46d78235ab6476ecc1889.tar.gz
xK-224073d3b2059ca5eea46d78235ab6476ecc1889.tar.xz
xK-224073d3b2059ca5eea46d78235ab6476ecc1889.zip
degesch: distinguish lines from other buffers
-rw-r--r--degesch.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/degesch.c b/degesch.c
index e1741f7..caec35b 100644
--- a/degesch.c
+++ b/degesch.c
@@ -27,6 +27,7 @@
#define ATTR_WARNING "attr_warning"
#define ATTR_ERROR "attr_error"
+#define ATTR_EXTERNAL "attr_external"
#define ATTR_TIMESTAMP "attr_timestamp"
#define ATTR_ACTION "attr_action"
#define ATTR_JOIN "attr_join"
@@ -91,6 +92,7 @@ static struct config_item g_config_table[] =
{ ATTR_WARNING, NULL, "Terminal attributes for warnings" },
{ ATTR_ERROR, NULL, "Terminal attributes for errors" },
+ { ATTR_EXTERNAL, NULL, "Terminal attributes for external lines" },
{ ATTR_TIMESTAMP, NULL, "Terminal attributes for timestamps" },
{ ATTR_ACTION, NULL, "Terminal attributes for user actions" },
{ ATTR_JOIN, NULL, "Terminal attributes for joins" },
@@ -768,6 +770,7 @@ init_colors (struct app_context *ctx)
INIT_ATTR (ATTR_WARNING, g_terminal.color_set_fg[3], "\x1b[33m");
INIT_ATTR (ATTR_ERROR, g_terminal.color_set_fg[1], "\x1b[31m");
+ INIT_ATTR (ATTR_EXTERNAL, g_terminal.color_set_fg[7], "\x1b[37m");
INIT_ATTR (ATTR_TIMESTAMP, g_terminal.color_set_fg[7], "\x1b[37m");
INIT_ATTR (ATTR_ACTION, g_terminal.color_set_fg[1], "\x1b[31m");
INIT_ATTR (ATTR_JOIN, g_terminal.color_set_fg[2], "\x1b[32m");
@@ -910,6 +913,7 @@ formatter_item_destroy (struct formatter_item *self)
struct formatter
{
struct app_context *ctx; ///< Application context
+ bool ignore_new_attributes; ///< Whether to ignore new attributes
struct formatter_item *items; ///< Items
struct formatter_item *items_tail; ///< Tail of items
@@ -938,32 +942,41 @@ formatter_add_blank (struct formatter *self)
}
static void
-formatter_add_attr (struct formatter *self, const char *attr_name)
+formatter_add_text (struct formatter *self, const char *text)
{
struct formatter_item *item = formatter_add_blank (self);
- item->type = FORMATTER_ITEM_ATTR;
- item->data = xstrdup (str_map_find (&self->ctx->config, attr_name));
+ item->type = FORMATTER_ITEM_TEXT;
+ item->data = xstrdup (text);
}
static void
formatter_add_reset (struct formatter *self)
{
+ if (self->ignore_new_attributes)
+ return;
+
struct formatter_item *item = formatter_add_blank (self);
item->type = FORMATTER_ITEM_ATTR;
item->data = NULL;
}
static void
-formatter_add_text (struct formatter *self, const char *text)
+formatter_add_attr (struct formatter *self, const char *attr_name)
{
+ if (self->ignore_new_attributes)
+ return;
+
struct formatter_item *item = formatter_add_blank (self);
- item->type = FORMATTER_ITEM_TEXT;
- item->data = xstrdup (text);
+ item->type = FORMATTER_ITEM_ATTR;
+ item->data = xstrdup (str_map_find (&self->ctx->config, attr_name));
}
static void
formatter_add_fg_color (struct formatter *self, int color)
{
+ if (self->ignore_new_attributes)
+ return;
+
struct formatter_item *item = formatter_add_blank (self);
item->type = FORMATTER_ITEM_FG_COLOR;
item->color = color;
@@ -972,6 +985,9 @@ formatter_add_fg_color (struct formatter *self, int color)
static void
formatter_add_bg_color (struct formatter *self, int color)
{
+ if (self->ignore_new_attributes)
+ return;
+
struct formatter_item *item = formatter_add_blank (self);
item->type = FORMATTER_ITEM_BG_COLOR;
item->color = color;
@@ -1187,8 +1203,13 @@ buffer_line_display (struct app_context *ctx,
formatter_add (&f, "#a#02d:#02d:#02d#r ",
ATTR_TIMESTAMP, current.tm_hour, current.tm_min, current.tm_sec);
- // TODO: when this comes from a different buffer (is_external),
- // ignore all attributes and instead print it with ATTR_OTHER
+ // Ignore all formatting for messages coming from other buffers, that is
+ // either from the global or server buffer. Instead print them in grey.
+ if (is_external)
+ {
+ formatter_add (&f, "#a", ATTR_EXTERNAL);
+ f.ignore_new_attributes = true;
+ }
// TODO: try to decode as much as possible using mIRC formatting;
// could either add a #m format specifier, or write a separate function