aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/interface-curses.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2015-07-15 04:36:08 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2015-07-15 05:32:53 +0200
commit8baae7579973b755b47250742d9a1a94795ae1bb (patch)
tree91f156d0d7c94a17f0b1e708801b3b5ebbe6edec /src/interface-curses.h
parentea9989266dcb64025ed90d0113ed7c052d07cc34 (diff)
downloadsciteco-8baae7579973b755b47250742d9a1a94795ae1bb.tar.gz
Curses UI: revised popup area, with borders and a scroll bar; reduce flickering
* InterfaceCurses::Popup has been turned into a proper class. This made sense since it is more complicated now and allows us to isolate popup-related code. This will also ease moving the popup code as a widget into its own file later (it seems we will need subdirs per interface anyway). * the popup is now implemented using curses pads of which pages are copied into the popup window (to implement cycling through the list of entries). This simplifies things conceptually. * instead of a trailing ellipsis, scrollbars are shown if the popup area is too small to show all entries. This looks much better and consistent with regard to Scinterm's scrollbars. Also, the planned GTK+ popup widget rewrite will have scroll bars, too for cycling through the list of entries. Therefore, the popup window will now always be the same size when cycling. This also looks better. * Borders are drawn around the popup area. This makes sense since the popup area had to be colored distinctly just to be able to discern it from the rest of the UI (esp. the Scintilla view). Now, less annoying colors may be used by default or set up in color profiles while still maintaining good visibility. Also, with the borders added, the popup area looks more consistent when it covers the entire screen. * Entries that are too long to fit on the screen (e.g. long file names) are now truncated with a bold/underline ellipsis. * Use scintilla_noutrefresh() to refresh the Scintilla view. Since popups have to be refreshed __after__ the Scintilla view, this improves performance significantly and reduces flickering when displaying large popups.
Diffstat (limited to 'src/interface-curses.h')
-rw-r--r--src/interface-curses.h59
1 files changed, 49 insertions, 10 deletions
diff --git a/src/interface-curses.h b/src/interface-curses.h
index b43069f..9bb17cd 100644
--- a/src/interface-curses.h
+++ b/src/interface-curses.h
@@ -52,6 +52,12 @@ public:
}
inline void
+ noutrefresh(void)
+ {
+ scintilla_noutrefresh(sci);
+ }
+
+ inline void
refresh(void)
{
scintilla_refresh(sci);
@@ -104,19 +110,44 @@ typedef class InterfaceCurses : public Interface<InterfaceCurses, ViewCurses> {
WINDOW *cmdline_window, *cmdline_pad;
gsize cmdline_len, cmdline_rubout_len;
- struct Popup {
- WINDOW *window;
+ class Popup {
+ WINDOW *window; /**! window showing part of pad */
+ WINDOW *pad; /**! full-height entry list */
+
GSList *list; /**! list of popup entries */
gint longest; /**! size of longest entry */
gint length; /**! total number of popup entries */
- GSList *cur_list; /**! next entry to display */
- gint cur_entry; /**! next entry to display (position) */
+ gint pad_first_line; /**! first line in pad to show */
+
+ public:
+ Popup() : window(NULL), pad(NULL),
+ list(NULL), longest(0), length(0),
+ pad_first_line(0) {}
+
+ void add(PopupEntryType type,
+ const gchar *name, bool highlight = false);
+
+ void show(attr_t attr);
+ inline bool
+ is_shown(void)
+ {
+ return window != NULL;
+ }
+
+ void clear(void);
+
+ inline void
+ noutrefresh(void)
+ {
+ if (window)
+ wnoutrefresh(window);
+ }
- Popup() : window(NULL), list(NULL),
- longest(3), length(0),
- cur_list(NULL), cur_entry(0) {}
~Popup();
+
+ private:
+ void init_pad(attr_t attr);
} popup;
public:
@@ -145,16 +176,24 @@ public:
void cmdline_update_impl(const Cmdline *cmdline);
/* implementation of Interface::popup_add() */
- void popup_add_impl(PopupEntryType type,
- const gchar *name, bool highlight = false);
+ inline void
+ popup_add_impl(PopupEntryType type,
+ const gchar *name, bool highlight = false)
+ {
+ if (cmdline_window)
+ /* interactive mode */
+ popup.add(type, name, highlight);
+ }
+
/* implementation of Interface::popup_show() */
void popup_show_impl(void);
/* implementation of Interface::popup_is_shown() */
inline bool
popup_is_shown_impl(void)
{
- return popup.window != NULL;
+ return popup.is_shown();
}
+
/* implementation of Interface::popup_clear() */
void popup_clear_impl(void);