aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-09-25 12:01:08 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-09-25 12:52:27 +0200
commit21e0d302fc849d9f8827b9f2cb93472f7c30fafe (patch)
tree310197da11284732293c7166a54142a220c1a29b /src
parentb710f6a01db827a6a6ea9f74894a6d3dec330734 (diff)
downloadsciteco-21e0d302fc849d9f8827b9f2cb93472f7c30fafe.tar.gz
curses UI: fixed truncation of non-filename popup entries
Diffstat (limited to 'src')
-rw-r--r--src/interface-curses.cpp23
-rw-r--r--src/interface-curses.h6
2 files changed, 24 insertions, 5 deletions
diff --git a/src/interface-curses.cpp b/src/interface-curses.cpp
index b4cdf7e..7466de3 100644
--- a/src/interface-curses.cpp
+++ b/src/interface-curses.cpp
@@ -388,9 +388,14 @@ void
InterfaceCurses::Popup::add(PopupEntryType type,
const gchar *name, bool highlight)
{
- gchar *entry = g_strconcat(highlight ? "*" : " ", name, NIL);
+ size_t name_len = strlen(name);
+ Entry *entry = (Entry *)g_malloc(sizeof(Entry) + name_len + 1);
- longest = MAX(longest, (gint)strlen(name));
+ entry->type = type;
+ entry->highlight = highlight;
+ strcpy(entry->name, name);
+
+ longest = MAX(longest, (gint)name_len);
length++;
/*
@@ -436,15 +441,23 @@ InterfaceCurses::Popup::init_pad(attr_t attr)
*/
cur_col = 0;
for (GSList *cur = list; cur != NULL; cur = g_slist_next(cur)) {
- gchar *entry = (gchar *)cur->data;
+ Entry *entry = (Entry *)cur->data;
gint cur_line = cur_col/pad_cols + 1;
wmove(pad, cur_line-1,
(cur_col % pad_cols)*pad_colwidth);
- wattrset(pad, *entry == '*' ? A_BOLD : A_NORMAL);
+ wattrset(pad, entry->highlight ? A_BOLD : A_NORMAL);
- format_filename(pad, entry+1);
+ switch (entry->type) {
+ case POPUP_FILE:
+ case POPUP_DIRECTORY:
+ format_filename(pad, entry->name);
+ break;
+ default:
+ format_str(pad, entry->name);
+ break;
+ }
cur_col++;
}
diff --git a/src/interface-curses.h b/src/interface-curses.h
index ed228ee..6116cae 100644
--- a/src/interface-curses.h
+++ b/src/interface-curses.h
@@ -118,6 +118,12 @@ typedef class InterfaceCurses : public Interface<InterfaceCurses, ViewCurses> {
WINDOW *window; /**! window showing part of pad */
WINDOW *pad; /**! full-height entry list */
+ struct Entry {
+ PopupEntryType type;
+ bool highlight;
+ gchar name[];
+ };
+
GSList *list; /**! list of popup entries */
gint longest; /**! size of longest entry */
gint length; /**! total number of popup entries */