diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/interface-curses.cpp | 23 | ||||
-rw-r--r-- | src/interface-curses.h | 6 |
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 */ |