From 8be99d3863a305046f0133116782734e87be0822 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 14 Nov 2014 02:43:23 +0100 Subject: first working version of the one-view-per-buffer design The user interface provides a Scintilla view abstraction and every buffer is based on a view. All Q-Register strings use a single dedicated view to save memory and initialization time when using many string registers. * this means we can finally implement a working lexer configuration and it only has to be done once when the buffer is first added to the ring. It is unnecessary to magically restore the lexer styles upon rubout of EB (very hard to implement anyway). It is also not necessary to rerun the lexer configuration macro upon rubout which would be hard to reconcile with SciTECO's basic design since every side-effect should be attached to a character. * this means that opening buffers is slightly slower now because of the view initialization * on the other hand, macros with many string q-reg operations are faster now, since the document must no longer be changed on the buffer's view and restored later on. * also now we can make a difference between editing a document in a view and changing the current view, which reduces UI calls * the Document class has been retained as an abstraction about Scintilla documents, used by QRegister Strings. It had to be made virtual, so the view on which the document is created can be specified by a virtual function. There is no additional space overhead for Documents. --- src/interface-ncurses.h | 51 ++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 7 deletions(-) (limited to 'src/interface-ncurses.h') diff --git a/src/interface-ncurses.h b/src/interface-ncurses.h index f1003de..647b1ef 100644 --- a/src/interface-ncurses.h +++ b/src/interface-ncurses.h @@ -31,19 +31,44 @@ namespace SciTECO { +typedef class ViewNCurses : public View { + Scintilla *sci; + +public: + ViewNCurses(); + ~ViewNCurses(); + + inline void + refresh(void) + { + scintilla_refresh(sci); + } + + inline WINDOW * + get_window(void) + { + return scintilla_get_window(sci); + } + + inline sptr_t + ssm(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 { SCREEN *screen; FILE *screen_tty; - Scintilla *sci; - WINDOW *info_window; gchar *info_current; - WINDOW *sci_window; WINDOW *msg_window; WINDOW *cmdline_window; gchar *cmdline_current; + ViewNCurses *current_view; + struct Popup { WINDOW *window; GSList *list; @@ -57,13 +82,12 @@ typedef class InterfaceNCurses : public Interface { public: InterfaceNCurses() : screen(NULL), screen_tty(NULL), - sci(NULL), info_window(NULL), info_current(NULL), - sci_window(NULL), msg_window(NULL), cmdline_window(NULL), - cmdline_current(NULL) {} + cmdline_current(NULL), + current_view(NULL) {} ~InterfaceNCurses(); void main(int &argc, char **&argv); @@ -71,10 +95,23 @@ public: void vmsg(MessageType type, const gchar *fmt, va_list ap); void msg_clear(void); + void show_view(View *view); + inline View * + get_current_view(void) + { + return current_view; + } + inline sptr_t ssm(unsigned int iMessage, uptr_t wParam = 0, sptr_t lParam = 0) { - return scintilla_send_message(sci, iMessage, wParam, lParam); + return current_view->ssm(iMessage, wParam, lParam); + } + inline void + undo_ssm(unsigned int iMessage, + uptr_t wParam = 0, sptr_t lParam = 0) + { + current_view->undo_ssm(iMessage, wParam, lParam); } void info_update(QRegister *reg); -- cgit v1.2.3