Browse Source

Added textarea line number enable function.

woollybah 6 năm trước cách đây
mục cha
commit
0e1bf1c468

+ 2 - 0
maxgui.mod/gadget.bmx

@@ -815,6 +815,8 @@ Type TGadget
 	End Method
 	End Method
 	Method SetLineNumberForeColor(r:Int, g:Int, b:Int)
 	Method SetLineNumberForeColor(r:Int, g:Int, b:Int)
 	End Method
 	End Method
+	Method SetLineNumberEnable(enabled:Int)
+	End Method
 	Method HasCharEventSupressionFixup:Int()
 	Method HasCharEventSupressionFixup:Int()
 	End Method
 	End Method
 ' progbar
 ' progbar

+ 4 - 0
maxgui.mod/maxgui.bmx

@@ -1804,6 +1804,10 @@ Function TextAreaHasLineNumbers:Int(textarea:TGadget)
 	Return textarea.HasLineNumbers()
 	Return textarea.HasLineNumbers()
 End Function
 End Function
 
 
+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)
 	textarea.SetLineNumberBackColor(red, green, blue)
 	textarea.SetLineNumberBackColor(red, green, blue)
 End Function
 End Function

+ 1 - 1
maxguitextareascintilla.mod/common.bmx

@@ -74,7 +74,7 @@ Extern
 	Function bmx_mgta_scintilla_getselectionlength:Int(handle:Byte Ptr, units:Int)
 	Function bmx_mgta_scintilla_getselectionlength:Int(handle:Byte Ptr, units:Int)
 	Function bmx_mgta_scintilla_addtext(handle:Byte Ptr, Text:Byte Ptr)
 	Function bmx_mgta_scintilla_addtext(handle:Byte Ptr, Text:Byte Ptr)
 	Function bmx_mgta_scintilla_textwidth:Int(handle:Byte Ptr, Text:String)
 	Function bmx_mgta_scintilla_textwidth:Int(handle:Byte Ptr, Text:String)
-	Function bmx_mgta_scintilla_setlinedigits(handle:Byte Ptr, lineDigits:Int Ptr)
+	Function bmx_mgta_scintilla_setlinedigits(handle:Byte Ptr, lineDigits:Int Ptr, show:Int)
 	Function bmx_mgta_scintilla_setmarginleft(handle:Byte Ptr, leftmargin:Int)
 	Function bmx_mgta_scintilla_setmarginleft(handle:Byte Ptr, leftmargin:Int)
 	Function bmx_mgta_scintilla_setcaretwidth(handle:Byte Ptr, width:Int)
 	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_setcaretcolor(handle:Byte Ptr, r:Int, g:Int, b:Int)

+ 9 - 1
maxguitextareascintilla.mod/linux_glue.c

@@ -85,8 +85,14 @@ void bmx_mgta_scintilla_setfont(ScintillaObject * sci, BBString * name, int size
 	bbMemFree(n);
 	bbMemFree(n);
 }
 }
 
 
