Fix keyboard event management for GTK+3, use standard colors by default, and draw matching braces differently.

[GB.FORM.EDITOR]
* BUG: TextEditor: Do not stop keyboard event if the key is not handled by the editor.
* NEW: TextEditor: Use the standard background and foreground colors by default.
* NEW: TextEditor: Draw the matching brace under the cursor with an underline.
This commit is contained in:
gambas 2020-11-24 21:36:12 +01:00
parent 3906550902
commit 2b43657ab3
4 changed files with 43 additions and 12 deletions

View File

@ -550,7 +550,7 @@ Private Sub DrawText(sText As String, SX As Integer, X As Integer, Y As Integer)
End
Private Sub DrawMatch(X As Integer, Y As Integer, H As Integer, XM As Integer, YM As Integer)
Private Sub DrawMatch(X As Integer, Y As Integer, H As Integer, XM As Integer, YM As Integer, bOther As Boolean)
'Dim sCar As String
Dim XY As Point
@ -559,8 +559,11 @@ Private Sub DrawMatch(X As Integer, Y As Integer, H As Integer, XM As Integer, Y
If Not $bShowCursor Then Return
XY = LinePos(YM, XM)
WW = TextWidth($hDoc.Lines[YM], XM + 1, 1)
'Paint.FillRect(X + XY.X, Y + XY.Y + H - 1, WW, 1, $iForeground)
Paint.FillRect(X + XY.X, Y + XY.Y, WW, H, $iMatchColor)
If bOther Then
Paint.FillRect(X + XY.X, Y + XY.Y, WW, H, $iMatchColor)
Else
Paint.FillRect(X + XY.X, Y + XY.Y + H - 2, WW, 2, $iMatchColor)
Endif
End
@ -1064,8 +1067,8 @@ Private Sub DrawLine(X As Integer, Y As Integer, Width As Integer, Height As Int
' Matching characters
If $YM >= 0 Then
If Row = $YMO Then DrawMatch(X, Y, H, $XMO, $YMO)
If Row = $YM Then DrawMatch(X, Y, H, $XM, $YM)
If Row = $YMO Then DrawMatch(X, Y, H, $XMO, $YMO, False)
If Row = $YM Then DrawMatch(X, Y, H, $XM, $YM, True)
Endif
' Text
@ -1882,6 +1885,9 @@ Public Sub View_KeyPress()
Case Key.Insert
Me.Overwrite = Not $bOverwrite
Case Else
Stop Event
End Select
STOP_EVENT:

View File

@ -12,9 +12,34 @@ Public Sub _new()
$aStyle = New TextEditorStyle[32]
$aStyle[Highlight.Background] = New TextEditorStyle(Color.White) As "Style"
$aStyle[Highlight.Normal] = New TextEditorStyle(Color.Black) As "Style"
$aStyle[Highlight.Keyword] = New TextEditorStyle(Color.Black, True) As "Style"
' $aStyle[Highlight.Background] = New TextEditorStyle(Color.White) As "Style"
' $aStyle[Highlight.Normal] = New TextEditorStyle(Color.Black) As "Style"
' $aStyle[Highlight.Keyword] = New TextEditorStyle(Color.Black, True) As "Style"
' $aStyle[Highlight.Datatype] = New TextEditorStyle(&HDF6B00&, True) As "Style"
' $aStyle[Highlight.Function] = New TextEditorStyle(&H3398C3&, True) As "Style"
' $aStyle[Highlight.Operator] = New TextEditorStyle(Color.Black, True) As "Style"
' $aStyle[Highlight.Symbol] = New TextEditorStyle(Color.Black) As "Style"
' $aStyle[Highlight.Number] = New TextEditorStyle(&HFF0000&, True) As "Style"
' $aStyle[Highlight.String] = New TextEditorStyle(&H7F0000&) As "Style"
' $aStyle[Highlight.Comment] = New TextEditorStyle(&H888888&, False) As "Style"
' $aStyle[Highlight.Help] = New TextEditorStyle(&H888888&, True) As "Style"
' $aStyle[Highlight.Preprocessor] = New TextEditorStyle(&H006E28&, True) As "Style"
' $aStyle[Highlight.Breakpoint] = New TextEditorStyle(&HFF5F5F&) As "Style"
' $aStyle[Highlight.Current] = New TextEditorStyle(&H42C9FF&) As "Style"
' $aStyle[Highlight.Selection] = New TextEditorStyle(&HC3EDFF&) As "Style"
' $aStyle[Highlight.Highlight] = New TextEditorStyle(&H7FFF00&) As "Style"
' $aStyle[Highlight.CurrentLine] = New TextEditorStyle(&HE7F3FF&) As "Style"
' $aStyle[Highlight.Error] = New TextEditorStyle(&HBF0303&, False, True) As "Style"
' $aStyle[Highlight.Escape] = New TextEditorStyle(&H7F0000&, True, False, True) As "Style"
' $aStyle[Highlight.Label] = New TextEditorStyle(Color.Black, False, False, True) As "Style"
' $aStyle[Highlight.Constant] = New TextEditorStyle(&HA00000&, True) As "Style"
' $aStyle[Highlight.Alternate] = New TextEditorStyle(&HE0E0E0&) As "Style"
' $aStyle[Highlight.Added] = New TextEditorStyle(&00FF00) As "Style"
' $aStyle[Highlight.Removed] = New TextEditorStyle(&FF8080) As "Style"
$aStyle[Highlight.Background] = New TextEditorStyle(Color.TextBackground) As "Style"
$aStyle[Highlight.Normal] = New TextEditorStyle(Color.TextForeground) As "Style"
$aStyle[Highlight.Keyword] = New TextEditorStyle(Color.TextForeground, True) As "Style"
$aStyle[Highlight.Datatype] = New TextEditorStyle(&HDF6B00&, True) As "Style"
$aStyle[Highlight.Function] = New TextEditorStyle(&H3398C3&, True) As "Style"
$aStyle[Highlight.Operator] = New TextEditorStyle(Color.Black, True) As "Style"
@ -26,9 +51,9 @@ Public Sub _new()
$aStyle[Highlight.Preprocessor] = New TextEditorStyle(&H006E28&, True) As "Style"
$aStyle[Highlight.Breakpoint] = New TextEditorStyle(&HFF5F5F&) As "Style"
$aStyle[Highlight.Current] = New TextEditorStyle(&H42C9FF&) As "Style"
$aStyle[Highlight.Selection] = New TextEditorStyle(&HC3EDFF&) As "Style"
$aStyle[Highlight.Selection] = New TextEditorStyle(Color.SelectedBackground) As "Style"
$aStyle[Highlight.Highlight] = New TextEditorStyle(&H7FFF00&) As "Style"
$aStyle[Highlight.CurrentLine] = New TextEditorStyle(&HE7F3FF&) As "Style"
$aStyle[Highlight.CurrentLine] = New TextEditorStyle(Color.LightBackground) As "Style"
$aStyle[Highlight.Error] = New TextEditorStyle(&HBF0303&, False, True) As "Style"
$aStyle[Highlight.Escape] = New TextEditorStyle(&H7F0000&, True, False, True) As "Style"
$aStyle[Highlight.Label] = New TextEditorStyle(Color.Black, False, False, True) As "Style"

View File

@ -29,7 +29,7 @@ End
Public Sub Form_Open()
Debug Style.ScrollbarSize
'Debug Style.ScrollbarSize
Application.Animations = True
Application.Shadows = True

View File

@ -44,7 +44,7 @@
Expand = True
{ TextEditor1 TextEditor
MoveScaled(14,5,47,33)
Font = Font["Go Mono,10"]
Font = Font["Gambas"]
Background = Color.TextBackground
Border = False
Mode = "Gambas"