aboutsummaryrefslogtreecommitdiffhomepage
path: root/symbols.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-24 17:56:29 +0100
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-11-24 17:56:29 +0100
commitfad826dcfe095d57aa5faf6cc8a863069f65b0d6 (patch)
tree729df2493b9a56a023ac04868bb5069451e27f45 /symbols.cpp
parent0e536bd36250419698fe884d01d5997581241d93 (diff)
downloadsciteco-fad826dcfe095d57aa5faf6cc8a863069f65b0d6.tar.gz
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
Diffstat (limited to 'symbols.cpp')
-rw-r--r--symbols.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/symbols.cpp b/symbols.cpp
index c123ebc..8e81354 100644
--- a/symbols.cpp
+++ b/symbols.cpp
@@ -1,3 +1,5 @@
+#include <string.h>
+
#include <glib.h>
#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;