From fad826dcfe095d57aa5faf6cc8a863069f65b0d6 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Sat, 24 Nov 2012 17:56:29 +0100 Subject: allow symbolic names (symbols) being specified for the scintilla (ES) command * new syntax is <[lParam,[wParam,[msg]]]>ES[msg[,wParam[,lParam]]]$[lParam string]$ * symbols are matched case-insensitive, the leading SCI_ for message symbols may be omitted * added support for more multiple string arguments (for commands in general) * fixed "C conditional: succeeds for every alpanumeric character, dot, dollar or underscore * added SCLEX_ and SCE_ constants as symbols * updated teco.ini: using symbolic names is preferred since that way code does not depend on the current Scintilla version --- symbols.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'symbols.cpp') diff --git a/symbols.cpp b/symbols.cpp index c123ebc..8e81354 100644 --- a/symbols.cpp +++ b/symbols.cpp @@ -1,3 +1,5 @@ +#include + #include #include "symbols.h" @@ -7,6 +9,7 @@ */ namespace Symbols { SymbolList __attribute__((weak)) scintilla; + SymbolList __attribute__((weak)) scilexer; } /* @@ -14,14 +17,24 @@ namespace Symbols { * binary search. */ gint -SymbolList::lookup(const gchar *name) +SymbolList::lookup(const gchar *name, const gchar *prefix, bool case_sensitive) { + int (*cmp_fnc)(const char *, const char *, size_t); + gint prefix_skip = strlen(prefix); + gint name_len = strlen(name); + gint left = 0; gint right = size - 1; + cmp_fnc = case_sensitive ? strncmp : g_ascii_strncasecmp; + + if (!cmp_fnc(name, prefix, prefix_skip)) + prefix_skip = 0; + while (left <= right) { gint cur = left + (right-left)/2; - gint cmp = g_strcmp0(entries[cur].name, name); + gint cmp = cmp_fnc(entries[cur].name + prefix_skip, + name, name_len + 1); if (!cmp) return entries[cur].value; -- cgit v1.2.3