aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile72
-rw-r--r--src/lutf8libext.patch178
-rw-r--r--src/scintilla.patch161
-rw-r--r--src/textadept.c26
-rw-r--r--src/tre.patch49
5 files changed, 261 insertions, 225 deletions
diff --git a/src/Makefile b/src/Makefile
index 315f696d..a3c15ec8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -97,7 +97,8 @@ endif
# Scintilla.
sci_flags = -pedantic $(plat_flag) -DSCI_LEXER -DNDEBUG -DNO_CXX11_REGEX \
- -Iscintilla/include -Iscintilla/src -Iscintilla/lexlib -Wall
+ -DSCI_OWNREGEX -Iscintilla/include -Iscintilla/src \
+ -Iscintilla/lexlib -Itre/lib -Wall
sci_objs = AutoComplete.o CallTip.o CaseConvert.o CaseFolder.o Catalogue.o \
CellBuffer.o CharClassify.o ContractionState.o Decoration.o \
@@ -109,6 +110,9 @@ sci_lex_objs = Accessor.o CharacterSet.o LexerBase.o LexerModule.o \
LexerNoExceptions.o LexerSimple.o PropSetSimple.o \
StyleContext.o WordList.o
sci_gtk_objs = PlatGTK.o ScintillaGTK.o
+regex_objs = regcomp.o regerror.o regexec.o tre-ast.o tre-compile.o \
+ tre-filter.o tre-match-backtrack.o tre-match-parallel.o tre-mem.o \
+ tre-parse.o tre-stack.o xmalloc.o
lexlpeg_objs = LexLPeg.o LexLPegjit.o LexLPeg-curses.o LexLPegjit-curses.o
# Textadept.
@@ -124,9 +128,9 @@ lua_objs = lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o \
lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o \
lauxlib.o lbaselib.o lbitlib.o lcorolib.o ldblib.o liolib.o \
lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o
-lua_lib_objs = lpcap.o lpcode.o lpprint.o lptree.o lpvm.o lfs.o lutf8libext.o
+lua_lib_objs = lpcap.o lpcode.o lpprint.o lptree.o lpvm.o lfs.o
luajit_lib_objs = lpcapjit.o lpcodejit.o lpprintjit.o lptreejit.o lpvmjit.o \
- lfsjit.o lutf8libjit.o lutf8libextjit.o
+ lfsjit.o lutf8libjit.o
lua_spawn_objs = lspawn.o lspawnjit.o lspawn-curses.o lspawnjit-curses.o
gtdialog_objs = gtdialog.o gtdialog-curses.o
termkey_unix_objs = driver-ti.o driver-csi.o
@@ -160,6 +164,8 @@ $(sci_gtk_objs): %.o: scintilla/gtk/%.cxx
$(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $(GTK_CFLAGS) $< -o $@
scintilla-marshal.o: scintilla/gtk/scintilla-marshal.c
$(CROSS)$(CC) -c $(CFLAGS) $(GTK_CFLAGS) $< -o $@
+$(regex_objs): %.o: tre/lib/%.c
+ $(CROSS)$(CC) -c $(CFLAGS) -Itre/lib $< -o $@
ScintillaTerm.o: scintilla/term/ScintillaTerm.cxx
$(CROSS)$(CXX) -c $(CXXFLAGS) $(sci_flags) $(CURSES_CFLAGS) $< -o $@
$(lexlpeg_objs): LexLPeg.cxx
@@ -217,43 +223,45 @@ lutf8libjit.o: LUA_CFLAGS += -Ilua/src
# Executables.
textadept: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \
- LexLPeg.o textadept.o $(lua_objs) $(lua_lib_objs) lspawn.o gtdialog.o
+ $(regex_objs) LexLPeg.o textadept.o $(lua_objs) $(lua_lib_objs) \
+ lspawn.o gtdialog.o
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS)
textadeptjit: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \
- LexLPegjit.o textadeptjit.o $(luajit_lib_objs) $(libluajit) \
- lspawnjit.o gtdialog.o
+ $(regex_objs) LexLPegjit.o textadeptjit.o $(luajit_lib_objs) \
+ $(libluajit) lspawnjit.o gtdialog.o
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS)
-textadept-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o LexLPeg-curses.o \
- textadept-curses.o $(lua_objs) $(lua_lib_objs) \
- lspawn-curses.o gtdialog-curses.o termkey.o \
+textadept-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o $(regex_objs) \
+ LexLPeg-curses.o textadept-curses.o $(lua_objs) \
+ $(lua_lib_objs) lspawn-curses.o gtdialog-curses.o termkey.o \
$(termkey_unix_objs) $(cdk_objs)
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS)
-textadeptjit-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \
+textadeptjit-curses: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o $(regex_objs) \
LexLPegjit-curses.o textadeptjit-curses.o \
$(luajit_lib_objs) $(libluajit) lspawnjit-curses.o \
gtdialog-curses.o termkey.o $(termkey_unix_objs) \
$(cdk_objs)
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS)
textadept.exe: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) scintilla-marshal.o \
- LexLPeg.o textadept.o textadept_rc.o $(lua_objs) \
+ $(regex_objs) LexLPeg.o textadept.o textadept_rc.o $(lua_objs) \
$(lua_lib_objs) lspawn.o gtdialog.o
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS)
textadeptjit.exe: $(sci_objs) $(sci_lex_objs) $(sci_gtk_objs) \
- scintilla-marshal.o LexLPegjit.o textadeptjit.o \
- textadept_rc.o $(luajit_lib_objs) $(libluajit) lspawnjit.o \
- gtdialog.o
+ scintilla-marshal.o $(regex_objs) LexLPegjit.o \
+ textadeptjit.o textadept_rc.o $(luajit_lib_objs) \
+ $(libluajit) lspawnjit.o gtdialog.o
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(GTK_LIBS) $(LDFLAGS)
textadept-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \
- LexLPeg-curses.o textadept-curses.o textadept_rc.o \
- $(lua_objs) $(lua_lib_objs) lspawn-curses.o \
- gtdialog-curses.o termkey.o $(termkey_win32_objs) \
- $(cdk_objs)
+ $(regex_objs) LexLPeg-curses.o textadept-curses.o \
+ textadept_rc.o $(lua_objs) $(lua_lib_objs) \
+ lspawn-curses.o gtdialog-curses.o termkey.o \
+ $(termkey_win32_objs) $(cdk_objs)
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS)
textadeptjit-curses.exe: $(sci_objs) $(sci_lex_objs) ScintillaTerm.o \
- LexLPegjit-curses.o textadeptjit-curses.o \
- textadept_rc.o $(luajit_lib_objs) $(libluajit) \
- lspawnjit-curses.o gtdialog-curses.o termkey.o \
- $(termkey_win32_objs) $(cdk_objs)
+ $(regex_objs) LexLPegjit-curses.o \
+ textadeptjit-curses.o textadept_rc.o \
+ $(luajit_lib_objs) $(libluajit) lspawnjit-curses.o \
+ gtdialog-curses.o termkey.o $(termkey_win32_objs) \
+ $(cdk_objs)
$(CROSS)$(CXX) $(CXXFLAGS) -o ../$@ $^ $(CURSES_LIBS) $(LDFLAGS)
# Install/uninstall.
@@ -361,8 +369,8 @@ osx-app: ../textadept ../textadeptjit ../textadept-curses \
# External dependencies.
-base_deps = scintilla scintilla/term scintillua lua lualibs luajit gtdialog \
- cdk ../doc/bombay
+base_deps = scintilla tre scintilla/term scintillua lua lualibs luajit \
+ gtdialog cdk ../doc/bombay
deps: $(base_deps) termkey
win32-deps: $(base_deps) win32gtk win32curses
osx-deps: $(base_deps) gtkosx termkey
@@ -380,12 +388,12 @@ else
endif
scintilla_tgz = scintilla366.tgz
+tre_zip = cdce45e8dd7a3b36954022b4a4d3570e1ac5a4f8.zip
scinterm_zip = scinterm_1.8.zip
scintillua_zip = scintillua_3.6.5-1.zip
lua_tgz = lua-5.3.3.tar.gz
lpeg_tgz = lpeg-1.0.0.tar.gz
lfs_zip = v_1_6_3.zip
-luautf8_zip = 0.1.1.zip
lspawn_zip = lspawn_1.5.zip
luajit_tgz = LuaJIT-2.0.3.tar.gz
libluajit_tgz = libluajit_2.0.3.x86_64.tgz
@@ -405,6 +413,10 @@ $(scintilla_tgz): ; wget http://prdownloads.sourceforge.net/scintilla/$@ -O $@
scintilla: scintilla.patch | $(scintilla_tgz)
mkdir $@ && tar xzf $| -C $@ && mv $@/*/* $@
patch -d $@ -N -p1 < $<
+$(tre_zip): ; wget https://github.com/laurikari/tre/archive/$@ -O $@
+tre: tre.patch | $(tre_zip)
+ mkdir $@ && unzip -d $@ $| && mv $@/*/* $@
+ patch -d $@ -N -p1 < $<
$(scinterm_zip): ; wget $(scinterm_url) -O $@
scintilla/term: | $(scinterm_zip) ; mkdir $@ && unzip -d $@ $| && mv $@/*/* $@
scintillua: ../lexers LexLPeg.cxx
@@ -415,24 +427,16 @@ LexLPeg.cxx: | ../lexers ; ln -s $|/$@ $@
$(lua_tgz): ; wget http://www.lua.org/ftp/$@
$(lpeg_tgz): ; wget http://www.inf.puc-rio.br/~roberto/lpeg/$@
$(lfs_zip): ; wget http://github.com/keplerproject/luafilesystem/archive/$@
-$(luautf8_zip): ; wget https://github.com/starwing/luautf8/archive/$@
$(lspawn_zip): ; wget $(lspawn_url) -O $@
lua: lua.patch | $(lua_tgz)
mkdir $@ && tar xzf $| -C $@ && mv $@/*/* $@
patch -d $@ -N -p1 < $<
-lualibs: lua/src/lib/lpeg lua/src/lib/lfs lua/src/lib/lutf8libext \
- lua/src/lib/lspawn
+lualibs: lua/src/lib/lpeg lua/src/lib/lfs lua/src/lib/lspawn
lua/src/lib/lpeg: | $(lpeg_tgz)
mkdir -p $@ && tar xzf $| -C $@ && mv $@/*/*.c $@/*/*.h $(dir $@)
lua/src/lib/lfs: lfs.patch | $(lfs_zip)
mkdir -p $@ && unzip -d $@ $| && mv $@/*/src/*.c $@/*/src/*.h $(dir $@)
patch -d $(dir $@) -N -p1 < $<
-lua/src/lib/lutf8libext: lutf8libext.patch | $(luautf8_zip)
- mkdir -p $@ && unzip -d $@ $| && mv $@/*/*.h $(dir $@)
- # Rename lutf8lib.c in order to prevent conflicts with Lua's lutf8lib.c,
- # needed by LuaJIT.
- mv $@/*/lutf8lib.c $(dir $@)lutf8libext.c
- patch -d $(dir $@) -N -p1 < $<
lua/src/lib/lspawn: | $(lspawn_zip)
mkdir -p $@ && unzip -d $@ $| && mv $@/*/*.c $(dir $@)
lua/src/lib/lutf8lib.c: lutf8libjit.patch
diff --git a/src/lutf8libext.patch b/src/lutf8libext.patch
deleted file mode 100644
index 5dd975ce..00000000
--- a/src/lutf8libext.patch
+++ /dev/null
@@ -1,178 +0,0 @@
---- lutf8libext.c 2016-03-26 09:39:32.469103890 -0400
-+++ lib/lutf8libext.c 2016-03-26 13:29:06.770738807 -0400
-@@ -199,8 +199,10 @@
- define_category(space)
- define_converter(tolower)
- define_converter(toupper)
-+#if 0
- define_converter(totitle)
- define_converter(tofold)
-+#endif
-
- #undef define_category
- #undef define_converter
-@@ -223,6 +225,7 @@
- return 0;
- }
-
-+#if 0
- static int utf8_width(unsigned ch, int ambi_is_single) {
- if (find_in_range(doublewidth_table, table_size(doublewidth_table), ch))
- return 2;
-@@ -234,6 +237,7 @@
- return 0;
- return 1;
- }
-+#endif
-
-
- /* string module compatible interface */
-@@ -258,11 +262,13 @@
- luaL_addlstring(b, buff, n);
- }
-
-+#if 0
- static lua_Integer byterelat(lua_Integer pos, size_t len) {
- if (pos >= 0) return pos;
- else if (0u - (size_t)pos > len) return 0;
- else return (lua_Integer)len + pos + 1;
- }
-+#endif
-
- static int u_posrange(const char **ps, const char **pe,
- lua_Integer posi, lua_Integer posj) {
-@@ -281,6 +287,7 @@
- return *ps < *pe;
- }
-
-+#if 0
- static int Lutf8_len(lua_State *L) {
- size_t len;
- const char *s = luaL_checklstring(L, 1, &len);
-@@ -292,6 +299,7 @@
- lua_pushinteger(L, (lua_Integer)utf8_length(s+posi, s+posj+1));
- return 1;
- }
-+#endif
-
- static int Lutf8_sub(lua_State *L) {
- const char *e, *s = check_utf8(L, 1, &e);
-@@ -344,11 +352,13 @@
- static int Lutf8_upper(lua_State *L)
- { return convert(L, utf8_toupper); }
-
-+#if 0
- static int Lutf8_title(lua_State *L)
- { return convert(L, utf8_totitle); }
-
- static int Lutf8_fold(lua_State *L)
- { return convert(L, utf8_tofold); }
-+#endif
-
- static int Lutf8_byte(lua_State *L) {
- size_t n = 0;
-@@ -367,6 +377,7 @@
- return n;
- }
-
-+#if 0
- static int Lutf8_codepoint(lua_State *L) {
- const char *e, *s = check_utf8(L, 1, &e);
- size_t len = e-s;
-@@ -643,6 +654,7 @@
- lua_pushinteger(L, 0);
- return 1;
- }
-+#endif
-
-
- /* utf8 pattern matching implement */
-@@ -1265,21 +1277,26 @@
-
- #define UTF8PATT "[\0-\x7F\xC2-\xF4][\x80-\xBF]*"
-
--LUALIB_API int luaopen_utf8(lua_State *L) {
-+LUALIB_API int luaopen_utf8_ext(lua_State *L) {
- luaL_Reg libs[] = {
- #define ENTRY(name) { #name, Lutf8_##name }
-+#if 0
- ENTRY(offset),
- ENTRY(codes),
- ENTRY(codepoint),
-
- ENTRY(len),
-+#endif
- ENTRY(sub),
- ENTRY(reverse),
- ENTRY(lower),
- ENTRY(upper),
-+#if 0
- ENTRY(title),
- ENTRY(fold),
-+#endif
- ENTRY(byte),
-+#if 0
- ENTRY(char),
- ENTRY(escape),
- ENTRY(insert),
-@@ -1289,6 +1306,7 @@
- ENTRY(width),
- ENTRY(widthindex),
- ENTRY(ncasecmp),
-+#endif
- ENTRY(find),
- ENTRY(gmatch),
- ENTRY(gsub),
-@@ -1297,15 +1315,17 @@
- { NULL, NULL }
- };
-
-+lua_getglobal(L, "utf8");
- #if LUA_VERSION_NUM >= 502
-- luaL_newlib(L, libs);
-+ luaL_setfuncs(L, libs, 0);
- #else
-- lua_createtable(L, 0, sizeof(libs)/sizeof(libs[0]));
- luaL_register(L, NULL, libs);
- #endif
-
-+#if 0
- lua_pushliteral(L, UTF8PATT);
- lua_setfield(L, -2, "charpattern");
-+#endif
-
- return 1;
- }
---- unidata.h 2015-05-31 04:48:35.000000000 -0400
-+++ lib/unidata.h 2016-03-26 13:01:16.951664669 -0400
-@@ -904,6 +904,7 @@
- { 0x3000, 0x3000, 1 },
- };
-
-+#if 0
- static struct range_table unprintable_table[] = {
- { 0xAD, 0x34F, 674 },
- { 0x61C, 0x115F, 2883 },
-@@ -921,6 +922,7 @@
- { 0x1D173, 0x1D17A, 1 },
- { 0xE0000, 0xE0FFF, 1 },
- };
-+#endif
-
- static struct range_table graph_table[] = {
- { 0x20, 0x7E, 1 },
-@@ -2547,6 +2549,7 @@
- { 0x118C0, 0x118DF, 1, -32 },
- };
-
-+#if 0
- static struct conv_table totitle_table[] = {
- { 0x61, 0x7A, 1, -32 },
- { 0xB5, 0xB5, 1, 743 },
-@@ -3060,5 +3063,6 @@
- { 0xF0000, 0xFFFFD, 1 },
- { 0x100000, 0x10FFFD, 1 },
- };
-+#endif
-
- #endif /* unidata_h */
diff --git a/src/scintilla.patch b/src/scintilla.patch
index a6111696..4731fef2 100644
--- a/src/scintilla.patch
+++ b/src/scintilla.patch
@@ -30,3 +30,164 @@ diff -r eb69b2b4bb85 gtk/ScintillaGTK.cxx
object_class->finalize = Destroy;
#if GTK_CHECK_VERSION(3,0,0)
widget_class->get_preferred_width = GetPreferredWidth;
+diff -r bfdfb44eb777 src/Document.cxx
+--- a/src/Document.cxx Sun May 22 08:57:20 2016 +1000
++++ b/src/Document.cxx Mon Jul 04 15:23:05 2016 -0400
+@@ -2845,3 +2845,157 @@
+ #endif
+
+ #endif
++
++#include "tre.h"
++
++class TreRegex : public RegexSearchBase {
++public:
++ explicit TreRegex() : lastS(NULL), lastSLen(0) {}
++ virtual ~TreRegex() { if (lastS) free(lastS), tre_regfree(&preg); }
++ virtual long FindText(Document *doc, int minPos, int maxPos, const char *s,
++ bool caseSensitive, bool word, bool wordStart, int flags,
++ int *length);
++ virtual const char *SubstituteByPosition(Document *doc, const char *text,
++ int *length);
++private:
++ char *lastS;
++ int lastSLen;
++ regex_t preg;
++ regmatch_t pmatch[10];
++ std::string substituted;
++};
++
++long TreRegex::FindText(Document *doc, int minPos, int maxPos, const char *s,
++ bool caseSensitive, bool, bool, int,
++ int *length) {
++ // Determine the search range. (From Document.cxx::RESearchRange.)
++ int increment, startPos, endPos;
++ if (minPos <= maxPos)
++ increment = 1, startPos = minPos, endPos = maxPos;
++ else
++ increment = -1, startPos = maxPos, endPos = minPos;
++ // Range endpoints should not be inside DBCS characters, but just in case,
++ // move them.
++ startPos = doc->MovePositionOutsideChar(startPos, 1, false);
++ endPos = doc->MovePositionOutsideChar(endPos, 1, false);
++ int lineRangeStart = doc->LineFromPosition(startPos);
++ int lineRangeEnd = doc->LineFromPosition(endPos);
++ if (increment == 1 && startPos >= doc->LineEnd(lineRangeStart) &&
++ lineRangeStart < lineRangeEnd) {
++ // The start position is at end of line or between line end characters.
++ lineRangeStart++;
++ startPos = doc->LineStart(lineRangeStart);
++ } else if (increment == -1 && startPos <= doc->LineStart(lineRangeStart) &&
++ lineRangeStart > lineRangeEnd) {
++ // The start position is at beginning of line.
++ lineRangeStart--;
++ startPos = doc->LineEnd(lineRangeStart);
++ }
++
++ // Compile the regex or used the cached one.
++ if (!lastS || lastSLen != *length || strncmp(lastS, s, *length) != 0) {
++ int cflags = REG_EXTENDED | (!caseSensitive ? REG_ICASE : 0) | REG_NEWLINE;
++ if (tre_regncomp(&preg, s, *length, cflags) != REG_OK) return -1;
++ if (lastS) free(lastS);
++ lastS = static_cast<char *>(malloc(*length + 1));
++ strncpy(lastS, s, *length);
++ lastS[*length] = '\0';
++ lastSLen = *length;
++ }
++
++ // Perform the matching.
++ int pos = -1, lenRet = 0;
++ const char *string = doc->BufferPointer();
++ size_t len = endPos - startPos;
++ int eflags = ((startPos != doc->LineStart(lineRangeStart)) ? REG_NOTBOL : 0) |
++ ((endPos != doc->LineEnd(lineRangeEnd)) ? REG_NOTEOL : 0);
++ int success = tre_regnexec(&preg, string + startPos, len, 10, pmatch, eflags) == REG_OK;
++ if (success) {
++ for (int i = 0; i < 10 && pmatch[i].rm_so != -1; i++)
++ pmatch[i].rm_so += startPos, pmatch[i].rm_eo += startPos; // adjust
++ pos = pmatch[0].rm_so, lenRet = pmatch[0].rm_eo - pmatch[0].rm_so;
++ if (increment == -1) {
++ // Check for the last match on this line.
++ int repetitions = 1000; // break out of infinite loop
++ while (success && pmatch[0].rm_eo <= endPos && repetitions--) {
++ success = tre_regnexec(&preg, string + pos + 1, len - (pos + 1), 10,
++ pmatch, eflags) == REG_OK;
++ if (success) {
++ for (int i = 0; i < 10 && pmatch[i].rm_so != -1; i++)
++ pmatch[i].rm_so += pos + 1, pmatch[i].rm_eo += pos + 1; // adjust
++ if (pmatch[0].rm_eo <= minPos)
++ pos = pmatch[0].rm_so, lenRet = pmatch[0].rm_eo - pmatch[0].rm_so;
++ else
++ success = 0;
++ }
++ }
++ }
++ }
++ *length = lenRet;
++ return pos;
++}
++
++const char *TreRegex::SubstituteByPosition(Document *doc, const char *text,
++ int *length) {
++ substituted.clear();
++ for (int j = 0; j < *length; j++) {
++ if (text[j] == '\\') {
++ if (text[j + 1] >= '0' && text[j + 1] <= '9') {
++ unsigned int patNum = text[j + 1] - '0';
++ unsigned int len = pmatch[patNum].rm_eo - pmatch[patNum].rm_so;
++ if (len > 0) // will be -1 for a match that did not occur
++ substituted.append(doc->BufferPointer() + pmatch[patNum].rm_so, len);
++ j++;
++ } else {
++ j++;
++ switch (text[j]) {
++ case 'a':
++ substituted.push_back('\a');
++ break;
++ case 'b':
++ substituted.push_back('\b');
++ break;
++ case 'f':
++ substituted.push_back('\f');
++ break;
++ case 'n':
++ substituted.push_back('\n');
++ break;
++ case 'r':
++ substituted.push_back('\r');
++ break;
++ case 't':
++ substituted.push_back('\t');
++ break;
++ case 'v':
++ substituted.push_back('\v');
++ break;
++ case '\\':
++ substituted.push_back('\\');
++ break;
++ default:
++ substituted.push_back('\\');
++ j--;
++ }
++ }
++ } else {
++ substituted.push_back(text[j]);
++ }
++ }
++ *length = static_cast<int>(substituted.length());
++ return substituted.c_str();
++}
++
++#ifdef SCI_NAMESPACE
++
++RegexSearchBase *Scintilla::CreateRegexSearch(CharClassify *charClassTable) {
++ return new TreRegex();
++}
++
++#else
++
++RegexSearchBase *CreateRegexSearch(CharClassify *charClassTable) {
++ return new TreRegex();
++}
++
++#endif
diff --git a/src/textadept.c b/src/textadept.c
index a1ee9e5c..a9a044f3 100644
--- a/src/textadept.c
+++ b/src/textadept.c
@@ -146,7 +146,7 @@ static GtkWidget *findbox, *find_entry, *replace_entry, *flabel, *rlabel;
#define repl_text gtk_entry_get_text(GTK_ENTRY(replace_entry))
typedef GtkWidget * FindButton;
static FindButton fnext_button, fprev_button, r_button, ra_button;
-static GtkWidget *match_case, *whole_word, *lua_pattern, *in_files;
+static GtkWidget *match_case, *whole_word, *regex, *in_files;
typedef GtkListStore ListStore;
static ListStore *find_store, *repl_store;
#define toggled(w) gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w))
@@ -195,7 +195,7 @@ static char *find_text, *repl_text, *flabel, *rlabel;
typedef enum {fnext_button, r_button, fprev_button, ra_button} FindButton;
static int find_options[4];
static int *match_case = &find_options[0], *whole_word = &find_options[1],
- *lua_pattern = &find_options[2], *in_files = &find_options[3];
+ *regex = &find_options[2], *in_files = &find_options[3];
static char *button_labels[4], *option_labels[4];
typedef char * ListStore;
static ListStore find_store[10], repl_store[10];
@@ -239,7 +239,7 @@ static void new_buffer(sptr_t);
static Scintilla *new_view(sptr_t);
static int lL_init(lua_State *, int, char **, int);
LUALIB_API int luaopen_lpeg(lua_State *), luaopen_lfs(lua_State *);
-LUALIB_API int luaopen_utf8_ext(lua_State *), luaopen_spawn(lua_State *);
+LUALIB_API int luaopen_spawn(lua_State *);
LUALIB_API int lspawn_pushfds(lua_State *), lspawn_readfds(lua_State *);
/**
@@ -522,8 +522,8 @@ static int lfind__index(lua_State *L) {
lua_pushboolean(L, toggled(match_case));
else if (strcmp(key, "whole_word") == 0)
lua_pushboolean(L, toggled(whole_word));
- else if (strcmp(key, "lua") == 0)
- lua_pushboolean(L, toggled(lua_pattern));
+ else if (strcmp(key, "regex") == 0)
+ lua_pushboolean(L, toggled(regex));
else if (strcmp(key, "in_files") == 0)
lua_pushboolean(L, toggled(in_files));
else
@@ -550,8 +550,8 @@ static int lfind__newindex(lua_State *L) {
toggle(match_case, lua_toboolean(L, -1));
else if (strcmp(key, "whole_word") == 0)
toggle(whole_word, lua_toboolean(L, -1));
- else if (strcmp(key, "lua") == 0)
- toggle(lua_pattern, lua_toboolean(L, -1));
+ else if (strcmp(key, "regex") == 0)
+ toggle(regex, lua_toboolean(L, -1));
else if (strcmp(key, "in_files") == 0)
toggle(in_files, lua_toboolean(L, -1));
else if (strcmp(key, "find_label_text") == 0)
@@ -570,8 +570,8 @@ static int lfind__newindex(lua_State *L) {
set_option_label(match_case, 0, lua_tostring(L, 3));
else if (strcmp(key, "whole_word_label_text") == 0)
set_option_label(whole_word, 1, lua_tostring(L, 3));
- else if (strcmp(key, "lua_pattern_label_text") == 0)
- set_option_label(lua_pattern, 2, lua_tostring(L, 3));
+ else if (strcmp(key, "regex_label_text") == 0)
+ set_option_label(regex, 2, lua_tostring(L, 3));
else if (strcmp(key, "in_files_label_text") == 0)
set_option_label(in_files, 3, lua_tostring(L, 3));
else
@@ -1534,7 +1534,7 @@ static int lL_init(lua_State *L, int argc, char **argv, int reinit) {
#endif
}
lua_pushinteger(L, (sptr_t)L), lua_setglobal(L, "_LUA");
- luaL_openlibs(L), lL_openlib(L, utf8_ext);
+ luaL_openlibs(L);
lL_openlib(L, lpeg), lL_openlib(L, lfs), lL_openlib(L, spawn);
lua_newtable(L);
@@ -2214,7 +2214,7 @@ static GtkWidget *new_findbox() {
ra_button = gtk_button_new_with_mnemonic("Replace _All");
match_case = gtk_check_button_new_with_mnemonic("_Match case");
whole_word = gtk_check_button_new_with_mnemonic("_Whole word");
- lua_pattern = gtk_check_button_new_with_mnemonic("_Lua pattern");
+ regex = gtk_check_button_new_with_mnemonic("Rege_x");
in_files = gtk_check_button_new_with_mnemonic("_In files");
gtk_label_set_mnemonic_widget(GTK_LABEL(flabel), find_entry);
@@ -2230,7 +2230,7 @@ static GtkWidget *new_findbox() {
attach(ra_button, 3, 4, 1, 2, FILL(SHRINK), FILL(SHRINK), 0, 0);
attach(match_case, 4, 5, 0, 1, FILL(SHRINK), FILL(SHRINK), 5, 0);
attach(whole_word, 4, 5, 1, 2, FILL(SHRINK), FILL(SHRINK), 5, 0);
- attach(lua_pattern, 5, 6, 0, 1, FILL(SHRINK), FILL(SHRINK), 5, 0);
+ attach(regex, 5, 6, 0, 1, FILL(SHRINK), FILL(SHRINK), 5, 0);
attach(in_files, 5, 6, 1, 2, FILL(SHRINK), FILL(SHRINK), 5, 0);
signal(fnext_button, "clicked", f_clicked);
@@ -2245,7 +2245,7 @@ static GtkWidget *new_findbox() {
gtk_widget_set_can_focus(ra_button, FALSE);
gtk_widget_set_can_focus(match_case, FALSE);
gtk_widget_set_can_focus(whole_word, FALSE);
- gtk_widget_set_can_focus(lua_pattern, FALSE);
+ gtk_widget_set_can_focus(regex, FALSE);
gtk_widget_set_can_focus(in_files, FALSE);
return findbox;
diff --git a/src/tre.patch b/src/tre.patch
new file mode 100644
index 00000000..d2457d21
--- /dev/null
+++ b/src/tre.patch
@@ -0,0 +1,49 @@
+diff -r c8148182a381 lib/tre-config.h
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/lib/tre-config.h Mon Jul 04 13:22:19 2016 -0400
+@@ -0,0 +1,45 @@
++/* tre-config.h.in. This file has all definitions that are needed in
++ `tre.h'. Note that this file must contain only the bare minimum
++ of definitions without the TRE_ prefix to avoid conflicts between
++ definitions here and definitions included from somewhere else. */
++
++/* Define to 1 if you have the <libutf8.h> header file. */
++#undef HAVE_LIBUTF8_H
++
++/* Define to 1 if the system has the type `reg_errcode_t'. */
++#undef HAVE_REG_ERRCODE_T
++
++/* Define to 1 if you have the <sys/types.h> header file. */
++#undef HAVE_SYS_TYPES_H
++
++/* Define to 1 if you have the <wchar.h> header file. */
++#undef HAVE_WCHAR_H
++
++/* Define if you want to enable approximate matching functionality. */
++#undef TRE_APPROX
++
++/* Define to enable multibyte character set support. */
++#undef TRE_MULTIBYTE
++
++/* Define to the absolute path to the system tre.h */
++#undef TRE_SYSTEM_REGEX_H_PATH
++
++/* Define to include the system regex.h from tre.h */
++#undef TRE_USE_SYSTEM_REGEX_H
++
++/* Define to enable wide character (wchar_t) support. */
++#undef TRE_WCHAR
++
++/* TRE version string. */
++#define TRE_VERSION "0.8.0"
++
++/* TRE version level 1. */
++#undef TRE_VERSION_1
++
++/* TRE version level 2. */
++#undef TRE_VERSION_2
++
++/* TRE version level 3. */
++#undef TRE_VERSION_3
++
++#define TRE_REGEX_T_FIELD value