浏览代码

[MaxGuiTextareaScintilla.mod] Add support for "caret line" (#30)

Adds support to enable and colorize the line at which the caret is currently
Ronny Otto 6 年之前
父节点
当前提交
9bfe81a614

+ 8 - 0
maxgui.mod/gadget.bmx

@@ -817,6 +817,14 @@ Type TGadget
 	End Method
 	Method SetLineNumberEnable(enabled:Int)
 	End Method
+	Method GetCaretLineVisible()
+	End Method
+	Method SetCaretLineVisible(enabled:Int)
+	End Method
+	Method SetCaretLineBackgroundColor(r:Int, g:Int, b:Int)
+	End Method
+	Method GetCaretLineBackgroundColor:int()
+	End Method
 	Method HasCharEventSupressionFixup:Int()
 	End Method
 ' progbar

+ 18 - 2
maxgui.mod/maxgui.bmx

@@ -1808,14 +1808,30 @@ Function TextAreaSetLineNumberEnable(textarea:TGadget, enabled:Int)
 	textarea.SetLineNumberEnable(enabled)
 End Function
 
-Function TextAreaSetLineNumberBackColor(textarea:TGadget, red:Int, green:Int, blue)
+Function TextAreaSetLineNumberBackColor(textarea:TGadget, red:Int, green:Int, blue:Int)
 	textarea.SetLineNumberBackColor(red, green, blue)
 End Function
 
-Function TextAreaSetLineNumberForeColor(textarea:TGadget, red:Int, green:Int, blue)
+Function TextAreaSetLineNumberForeColor(textarea:TGadget, red:Int, green:Int, blue:Int)
 	textarea.SetLineNumberForeColor(red, green, blue)
 End Function
 
+Function TextAreaSetCaretLineVisible(textarea:TGadget, enabled:Int)
+	textarea.SetCaretLineVisible(enabled)
+End Function
+
+Function TextAreaGetCaretLineVisible:int(textarea:TGadget)
+	return textarea.GetCaretLineVisible()
+End Function
+
+Function TextAreaSetCaretLineBackgroundColor(textarea:TGadget, red:Int, green:Int, blue:Int)
+	textarea.SetCaretLineBackgroundColor(red, green, blue)
+End Function
+
+Function TextAreaGetCaretLineBackgroundColor:int(textarea:TGadget)
+	return textarea.GetCaretLineBackgroundColor()
+End Function
+
 Function TextAreaHasCharEventSupressionFixup:Int(textarea:TGadget)
 	Return textarea.HasCharEventSupressionFixup()
 End Function

+ 4 - 0
maxguitextareascintilla.mod/common.bmx

@@ -78,6 +78,10 @@ Extern
 	Function bmx_mgta_scintilla_setcaretwidth(handle:Byte Ptr, width:Int)
 	Function bmx_mgta_scintilla_setcaretcolor(handle:Byte Ptr, r:Int, g:Int, b:Int)
 	Function bmx_mgta_scintilla_startendfromchar(handle:Byte Ptr, pos:Int, length:Int, startPos:Int Var, endPos:Int Var)
+	Function bmx_mgta_scintilla_setcaretlinevisible(handle:Byte Ptr, enable:int)
+	Function bmx_mgta_scintilla_getcaretlinevisible:Int(handle:Byte Ptr)
+	Function bmx_mgta_scintilla_setcaretlineback:Int(handle:Byte Ptr, r:Int, g:Int, b:Int)
+	Function bmx_mgta_scintilla_getcaretlineback:Int(handle:Byte Ptr)
 
 	Function bmx_mgta_scintilla_notifcation_update(obj:Object, handle:Byte Ptr)
 	

+ 16 - 0
maxguitextareascintilla.mod/glue.c

@@ -343,6 +343,22 @@ void bmx_mgta_scintilla_setmarginleft(SCI_HANDLE sci, int leftmargin) {
 	scintilla_send_message(sci, SCI_SETMARGINLEFT, 0, leftmargin);
 }
 
+void bmx_mgta_scintilla_setcaretlinevisible(SCI_HANDLE sci, int enable) {
+	scintilla_send_message(sci, SCI_SETCARETLINEVISIBLE, enable, 0);
+}
+
+int bmx_mgta_scintilla_getcaretlinevisible(SCI_HANDLE sci) {
+	return scintilla_send_message(sci, SCI_GETCARETLINEVISIBLE, 0, 0);
+}
+
+void bmx_mgta_scintilla_setcaretlineback(SCI_HANDLE sci, int r, int g, int b) {
+	scintilla_send_message(sci, SCI_SETCARETLINEBACK, r | (g << 8) | (b << 16), 0);
+}
+
+int bmx_mgta_scintilla_getcaretlineback(SCI_HANDLE sci) {
+	return scintilla_send_message(sci, SCI_GETCARETLINEBACK, 0, 0);
+}
+
 void bmx_mgta_scintilla_setcaretwidth(SCI_HANDLE sci, int width) {
 	scintilla_send_message(sci, SCI_SETCARETWIDTH, width, 0);
 }

+ 19 - 0
maxguitextareascintilla.mod/linuxgtk.bmx

@@ -47,6 +47,7 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 	Field lineDigits:Int
 	
 	Field showLineNumbers:Int = True
+	Field showCaretLine:Int = True
 
 	' 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
@@ -496,6 +497,24 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 		showLineNumbers = enabled
 		bmx_mgta_scintilla_setlinedigits(sciPtr, Varptr lineDigits, showLineNumbers)
 	End Method
+	
+	Method SetCaretLineVisible(enabled:Int)
+		showCaretLine = enabled
+		bmx_mgta_scintilla_setcaretlinevisible(sciPtr, showCaretLine)
+	End Method
+
+	Method GetCaretLineVisible:int()
+		showCaretLine = bmx_mgta_scintilla_getcaretlinevisible(sciPtr)
+		Return showCaretLine
+	End Method
+
+	Method SetCaretLineBackgroundColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setcaretlineback(sciPtr, r, g, b)
+	End Method
+
+	Method GetCaretLineBackgroundColor:int()
+		Return bmx_mgta_scintilla_getcaretlineback(sciPtr)
+	End Method
 
 End Type
 

+ 18 - 0
maxguitextareascintilla.mod/win32.bmx

@@ -478,6 +478,24 @@ Type TWindowsScintillaTextArea Extends TWindowsTextArea
 		bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits, showLineNumbers)
 	End Method
 	
+	Method SetCaretLineVisible(enabled:Int)
+		showCaretLine = enabled
+		bmx_mgta_scintilla_setcaretlinevisible(_hwnd, showCaretLine)
+	End Method
+
+	Method GetCaretLineVisible:int()
+		showCaretLine = bmx_mgta_scintilla_getcaretlinevisible(_hwnd)
+		Return showCaretLine
+	End Method
+
+	Method SetCaretLineBackgroundColor(r:Int, g:Int, b:Int)
+		bmx_mgta_scintilla_setcaretlineback(_hwnd, r, g, b)
+	End Method
+
+	Method GetCaretLineBackgroundColor:int()
+		Return bmx_mgta_scintilla_getcaretlineback(_hwnd)
+	End Method
+	
 	Method HasCharEventSupressionFixup:Int()
 		Return True
 	End Method