aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2013-10-09 02:54:19 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2013-10-09 02:54:19 +0200
commitd7114f06346ef876d7cf8ac1f7b391ca7df2292a (patch)
treefa9e03813e55287baa2f62e81271e294d2b4a1a6 /src
parentadce15243ac55b6a1d8a832f21e4eaf6c9e54cf2 (diff)
downloadtdv-d7114f06346ef876d7cf8ac1f7b391ca7df2292a.tar.gz
tdv-d7114f06346ef876d7cf8ac1f7b391ca7df2292a.tar.xz
tdv-d7114f06346ef876d7cf8ac1f7b391ca7df2292a.zip
Don't apply the bold attribute to padding.
It looked awful when it caused a change in the colour of underlining.
Diffstat (limited to 'src')
-rw-r--r--src/sdtui.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/src/sdtui.c b/src/sdtui.c
index 1dea37e..e4ccab2 100644
--- a/src/sdtui.c
+++ b/src/sdtui.c
@@ -357,10 +357,12 @@ app_destroy (Application *self)
/** Write the given utf-8 string padded with spaces.
* @param[in] n The number of characters to write, or -1 for the whole string.
+ * @param[in] attrs Text attributes for the text, without padding.
+ * To change the attributes of all output, use attrset().
* @return The number of wide characters written.
*/
static gsize
-app_add_utf8_string (Application *self, const gchar *str, int n)
+app_add_utf8_string (Application *self, const gchar *str, int attrs, int n)
{
wchar_t *wide_str = (wchar_t *) g_convert_with_iconv
(str, -1, self->utf8_to_wchar, NULL, NULL, NULL);
@@ -420,7 +422,7 @@ app_add_utf8_string (Application *self, const gchar *str, int n)
cchar_t cch;
for (i = 0; i < len; i++)
{
- if (setcchar (&cch, &wide_str[i], A_NORMAL, 0, NULL) == OK)
+ if (setcchar (&cch, &wide_str[i], attrs, 0, NULL) == OK)
add_wch (&cch);
else
// This shouldn't happen
@@ -441,15 +443,16 @@ app_redraw_top (Application *self)
{
mvwhline (stdscr, 0, 0, A_UNDERLINE, COLS);
attrset (A_UNDERLINE);
- gsize indent = app_add_utf8_string (self, self->search_label, -1);
+ gsize indent = app_add_utf8_string (self, self->search_label, 0, -1);
gchar *input_utf8 = g_ucs4_to_utf8
((gunichar *) self->input->data, -1, NULL, NULL, NULL);
g_return_if_fail (input_utf8 != NULL);
+ int word_attrs = 0;
if (self->input_confirmed)
- attron (A_BOLD);
- app_add_utf8_string (self, input_utf8, COLS - indent);
+ word_attrs |= A_BOLD;
+ app_add_utf8_string (self, input_utf8, word_attrs, COLS - indent);
g_free (input_utf8);
guint offset, i;
@@ -497,7 +500,7 @@ app_show_message (Application *self, const gchar *lines[], gsize len)
x = 0;
move (1 + i, x);
- app_add_utf8_string (self, *lines, COLS - x);
+ app_add_utf8_string (self, *lines, 0, COLS - x);
lines++;
i++;
@@ -547,10 +550,10 @@ app_redraw_view (Application *self)
attrset (attrs);
guint left_width = app_get_left_column_width (self);
- app_add_utf8_string (self, ve->word, left_width);
+ app_add_utf8_string (self, ve->word, 0, left_width);
addwstr (L" ");
app_add_utf8_string (self,
- ve->definitions[k], COLS - left_width - 1);
+ ve->definitions[k], 0, COLS - left_width - 1);
if ((gint) ++shown == LINES - 1)
goto done;