Răsfoiți Sursa

Added highlighting support for Linux.
Added lexers for Linux.

woollybah 6 ani în urmă
părinte
comite
46b86e95d2

+ 517 - 389
maxguitextareascintilla.mod/linux_glue.c

@@ -1,389 +1,517 @@
-/*
- Copyright (c) 2014-2018 Bruce A Henderson
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
- 
-*/
-
-#include <gtk/gtk.h>
-#include "Scintilla.h"
-#include "SciLexer.h"
-#include "ScintillaWidget.h"
-
-#include "blitz.h"
-
-#ifdef BMX_NG
-	void maxgui_maxguitextareascintilla_common_TSCNotification__update(BBObject *, int, int, int);
-#else
-	void _maxgui_maxguitextareascintilla_TSCNotification__update(BBObject *, int, int, int);
-#endif
-
-ScintillaObject * bmx_mgta_scintilla_getsci(void * editor, int id) {
-	ScintillaObject * obj = SCINTILLA(editor);
-	scintilla_set_id(obj, id);
-
-	scintilla_send_message(obj, SCI_SETCODEPAGE, SC_CP_UTF8, 0);
-
-	return obj;
-}
-
-BBString * bmx_mgta_scintilla_gettext(ScintillaObject * sci) {
-	int len = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
-	
-	char * buffer = malloc(len + 1);
-	
-	scintilla_send_message(sci, SCI_GETTEXT, len, buffer);
-	
-	BBString * s = bbStringFromUTF8String(buffer);
-	
-	free(buffer);
-
-	return s;
-}
-
-void bmx_mgta_scintilla_settext(ScintillaObject * sci, BBString * text) {
-
-	char * t = bbStringToUTF8String(text);
-
-	scintilla_send_message(sci, SCI_SETTEXT, 0, t);
-	
-	bbMemFree(t);
-}
-
-void bmx_mgta_scintilla_setfont(ScintillaObject * sci, BBString * name, int size) {
-	int style;
-
-	char * n = bbStringToUTF8String(name);
-
-	/* make sure all the styles are changed */
-	for (style = 0; style < STYLE_MAX; style++) {
-		scintilla_send_message(sci, SCI_STYLESETFONT, style, n);
-		scintilla_send_message(sci, SCI_STYLESETSIZE, style, size);
-	}
-	
-	bbMemFree(n);
-}
-
-void bmx_mgta_scintilla_setlinedigits(ScintillaObject * sci, int * digits) {
-
-	int lines = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
-	int newDigits = (lines < 10 ? 1 : (lines < 100 ? 2 :   
-		(lines < 1000 ? 3 : (lines < 10000 ? 4 :   
-		(lines < 100000 ? 5 : (lines < 1000000 ? 6 :   
-		(lines < 10000000 ? 7 : (lines < 100000000 ? 8 :  
-		(lines < 1000000000 ? 9 : 10)))))))));
-
-	if (*digits != newDigits) {
-		*digits = newDigits;
-
-		int i;
-		int len = newDigits + 1;
-		char * buf = malloc(len + 1);
-		buf[0] = '_';
-		buf[len] = 0;
-		for (i = 1; i < len; i++) {
-			buf[i] = '9';
-		}
-		
-		/* set the linenumber margin width */
-		int textWidth = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, buf) + 4;
-		scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, textWidth);
-		
-		free(buf);
-	}
-}
-
-int bmx_mgta_scintilla_textwidth(ScintillaObject * sci, BBString * text) {
-	char * t = bbStringToUTF8String(text);
-	int textWidth = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, t);
-	bbMemFree(t);
-
-	return textWidth;
-}
-
-int bmx_mgta_scintilla_charfrombyte(ScintillaObject * sci, int pos, int startPos) {
-	int i;
-	int characterOffset = 0;
-	int length = pos - startPos;
-
-	if (length == 0) {
-		return 0;
-	}
-
-	struct Sci_TextRange range;
-	range.chrg.cpMin = startPos;
-	range.chrg.cpMax = pos;
-	
-	range.lpstrText = malloc(length + 1);
-	
-	int len = scintilla_send_message(sci, SCI_GETTEXTRANGE, 0, &range);
-
-	for (i = 0; i < length; i++) {
-		char c = range.lpstrText[i];
-		if ((c & 0xc0) != 0x80) {
-				characterOffset++;
-		}
-	}
-	free(range.lpstrText);
-
-	return characterOffset;
-}
-
-/* startBytePos is a known byte offset for startCharPos */
-int bmx_mgta_scintilla_bytefromchar(ScintillaObject * sci, int charLength, int startBytePos, int startCharPos) {
-	int i;
-	int characterOffset = startBytePos;
-
-	int characters = charLength;
-	if (!characters) {
-		return startBytePos;
-	}
-
-	int endBytePos = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
-
-	if (characters == -1) {
-		return endBytePos;
-	}
-
-	int length = endBytePos - startBytePos + 1;
-
-	struct Sci_TextRange range;
-	range.chrg.cpMin = startBytePos;
-	range.chrg.cpMax = endBytePos;
-	
-	range.lpstrText = malloc(length);
-	
-	int len = scintilla_send_message(sci, SCI_GETTEXTRANGE, 0, &range);
-
-	for (i = 0; i < len; i++) {
-		char c = range.lpstrText[i];
-		if ((c & 0xc0) != 0x80) {
-				if (! --characters) {
-					break;
-				}
-		}
-	}
-	free(range.lpstrText);
-
-	return startBytePos + i + 1;
-}
-
-int bmx_mgta_scintilla_positionfromline(ScintillaObject * sci, int line, int valueInBytes) {
-	int bytePos = scintilla_send_message(sci, SCI_POSITIONFROMLINE, line, 0);
-	return (valueInBytes) ? bytePos : bmx_mgta_scintilla_charfrombyte(sci, bytePos, 0);
-}
-
-void bmx_mgta_scintilla_setselectionstart(ScintillaObject * sci, int pos) {
-	scintilla_send_message(sci, SCI_SETSELECTIONSTART, pos, 0);
-}
-
-void bmx_mgta_scintilla_setselectionend(ScintillaObject * sci, int pos) {
-	scintilla_send_message(sci, SCI_SETSELECTIONEND, pos, 0);
-}
-
-void bmx_mgta_scintilla_scrollcaret(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_SCROLLCARET, 0, 0);
-}
-
-void bmx_mgta_scintilla_setsel(ScintillaObject * sci, int startPos, int endPos) {
-	scintilla_send_message(sci, SCI_SETSEL, startPos, endPos);
-}
-
-void bmx_mgta_scintilla_replacesel(ScintillaObject * sci, const char * text) {
-	scintilla_send_message(sci, SCI_REPLACESEL, 0, text);
-}
-
-void bmx_mgta_scintilla_stylesetback(ScintillaObject * sci, int col) {
-	int style;
-	
-	for (style = 0; style < 33; style++) {
-		scintilla_send_message(sci, SCI_STYLESETBACK, style, col);
-	}
-}
-
-void bmx_mgta_scintilla_stylesetfore(ScintillaObject * sci, int style, int color) {
-	scintilla_send_message(sci, SCI_STYLESETFORE, style, color);
-}
-
-void bmx_mgta_scintilla_stylesetitalic(ScintillaObject * sci, int style, int value) {
-	scintilla_send_message(sci, SCI_STYLESETITALIC, style, value);
-}
-
-void bmx_mgta_scintilla_stylesetbold(ScintillaObject * sci, int style, int value) {
-	scintilla_send_message(sci, SCI_STYLESETBOLD, style, value);
-}
-
-void bmx_mgta_scintilla_stylesetunderline(ScintillaObject * sci, int style, int value) {
-	scintilla_send_message(sci, SCI_STYLESETUNDERLINE, style, value);
-}
-
-void bmx_mgta_scintilla_startstyling(ScintillaObject * sci, int startPos) {
-	scintilla_send_message(sci, SCI_STARTSTYLING, startPos, 0x1f);
-}
-
-void bmx_mgta_scintilla_setstyling(ScintillaObject * sci, int realLength, int style) {
-	if (realLength == -1) {
-		realLength = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
-	}
-	scintilla_send_message(sci, SCI_SETSTYLING, realLength, style);
-}
-
-BBString * bmx_mgta_scintilla_gettextrange(ScintillaObject * sci, int startPos, int endPos) {
-	if (endPos == -1) {
-		endPos = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
-	}
-
-	struct Sci_TextRange range;
-	range.chrg.cpMin = startPos;
-	range.chrg.cpMax = endPos;
-	
-	range.lpstrText = malloc(endPos - startPos + 1);
-	
-	int len = scintilla_send_message(sci, SCI_GETTEXTRANGE, 0, &range);
-	
-	BBString * s = bbStringFromUTF8String(range.lpstrText);
-	free(range.lpstrText);
-	return s;
-}
-
-int bmx_mgta_scintilla_getlinecount(ScintillaObject * sci) {
-	return scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
-}
-
-int bmx_mgta_scintilla_getlength(ScintillaObject * sci) {
-	return scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
-}
-
-int bmx_mgta_scintilla_getcurrentpos(ScintillaObject * sci) {
-	int bytePos = scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0);
-	return bmx_mgta_scintilla_charfrombyte(sci, bytePos, 0);
-}
-
-int bmx_mgta_scintilla_getcurrentline(ScintillaObject * sci) {
-	return scintilla_send_message(sci, SCI_LINEFROMPOSITION, scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0), 0);
-}
-
-void bmx_mgta_scintilla_settabwidth(ScintillaObject * sci, int tabs) {
-	scintilla_send_message(sci, SCI_SETTABWIDTH, tabs, 0);
-}
-
-void bmx_mgta_scintilla_settargetstart(ScintillaObject * sci, int pos) {
-	scintilla_send_message(sci, SCI_SETTARGETSTART, pos, 0);
-}
-
-void bmx_mgta_scintilla_settargetend(ScintillaObject * sci, int pos) {
-	scintilla_send_message(sci, SCI_SETTARGETEND, pos, 0);
-}
-
-void bmx_mgta_scintilla_replacetarget(ScintillaObject * sci, const char * text) {
-	scintilla_send_message(sci, SCI_REPLACETARGET, -1, text);
-}
-
-void bmx_mgta_scintilla_cut(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_CUT, 0, 0);
-}
-
-void bmx_mgta_scintilla_copy(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_COPY, 0, 0);
-}
-
-void bmx_mgta_scintilla_paste(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_PASTE, 0, 0);
-}
-
-int bmx_mgta_scintilla_linefromposition(ScintillaObject * sci, int pos) {
-	return scintilla_send_message(sci, SCI_LINEFROMPOSITION, pos, 0);
-}
-
-void bmx_mgta_scintilla_appendtext(ScintillaObject * sci, BBString * text) {
-	char * s = bbStringToUTF8String(text);
-	scintilla_send_message(sci, SCI_APPENDTEXT, strlen(s), s);
-	bbMemFree(s);
-}
-
-void bmx_mgta_scintilla_scrolltoend(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_GOTOPOS, scintilla_send_message(sci, SCI_GETLENGTH, 0, 0), 0);
-}
-
-int bmx_mgta_scintilla_getselectionlength(ScintillaObject * sci, int units) {
-	if (units == 2) {
-		/* lines */
-		int startPos = scintilla_send_message(sci, SCI_LINEFROMPOSITION, scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0), 0);
-		int endPos = scintilla_send_message(sci, SCI_LINEFROMPOSITION, scintilla_send_message(sci, SCI_GETSELECTIONEND, 0, 0), 0);
-		return endPos - startPos;
-	} else {
-		/* chars */
-		int startPos = bmx_mgta_scintilla_charfrombyte(sci, scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0), 0);
-		int length = bmx_mgta_scintilla_charfrombyte(sci, scintilla_send_message(sci, SCI_GETSELECTIONEND, 0, 0), startPos);
-		return length;
-	}
-}
-
-void bmx_mgta_scintilla_addtext(ScintillaObject * sci, gchar * text) {
-	int length = strlen(text);
-	scintilla_send_message(sci, SCI_ADDTEXT, length, text);
-}
-
-void bmx_mgta_scintilla_notifcation_update(BBObject * obj, struct SCNotification * notification) {
-#ifdef BMX_NG
-	maxgui_maxguitextareascintilla_common_TSCNotification__update(obj, notification->nmhdr.code, notification->modificationType, notification->updated);
-#else
-	_maxgui_maxguitextareascintilla_TSCNotification__update(obj, notification->nmhdr.code, notification->modificationType, notification->updated);
-#endif
-}
-
-void bmx_mgta_scintilla_setmarginleft(ScintillaObject * sci, int leftmargin) {
-	scintilla_send_message(sci, SCI_SETMARGINLEFT, 0, leftmargin);
-}
-
-void bmx_mgta_scintilla_setcaretwidth(ScintillaObject * sci, int width) {
-	scintilla_send_message(sci, SCI_SETCARETWIDTH, width, 0);
-}
-
-void bmx_mgta_scintilla_setcaretcolor(ScintillaObject * sci, int r, int g, int b) {
-	scintilla_send_message(sci, SCI_SETCARETFORE, r | (g << 8) | (b << 16), 0);
-}
-
-void bmx_mgta_scintilla_enableundoredo(ScintillaObject * sci, int enable) {
-	scintilla_send_message(sci, SCI_SETUNDOCOLLECTION, enable, 0);
-}
-
-int bmx_mgta_scintilla_undoredoenabled(ScintillaObject * sci) {
-	return scintilla_send_message(sci, SCI_GETUNDOCOLLECTION, 0, 0);
-}
-
-void bmx_mgta_scintilla_undo(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_UNDO, 0, 0);
-}
-
-void bmx_mgta_scintilla_redo(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_REDO, 0, 0);
-}
-
-int bmx_mgta_scintilla_canundo(ScintillaObject * sci) {
-	return scintilla_send_message(sci, SCI_CANUNDO, 0, 0);
-}
-
-int bmx_mgta_scintilla_canredo(ScintillaObject * sci) {
-	return scintilla_send_message(sci, SCI_CANREDO, 0, 0);
-}
-
-void bmx_mgta_scintilla_clearundoredo(ScintillaObject * sci) {
-	scintilla_send_message(sci, SCI_EMPTYUNDOBUFFER, 0, 0);
-}
+/*
+ Copyright (c) 2014-2018 Bruce A Henderson
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ 
+*/
+
+#include <gtk/gtk.h>
+#include "Scintilla.h"
+#include "SciLexer.h"
+#include "ScintillaWidget.h"
+
+#include "blitz.h"
+
+#define TEXTFORMAT_BOLD 1
+#define TEXTFORMAT_ITALIC 2
+#define TEXTFORMAT_UNDERLINE 4
+
+#ifdef BMX_NG
+	void maxgui_maxguitextareascintilla_common_TSCNotification__update(BBObject *, int, int, int);
+#else
+	void _maxgui_maxguitextareascintilla_TSCNotification__update(BBObject *, int, int, int);
+#endif
+
+ScintillaObject * bmx_mgta_scintilla_getsci(void * editor, int id) {
+	ScintillaObject * obj = SCINTILLA(editor);
+	scintilla_set_id(obj, id);
+
+	scintilla_send_message(obj, SCI_SETCODEPAGE, SC_CP_UTF8, 0);
+
+	return obj;
+}
+
+BBString * bmx_mgta_scintilla_gettext(ScintillaObject * sci) {
+	int len = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
+	
+	char * buffer = malloc(len + 1);
+	
+	scintilla_send_message(sci, SCI_GETTEXT, len, buffer);
+	
+	BBString * s = bbStringFromUTF8String(buffer);
+	
+	free(buffer);
+
+	return s;
+}
+
+void bmx_mgta_scintilla_settext(ScintillaObject * sci, BBString * text) {
+
+	char * t = bbStringToUTF8String(text);
+
+	scintilla_send_message(sci, SCI_SETTEXT, 0, t);
+	
+	bbMemFree(t);
+}
+
+void bmx_mgta_scintilla_setfont(ScintillaObject * sci, BBString * name, int size) {
+	int style;
+
+	char * n = bbStringToUTF8String(name);
+
+	/* make sure all the styles are changed */
+	for (style = 0; style < STYLE_MAX; style++) {
+		scintilla_send_message(sci, SCI_STYLESETFONT, style, n);
+		scintilla_send_message(sci, SCI_STYLESETSIZE, style, size);
+	}
+	
+	bbMemFree(n);
+}
+
+void bmx_mgta_scintilla_setlinedigits(ScintillaObject * sci, int * digits) {
+
+	int lines = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
+	int newDigits = (lines < 10 ? 1 : (lines < 100 ? 2 :   
+		(lines < 1000 ? 3 : (lines < 10000 ? 4 :   
+		(lines < 100000 ? 5 : (lines < 1000000 ? 6 :   
+		(lines < 10000000 ? 7 : (lines < 100000000 ? 8 :  
+		(lines < 1000000000 ? 9 : 10)))))))));
+
+	if (*digits != newDigits) {
+		*digits = newDigits;
+
+		int i;
+		int len = newDigits + 1;
+		char * buf = malloc(len + 1);
+		buf[0] = '_';
+		buf[len] = 0;
+		for (i = 1; i < len; i++) {
+			buf[i] = '9';
+		}
+		
+		/* set the linenumber margin width */
+		int textWidth = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, buf) + 4;
+		scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, textWidth);
+		
+		free(buf);
+	}
+}
+
+int bmx_mgta_scintilla_textwidth(ScintillaObject * sci, BBString * text) {
+	char * t = bbStringToUTF8String(text);
+	int textWidth = scintilla_send_message(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, t);
+	bbMemFree(t);
+
+	return textWidth;
+}
+
+int bmx_mgta_scintilla_charfrombyte(ScintillaObject * sci, int pos, int startPos) {
+	int i;
+	int characterOffset = 0;
+	int length = pos - startPos;
+
+	if (length == 0) {
+		return 0;
+	}
+
+	struct Sci_TextRange range;
+	range.chrg.cpMin = startPos;
+	range.chrg.cpMax = pos;
+	
+	range.lpstrText = malloc(length + 1);
+	
+	int len = scintilla_send_message(sci, SCI_GETTEXTRANGE, 0, &range);
+
+	for (i = 0; i < length; i++) {
+		char c = range.lpstrText[i];
+		if ((c & 0xc0) != 0x80) {
+				characterOffset++;
+		}
+	}
+	free(range.lpstrText);
+
+	return characterOffset;
+}
+
+/* startBytePos is a known byte offset for startCharPos */
+int bmx_mgta_scintilla_bytefromchar(ScintillaObject * sci, int charLength, int startBytePos, int startCharPos) {
+	int i;
+	int characterOffset = startBytePos;
+
+	int characters = charLength;
+	if (!characters) {
+		return startBytePos;
+	}
+
+	int endBytePos = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
+
+	if (characters == -1) {
+		return endBytePos;
+	}
+
+	int length = endBytePos - startBytePos + 1;
+
+	struct Sci_TextRange range;
+	range.chrg.cpMin = startBytePos;
+	range.chrg.cpMax = endBytePos;
+	
+	range.lpstrText = malloc(length);
+	
+	int len = scintilla_send_message(sci, SCI_GETTEXTRANGE, 0, &range);
+
+	for (i = 0; i < len; i++) {
+		char c = range.lpstrText[i];
+		if ((c & 0xc0) != 0x80) {
+				if (! --characters) {
+					break;
+				}
+		}
+	}
+	free(range.lpstrText);
+
+	return startBytePos + i + 1;
+}
+
+int bmx_mgta_scintilla_positionfromline(ScintillaObject * sci, int line, int valueInBytes) {
+	int bytePos = scintilla_send_message(sci, SCI_POSITIONFROMLINE, line, 0);
+	return (valueInBytes) ? bytePos : bmx_mgta_scintilla_charfrombyte(sci, bytePos, 0);
+}
+
+void bmx_mgta_scintilla_setselectionstart(ScintillaObject * sci, int pos) {
+	scintilla_send_message(sci, SCI_SETSELECTIONSTART, pos, 0);
+}
+
+void bmx_mgta_scintilla_setselectionend(ScintillaObject * sci, int pos) {
+	scintilla_send_message(sci, SCI_SETSELECTIONEND, pos, 0);
+}
+
+void bmx_mgta_scintilla_scrollcaret(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_SCROLLCARET, 0, 0);
+}
+
+void bmx_mgta_scintilla_setsel(ScintillaObject * sci, int startPos, int endPos) {
+	scintilla_send_message(sci, SCI_SETSEL, startPos, endPos);
+}
+
+void bmx_mgta_scintilla_replacesel(ScintillaObject * sci, const char * text) {
+	scintilla_send_message(sci, SCI_REPLACESEL, 0, text);
+}
+
+void bmx_mgta_scintilla_stylesetback(ScintillaObject * sci, int col) {
+	int style;
+	
+	for (style = 0; style < 33; style++) {
+		scintilla_send_message(sci, SCI_STYLESETBACK, style, col);
+	}
+}
+
+void bmx_mgta_scintilla_stylesetfore(ScintillaObject * sci, int style, int color) {
+	scintilla_send_message(sci, SCI_STYLESETFORE, style, color);
+}
+
+void bmx_mgta_scintilla_stylesetitalic(ScintillaObject * sci, int style, int value) {
+	scintilla_send_message(sci, SCI_STYLESETITALIC, style, value);
+}
+
+void bmx_mgta_scintilla_stylesetbold(ScintillaObject * sci, int style, int value) {
+	scintilla_send_message(sci, SCI_STYLESETBOLD, style, value);
+}
+
+void bmx_mgta_scintilla_stylesetunderline(ScintillaObject * sci, int style, int value) {
+	scintilla_send_message(sci, SCI_STYLESETUNDERLINE, style, value);
+}
+
+void bmx_mgta_scintilla_startstyling(ScintillaObject * sci, int startPos) {
+	scintilla_send_message(sci, SCI_STARTSTYLING, startPos, 0x1f);
+}
+
+void bmx_mgta_scintilla_setstyling(ScintillaObject * sci, int realLength, int style) {
+	if (realLength == -1) {
+		realLength = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
+	}
+	scintilla_send_message(sci, SCI_SETSTYLING, realLength, style);
+}
+
+BBString * bmx_mgta_scintilla_gettextrange(ScintillaObject * sci, int startPos, int endPos) {
+	if (endPos == -1) {
+		endPos = scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
+	}
+
+	struct Sci_TextRange range;
+	range.chrg.cpMin = startPos;
+	range.chrg.cpMax = endPos;
+	
+	range.lpstrText = malloc(endPos - startPos + 1);
+	
+	int len = scintilla_send_message(sci, SCI_GETTEXTRANGE, 0, &range);
+	
+	BBString * s = bbStringFromUTF8String(range.lpstrText);
+	free(range.lpstrText);
+	return s;
+}
+
+int bmx_mgta_scintilla_getlinecount(ScintillaObject * sci) {
+	return scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
+}
+
+int bmx_mgta_scintilla_getlength(ScintillaObject * sci) {
+	return scintilla_send_message(sci, SCI_GETLENGTH, 0, 0);
+}
+
+int bmx_mgta_scintilla_getcurrentpos(ScintillaObject * sci) {
+	int bytePos = scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0);
+	return bmx_mgta_scintilla_charfrombyte(sci, bytePos, 0);
+}
+
+int bmx_mgta_scintilla_getcurrentline(ScintillaObject * sci) {
+	return scintilla_send_message(sci, SCI_LINEFROMPOSITION, scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0), 0);
+}
+
+void bmx_mgta_scintilla_settabwidth(ScintillaObject * sci, int tabs) {
+	scintilla_send_message(sci, SCI_SETTABWIDTH, tabs, 0);
+}
+
+void bmx_mgta_scintilla_settargetstart(ScintillaObject * sci, int pos) {
+	scintilla_send_message(sci, SCI_SETTARGETSTART, pos, 0);
+}
+
+void bmx_mgta_scintilla_settargetend(ScintillaObject * sci, int pos) {
+	scintilla_send_message(sci, SCI_SETTARGETEND, pos, 0);
+}
+
+void bmx_mgta_scintilla_replacetarget(ScintillaObject * sci, const char * text) {
+	scintilla_send_message(sci, SCI_REPLACETARGET, -1, text);
+}
+
+void bmx_mgta_scintilla_cut(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_CUT, 0, 0);
+}
+
+void bmx_mgta_scintilla_copy(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_COPY, 0, 0);
+}
+
+void bmx_mgta_scintilla_paste(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_PASTE, 0, 0);
+}
+
+int bmx_mgta_scintilla_linefromposition(ScintillaObject * sci, int pos) {
+	return scintilla_send_message(sci, SCI_LINEFROMPOSITION, pos, 0);
+}
+
+void bmx_mgta_scintilla_appendtext(ScintillaObject * sci, BBString * text) {
+	char * s = bbStringToUTF8String(text);
+	scintilla_send_message(sci, SCI_APPENDTEXT, strlen(s), s);
+	bbMemFree(s);
+}
+
+void bmx_mgta_scintilla_scrolltoend(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_GOTOPOS, scintilla_send_message(sci, SCI_GETLENGTH, 0, 0), 0);
+}
+
+int bmx_mgta_scintilla_getselectionlength(ScintillaObject * sci, int units) {
+	if (units == 2) {
+		/* lines */
+		int startPos = scintilla_send_message(sci, SCI_LINEFROMPOSITION, scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0), 0);
+		int endPos = scintilla_send_message(sci, SCI_LINEFROMPOSITION, scintilla_send_message(sci, SCI_GETSELECTIONEND, 0, 0), 0);
+		return endPos - startPos;
+	} else {
+		/* chars */
+		int startPos = bmx_mgta_scintilla_charfrombyte(sci, scintilla_send_message(sci, SCI_GETSELECTIONSTART, 0, 0), 0);
+		int length = bmx_mgta_scintilla_charfrombyte(sci, scintilla_send_message(sci, SCI_GETSELECTIONEND, 0, 0), startPos);
+		return length;
+	}
+}
+
+void bmx_mgta_scintilla_addtext(ScintillaObject * sci, gchar * text) {
+	int length = strlen(text);
+	scintilla_send_message(sci, SCI_ADDTEXT, length, text);
+}
+
+void bmx_mgta_scintilla_notifcation_update(BBObject * obj, struct SCNotification * notification) {
+#ifdef BMX_NG
+	maxgui_maxguitextareascintilla_common_TSCNotification__update(obj, notification->nmhdr.code, notification->modificationType, notification->updated);
+#else
+	_maxgui_maxguitextareascintilla_TSCNotification__update(obj, notification->nmhdr.code, notification->modificationType, notification->updated);
+#endif
+}
+
+void bmx_mgta_scintilla_setmarginleft(ScintillaObject * sci, int leftmargin) {
+	scintilla_send_message(sci, SCI_SETMARGINLEFT, 0, leftmargin);
+}
+
+void bmx_mgta_scintilla_setcaretwidth(ScintillaObject * sci, int width) {
+	scintilla_send_message(sci, SCI_SETCARETWIDTH, width, 0);
+}
+
+void bmx_mgta_scintilla_setcaretcolor(ScintillaObject * sci, int r, int g, int b) {
+	scintilla_send_message(sci, SCI_SETCARETFORE, r | (g << 8) | (b << 16), 0);
+}
+
+void bmx_mgta_scintilla_enableundoredo(ScintillaObject * sci, int enable) {
+	scintilla_send_message(sci, SCI_SETUNDOCOLLECTION, enable, 0);
+}
+
+int bmx_mgta_scintilla_undoredoenabled(ScintillaObject * sci) {
+	return scintilla_send_message(sci, SCI_GETUNDOCOLLECTION, 0, 0);
+}
+
+void bmx_mgta_scintilla_undo(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_UNDO, 0, 0);
+}
+
+void bmx_mgta_scintilla_redo(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_REDO, 0, 0);
+}
+
+int bmx_mgta_scintilla_canundo(ScintillaObject * sci) {
+	return scintilla_send_message(sci, SCI_CANUNDO, 0, 0);
+}
+
+int bmx_mgta_scintilla_canredo(ScintillaObject * sci) {
+	return scintilla_send_message(sci, SCI_CANREDO, 0, 0);
+}
+
+void bmx_mgta_scintilla_clearundoredo(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_EMPTYUNDOBUFFER, 0, 0);
+}
+
+void bmx_mgta_scintilla_sethighlightlanguage(ScintillaObject * sci, BBString * lang) {
+	char * t = (lang != &bbEmptyString) ? bbStringToUTF8String(lang) : 0;
+
+	if (t) {
+		scintilla_send_message(sci, SCI_SETLEXERLANGUAGE, 0, t);
+		bbMemFree(t);
+	} else {
+		scintilla_send_message(sci, SCI_SETLEXER, SCLEX_NULL, 0);
+	}
+}
+
+bmx_mgta_scintilla_sethighlightkeywords(ScintillaObject * sci, int index, BBString * keywords) {
+	char * t = (keywords != &bbEmptyString) ? bbStringToUTF8String(keywords) : 0;
+	
+	scintilla_send_message(sci, SCI_SETKEYWORDS, index, t != NULL ? t : "");
+
+	if (t) bbMemFree(t);
+}
+
+void bmx_mgta_scintilla_sethighlightstyle(ScintillaObject * sci, int style, int flags, int color) {
+
+	int lang = scintilla_send_message(sci, SCI_GETLEXER, 0, 0);
+
+	if (style == 0) {
+		scintilla_send_message(sci, SCI_STYLESETFORE, style, color);
+	} else {
+
+		switch (lang) {
+			case 222:
+				switch (style) {
+					case 1:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_COMMENT, color);
+						break;
+					case 2:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_STRING, color);
+						break;
+					case 3:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_KEYWORD, color);
+						break;
+					case 4:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_NUMBER, color);
+						break;
+				}
+				break;
+			case SCLEX_CPP:
+				switch (style) {
+					case 1:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_COMMENT, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_COMMENTLINE, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_COMMENTDOC, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_COMMENTLINEDOC, color);
+						break;
+					case 2:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_STRING, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_CHARACTER, color);
+						break;
+					case 3:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_WORD, color);
+						break;
+					case 4:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_C_NUMBER, color);
+						break;
+				}
+				break;
+			case SCLEX_HTML:
+				break;
+			case SCLEX_XML:
+				break;
+			case SCLEX_LUA:
+				switch (style) {
+					case 1:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_COMMENT, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_COMMENTLINE, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_COMMENTDOC, color);
+						break;
+					case 2:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_STRING, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_CHARACTER, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_LITERALSTRING, color);
+						break;
+					case 3:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_WORD, color);
+						break;
+					case 4:
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_LUA_NUMBER, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_HEXNUMBER, color);
+						break;
+				}
+				break;
+		}
+	}
+
+	if (flags & TEXTFORMAT_BOLD) {
+		scintilla_send_message(sci, SCI_STYLESETBOLD, style, 1);
+	}
+
+	if (flags & TEXTFORMAT_ITALIC) {
+		scintilla_send_message(sci, SCI_STYLESETITALIC, style, 1);
+	}
+
+	if (flags & TEXTFORMAT_UNDERLINE) {
+		scintilla_send_message(sci, SCI_STYLESETUNDERLINE, style, 1);
+	}
+}
+
+void bmx_mgta_scintilla_highlight(ScintillaObject * sci) {
+	scintilla_send_message(sci, SCI_COLOURISE, 0, -1);
+}
+
+void bmx_mgta_scintilla_clearhighlightstyles(ScintillaObject * sci, int backcolor, int forecolor) {
+	scintilla_send_message(sci, SCI_STYLERESETDEFAULT, 0, 0);
+	scintilla_send_message(sci, SCI_STYLESETBACK, STYLE_DEFAULT, backcolor);
+	scintilla_send_message(sci, SCI_STYLESETFORE, STYLE_DEFAULT, forecolor);
+	scintilla_send_message(sci, SCI_STYLECLEARALL, 0, 0);
+}
+
+void bmx_mgta_scintilla_setlinenumberbackcolor(ScintillaObject * sci, int color) {
+	scintilla_send_message(sci, SCI_STYLESETBACK, STYLE_LINENUMBER, color);
+}
+
+void bmx_mgta_scintilla_setlinenumberforecolor(ScintillaObject * sci, int color) {
+	scintilla_send_message(sci, SCI_STYLESETFORE, STYLE_LINENUMBER, color);
+}

