Преглед изворни кода

Added textarea bracket matching.

woollybah пре 6 година
родитељ
комит
1e720bbc16

+ 6 - 0
maxgui.mod/gadget.bmx

@@ -834,6 +834,12 @@ Type TGadget
 	End Method
 	Method EndUndoAction()
 	End Method
+	Method HasBracketMatching:Int()
+	End Method
+	Method SetBracketMatchingColor(r:Int, g:Int, b:Int)
+	End Method
+	Method MatchBrackets()
+	End Method
 ' progbar
 	Method SetValue(value#)
 	End Method	

+ 12 - 0
maxgui.mod/maxgui.bmx

@@ -1848,6 +1848,18 @@ Function TextAreaEndUndoAction(textarea:TGadget)
 	textarea.EndUndoAction()
 End Function
 
+Function TextAreaHasBracketMatching:Int(textarea:TGadget)
+	Return textarea.HasBracketMatching()
+End Function
+
+Function TextAreaSetBracketMatchingColor(textarea:TGadget, red:Int, green:Int, blue:Int)
+	textarea.SetBracketMatchingColor(red, green, blue)
+End Function
+
+Function TextAreaMatchBrackets(textarea:TGadget)
+	textarea.MatchBrackets()
+End Function
+
 ' gadget lists
 
 Rem

+ 4 - 0
maxguitextareascintilla.mod/common.bmx

@@ -104,6 +104,10 @@ Extern
 
 	Function bmx_mgta_scintilla_beginundoaction(handle:Byte Ptr)
 	Function bmx_mgta_scintilla_endundoaction(handle:Byte Ptr)
+
+	Function bmx_mgta_scintilla_setbracketmatchingcolor(handle:Byte Ptr, r:Int, g:Int, b:Int)
+	Function bmx_mgta_scintilla_matchbrackets(handle:Byte Ptr)
+
 End Extern
 
 Type TSCNotification

+ 14 - 0
maxguitextareascintilla.mod/glue.c

@@ -531,3 +531,17 @@ void bmx_mgta_scintilla_beginundoaction(SCI_HANDLE sci) {
 void bmx_mgta_scintilla_endundoaction(SCI_HANDLE sci) {
 	scintilla_send_message(sci, SCI_ENDUNDOACTION, 0, 0);
 }
+
+void bmx_mgta_scintilla_setbracketmatchingcolor(SCI_HANDLE sci, int r, int g, int b) {
+	scintilla_send_message(sci, SCI_STYLESETFORE, STYLE_BRACELIGHT, r | (g << 8) | (b << 16));
+}
+
+void bmx_mgta_scintilla_matchbrackets(SCI_HANDLE sci) {
+	int pos = scintilla_send_message(sci, SCI_GETCURRENTPOS, 0, 0);
+	int endPos = scintilla_send_message(sci, SCI_BRACEMATCH, pos, 0);
+	if (endPos != -1) {
+		scintilla_send_message(sci, SCI_BRACEHIGHLIGHT, pos, endPos);
+	} else {
+		scintilla_send_message(sci, SCI_BRACEBADLIGHT, -1, 0);
+	}
+}

+ 12 - 0
maxguitextareascintilla.mod/linuxgtk.bmx

@@ -525,6 +525,18 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 		bmx_mgta_scintilla_endundoaction(sciPtr)
 	End Method
 
+	Method HasBracketMatching:Int()
+		Return True
+	End Method
+	
+	Method SetBracketMatchingColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setbracketmatchingcolor(sciPtr, r, g, b)
+	End Method
+	
+	Method MatchBrackets()
+		bmx_mgta_scintilla_matchbrackets(sciPtr)
+	End Method
+
 End Type
 
 

+ 12 - 0
maxguitextareascintilla.mod/win32.bmx

@@ -510,6 +510,18 @@ Type TWindowsScintillaTextArea Extends TWindowsTextArea
 		bmx_mgta_scintilla_endundoaction(_hwnd)
 	End Method
 
+	Method HasBracketMatching:Int()
+		Return True
+	End Method
+	
+	Method SetBracketMatchingColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setbracketmatchingcolor(_hwnd, r, g, b)
+	End Method
+	
+	Method MatchBrackets()
+		bmx_mgta_scintilla_matchbrackets(_hwnd)
+	End Method
+
 End Type