-void bmx_mgta_scintilla_setlinedigits(ScintillaObject * sci, int * digits) {
+void bmx_mgta_scintilla_setlinedigits(ScintillaObject * sci, int * digits, int show) {
 
 
+	if (!show) {
+		*digits = 0;
+		scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, 0);
+		return;
+	}
+	
 	int lines = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
 	int lines = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
 	int newDigits = (lines < 10 ? 1 : (lines < 100 ? 2 :   
 	int newDigits = (lines < 10 ? 1 : (lines < 100 ? 2 :   
 		(lines < 1000 ? 3 : (lines < 10000 ? 4 :   
 		(lines < 1000 ? 3 : (lines < 10000 ? 4 :   
@@ -435,6 +441,8 @@ void bmx_mgta_scintilla_sethighlightstyle(ScintillaObject * sci, int style, int
 						break;
 						break;
 					case 4:
 					case 4:
 						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_NUMBER, color);
 						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_NUMBER, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_HEXNUMBER, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_BINNUMBER, color);
 						break;
 						break;
 				}
 				}
 				break;
 				break;

+ 9 - 2
maxguitextareascintilla.mod/linuxgtk.bmx

@@ -46,6 +46,8 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 	
 	
 	Field lineDigits:Int
 	Field lineDigits:Int
 	
 	
+	Field showLineNumbers:Int = True
+
 	' holder for the latest notification
 	' 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
 	' 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
 	Field notification:TSCNotification = New TSCNotification
@@ -135,7 +137,7 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 		bmx_mgta_scintilla_setfont(sciPtr, font.name, font.size)
 		bmx_mgta_scintilla_setfont(sciPtr, font.name, font.size)
 		
 		
 		' set the margin size for line numbers
 		' set the margin size for line numbers
-		bmx_mgta_scintilla_setlinedigits(sciPtr, Varptr lineDigits)
+		bmx_mgta_scintilla_setlinedigits(sciPtr, Varptr lineDigits, showLineNumbers)
 		
 		
 		SetTabs()
 		SetTabs()
 	End Method
 	End Method
@@ -417,7 +419,7 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 					End If
 					End If
 					ta.ignoreChange = False
 					ta.ignoreChange = False
 					
 					
-					bmx_mgta_scintilla_setlinedigits(ta.sciPtr, Varptr ta.lineDigits)
+					bmx_mgta_scintilla_setlinedigits(ta.sciPtr, Varptr ta.lineDigits, showLineNumbers)
 				End If
 				End If
 		End Select
 		End Select
 
 
@@ -499,6 +501,11 @@ Type TGTKScintillaTextArea Extends TGTKTextArea
 		bmx_mgta_scintilla_setlinenumberforecolor(sciPtr, r | g Shl 8 | b Shl 16)
 		bmx_mgta_scintilla_setlinenumberforecolor(sciPtr, r | g Shl 8 | b Shl 16)
 	End Method
 	End Method
 
 
+	Method SetLineNumberEnable(enabled:Int)
+		showLineNumbers = enabled
+		bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits, showLineNumbers)
+	End Method
+
 End Type
 End Type
 
 
 
 

+ 9 - 2
maxguitextareascintilla.mod/win32.bmx

@@ -46,6 +46,8 @@ Type TWindowsScintillaTextArea Extends TWindowsTextArea
 	
 	
 	Field lineDigits:Int
 	Field lineDigits:Int
 	
 	
+	Field showLineNumbers:Int = True
+	
 	' holder for the latest notification
 	' 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
 	' 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
 	Field notification:TSCNotification = New TSCNotification
@@ -115,7 +117,7 @@ Type TWindowsScintillaTextArea Extends TWindowsTextArea
 					End If
 					End If
 					ignoreChange = False
 					ignoreChange = False
 					
 					
-					bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits)
+					bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits, showLineNumbers)
 				End If
 				End If
 		End Select
 		End Select
 
 
@@ -142,7 +144,7 @@ Type TWindowsScintillaTextArea Extends TWindowsTextArea
 		bmx_mgta_scintilla_setfont(_hwnd, font.name, font.size)
 		bmx_mgta_scintilla_setfont(_hwnd, font.name, font.size)
 		
 		
 		' set the margin size for line numbers
 		' set the margin size for line numbers
-		bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits)
+		bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits, showLineNumbers)
 		
 		
 		SetTabs()
 		SetTabs()
 	End Method
 	End Method
@@ -479,6 +481,11 @@ Type TWindowsScintillaTextArea Extends TWindowsTextArea
 		bmx_mgta_scintilla_setlinenumberforecolor(_hwnd, r | g Shl 8 | b Shl 16)
 		bmx_mgta_scintilla_setlinenumberforecolor(_hwnd, r | g Shl 8 | b Shl 16)
 	End Method
 	End Method
 
 
+	Method SetLineNumberEnable(enabled:Int)
+		showLineNumbers = enabled
+		bmx_mgta_scintilla_setlinedigits(_hwnd, Varptr lineDigits, showLineNumbers)
+	End Method
+	
 	Method HasCharEventSupressionFixup:Int()
 	Method HasCharEventSupressionFixup:Int()
 		Return True
 		Return True
 	End Method
 	End Method

+ 9 - 1
maxguitextareascintilla.mod/win32_glue.c

@@ -93,8 +93,14 @@ void bmx_mgta_scintilla_setfont(HWND sci, BBString * name, int size) {
 	bbMemFree(n);
 	bbMemFree(n);
 }
 }
 
 
-void bmx_mgta_scintilla_setlinedigits(HWND sci, int * digits) {
+void bmx_mgta_scintilla_setlinedigits(HWND sci, int * digits, int show) {
 
 
+	if (!show) {
+		*digits = 0;
+		scintilla_send_message(sci, SCI_SETMARGINWIDTHN, 0, 0);
+		return;
+	}
+	
 	int lines = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
 	int lines = scintilla_send_message(sci, SCI_GETLINECOUNT, 0, 0);
 	int newDigits = (lines < 10 ? 1 : (lines < 100 ? 2 :   
 	int newDigits = (lines < 10 ? 1 : (lines < 100 ? 2 :   
 		(lines < 1000 ? 3 : (lines < 10000 ? 4 :   
 		(lines < 1000 ? 3 : (lines < 10000 ? 4 :   
@@ -438,6 +444,8 @@ void bmx_mgta_scintilla_sethighlightstyle(HWND sci, int style, int flags, int co
 						break;
 						break;
 					case 4:
 					case 4:
 						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_NUMBER, color);
 						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_NUMBER, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_HEXNUMBER, color);
+						scintilla_send_message(sci, SCI_STYLESETFORE, SCE_B_BINNUMBER, color);
 						break;
 						break;
 				}
 				}
 				break;
 				break;