aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/symbols.c
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-11 08:02:05 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2021-10-11 08:02:05 +0300
commit6e67f5a682ff46d69888fec61b94bf45cec46721 (patch)
tree4d3bdae0e48a3d69e238c369f6b283975560546d /src/symbols.c
parent9b273f1664946543a6f3d8de5058450d412249a1 (diff)
downloadsciteco-6e67f5a682ff46d69888fec61b94bf45cec46721.tar.gz
upgraded to Scintilla 5.1.3 and Scinterm 3.1
* Previous Scintilla version was 3.6.4 and Scinterm was 1.7 (with lots of custom patches). All of the patches are now either irrelevant or have been merged upstream. * Since Scintilla 5 requires C++17, this increases the minimum GCC version at least to 5.0. We may actually require even newer versions. * I could not upgrade the scintilla-mirror (which was imported from Mercurial), so the old sciteco-dev branch was renamed to sciteco-dev-pre-v2.0.0, master was deleted and I reimported the entire Scintilla repo using git-remote-hg. This means that scintilla-mirror now contains two entirely separate trees. But it is still possible to clone old SciTECO repos. * The strategy/workflow of maintaining hotfix branches on scintilla-mirror has been changed. Instead of having one sciteco-dev branch that is rebased onto new Scintilla upstream releases and tagging SciTECO releases in scintilla-mirror (to keep the commits referenced), we now create a branch for every Scintilla version we are based on (eg. sciteco-rel-5-1-3). This branch is never rebased or deleted. Therefore, we are guaranteed to be able to clone arbitrary SciTECO repo commits - not only releases. Releases no longer have to be tagged in scintilla-mirror. On the downside, fixup commits may accumulate in these new branches. They can only be squashed once a new branch for a new Scintilla release is created (e.g. by cherry-picking followed by rebase). * Scinterm does no longer have to reside in the Scintilla subdirectory, so we added it as a regular submodule. There are no more recursive submodules. The Scinterm build system has not been improved at all, but we use a trick based on VPATH to build Scinterm in scintilla/bin/. * Scinterm is now in Git and we reference the upstream repo for the time being. We might mirror it and apply the same branching workflow as with Scintilla if necessary. The scinterm-mirror repository still exists but has not been touched. We will also have to rewrite its master branch as it was a non-reproducible Mercurial import. * Scinterm now also comes with patches for Scintilla which we simply applied on our sciteco-rel-5-1-3 branch. * Scintilla 5 outsourced its lexers into the Lexilla project. We added it as yet another submodule. * All submodules have been moved into contrib/. * The Scintilla API for setting lexers has consequently changed. We now have to call SCI_SETILEXER(0, CreateLexer(name)). As I did not want to introduce a separate command for setting lexers, <ES> has been extended to allow setting lexers by name with the SCI_SETILEXER message which effectively replaces SCI_SETLEXERLANGUAGE. * The lexer macros (SCLEX_...) no longer serve any purpose - they weren't used in the SciTECO standard library anyway - and have consequently been removed from symbols-scilexer.c. The style macros from SciLexer.h (SCE_...) are theoretically still useful - even though they are not used by our current color schemes - and have therefore been retained. They can be specified as wParam in <ES>. * <ES> no longer allows symbolic constants for lParam. This never made any sense since all supported symbols were always wParam. * Scinterm supports new native cursor modes. They are not used for the time being and the previous CARETSTYLE_BLOCK_AFTER caret style is configured by default. It makes no sense to enable native cursor modes now since the command line should have a native cursor but is not yet a Scintilla view. * The Scintilla upgrade performed much worse than before, so some optimizations will be necessary.
Diffstat (limited to 'src/symbols.c')
-rw-r--r--src/symbols.c85
1 files changed, 45 insertions, 40 deletions
diff --git a/src/symbols.c b/src/symbols.c
index 003d745..fc2ec5b 100644
--- a/src/symbols.c
+++ b/src/symbols.c
@@ -24,6 +24,9 @@
#include <glib.h>
+#include <Scintilla.h>
+#include <Lexilla.h>
+
#include "sciteco.h"
#include "string-utils.h"
#include "error.h"
@@ -194,26 +197,13 @@ teco_scintilla_parse_symbols(teco_machine_scintilla_t *scintilla, const teco_str
gint v = teco_symbol_list_lookup(&teco_symbol_list_scilexer, symbols[1], "");
if (v < 0) {
g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Unknown Scintilla Lexer symbol \"%s\"",
+ "Unknown Lexilla style symbol \"%s\"",
symbols[1]);
return FALSE;
}
scintilla->wParam = v;
}
- if (!symbols[2])
- return TRUE;
- if (*symbols[2]) {
- gint v = teco_symbol_list_lookup(&teco_symbol_list_scilexer, symbols[2], "");
- if (v < 0) {
- g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Unknown Scintilla Lexer symbol \"%s\"",
- symbols[2]);
- return FALSE;
- }
- scintilla->lParam = v;
- }
-
return TRUE;
}
@@ -263,35 +253,40 @@ gboolean teco_state_scintilla_symbols_process_edit_cmd(teco_machine_main_t *ctx,
/*$ ES scintilla message
* -- Send Scintilla message
- * [lParam[,wParam]]ESmessage[,wParam[,lParam]]$[lParam]$ -> result
+ * [lParam,][wParam,][message]ES[message][,wParam]$[lParam]$ -> result
*
- * Send Scintilla message with code specified by symbolic
- * name <message>, <wParam> and <lParam>.
- * <wParam> may be symbolic when specified as part of the
- * first string argument.
- * If not it is popped from the stack.
+ * Send Scintilla message with code specified by
+ * <message>, <wParam> and <lParam>.
+ * <message> and <wParam> may be a symbolic names when specified as
+ * part of the first string argument.
+ * If not, they are popped from the stack.
* <lParam> may be specified as a constant string whose
* pointer is passed to Scintilla if specified as the second
* string argument.
+ * It is automatically null-terminated.
* If the second string argument is empty, <lParam> is popped
* from the stack instead.
* Parameters popped from the stack may be omitted, in which
* case 0 is implied.
* The message's return value is pushed onto the stack.
*
- * All messages defined by Scintilla (as C macros) can be
- * used by passing their name as a string to ES
+ * All messages defined by Scintilla (as C macros in Scintilla.h)
+ * can be used by passing their name as a string to ES
* (e.g. ESSCI_LINESONSCREEN...).
* The \(lqSCI_\(rq prefix may be omitted and message symbols
* are case-insensitive.
- * Only the Scintilla lexer symbols (SCLEX_..., SCE_...)
- * may be used symbolically with the ES command as <wParam>,
- * other values must be passed as integers on the stack.
+ * Only the Lexilla style names (SCE_...)
+ * may be used symbolically with the ES command as <wParam>.
* In interactive mode, symbols may be auto-completed by
* pressing Tab.
* String-building characters are by default interpreted
* in the string arguments.
*
+ * As a special exception, you can and must specify a
+ * Lexilla lexer name as a string argument for the \fBSCI_SETILEXER\fP
+ * message, ie. in order to load a Lexilla lexer
+ * (this works similar to the old \fBSCI_SETLEXERLANGUAGE\fP message).
+ *
* .BR Warning :
* Almost all Scintilla messages may be dispatched using
* this command.
@@ -322,26 +317,36 @@ teco_state_scintilla_lparam_done(teco_machine_main_t *ctx, const teco_string_t *
if (ctx->mode > TECO_MODE_NORMAL)
return &teco_state_start;
- if (teco_string_contains(str, '\0')) {
- g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
- "Scintilla lParam string must not contain null-byte.");
- return NULL;
- }
+ sptr_t lParam = 0;
+
+ if (ctx->scintilla.iMessage == SCI_SETILEXER) {
+ if (teco_string_contains(str, '\0')) {
+ g_set_error_literal(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Lexer name must not contain null-byte.");
+ return NULL;
+ }
- if (!ctx->scintilla.lParam) {
- if (str->len > 0) {
- ctx->scintilla.lParam = (sptr_t)str->data;
- } else {
- teco_int_t v;
- if (!teco_expressions_pop_num_calc(&v, 0, error))
- return NULL;
- ctx->scintilla.lParam = v;
+ lParam = (sptr_t)CreateLexer(str->data);
+ if (!lParam) {
+ g_set_error(error, TECO_ERROR, TECO_ERROR_FAILED,
+ "Lexilla lexer \"%s\" not found.", str->data);
+ return NULL;
}
+ } else if (str->len > 0) {
+ /*
+ * NOTE: There may even be messages that read strings
+ * with embedded nulls.
+ */
+ lParam = (sptr_t)str->data;
+ } else {
+ teco_int_t v;
+ if (!teco_expressions_pop_num_calc(&v, 0, error))
+ return NULL;
+ lParam = v;
}
teco_expressions_push(teco_interface_ssm(ctx->scintilla.iMessage,
- ctx->scintilla.wParam,
- ctx->scintilla.lParam));
+ ctx->scintilla.wParam, lParam));
return &teco_state_start;
}