diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-11 08:43:33 +0300 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2021-10-11 08:43:33 +0300 |
commit | 8baa1b3ebe163de3a55696e50d49f160529473b3 (patch) | |
tree | c7d54d763c5743765206ab125fffc28cea9d95d6 /src | |
parent | 6e67f5a682ff46d69888fec61b94bf45cec46721 (diff) | |
download | sciteco-8baa1b3ebe163de3a55696e50d49f160529473b3.tar.gz |
optimized character representation setting
* Esp. with the new Scintilla version, the representation
setting as part of every SCI_SETDOCPOINTER has turned out to
be a performance bottleneck.
* The new Scintilla has a custom tweak/patch that disables any
automatic representation setting in Scintilla itself.
It is now sufficient to initialize the SciTECO-style representations
only once in the lifetime of any view.
Diffstat (limited to 'src')
-rw-r--r-- | src/doc.c | 31 | ||||
-rw-r--r-- | src/interface-curses/curses-utils.c | 2 | ||||
-rw-r--r-- | src/ring.c | 2 | ||||
-rw-r--r-- | src/view.c | 10 | ||||
-rw-r--r-- | src/view.h | 3 |
5 files changed, 15 insertions, 33 deletions
@@ -41,19 +41,6 @@ teco_doc_get_scintilla(teco_doc_t *ctx) void teco_doc_edit(teco_doc_t *ctx) { - /* - * FIXME: SCI_SETREPRESENTATION does not redraw - * the screen - also that would be very slow. - * Since SCI_SETDOCPOINTER resets the representation - * (this should probably be fixed in Scintilla), - * the screen is garbled since the layout cache - * is calculated with the default representations. - * We work around this by temporarily disabling the - * layout cache. - */ - gint old_mode = teco_view_ssm(teco_qreg_view, SCI_GETLAYOUTCACHE, 0, 0); - teco_view_ssm(teco_qreg_view, SCI_SETLAYOUTCACHE, SC_CACHE_NONE, 0); - teco_view_ssm(teco_qreg_view, SCI_SETDOCPOINTER, 0, (sptr_t)teco_doc_get_scintilla(ctx)); teco_view_ssm(teco_qreg_view, SCI_SETFIRSTVISIBLELINE, ctx->first_line, 0); @@ -61,12 +48,11 @@ teco_doc_edit(teco_doc_t *ctx) teco_view_ssm(teco_qreg_view, SCI_SETSEL, ctx->anchor, (sptr_t)ctx->dot); /* - * Default TECO-style character representations. - * They are reset on EVERY SETDOCPOINTER call by Scintilla. + * NOTE: Thanks to a custom Scintilla patch, se representations + * do not get reset after SCI_SETDOCPOINTER, so they have to be + * initialized only once. */ - teco_view_set_representations(teco_qreg_view); - - teco_view_ssm(teco_qreg_view, SCI_SETLAYOUTCACHE, old_mode, 0); + //teco_view_set_representations(teco_qreg_view); } /** @memberof teco_doc_t */ @@ -74,20 +60,15 @@ void teco_doc_undo_edit(teco_doc_t *ctx) { /* - * FIXME: see above in teco_doc_edit() + * NOTE: see above in teco_doc_edit() */ - undo__teco_view_ssm(teco_qreg_view, SCI_SETLAYOUTCACHE, - teco_view_ssm(teco_qreg_view, SCI_GETLAYOUTCACHE, 0, 0), 0); - - undo__teco_view_set_representations(teco_qreg_view); + //undo__teco_view_set_representations(teco_qreg_view); undo__teco_view_ssm(teco_qreg_view, SCI_SETSEL, ctx->anchor, (sptr_t)ctx->dot); undo__teco_view_ssm(teco_qreg_view, SCI_SETXOFFSET, ctx->xoffset, 0); undo__teco_view_ssm(teco_qreg_view, SCI_SETFIRSTVISIBLELINE, ctx->first_line, 0); undo__teco_view_ssm(teco_qreg_view, SCI_SETDOCPOINTER, 0, (sptr_t)teco_doc_get_scintilla(ctx)); - - undo__teco_view_ssm(teco_qreg_view, SCI_SETLAYOUTCACHE, SC_CACHE_NONE, 0); } /** @memberof teco_doc_t */ diff --git a/src/interface-curses/curses-utils.c b/src/interface-curses/curses-utils.c index ace5795..1ae24f2 100644 --- a/src/interface-curses/curses-utils.c +++ b/src/interface-curses/curses-utils.c @@ -43,7 +43,7 @@ teco_curses_format_str(WINDOW *win, const gchar *str, gsize len, gint max_width) while (len > 0) { /* * NOTE: This mapping is similar to - * View::set_representations() + * teco_view_set_representations(). */ switch (*str) { case '\e': @@ -45,8 +45,6 @@ teco_buffer_new(void) teco_buffer_t *ctx = g_new0(teco_buffer_t, 1); ctx->view = teco_view_new(); teco_view_setup(ctx->view); - /* only have to do this once: */ - teco_view_set_representations(ctx->view); return ctx; } @@ -107,6 +107,14 @@ teco_view_setup(teco_view_t *ctx) */ teco_view_ssm(ctx, SCI_STYLESETFORE, STYLE_CALLTIP, 0x000000); teco_view_ssm(ctx, SCI_STYLESETBACK, STYLE_CALLTIP, 0xFFFFFF); + + /* + * Since we have patched out Scintilla's original SetRepresentations(), + * it no longer resets them on SCI_SETDOCPOINTER. + * Therefore it is sufficient for all kinds of views to initialize + * the representations only once. + */ + teco_view_set_representations(ctx); } TECO_DEFINE_UNDO_CALL(teco_view_ssm, teco_view_t *, unsigned int, uptr_t, sptr_t); @@ -128,8 +136,6 @@ teco_view_set_representations(teco_view_t *ctx) } } -TECO_DEFINE_UNDO_CALL(teco_view_set_representations, teco_view_t *); - /** * Loads the view's document by reading all data from * a GIOChannel. @@ -45,9 +45,6 @@ void undo__teco_view_ssm(teco_view_t *, unsigned int, uptr_t, sptr_t); void teco_view_set_representations(teco_view_t *ctx); /** @memberof teco_view_t */ -void undo__teco_view_set_representations(teco_view_t *); - -/** @memberof teco_view_t */ static inline void teco_view_set_scintilla_undo(teco_view_t *ctx, gboolean state) { |