aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-11 08:43:33 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-11 08:43:33 +0300
commit8baa1b3ebe163de3a55696e50d49f160529473b3 (patch)
treec7d54d763c5743765206ab125fffc28cea9d95d6 /src
parent6e67f5a682ff46d69888fec61b94bf45cec46721 (diff)
downloadsciteco-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.c31
-rw-r--r--src/interface-curses/curses-utils.c2
-rw-r--r--src/ring.c2
-rw-r--r--src/view.c10
-rw-r--r--src/view.h3
5 files changed, 15 insertions, 33 deletions
diff --git a/src/doc.c b/src/doc.c
index 41acf40..9485f13 100644
--- a/src/doc.c
+++ b/src/doc.c
@@ -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':
diff --git a/src/ring.c b/src/ring.c
index f9cf41f..606c3de 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -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;
}
diff --git a/src/view.c b/src/view.c
index 80835a2..3d67bef 100644
--- a/src/view.c
+++ b/src/view.c
@@ -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.
diff --git a/src/view.h b/src/view.h
index b666d0a..a918c00 100644
--- a/src/view.h
+++ b/src/view.h
@@ -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)
{