diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-16 19:31:29 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-11-16 23:34:25 +0100 |
commit | 38fcf6d15cdf09591e7d7a142ad724164875e433 (patch) | |
tree | bc6d81a5c3e33b6832cf0507fbf7e9e4a01a4358 /src/interface-ncurses.h | |
parent | 7a0857515ad216325fc3021c7490df9d01a21c7c (diff) | |
download | sciteco-38fcf6d15cdf09591e7d7a142ad724164875e433.tar.gz |
rewritten View and Interface base classes using the Curiously Recurring Template Pattern.
* without the one-view-per-buffer designs, many Scintilla send message (SSM)
calls could be inlined
* with the new design, this was no longer possible using the abstract
base classes. the CRT pattern allows inlining again but introduces
a strange level of code obscurity.
* tests suggest that at high optimization levels, the one-view-per-buffer
design and the CRT pattern reduces typical macro runtimes by 30%
(e.g. for symbols-extract.tes).
* only updated the NCurses UI for the time being
Diffstat (limited to 'src/interface-ncurses.h')
-rw-r--r-- | src/interface-ncurses.h | 53 |
1 files changed, 33 insertions, 20 deletions
diff --git a/src/interface-ncurses.h b/src/interface-ncurses.h index 647b1ef..0d13615 100644 --- a/src/interface-ncurses.h +++ b/src/interface-ncurses.h @@ -31,7 +31,7 @@ namespace SciTECO { -typedef class ViewNCurses : public View { +typedef class ViewNCurses : public View<ViewNCurses> { Scintilla *sci; public: @@ -50,14 +50,15 @@ public: return scintilla_get_window(sci); } + /* implementation of View::ssm() */ inline sptr_t - ssm(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) + ssm_impl(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) { return scintilla_send_message(sci, iMessage, wParam, lParam); } } ViewCurrent; -typedef class InterfaceNCurses : public Interface { +typedef class InterfaceNCurses : public Interface<InterfaceNCurses, ViewNCurses> { SCREEN *screen; FILE *screen_tty; @@ -90,42 +91,54 @@ public: current_view(NULL) {} ~InterfaceNCurses(); - void main(int &argc, char **&argv); + /* implementation of Interface::main() */ + void main_impl(int &argc, char **&argv); - void vmsg(MessageType type, const gchar *fmt, va_list ap); + /* implementation of Interface::vmsg() */ + void vmsg_impl(MessageType type, const gchar *fmt, va_list ap); + /* override of Interface::msg_clear() */ void msg_clear(void); - void show_view(View *view); - inline View * - get_current_view(void) + /* implementation of Interface::show_view() */ + void show_view_impl(ViewNCurses *view); + /* implementation of Interface::get_current_view() */ + inline ViewNCurses * + get_current_view_impl(void) { return current_view; } + /* implementation of Interface::ssm() */ inline sptr_t - ssm(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) + ssm_impl(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) { return current_view->ssm(iMessage, wParam, lParam); } + /* implementation of Interface::undo_ssm() */ inline void - undo_ssm(unsigned int iMessage, - uptr_t wParam = 0, sptr_t lParam = 0) + undo_ssm_impl(unsigned int iMessage, + uptr_t wParam = 0, sptr_t lParam = 0) { current_view->undo_ssm(iMessage, wParam, lParam); } - void info_update(QRegister *reg); - void info_update(Buffer *buffer); + /* implementation of Interface::info_update() */ + void info_update_impl(QRegister *reg); + void info_update_impl(Buffer *buffer); - void cmdline_update(const gchar *cmdline = NULL); + /* implementation of Interface::cmdline_update() */ + void cmdline_update_impl(const gchar *cmdline = NULL); - void popup_add(PopupEntryType type, - const gchar *name, bool highlight = false); - void popup_show(void); - void popup_clear(void); + /* implementation of Interface::popup_add() */ + void popup_add_impl(PopupEntryType type, + const gchar *name, bool highlight = false); + /* implementation of Interface::popup_show() */ + void popup_show_impl(void); + /* implementation of Interface::popup_clear() */ + void popup_clear_impl(void); - /* main entry point */ - void event_loop(void); + /* main entry point (implementation) */ + void event_loop_impl(void); private: void init_screen(void); |