New Highlight.Alternate style, and make the matching braces blink with the cursor.

[GB.EVAL]
* NEW: Highlight.Alternate is a new constant that represents the background style used for coloring code embedded into webpages.

[GB.EVAL.HIGHLIGHT]
* NEW: Support for new Highlight.Alternate style.

[GB.FORM.EDITOR]
* NEW: Support for new Highlight.Alternate style.
* NEW: Matching braces now blink with the cursor.
* BUG: When the cursor moves, the blinking timer is reset so that the cursor blinks only when it is not moving.
This commit is contained in:
gambas 2019-06-29 16:11:51 +02:00
parent 4128a33adf
commit 01a3106d20
8 changed files with 17 additions and 16 deletions

View file

@ -1,4 +1,4 @@
[Component]
Key=gb.eval.highlight
Version=3.12.90
Version=3.13.90
Requires=gb.eval

View file

@ -1,7 +1,7 @@
# Gambas Project File 3.0
Title=gb.eval.highlight
Startup=Main
Version=3.12.90
Version=3.13.90
VersionFile=1
Component=gb.eval
Component=gb.net

View file

@ -146,8 +146,8 @@ Public Sub ToHTML(Text As String, Optional Styles As TextHighlighterStyle[]) As
If hStyle.Underline Then sHtml = "<u>" & sHtml & "</u>"
sStyle = ""
If bAlt Then sStyle &= "background:#E0E0E0;"
If hStyle.Color Then sStyle &= "color:#" & Hex$(hStyle.Color, 6)
If bAlt Then sStyle &= "background:#" & Hex$(Styles[Highlight.Alternate], 6) & ";"
If hStyle.Color Then sStyle &= "color:#" & Hex$(hStyle.Color, 6) & ";"
If sStyle <> sOldStyle Then
sOldStyle = sStyle
@ -206,6 +206,7 @@ Static Private Function DefaultStyle_Read() As TextHighlighterStyle[]
$aStyle[Highlight.Escape] = TextHighlighterStyle(&H7F0000&, False, True)
$aStyle[Highlight.Label] = TextHighlighterStyle(&H000000&, False, True)
$aStyle[Highlight.Constant] = TextHighlighterStyle(&HA00000&, True)
$aStyle[Highlight.Alternate] = TextHighlighterStyle(&HA00000&, True)
Endif

View file

@ -1,7 +1,6 @@
# Gambas Project File 3.0
Title=Text editor with syntax highlighting
Startup=FTestEditor
Profiling=1
Icon=.hidden/control/texteditor.png
Version=3.13.90
VersionFile=1

View file

@ -520,9 +520,11 @@ Private Sub DrawMatch(X As Integer, Y As Integer, H As Integer, XM As Integer, Y
Dim XY As Point
Dim WW As Integer
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 + H - 1, WW, 1, $iForeground)
Paint.FillRect(X + XY.X, Y + XY.Y, WW, H, $iMatchColor)
End
@ -643,7 +645,7 @@ Private Sub DrawHighlightedText(Row As Integer, sText As String, aColor As Byte[
iBg = hStyle.Background
If iBg <> Color.Default Then Paint.FillRect(XX, YY, X2 - XX, H, iBg)
If bAlt Then Paint.FillRect(XX, YY, X2 - XX, H, Color.SetAlpha(&HD0D0D0&, 192))
If bAlt Then Paint.FillRect(XX, YY, X2 - XX, H, Color.SetAlpha(aStyle[Highlight.Alternate].Color, 192))
sStr = String.Mid$(sText, P + 1, iLen)
' If hStyle.Bold Then
@ -1390,6 +1392,10 @@ Public Sub TimerCursor_Timer()
If $bMouseDown Then Return
$bShowCursor = Not $bShowCursor
_RefreshLine($Y)
If $YM >= 0 Then
If $YM <> $Y Then _RefreshLine($YM)
If $YMO <> $Y Then _RefreshLine($YMO)
Endif
End
@ -1732,6 +1738,7 @@ Public Sub Goto(NX As Integer, NY As Integer, Optional Mark As Boolean)
Endif
$bShowCursor = True
$hTimerCursor.Restart
If Not $bReadOnly Then $hTimerCursor.Start
CheckMatch

View file

@ -31,6 +31,7 @@ Public Sub _new()
$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"
End

View file

@ -268,13 +268,6 @@ BEGIN_PROPERTY(Highlight_TextAfter)
END_PROPERTY
BEGIN_PROPERTY(Highlight_Alternate)
GB.Deprecated("gb.eval", "Highlight.Alternate", NULL);
GB.ReturnInteger(-1);
END_PROPERTY
GB_DESC CHighlightDesc[] =
{
GB_DECLARE("Highlight", 0), GB_VIRTUAL_CLASS(),
@ -300,10 +293,9 @@ GB_DESC CHighlightDesc[] =
GB_CONSTANT("Escape", "i", HIGHLIGHT_ESCAPE),
GB_CONSTANT("Label", "i", HIGHLIGHT_LABEL),
GB_CONSTANT("Constant", "i", HIGHLIGHT_CONSTANT),
GB_CONSTANT("Alternate", "i", HIGHLIGHT_ALTERNATE),
GB_CONSTANT("Custom", "i", HIGHLIGHT_NUM_COLOR),
GB_STATIC_PROPERTY_READ("Alternate", "i", Highlight_Alternate),
GB_STATIC_METHOD("_exit", NULL, Highlight_exit, NULL),
GB_STATIC_METHOD("Analyze", "String[]", Highlight_Analyze, "(Code)s[(Rewrite)b(State)i]"),
GB_STATIC_PROPERTY_READ("Symbols", "String[]", Highlight_Symbols),

View file

@ -96,6 +96,7 @@ typedef
HIGHLIGHT_ESCAPE,
HIGHLIGHT_LABEL,
HIGHLIGHT_CONSTANT,
HIGHLIGHT_ALTERNATE,
HIGHLIGHT_NUM_COLOR
}
HIGHLIGHT_COLOR;