+ 512 - 476
maxguitextareascintilla.mod/linuxgtk.bmx

@@ -1,476 +1,512 @@
-' Copyright (c) 2014-2018 Bruce A Henderson
-' 
-' Permission is hereby granted, free of charge, to any person obtaining a copy
-' of this software and associated documentation files (the "Software"), to deal
-' in the Software without restriction, including without limitation the rights
-' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-' copies of the Software, and to permit persons to whom the Software is
-' furnished to do so, subject to the following conditions:
-' 
-' The above copyright notice and this permission notice shall be included in
-' all copies or substantial portions of the Software.
-' 
-' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-' THE SOFTWARE.
-'
-Strict
-
-Import MaxGUI.GTK3MaxGUI
-
-Import "common.bmx"
-
-Rem
-bbdoc: 
-End Rem
-Type TGTKScintillaTextArea Extends TGTKTextArea
-
-	Field sciPtr:Byte Ptr
-	Field sciId:Int
-	
-	Field styleMap:TMap = New TMap
-	Field styles:Int[] = New Int[31]
-	Field styleIndex:Int = 0
-	
-	Field lastStyleValue:Int = -1
-	Field lastStyle:Int
-
-	Global sci_id_count:Int = 0
-	
-	Field ignoreChange:Int
-	Field tabPixelWidth:Int
-	
-	Field lineDigits:Int
-	
-	' holder for the latest notification
-	' keep one in the type rather than locally in the callback function so we don't have to create a new object for every notification
-	Field notification:TSCNotification = New TSCNotification
-
-	Function CreateTextArea:TGTKTextArea(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
-		Local this:TGTKScintillaTextArea = New TGTKScintillaTextArea
-
-		this.initTextArea(x, y, w, h, label, group, style)
-
-		Return this
-	End Function
-
-	Method initTextArea(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
-
-		parent = group
-
-		sciId = sci_id_count
-
-		handle = scintilla_new()
-		sciPtr = bmx_mgta_scintilla_getsci(handle, sciId)
-
-		' increment internal counter		
-		sci_id_count :+ 1
-
-		gtk_widget_show(handle)
-
-		gtk_layout_put(TGTKContainer(parent).container, handle, x, y)
-		gtk_widget_set_size_request(handle, w, Max(h,0))
-
-
-		addConnection("sci-notify", g_signal_cbsci(handle, "sci-notify", OnSciNotify, Self, Destroy, 0))
-		addConnection("button-press-event", g_signal_cb3(handle, "button-press-event", OnMouseDown, Self, Destroy, 0))
-		addConnection("button-release-event", g_signal_cb3(handle, "button-release-event", OnMouseUp, Self, Destroy, 0))
-		addConnection("key-press-event", g_signal_cb3(handle, "key-press-event", OnKeyDown, Self, Destroy, 0))
-		
-		' set some default monospaced font
-		SetFont(LookupGuiFont(GUIFONT_MONOSPACED))
-
-	End Method
-	
-	Function OnMouseDown:Int(widget:Byte Ptr, event:Byte Ptr, obj:Object)
-		Local x:Double, y:Double, button:Int
-		bmx_gtk3maxgui_gdkeventbutton(event, Varptr x, Varptr y, Varptr button)
-
-		If button = 3 Then ' right mouse button
-			' ignore this...  see MouseUp for menu event!
-			Return True
-		End If
-
-		PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
-	End Function
-
-	Rem
-	bbdoc: Callback for mouse button release
-	End Rem
-	Function OnMouseUp:Int(widget:Byte Ptr, event:Byte Ptr, obj:Object)
-		Local x:Double, y:Double, button:Int
-		bmx_gtk3maxgui_gdkeventbutton(event, Varptr x, Varptr y, Varptr button)
-
-		If button = 3 Then ' right mouse button
-			PostGuiEvent(EVENT_GADGETMENU, TGadget(obj),,,x,y)
-			Return True
-		End If
-
-		PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
-	End Function
-
-	Method GetText:String()
-		Return bmx_mgta_scintilla_gettext(sciPtr)
-	End Method
-
-	Rem
-	bbdoc: Sets the text.
-	End Rem
-	Method SetText(txt:String)
-		bmx_mgta_scintilla_settext(sciPtr, txt)
-	End Method
-
-	Method SetFont(font:TGuiFont)
-
-		If font = Null Then
-			Return
-		End If
-
-		_font = font
-
-		bmx_mgta_scintilla_setfont(sciPtr, font.name, font.size)
-		
-		' set the margin size for line numbers
-		bmx_mgta_scintilla_setlinedigits(sciPtr, Varptr lineDigits)
-		
-		SetTabs()
-	End Method
-
-	Rem
-	bbdoc: Set the text area selection
-	End Rem
-	Method SetSelection(pos:Int, length:Int, units:Int)
-		'ignoreChange = True
-		Local startPos:Int
-		Local endPos:Int
-
-		If length = 0 Then
-			If units = TEXTAREA_LINES Then
-				startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
-				endPos = startPos
-			Else
-				startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
-				endPos = startPos
-			End If
-		Else
-			If units = TEXTAREA_LINES Then
-				startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
-				endPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True)
-			Else ' must be TEXTAREA_CHARS
-				'startPos = pos
-				'endPos = pos + length
-				startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
-				endPos = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos)
-			End If
-		End If
-
-		bmx_mgta_scintilla_setsel(sciPtr, startPos, endPos)
-
-
-		PostGuiEvent(EVENT_GADGETSELECT, Self)
-
-		' scroll to the start of the selection
-'		bmx_mgta_scintilla_scrollcaret(sciPtr)
-
-	End Method
-
-	Method GetSelectionLength:Int(units:Int)
-		Return bmx_mgta_scintilla_getselectionlength(sciPtr, units)
-	End Method
-
-	Method SetMargins(leftmargin:Int)
-		bmx_mgta_scintilla_setmarginleft(sciPtr, leftmargin)
-	End Method
-
-	Method CharX:Int(char:Int)
-		' TODO
-	EndMethod
-
-	Method CharY:Int(char:Int)
-		' TODO
-	EndMethod
-
-	Method AddText(Text:String)
-		ignoreChange = True
-
-		bmx_mgta_scintilla_appendtext(sciPtr, Text)
-
-?bmxng
-		IWrappedSystemDriver(SystemDriver()).GetDriver().Poll()
-?Not bmxng
-		brl.System.Driver.Poll() ' update events, before scrolling to the end...
-?
-		bmx_mgta_scintilla_scrolltoend(sciPtr)
-	End Method
-
-	Method ReplaceText(pos:Int, length:Int, Text:String, units:Int)
-		ignoreChange = True
-		If length = TEXTAREA_ALL Then
-			SetText(Text)
-		Else
-			Local startPos:Int
-			Local endPos:Int
-	
-			If units = TEXTAREA_LINES Then
-				startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
-				endPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True)
-			Else ' must be TEXTAREA_CHARS
-				'startPos = pos
-				'endPos = pos + length
-				startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
-				endPos = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos)
-			End If
-
-			bmx_mgta_scintilla_settargetstart(sciPtr, startPos)
-			bmx_mgta_scintilla_settargetend(sciPtr, endPos)
-	
-			' insert new text
-			Local textPtr:Byte Ptr = Text.ToUTF8String()
-			bmx_mgta_scintilla_replacetarget(sciPtr, textPtr)
-			MemFree(textPtr)
-		End If
-	End Method
-
-	Method SetColor(r:Int, g:Int, b:Int)
-		bmx_mgta_scintilla_stylesetback(sciPtr, r | g Shl 8 | b Shl 16)
-	End Method
-
-	Method SetTextColor(r:Int, g:Int, b:Int)
-		' set style 0 color (should be main text style)
-		bmx_mgta_scintilla_stylesetfore(sciPtr, 0, r | g Shl 8 | b Shl 16)
-	End Method
-
-	Method SetStyle(r:Int, g:Int, b:Int, flags:Int, pos:Int, length:Int, units:Int)
-		' Build a style string
-		Local s:Int = r Shl 24 | g Shl 16 | b Shl 8 | (flags & $ff)
-		Local style:Int = lastStyle
-
-		If s <> lastStyleValue Then
-		
-			Local styleText:String = String(s)
-	
-			Local st:String = String(styleMap.ValueForKey(styleText))
-			If Not st Then
-
-				' is there already an entry for this one?
-				If styles[styleIndex] Then
-					' remove it from the map
-					styleMap.Remove(String(styles[styleIndex]))
-				End If
-				
-				styles[styleIndex] = s
-				
-				styleMap.Insert(styleText, Chr(styleIndex + 65))
-				style = styleIndex
-				
-				styleIndex :+ 1
-				If styleIndex > 31 Then
-					styleIndex = 0
-				End If
-
-				' create the styling
-				bmx_mgta_scintilla_stylesetfore(sciPtr, style, r | g Shl 8 | b Shl 16)
-	
-				If flags & TEXTFORMAT_ITALIC Then
-					bmx_mgta_scintilla_stylesetitalic(sciPtr, style, True)
-				Else
-					bmx_mgta_scintilla_stylesetitalic(sciPtr, style, False)
-				End If
-	
-				If flags & TEXTFORMAT_BOLD Then
-					bmx_mgta_scintilla_stylesetbold(sciPtr, style, True)
-				Else
-					bmx_mgta_scintilla_stylesetbold(sciPtr, style, False)
-				End If
-	
-				If flags & TEXTFORMAT_UNDERLINE Then
-					bmx_mgta_scintilla_stylesetunderline(sciPtr, style, True)
-				Else
-					bmx_mgta_scintilla_stylesetunderline(sciPtr, style, False)
-				End If
-				
-			Else
-				style = Asc(st) - 65
-			End If
-			
-			lastStyle = style
-			lastStyleValue = s
-
-		End If
-		
-		applyStyle(pos, length, units, style)
-		
-	End Method
-	
-	Method applyStyle(pos:Int, length:Int, units:Int, style:Int)
-		Local startPos:Int
-		Local realLength:Int
-
-		If units = TEXTAREA_LINES Then
-			startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
-			realLength = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True) - startPos
-		Else ' must be TEXTAREA_CHARS
-			startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
-			realLength = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos) - startPos
-		End If
-
-		bmx_mgta_scintilla_startstyling(sciPtr, startPos)
-		bmx_mgta_scintilla_setstyling(sciPtr, realLength, style)
-
-	End Method
-
-	Method AreaText:String(pos:Int, length:Int, units:Int)
-		Local startPos:Int
-		Local endPos:Int
-
-		If units = TEXTAREA_LINES Then
-			startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
-			endPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True)
-		Else ' must be TEXTAREA_CHARS
-			'startPos = pos
-			'endPos = pos + length
-			startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
-			endPos = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos)
-		End If
-		
-		Return bmx_mgta_scintilla_gettextrange(sciPtr, startPos, endPos)
-	End Method
-
-	Method AreaLen:Int(units:Int)
-		If units = TEXTAREA_LINES Then
-			Return bmx_mgta_scintilla_getlinecount(sciPtr)
-		Else
-			Return bmx_mgta_scintilla_getlength(sciPtr)
-		End If
-	End Method
-
-	Method GetCursorPos:Int(units:Int)
-		If units = TEXTAREA_LINES Then
-			Return bmx_mgta_scintilla_getcurrentline(sciPtr)
-		Else
-			Return bmx_mgta_scintilla_getcurrentpos(sciPtr)
-		End If
-	End Method
-
-	Method SetTabs(tabWidth:Int = -1)
-
-		If tabWidth >= 0 Then
-			tabPixelWidth = tabWidth
-		Else
-			tabWidth = tabPixelWidth
-		End If
-
-		' convert from pixels to characters
-		If _font Then
-			tabWidth = tabWidth / _font.CharWidth(32)
-		Else
-			tabWidth = 4
-		End If
-
-		bmx_mgta_scintilla_settabwidth(sciPtr, tabWidth)
-
-	End Method
-
-	Method Activate(cmd:Int)
-		Super.Activate(cmd)
-
-		Select cmd
-			Case ACTIVATE_CUT
-				bmx_mgta_scintilla_cut(sciPtr)
-
-			Case ACTIVATE_COPY
-				bmx_mgta_scintilla_copy(sciPtr)
-
-			Case ACTIVATE_PASTE
-				bmx_mgta_scintilla_paste(sciPtr)
-
-		End Select
-	End Method
-
-	Method CharAt:Int(line:Int)
-		Return bmx_mgta_scintilla_positionfromline(sciPtr, line, False)
-	End Method
-
-	Method LineAt:Int(index:Int)
-		Return bmx_mgta_scintilla_linefromposition(sciPtr, index)
-	End Method
-
-	Function OnSciNotify(widget:Byte Ptr, id:Int, notificationPtr:Byte Ptr, obj:Object)
-		Local ta:TGTKScintillaTextArea = TGTKScintillaTextArea(obj)
-
-		bmx_mgta_scintilla_notifcation_update(ta.notification, notificationPtr)
-
-		Select ta.notification.code
-			Case SCN_UPDATEUI
-				If ta.notification.updated & SC_UPDATE_SELECTION Then
-					PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
-				End If
-			Case SCN_MODIFIED
-				If ta.notification.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT) Then
-					If Not ta.ignoreChange Then
-						PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
-						PostGuiEvent(EVENT_GADGETACTION, TGadget(obj))
-					End If
-					ta.ignoreChange = False
-					
-					bmx_mgta_scintilla_setlinedigits(ta.sciPtr, Varptr ta.lineDigits)
-				End If
-		End Select
-
-	End Function
-
-	Method SetCaretWidth(width:Int)
-		bmx_mgta_scintilla_setcaretwidth(sciPtr, width)
-	End Method
-	
-	Method SetCaretColor(r:Int, g:Int, b:Int)
-		bmx_mgta_scintilla_setcaretcolor(sciPtr, r, g, b)
-	End Method
-
-	Method HasUndoRedo:Int()
-		Return True
-	End Method
-
-	Method EnableUndoRedo(enable:Int)
-		bmx_mgta_scintilla_enableundoredo(sciPtr, enable)
-	End Method
-
-	Method UndoRedoEnabled:Int()
-		Return bmx_mgta_scintilla_undoredoenabled(sciPtr)
-	End Method
-
-	Method Undo()
-		bmx_mgta_scintilla_undo(sciPtr)
-	End Method
-
-	Method Redo()
-		bmx_mgta_scintilla_redo(sciPtr)
-	End Method
-
-	Method CanUndo:Int()
-		Return bmx_mgta_scintilla_canundo(sciPtr)
-	End Method
-
-	Method CanRedo:Int()
-		Return bmx_mgta_scintilla_canredo(sciPtr)
-	End Method
-
-	Method ClearUndoRedo()
-		bmx_mgta_scintilla_clearundoredo(sciPtr)
-	End Method
-
-End Type
-
-
-' scintilla text area driver
-Type TGTKScintillaTextAreaDriver Extends TGTKTextAreaDriver
-	Function CreateTextArea:TGTKTextArea(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
-		Return TGTKScintillaTextArea.CreateTextArea(x, y, w, h, label, group, style)
-	End Function
-End Type
-
-gtk3maxgui_textarea = New TGTKScintillaTextAreaDriver
+' Copyright (c) 2014-2018 Bruce A Henderson
+' 
+' Permission is hereby granted, free of charge, to any person obtaining a copy
+' of this software and associated documentation files (the "Software"), to deal
+' in the Software without restriction, including without limitation the rights
+' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+' copies of the Software, and to permit persons to whom the Software is
+' furnished to do so, subject to the following conditions:
+' 
+' The above copyright notice and this permission notice shall be included in
+' all copies or substantial portions of the Software.
+' 
+' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+' THE SOFTWARE.
+'
+Strict
+
+Import MaxGUI.GTK3MaxGUI
+
+Import "common.bmx"
+
+Rem
+bbdoc: 
+End Rem
+Type TGTKScintillaTextArea Extends TGTKTextArea
+
+	Field sciPtr:Byte Ptr
+	Field sciId:Int
+	
+	Field styleMap:TMap = New TMap
+	Field styles:Int[] = New Int[31]
+	Field styleIndex:Int = 0
+	
+	Field lastStyleValue:Int = -1
+	Field lastStyle:Int
+
+	Global sci_id_count:Int = 0
+	
+	Field ignoreChange:Int
+	Field tabPixelWidth:Int
+	
+	Field lineDigits:Int
+	
+	' holder for the latest notification
+	' keep one in the type rather than locally in the callback function so we don't have to create a new object for every notification
+	Field notification:TSCNotification = New TSCNotification
+
+	Function CreateTextArea:TGTKTextArea(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
+		Local this:TGTKScintillaTextArea = New TGTKScintillaTextArea
+
+		this.initTextArea(x, y, w, h, label, group, style)
+
+		Return this
+	End Function
+
+	Method initTextArea(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
+
+		parent = group
+
+		sciId = sci_id_count
+
+		handle = scintilla_new()
+		sciPtr = bmx_mgta_scintilla_getsci(handle, sciId)
+
+		' increment internal counter		
+		sci_id_count :+ 1
+
+		gtk_widget_show(handle)
+
+		gtk_layout_put(TGTKContainer(parent).container, handle, x, y)
+		gtk_widget_set_size_request(handle, w, Max(h,0))
+
+
+		addConnection("sci-notify", g_signal_cbsci(handle, "sci-notify", OnSciNotify, Self, Destroy, 0))
+		addConnection("button-press-event", g_signal_cb3(handle, "button-press-event", OnMouseDown, Self, Destroy, 0))
+		addConnection("button-release-event", g_signal_cb3(handle, "button-release-event", OnMouseUp, Self, Destroy, 0))
+		addConnection("key-press-event", g_signal_cb3(handle, "key-press-event", OnKeyDown, Self, Destroy, 0))
+		
+		' set some default monospaced font
+		SetFont(LookupGuiFont(GUIFONT_MONOSPACED))
+
+	End Method
+	
+	Function OnMouseDown:Int(widget:Byte Ptr, event:Byte Ptr, obj:Object)
+		Local x:Double, y:Double, button:Int
+		bmx_gtk3maxgui_gdkeventbutton(event, Varptr x, Varptr y, Varptr button)
+
+		If button = 3 Then ' right mouse button
+			' ignore this...  see MouseUp for menu event!
+			Return True
+		End If
+
+		PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
+	End Function
+
+	Rem
+	bbdoc: Callback for mouse button release
+	End Rem
+	Function OnMouseUp:Int(widget:Byte Ptr, event:Byte Ptr, obj:Object)
+		Local x:Double, y:Double, button:Int
+		bmx_gtk3maxgui_gdkeventbutton(event, Varptr x, Varptr y, Varptr button)
+
+		If button = 3 Then ' right mouse button
+			PostGuiEvent(EVENT_GADGETMENU, TGadget(obj),,,x,y)
+			Return True
+		End If
+
+		PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
+	End Function
+
+	Method GetText:String()
+		Return bmx_mgta_scintilla_gettext(sciPtr)
+	End Method
+
+	Rem
+	bbdoc: Sets the text.
+	End Rem
+	Method SetText(txt:String)
+		bmx_mgta_scintilla_settext(sciPtr, txt)
+	End Method
+
+	Method SetFont(font:TGuiFont)
+
+		If font = Null Then
+			Return
+		End If
+
+		_font = font
+
+		bmx_mgta_scintilla_setfont(sciPtr, font.name, font.size)
+		
+		' set the margin size for line numbers
+		bmx_mgta_scintilla_setlinedigits(sciPtr, Varptr lineDigits)
+		
+		SetTabs()
+	End Method
+
+	Rem
+	bbdoc: Set the text area selection
+	End Rem
+	Method SetSelection(pos:Int, length:Int, units:Int)
+		'ignoreChange = True
+		Local startPos:Int
+		Local endPos:Int
+
+		If length = 0 Then
+			If units = TEXTAREA_LINES Then
+				startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
+				endPos = startPos
+			Else
+				startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
+				endPos = startPos
+			End If
+		Else
+			If units = TEXTAREA_LINES Then
+				startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
+				endPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True)
+			Else ' must be TEXTAREA_CHARS
+				'startPos = pos
+				'endPos = pos + length
+				startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
+				endPos = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos)
+			End If
+		End If
+
+		bmx_mgta_scintilla_setsel(sciPtr, startPos, endPos)
+
+
+		PostGuiEvent(EVENT_GADGETSELECT, Self)
+
+		' scroll to the start of the selection
+'		bmx_mgta_scintilla_scrollcaret(sciPtr)
+
+	End Method
+
+	Method GetSelectionLength:Int(units:Int)
+		Return bmx_mgta_scintilla_getselectionlength(sciPtr, units)
+	End Method
+
+	Method SetMargins(leftmargin:Int)
+		bmx_mgta_scintilla_setmarginleft(sciPtr, leftmargin)
+	End Method
+
+	Method CharX:Int(char:Int)
+		' TODO
+	EndMethod
+
+	Method CharY:Int(char:Int)
+		' TODO
+	EndMethod
+
+	Method AddText(Text:String)
+		ignoreChange = True
+
+		bmx_mgta_scintilla_appendtext(sciPtr, Text)
+
+?bmxng
+		IWrappedSystemDriver(SystemDriver()).GetDriver().Poll()
+?Not bmxng
+		brl.System.Driver.Poll() ' update events, before scrolling to the end...
+?
+		bmx_mgta_scintilla_scrolltoend(sciPtr)
+	End Method
+
+	Method ReplaceText(pos:Int, length:Int, Text:String, units:Int)
+		ignoreChange = True
+		If length = TEXTAREA_ALL Then
+			SetText(Text)
+		Else
+			Local startPos:Int
+			Local endPos:Int
+	
+			If units = TEXTAREA_LINES Then
+				startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
+				endPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True)
+			Else ' must be TEXTAREA_CHARS
+				'startPos = pos
+				'endPos = pos + length
+				startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
+				endPos = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos)
+			End If
+
+			bmx_mgta_scintilla_settargetstart(sciPtr, startPos)
+			bmx_mgta_scintilla_settargetend(sciPtr, endPos)
+	
+			' insert new text
+			Local textPtr:Byte Ptr = Text.ToUTF8String()
+			bmx_mgta_scintilla_replacetarget(sciPtr, textPtr)
+			MemFree(textPtr)
+		End If
+	End Method
+
+	Method SetColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_stylesetback(sciPtr, r | g Shl 8 | b Shl 16)
+	End Method
+
+	Method SetTextColor(r:Int, g:Int, b:Int)
+		' set style 0 color (should be main text style)
+		bmx_mgta_scintilla_stylesetfore(sciPtr, 0, r | g Shl 8 | b Shl 16)
+	End Method
+
+	Method SetStyle(r:Int, g:Int, b:Int, flags:Int, pos:Int, length:Int, units:Int)
+		' Build a style string
+		Local s:Int = r Shl 24 | g Shl 16 | b Shl 8 | (flags & $ff)
+		Local style:Int = lastStyle
+
+		If s <> lastStyleValue Then
+		
+			Local styleText:String = String(s)
+	
+			Local st:String = String(styleMap.ValueForKey(styleText))
+			If Not st Then
+
+				' is there already an entry for this one?
+				If styles[styleIndex] Then
+					' remove it from the map
+					styleMap.Remove(String(styles[styleIndex]))
+				End If
+				
+				styles[styleIndex] = s
+				
+				styleMap.Insert(styleText, Chr(styleIndex + 65))
+				style = styleIndex
+				
+				styleIndex :+ 1
+				If styleIndex > 31 Then
+					styleIndex = 0
+				End If
+
+				' create the styling
+				bmx_mgta_scintilla_stylesetfore(sciPtr, style, r | g Shl 8 | b Shl 16)
+	
+				If flags & TEXTFORMAT_ITALIC Then
+					bmx_mgta_scintilla_stylesetitalic(sciPtr, style, True)
+				Else
+					bmx_mgta_scintilla_stylesetitalic(sciPtr, style, False)
+				End If
+	
+				If flags & TEXTFORMAT_BOLD Then
+					bmx_mgta_scintilla_stylesetbold(sciPtr, style, True)
+				Else
+					bmx_mgta_scintilla_stylesetbold(sciPtr, style, False)
+				End If
+	
+				If flags & TEXTFORMAT_UNDERLINE Then
+					bmx_mgta_scintilla_stylesetunderline(sciPtr, style, True)
+				Else
+					bmx_mgta_scintilla_stylesetunderline(sciPtr, style, False)
+				End If
+				
+			Else
+				style = Asc(st) - 65
+			End If
+			
+			lastStyle = style
+			lastStyleValue = s
+
+		End If
+		
+		applyStyle(pos, length, units, style)
+		
+	End Method
+	
+	Method applyStyle(pos:Int, length:Int, units:Int, style:Int)
+		Local startPos:Int
+		Local realLength:Int
+
+		If units = TEXTAREA_LINES Then
+			startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
+			realLength = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True) - startPos
+		Else ' must be TEXTAREA_CHARS
+			startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
+			realLength = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos) - startPos
+		End If
+
+		bmx_mgta_scintilla_startstyling(sciPtr, startPos)
+		bmx_mgta_scintilla_setstyling(sciPtr, realLength, style)
+
+	End Method
+
+	Method AreaText:String(pos:Int, length:Int, units:Int)
+		Local startPos:Int
+		Local endPos:Int
+
+		If units = TEXTAREA_LINES Then
+			startPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos, True)
+			endPos = bmx_mgta_scintilla_positionfromline(sciPtr, pos + length, True)
+		Else ' must be TEXTAREA_CHARS
+			'startPos = pos
+			'endPos = pos + length
+			startPos = bmx_mgta_scintilla_bytefromchar(sciPtr, pos, 0, 0)
+			endPos = bmx_mgta_scintilla_bytefromchar(sciPtr, length, startPos, pos)
+		End If
+		
+		Return bmx_mgta_scintilla_gettextrange(sciPtr, startPos, endPos)
+	End Method
+
+	Method AreaLen:Int(units:Int)
+		If units = TEXTAREA_LINES Then
+			Return bmx_mgta_scintilla_getlinecount(sciPtr)
+		Else
+			Return bmx_mgta_scintilla_getlength(sciPtr)
+		End If
+	End Method
+
+	Method GetCursorPos:Int(units:Int)
+		If units = TEXTAREA_LINES Then
+			Return bmx_mgta_scintilla_getcurrentline(sciPtr)
+		Else
+			Return bmx_mgta_scintilla_getcurrentpos(sciPtr)
+		End If
+	End Method
+
+	Method SetTabs(tabWidth:Int = -1)
+
+		If tabWidth >= 0 Then
+			tabPixelWidth = tabWidth
+		Else
+			tabWidth = tabPixelWidth
+		End If
+
+		' convert from pixels to characters
+		If _font Then
+			tabWidth = tabWidth / _font.CharWidth(32)
+		Else
+			tabWidth = 4
+		End If
+
+		bmx_mgta_scintilla_settabwidth(sciPtr, tabWidth)
+
+	End Method
+
+	Method Activate(cmd:Int)
+		Super.Activate(cmd)
+
+		Select cmd
+			Case ACTIVATE_CUT
+				bmx_mgta_scintilla_cut(sciPtr)
+
+			Case ACTIVATE_COPY
+				bmx_mgta_scintilla_copy(sciPtr)
+
+			Case ACTIVATE_PASTE
+				bmx_mgta_scintilla_paste(sciPtr)
+
+		End Select
+	End Method
+
+	Method CharAt:Int(line:Int)
+		Return bmx_mgta_scintilla_positionfromline(sciPtr, line, False)
+	End Method
+
+	Method LineAt:Int(index:Int)
+		Return bmx_mgta_scintilla_linefromposition(sciPtr, index)
+	End Method
+
+	Function OnSciNotify(widget:Byte Ptr, id:Int, notificationPtr:Byte Ptr, obj:Object)
+		Local ta:TGTKScintillaTextArea = TGTKScintillaTextArea(obj)
+
+		bmx_mgta_scintilla_notifcation_update(ta.notification, notificationPtr)
+
+		Select ta.notification.code
+			Case SCN_UPDATEUI
+				If ta.notification.updated & SC_UPDATE_SELECTION Then
+					PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
+				End If
+			Case SCN_MODIFIED
+				If ta.notification.modificationType & (SC_MOD_INSERTTEXT | SC_MOD_DELETETEXT) Then
+					If Not ta.ignoreChange Then
+						PostGuiEvent(EVENT_GADGETSELECT, TGadget(obj))
+						PostGuiEvent(EVENT_GADGETACTION, TGadget(obj))
+					End If
+					ta.ignoreChange = False
+					
+					bmx_mgta_scintilla_setlinedigits(ta.sciPtr, Varptr ta.lineDigits)
+				End If
+		End Select
+
+	End Function
+
+	Method SetCaretWidth(width:Int)
+		bmx_mgta_scintilla_setcaretwidth(sciPtr, width)
+	End Method
+	
+	Method SetCaretColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setcaretcolor(sciPtr, r, g, b)
+	End Method
+
+	Method HasUndoRedo:Int()
+		Return True
+	End Method
+
+	Method EnableUndoRedo(enable:Int)
+		bmx_mgta_scintilla_enableundoredo(sciPtr, enable)
+	End Method
+
+	Method UndoRedoEnabled:Int()
+		Return bmx_mgta_scintilla_undoredoenabled(sciPtr)
+	End Method
+
+	Method Undo()
+		bmx_mgta_scintilla_undo(sciPtr)
+	End Method
+
+	Method Redo()
+		bmx_mgta_scintilla_redo(sciPtr)
+	End Method
+
+	Method CanUndo:Int()
+		Return bmx_mgta_scintilla_canundo(sciPtr)
+	End Method
+
+	Method CanRedo:Int()
+		Return bmx_mgta_scintilla_canredo(sciPtr)
+	End Method
+
+	Method ClearUndoRedo()
+		bmx_mgta_scintilla_clearundoredo(sciPtr)
+	End Method
+
+	Method HasHighlighting:Int()
+		Return True
+	End Method
+
+	Method SetHighlightLanguage(lang:String)
+		bmx_mgta_scintilla_sethighlightlanguage(sciPtr, lang)
+	End Method
+
+	Method SetHighlightKeywords(index:Int, keywords:String)
+		bmx_mgta_scintilla_sethighlightkeywords(sciPtr, index, keywords)
+	End Method
+
+	Method SetHighlightStyle(index:Int, flags:Int, red:Int, green:Int, blue:Int)
+		bmx_mgta_scintilla_sethighlightstyle(sciPtr, index, flags, red | green Shl 8 | blue Shl 16)
+	End Method
+
+	Method HighLight()
+		bmx_mgta_scintilla_highlight(sciPtr)
+	End Method
+
+	Method ClearHighlightStyles(br:Int, bg:Int, bb:Int, fr:Int, fg:Int, fb:Int)
+		bmx_mgta_scintilla_clearhighlightstyles(sciPtr, br | bg Shl 8 | bb Shl 16, fr | fg Shl 8 | fb Shl 16)
+	End Method
+
+	Method HasLineNumbers:Int()
+		Return True
+	End Method
+
+	Method SetLineNumberBackColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setlinenumberbackcolor(sciPtr, r | g Shl 8 | b Shl 16)
+	End Method
+
+	Method SetLineNumberForeColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setlinenumberforecolor(sciPtr, r | g Shl 8 | b Shl 16)
+	End Method
+
+End Type
+
+
+' scintilla text area driver
+Type TGTKScintillaTextAreaDriver Extends TGTKTextAreaDriver
+	Function CreateTextArea:TGTKTextArea(x:Int, y:Int, w:Int, h:Int, label:String, group:TGadget, style:Int)
+		Return TGTKScintillaTextArea.CreateTextArea(x, y, w, h, label, group, style)
+	End Function
+End Type
+
+gtk3maxgui_textarea = New TGTKScintillaTextAreaDriver

