diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-02 15:33:00 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2024-09-09 18:22:21 +0200 |
commit | 33124e3d469d028f367b5fcd1f1a7197754f8f09 (patch) | |
tree | bd864a0d11213556c8495c84d2362b70d56d5b18 /src/doc.c | |
parent | e466218d6c608ec4456384dc94aefafdb5b60586 (diff) | |
download | sciteco-33124e3d469d028f367b5fcd1f1a7197754f8f09.tar.gz |
:EL can be used to perform codepage conversions now (refs #5)
* I decoded the Scintilla charset values into codepages, at least
those used on Gtk.
* make sure that the line character index is not allocated or released
too often, as it is actually internally reference counted, which
could result in it missing when we really need it.
* The line character index still appears to be released whenever
the document pointer changes, which will happen after using
a different Q-Register.
This could be a performance bottleneck (FIXME).
Diffstat (limited to 'src/doc.c')
-rw-r--r-- | src/doc.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -48,22 +48,28 @@ teco_doc_edit(teco_doc_t *ctx) teco_view_ssm(teco_qreg_view, SCI_SETSEL, ctx->anchor, (sptr_t)ctx->dot); /* - * NOTE: Thanks to a custom Scintilla patch, se representations + * NOTE: Thanks to a custom Scintilla patch, representations * do not get reset after SCI_SETDOCPOINTER, so they have to be * initialized only once. */ //teco_view_set_representations(teco_qreg_view); /* - * Documents are UTF-8 by default and all UTF-8 documents - * are expected to have a character index. + * All UTF-8 documents are expected to have a character index. + * This allocates nothing if the document is not UTF-8. + * But it is reference counted, so it must not be allocated + * more than once. * - * FIXME: This apparently gets reset with every SCI_SETDOCPOINTER. - * Does that mean the index needs to be recalculated repeatedly as well? - * What if the document/register is made non-UTF-8 afterwards? + * FIXME: This apparently gets reset with every SCI_SETDOCPOINTER + * (although I don't know why and where). + * Recalculating it could be inefficient. + * The index is reference-counted. Perhaps we could just allocate + * one more time, so it doesn't get freed when changing documents. */ - teco_view_ssm(teco_qreg_view, SCI_ALLOCATELINECHARACTERINDEX, - SC_LINECHARACTERINDEX_UTF32, 0); + if (!(teco_view_ssm(teco_qreg_view, + SCI_GETLINECHARACTERINDEX, 0, 0) & SC_LINECHARACTERINDEX_UTF32)) + teco_view_ssm(teco_qreg_view, SCI_ALLOCATELINECHARACTERINDEX, + SC_LINECHARACTERINDEX_UTF32, 0); } /** @memberof teco_doc_t */ |