aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2016-09-28 05:05:24 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2016-09-28 05:05:24 +0200
commit30345ec8d4e9093452cc1798caede15e28dc4841 (patch)
tree63e5c8fa79fe91c34f18e749f6241e0b28569e62 /src
parent4f0a47d5f7bd98b9e8e8540203385fd33227c45f (diff)
downloadtdv-30345ec8d4e9093452cc1798caede15e28dc4841.tar.gz
tdv-30345ec8d4e9093452cc1798caede15e28dc4841.tar.xz
tdv-30345ec8d4e9093452cc1798caede15e28dc4841.zip
Show all dictionaries in the header
Make the style of the active dictionary's name configurable.
Diffstat (limited to 'src')
-rw-r--r--src/sdtui.c30
1 files changed, 22 insertions, 8 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index 1451c79..f2bf15c 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -153,11 +153,12 @@ resolve_filename (const gchar *filename, gchar *(*relative_cb) (const char *))
// --- Application -------------------------------------------------------------
-#define ATTRIBUTE_TABLE(XX) \
- XX( HEADER, "header", -1, -1, A_REVERSE ) \
- XX( SEARCH, "search", -1, -1, A_UNDERLINE ) \
- XX( EVEN, "even", -1, -1, 0 ) \
- XX( ODD, "odd", -1, -1, 0 )
+#define ATTRIBUTE_TABLE(XX) \
+ XX( HEADER, "header", -1, -1, A_REVERSE ) \
+ XX( ACTIVE, "header-active", -1, -1, A_UNDERLINE ) \
+ XX( SEARCH, "search", -1, -1, A_UNDERLINE ) \
+ XX( EVEN, "even", -1, -1, 0 ) \
+ XX( ODD, "odd", -1, -1, 0 )
enum
{
@@ -337,6 +338,11 @@ dictionary_load (Dictionary *self, GError **e)
(stardict_dict_get_info (self->dict)));
}
+ // Add some padding for decorative purposes
+ gchar *tmp = g_strdup_printf (" %s ", self->name);
+ g_free (self->name);
+ self->name = tmp;
+
gunichar *ucs4 = g_utf8_to_ucs4_fast (self->name, -1, NULL);
for (gunichar *it = ucs4; *it; it++)
self->name_width += unichar_width (*it);
@@ -867,9 +873,17 @@ app_redraw_top (Application *self)
{
attrset (APP_ATTR (HEADER));
mvwhline (stdscr, 0, 0, APP_ATTR (HEADER), COLS);
- gsize indent = app_add_utf8_string (self, PROJECT_NAME " ", A_BOLD, -1);
- app_add_utf8_string (self, stardict_info_get_book_name
- (stardict_dict_get_info (self->dict)), 0, COLS - indent);
+ gsize indent = app_add_utf8_string (self, PROJECT_NAME " ", A_BOLD, -1);
+
+ attrset (0);
+ for (guint i = 0; i < self->dictionaries->len; i++)
+ {
+ Dictionary *dict = &g_array_index (self->dictionaries, Dictionary, i);
+ indent += app_add_utf8_string (self, dict->name,
+ (self->dictionaries->len > 1 && self->dict == dict->dict)
+ ? APP_ATTR (ACTIVE) : APP_ATTR (HEADER),
+ MIN (COLS - indent, dict->name_width));
+ }
attrset (APP_ATTR (SEARCH));
mvwhline (stdscr, 1, 0, APP_ATTR (SEARCH), COLS);