+ 86 - 83
maxguitextareascintilla.mod/maxguitextareascintilla.bmx

@@ -1,83 +1,86 @@
-' Copyright (c) 2014-2018 Bruce A Henderson
-' 
-' Permission is hereby granted, free of charge, to any person obtaining a copy
-' of this software and associated documentation files (the "Software"), to deal
-' in the Software without restriction, including without limitation the rights
-' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-' copies of the Software, and to permit persons to whom the Software is
-' furnished to do so, subject to the following conditions:
-' 
-' The above copyright notice and this permission notice shall be included in
-' all copies or substantial portions of the Software.
-' 
-' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-' THE SOFTWARE.
-'
-SuperStrict
-
-Rem
-bbdoc: Scintilla-based MaxGUI TextArea gadget.
-End Rem
-Module MaxGUI.MaxGUITextAreaScintilla
-
-ModuleInfo "Version: 1.00"
-ModuleInfo "License: MIT"
-ModuleInfo "Copyright: (c) 2014-2018 Bruce A Henderson"
-
-ModuleInfo "History: 1.00"
-ModuleInfo "History: Initial Release."
-
-'
-' Notes :
-'   commented out EM_SETSEL handler section in ScintillaWin.cxx - it was causing all the text to highlight whenever the gadget came into focus.
-'
-'   Added LINK_LEXER(lmBlitzMax); to Catalogue.cxx
-
-ModuleInfo "CC_OPTS: -fexceptions"
-
-?Linux
-
-ModuleInfo "CC_OPTS: -DGTK"
-ModuleInfo "CC_OPTS: -std=c++11"
-
-' glib
-ModuleInfo "CC_OPTS: -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include"
-' gtk
-ModuleInfo "CC_OPTS: -I/usr/include/gtk-3.0  -I/usr/lib/i386-linux-gnu/gtk-3.0/include"
-' cairo
-ModuleInfo "CC_OPTS: -I/usr/include/cairo"
-' pango
-ModuleInfo "CC_OPTS: -I/usr/include/pango-1.0"
-' gdk
-ModuleInfo "CC_OPTS: -I/usr/include/gdk-pixbuf-2.0"
-' atk
-ModuleInfo "CC_OPTS: -I/usr/include/atk-1.0"
-
-?linuxarm
-' glib
-ModuleInfo "CC_OPTS: -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include"
-' gtk
-ModuleInfo "CC_OPTS: -I/usr/lib/arm-linux-gnueabihf/gtk-3.0/include"
-
-?linux
-Import "linuxgtk.bmx"
-
-?macos
-
-ModuleInfo "CPP_OPTS: -std=c++11 -DSCI_NAMESPACE -DSCI_LEXER"
-ModuleInfo "CC_OPTS: -DSCI_NAMESPACE -DSCI_LEXER"
-
-'Import "macos.bmx"
-
-?win32
-
-ModuleInfo "CC_OPTS: -std=c++11 -DSCI_NAMESPACE -DSCI_LEXER -DSTATIC_BUILD"
-
-Import "win32.bmx"
-
-?
+' Copyright (c) 2014-2018 Bruce A Henderson
+' 
+' Permission is hereby granted, free of charge, to any person obtaining a copy
+' of this software and associated documentation files (the "Software"), to deal
+' in the Software without restriction, including without limitation the rights
+' to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+' copies of the Software, and to permit persons to whom the Software is
+' furnished to do so, subject to the following conditions:
+' 
+' The above copyright notice and this permission notice shall be included in
+' all copies or substantial portions of the Software.
+' 
+' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+' IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+' FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+' AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+' LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+' OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+' THE SOFTWARE.
+'
+SuperStrict
+
+Rem
+bbdoc: Scintilla-based MaxGUI TextArea gadget.
+End Rem
+Module MaxGUI.MaxGUITextAreaScintilla
+
+ModuleInfo "Version: 1.00"
+ModuleInfo "License: MIT"
+ModuleInfo "Copyright: (c) 2014-2018 Bruce A Henderson"
+
+ModuleInfo "History: 1.00"
+ModuleInfo "History: Initial Release."
+
+'
+' Notes :
+'   commented out EM_SETSEL handler section in ScintillaWin.cxx - it was causing all the text to highlight whenever the gadget came into focus.
+'
+'   Added LINK_LEXER(lmBlitzMax); to Catalogue.cxx
+
+ModuleInfo "CC_OPTS: -fexceptions"
+
+?Linux
+
+ModuleInfo "CC_OPTS: -DGTK"
+ModuleInfo "CC_OPTS: -std=c++11"
+
+' glib
+ModuleInfo "CC_OPTS: -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include"
+' gtk
+ModuleInfo "CC_OPTS: -I/usr/include/gtk-3.0  -I/usr/lib/i386-linux-gnu/gtk-3.0/include"
+' cairo
+ModuleInfo "CC_OPTS: -I/usr/include/cairo"
+' pango
+ModuleInfo "CC_OPTS: -I/usr/include/pango-1.0"
+' gdk
+ModuleInfo "CC_OPTS: -I/usr/include/gdk-pixbuf-2.0"
+' atk
+ModuleInfo "CC_OPTS: -I/usr/include/atk-1.0"
+
+?linuxarm
+' glib
+ModuleInfo "CC_OPTS: -I/usr/lib/arm-linux-gnueabihf/glib-2.0/include"
+' gtk
+ModuleInfo "CC_OPTS: -I/usr/lib/arm-linux-gnueabihf/gtk-3.0/include"
+
+?linux
+ModuleInfo "CPP_OPTS: -std=c++11 -DSCI_NAMESPACE -DSCI_LEXER"
+ModuleInfo "CC_OPTS: -DSCI_NAMESPACE -DSCI_LEXER"
+
+Import "linuxgtk.bmx"
+
+?macos
+
+ModuleInfo "CPP_OPTS: -std=c++11 -DSCI_NAMESPACE -DSCI_LEXER"
+ModuleInfo "CC_OPTS: -DSCI_NAMESPACE -DSCI_LEXER"
+
+'Import "macos.bmx"
+
+?win32
+
+ModuleInfo "CC_OPTS: -std=c++11 -DSCI_NAMESPACE -DSCI_LEXER -DSTATIC_BUILD"
+
+Import "win32.bmx"
+
+?

+ 2 - 2
maxguitextareascintilla.mod/source.bmx

@@ -186,6 +186,8 @@ Import "scintilla/lexers/LexNull.cxx"
 Import "scintilla/lexers/LexProps.cxx"
 Import "scintilla/lexers/LexSAS.cxx"
 Import "scintilla/lexers/LexStata.cxx"
+Import "scintilla/lexers/LexRegistry.cxx"
+Import "scintilla/lexers/LexDMIS.cxx"
 
 Import "LexMax.cxx" ' BlitzMax lexer
 
@@ -209,8 +211,6 @@ Import "macos_glue.mm"
 Import "scintilla/win32/PlatWin.cxx"
 Import "scintilla/win32/ScintillaWin.cxx"
 Import "scintilla/win32/HanjaDic.cxx"
-Import "scintilla/lexers/LexRegistry.cxx"
-Import "scintilla/lexers/LexDMIS.cxx"
 
 Import "win32_glue.c"
 ?