aboutsummaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am9
-rw-r--r--src/cmdline.c5
-rw-r--r--src/interface-curses/interface.c14
-rw-r--r--src/interface-gtk/interface.c4
-rw-r--r--src/interface.c4
-rw-r--r--src/interface.h2
-rw-r--r--src/parser.h1
-rw-r--r--src/symbols.c85
-rw-r--r--src/view.c4
9 files changed, 68 insertions, 60 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 194d8ee..76c5843 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -9,7 +9,7 @@ LIBSCITECO_INTERFACE = interface-curses/libsciteco-interface.la
endif
include $(top_srcdir)/bootstrap.am
-include $(top_srcdir)/scintilla.am
+include $(top_srcdir)/contrib/scintilla.am
# FIXME: Common flags should be in configure.ac
AM_CFLAGS = -std=gnu11 -Wall -Wno-initializer-overrides -Wno-unused-value
@@ -74,7 +74,8 @@ sciteco_minimal_SOURCES =
symbols-scintilla.c symbols-scilexer.c : sciteco-minimal$(EXEEXT)
endif
sciteco_minimal_LDADD = libsciteco-base.la \
- @SCINTILLA_PATH@/bin/scintilla.a
+ @SCINTILLA_PATH@/bin/scintilla.a \
+ @LEXILLA_PATH@/bin/liblexilla.a
# Scintilla is unfortunately still written in C++, so we must force
# Automake to use the C++ linker when linking the binaries.
# The following hack is actually advocated in the Automake manual.
@@ -102,7 +103,7 @@ symbols-scintilla.c : @SCINTILLA_PATH@/include/Scintilla.h \
$(SCITECO_MINIMAL) -m -- @srcdir@/symbols-extract.tes \
-p "SCI_" -n teco_symbol_list_scintilla $@ $<
-symbols-scilexer.c : @SCINTILLA_PATH@/include/SciLexer.h \
+symbols-scilexer.c : @LEXILLA_PATH@/include/SciLexer.h \
symbols-extract.tes
$(SCITECO_MINIMAL) -m -- @srcdir@/symbols-extract.tes \
- -p "SCLEX_,SCE_" -n teco_symbol_list_scilexer $@ $<
+ -p "SCE_" -n teco_symbol_list_scilexer $@ $<
diff --git a/src/cmdline.c b/src/cmdline.c
index 9e73e4e..018998e 100644
--- a/src/cmdline.c
+++ b/src/cmdline.c
@@ -923,10 +923,11 @@ teco_state_scintilla_symbols_process_edit_cmd(teco_machine_main_t *ctx, teco_mac
: &teco_symbol_list_scilexer;
g_auto(teco_string_t) new_chars, new_chars_escaped;
gboolean unambiguous = teco_symbol_list_auto_complete(list, symbol, &new_chars);
+
+ teco_machine_stringbuilding_escape(stringbuilding_ctx, new_chars.data, new_chars.len, &new_chars_escaped);
/*
- * FIXME: Does not escape `,`. Also, <^Q,> is not allowed currently?
+ * FIXME: Does not escape `,`.
*/
- teco_machine_stringbuilding_escape(stringbuilding_ctx, new_chars.data, new_chars.len, &new_chars_escaped);
if (unambiguous)
teco_string_append_c(&new_chars_escaped, ',');
diff --git a/src/interface-curses/interface.c b/src/interface-curses/interface.c
index 5470264..825a312 100644
--- a/src/interface-curses/interface.c
+++ b/src/interface-curses/interface.c
@@ -57,7 +57,7 @@
#endif
#include <Scintilla.h>
-#include <ScintillaTerm.h>
+#include <ScintillaCurses.h>
#include "sciteco.h"
#include "string-utils.h"
@@ -262,7 +262,7 @@ teco_xterm_version(void)
*/
static void
-teco_view_scintilla_notify(Scintilla *sci, int idFrom, void *notify, void *user_data)
+teco_view_scintilla_notify(void *sci, int iMessage, SCNotification *notify, void *user_data)
{
teco_interface_process_notify(notify);
}
@@ -270,31 +270,31 @@ teco_view_scintilla_notify(Scintilla *sci, int idFrom, void *notify, void *user_
teco_view_t *
teco_view_new(void)
{
- return (teco_view_t *)scintilla_new(teco_view_scintilla_notify);
+ return (teco_view_t *)scintilla_new(teco_view_scintilla_notify, NULL);
}
static inline void
teco_view_noutrefresh(teco_view_t *ctx)
{
- scintilla_noutrefresh((Scintilla *)ctx);
+ scintilla_noutrefresh(ctx);
}
static inline WINDOW *
teco_view_get_window(teco_view_t *ctx)
{
- return scintilla_get_window((Scintilla *)ctx);
+ return scintilla_get_window(ctx);
}
sptr_t
teco_view_ssm(teco_view_t *ctx, unsigned int iMessage, uptr_t wParam, sptr_t lParam)
{
- return scintilla_send_message((Scintilla *)ctx, iMessage, wParam, lParam);
+ return scintilla_send_message(ctx, iMessage, wParam, lParam);
}
void
teco_view_free(teco_view_t *ctx)
{
- scintilla_delete((Scintilla *)ctx);
+ scintilla_delete(ctx);
}
static struct {
diff --git a/src/interface-gtk/interface.c b/src/interface-gtk/interface.c
index 567f034..5b9f530 100644
--- a/src/interface-gtk/interface.c
+++ b/src/interface-gtk/interface.c
@@ -92,8 +92,8 @@ teco_bgr2rgb(guint32 bgr)
*/
static void
-teco_view_scintilla_notify(ScintillaObject *sci, gint id,
- struct SCNotification *notify, gpointer user_data)
+teco_view_scintilla_notify(ScintillaObject *sci, gint iMessage,
+ SCNotification *notify, gpointer user_data)
{
teco_interface_process_notify(notify);
}
diff --git a/src/interface.c b/src/interface.c
index 21a83ff..2c06cd0 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -27,9 +27,9 @@
#include <glib/gstdio.h>
#include <Scintilla.h>
-#include <SciLexer.h>
#include "sciteco.h"
+#include "string-utils.h"
#include "undo.h"
#include "view.h"
#include "interface.h"
@@ -112,7 +112,7 @@ teco_interface_stdio_vmsg(teco_msg_t type, const gchar *fmt, va_list ap)
}
void
-teco_interface_process_notify(struct SCNotification *notify)
+teco_interface_process_notify(SCNotification *notify)
{
#ifdef DEBUG
g_printf("SCINTILLA NOTIFY: code=%d\n", notify->nmhdr.code);
diff --git a/src/interface.h b/src/interface.h
index c396225..ff98be0 100644
--- a/src/interface.h
+++ b/src/interface.h
@@ -149,7 +149,7 @@ gboolean teco_interface_event_loop(GError **error);
*/
/** @protected */
void teco_interface_stdio_vmsg(teco_msg_t type, const gchar *fmt, va_list ap);
-void teco_interface_process_notify(struct SCNotification *notify);
+void teco_interface_process_notify(SCNotification *notify);
/** @pure */
void teco_interface_cleanup(void);
diff --git a/src/parser.h b/src/parser.h
index b594edc..21c0e20 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -405,7 +405,6 @@ typedef struct {
typedef struct {
unsigned int iMessage;
uptr_t wParam;
- sptr_t lParam;
} teco_machine_scintilla_t;
typedef enum {
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;
}
diff --git a/src/view.c b/src/view.c
index 0ccf42e..80835a2 100644
--- a/src/view.c
+++ b/src/view.c
@@ -77,12 +77,14 @@ teco_view_setup(teco_view_t *ctx)
* a consistent look across UIs if no profile
* is used. This makes writing UI-agnostic profiles
* and color schemes easier.
+ *
* FIXME: Some settings like fonts should probably
* be set per UI (i.e. Scinterm doesn't use it,
* GTK might try to use a system-wide default
* monospaced font).
*/
- teco_view_ssm(ctx, SCI_SETCARETSTYLE, CARETSTYLE_BLOCK, 0);
+ teco_view_ssm(ctx, SCI_SETCARETSTYLE,
+ CARETSTYLE_BLOCK | CARETSTYLE_OVERSTRIKE_BLOCK | CARETSTYLE_BLOCK_AFTER, 0);
teco_view_ssm(ctx, SCI_SETCARETPERIOD, 0, 0);
teco_view_ssm(ctx, SCI_SETCARETFORE, 0xFFFFFF, 0);