[GB.FORM.TERMINAL]
* BUG: Fix drawing of bold characters. * OPT: Detect spaces to draw them a bit faster. git-svn-id: svn://localhost/gambas/trunk@7734 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
757c55146c
commit
229928614e
@ -9,6 +9,7 @@ Component=gb.image
|
|||||||
Component=gb.gui
|
Component=gb.gui
|
||||||
Component=gb.form
|
Component=gb.form
|
||||||
Authors="Benoît Minisini\nFabien Bodard"
|
Authors="Benoît Minisini\nFabien Bodard"
|
||||||
|
Environment="GB_GUI=gb.gtk3"
|
||||||
TabSize=2
|
TabSize=2
|
||||||
Language=fr
|
Language=fr
|
||||||
Type=Component
|
Type=Component
|
||||||
|
@ -26,7 +26,6 @@ End
|
|||||||
|
|
||||||
Public Sub Form_Open()
|
Public Sub Form_Open()
|
||||||
|
|
||||||
TerminalView1.Font.Size = 13.95
|
|
||||||
TerminalView1.Exec(["bash"])
|
TerminalView1.Exec(["bash"])
|
||||||
|
|
||||||
End
|
End
|
||||||
@ -75,6 +74,11 @@ End
|
|||||||
' Dim B As Integer
|
' Dim B As Integer
|
||||||
'
|
'
|
||||||
' For B = 0 To 1
|
' For B = 0 To 1
|
||||||
|
' If B = 0 Then
|
||||||
|
' TerminalView1.Print("\e[m")
|
||||||
|
' Else
|
||||||
|
' TerminalView1.Print("\e[1m")
|
||||||
|
' Endif
|
||||||
' For I = &H2500 To &H259F Step 16
|
' For I = &H2500 To &H259F Step 16
|
||||||
' TerminalView1.Print(Hex$(I, 4) & ": ")
|
' TerminalView1.Print(Hex$(I, 4) & ": ")
|
||||||
' For J = I To I + 15
|
' For J = I To I + 15
|
||||||
@ -82,13 +86,23 @@ End
|
|||||||
' Next
|
' Next
|
||||||
' TerminalView1.Print("\n\n")
|
' TerminalView1.Print("\n\n")
|
||||||
' Next
|
' Next
|
||||||
' If B = 0 Then
|
|
||||||
' TerminalView1.Print("\e[1m")
|
|
||||||
' Else
|
|
||||||
' TerminalView1.Print("\e[m")
|
|
||||||
' Endif
|
|
||||||
' Next
|
' Next
|
||||||
'
|
'
|
||||||
|
' TerminalView1.Print("\e[m")
|
||||||
' TerminalView1.Print(String$(4, String$(20, String.Chr$(&H2572)) & "\n"))
|
' TerminalView1.Print(String$(4, String$(20, String.Chr$(&H2572)) & "\n"))
|
||||||
|
'
|
||||||
|
' For B = 0 To 1
|
||||||
|
' If B = 0 Then
|
||||||
|
' TerminalView1.Print("\e[m")
|
||||||
|
' Else
|
||||||
|
' TerminalView1.Print("\e[1m")
|
||||||
|
' Endif
|
||||||
|
' For I = 256 To 1024
|
||||||
|
' TerminalView1.Print(String.Chr$(I))
|
||||||
|
' Next
|
||||||
|
' TerminalView1.Print("\n\n")
|
||||||
|
' Next
|
||||||
|
'
|
||||||
|
' TerminalView1.Print("\e[m")
|
||||||
'
|
'
|
||||||
' End
|
' End
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
Arrangement = Arrange.Vertical
|
Arrangement = Arrange.Vertical
|
||||||
{ TerminalView1 TerminalView
|
{ TerminalView1 TerminalView
|
||||||
MoveScaled(6,1,59,52)
|
MoveScaled(6,1,59,52)
|
||||||
Font = Font["Gambas,10"]
|
Font = Font["Droid Sans Mono,10"]
|
||||||
Expand = True
|
Expand = True
|
||||||
Border = False
|
Border = False
|
||||||
Limit = 0
|
Limit = 0
|
||||||
|
@ -157,6 +157,10 @@ Public Sub Resize(W As Integer, H As Integer) As Boolean
|
|||||||
$H = H
|
$H = H
|
||||||
$X = Min($X, $W - 1)
|
$X = Min($X, $W - 1)
|
||||||
$Y = ScreenTop() + Max(0, Min($Y - ScreenTop(), $H - 1))
|
$Y = ScreenTop() + Max(0, Min($Y - ScreenTop(), $H - 1))
|
||||||
|
$X1 = 0
|
||||||
|
$Y1 = 0
|
||||||
|
$X2 = 0
|
||||||
|
$Y2 = 0
|
||||||
'Debug "$Y = "; $Y
|
'Debug "$Y = "; $Y
|
||||||
$iScrollStart = -1
|
$iScrollStart = -1
|
||||||
$iScrollEnd = -1
|
$iScrollEnd = -1
|
||||||
@ -730,11 +734,10 @@ Private Function Height_Read() As Integer
|
|||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Private Sub DrawLine(L As Integer, X As Integer, Y As Integer, LH As Integer, CW As Float, (LA) As Integer, hFontCache As Image)
|
Private Sub DrawLine(hView As TerminalView, L As Integer, X As Integer, Y As Integer, LH As Integer, CW As Integer, (LA) As Integer, hFontCache As Image)
|
||||||
|
|
||||||
Dim hView As TerminalView = GetView()
|
|
||||||
Dim hLine As CTerminalLine
|
Dim hLine As CTerminalLine
|
||||||
Dim I As Integer
|
Dim I, J, K As Integer
|
||||||
'Dim sText As String
|
'Dim sText As String
|
||||||
Dim aAttr As Integer[]
|
Dim aAttr As Integer[]
|
||||||
Dim hAttr As New TerminalAttr
|
Dim hAttr As New TerminalAttr
|
||||||
@ -743,8 +746,7 @@ Private Sub DrawLine(L As Integer, X As Integer, Y As Integer, LH As Integer, CW
|
|||||||
'Dim hRect As Rect
|
'Dim hRect As Rect
|
||||||
Dim P, iLen As Integer
|
Dim P, iLen As Integer
|
||||||
Dim XT As Integer
|
Dim XT As Integer
|
||||||
Dim J As Integer
|
Dim C, OC As Integer
|
||||||
Dim C As Integer
|
|
||||||
Dim hFont As Font
|
Dim hFont As Font
|
||||||
Dim HC As Integer
|
Dim HC As Integer
|
||||||
Dim hRect As Rect
|
Dim hRect As Rect
|
||||||
@ -752,6 +754,9 @@ Private Sub DrawLine(L As Integer, X As Integer, Y As Integer, LH As Integer, CW
|
|||||||
Dim YC As Integer
|
Dim YC As Integer
|
||||||
Dim XC As Integer
|
Dim XC As Integer
|
||||||
Dim bNoText As Boolean
|
Dim bNoText As Boolean
|
||||||
|
Dim XB, WB As Integer
|
||||||
|
Dim sText As String
|
||||||
|
|
||||||
|
|
||||||
hLine = Lines[L]
|
hLine = Lines[L]
|
||||||
If Not hLine Then
|
If Not hLine Then
|
||||||
@ -800,7 +805,7 @@ Private Sub DrawLine(L As Integer, X As Integer, Y As Integer, LH As Integer, CW
|
|||||||
|
|
||||||
If hAttr.Dim Then iFg = Color.Merge(iFg, hView.Background)
|
If hAttr.Dim Then iFg = Color.Merge(iFg, hView.Background)
|
||||||
|
|
||||||
Paint.Background = Color.White
|
'Paint.Background = Color.White
|
||||||
|
|
||||||
If hAttr.Bold Then
|
If hAttr.Bold Then
|
||||||
HC = LH
|
HC = LH
|
||||||
@ -831,22 +836,27 @@ DRAW_TEXT:
|
|||||||
|
|
||||||
W = iLen * CW
|
W = iLen * CW
|
||||||
|
|
||||||
If hFontCache Then
|
sText = String.Mid$(hLine.Text, P, iLen)
|
||||||
|
If IsSpace(sText) Then
|
||||||
|
|
||||||
|
Paint.FillRect(X, Y, W, LH, iBg)
|
||||||
|
|
||||||
|
Else
|
||||||
|
|
||||||
Paint.Begin($hLineCache)
|
Paint.Begin($hLineCache)
|
||||||
Paint.Font = hFont
|
Paint.Font = hFont
|
||||||
|
|
||||||
Paint.FillRect(0, 0, W, LH, iFg)
|
Paint.FillRect(0, 0, W, LH, iFg)
|
||||||
|
|
||||||
XT = 0
|
XT = 0
|
||||||
|
|
||||||
hRect = Rect(0, 0, CW, LH)
|
hRect = Rect(0, 0, CW, LH)
|
||||||
|
|
||||||
Paint.Operator = Paint.OperatorDestATop
|
Paint.Operator = Paint.OperatorDestATop
|
||||||
For J = P To P + iLen - 1
|
For J = 1 To iLen
|
||||||
'sCar = String.Mid$(hLine.Text, J, 1)
|
'sCar = String.Mid$(hLine.Text, J, 1)
|
||||||
|
|
||||||
C = String.Code(hLine.Text, J)
|
C = String.Code(sText, J)
|
||||||
|
|
||||||
If C <= 255 Then
|
If C <= 255 Then
|
||||||
|
|
||||||
@ -855,7 +865,7 @@ DRAW_TEXT:
|
|||||||
|
|
||||||
Else If C >= &H2500 And If C <= &H259F Then
|
Else If C >= &H2500 And If C <= &H259F Then
|
||||||
|
|
||||||
Paint.Background = Color.White
|
'Paint.Background = Color.White
|
||||||
DrawLineChar(C, XT, 0, CW, LH, XT, Y, hAttr.Bold)
|
DrawLineChar(C, XT, 0, CW, LH, XT, Y, hAttr.Bold)
|
||||||
|
|
||||||
Else
|
Else
|
||||||
@ -868,9 +878,18 @@ DRAW_TEXT:
|
|||||||
|
|
||||||
Else
|
Else
|
||||||
|
|
||||||
If $cCharCache.Count < 32 Then
|
If $cCharCache.Count = 32 Then
|
||||||
|
For Each OC In $cCharCache
|
||||||
|
$cCharCache.Remove($cCharCache.Key)
|
||||||
|
Break
|
||||||
|
Next
|
||||||
|
Else
|
||||||
|
OC = $cCharCache.Count
|
||||||
|
Endif
|
||||||
|
|
||||||
|
If True '$cCharCache.Count < 32 Then
|
||||||
|
|
||||||
XC = $cCharCache.Count * CW
|
XC = OC * CW
|
||||||
YC = 0
|
YC = 0
|
||||||
|
|
||||||
Paint.Begin(hFontCache)
|
Paint.Begin(hFontCache)
|
||||||
@ -881,38 +900,39 @@ DRAW_TEXT:
|
|||||||
Paint.Operator = Paint.OperatorOver
|
Paint.Operator = Paint.OperatorOver
|
||||||
|
|
||||||
Paint.ClipRect = Rect(XC, YC, CW, LH)
|
Paint.ClipRect = Rect(XC, YC, CW, LH)
|
||||||
Paint.Background = Color.White
|
'Paint.Background = Color.White
|
||||||
GoSub DRAW_CHAR
|
GoSub DRAW_CHAR
|
||||||
|
|
||||||
YC += LH
|
YC += LH
|
||||||
|
|
||||||
Paint.ClipRect = Rect(XC, YC, CW, LH)
|
Paint.ClipRect = Rect(XC, YC, CW, LH)
|
||||||
'Paint.DrawText(String.Chr(C), XC, YC, CW, LH, Align.Center)
|
GoSub DRAW_BOLD_CHAR
|
||||||
GoSub DRAW_CHAR
|
|
||||||
Paint.Background = Color.SetAlpha(Color.White, 64)
|
' 'Paint.DrawText(String.Chr(C), XC, YC, CW, LH, Align.Center)
|
||||||
'Paint.DrawText(String.Chr(C), XC + 1, YC, CW, LH, Align.Center)
|
' GoSub DRAW_CHAR
|
||||||
Inc XC
|
' Paint.Background = Color.SetAlpha(Color.White, 64)
|
||||||
GoSub DRAW_CHAR
|
' 'Paint.DrawText(String.Chr(C), XC + 1, YC, CW, LH, Align.Center)
|
||||||
Dec XC
|
' Inc XC
|
||||||
|
' GoSub DRAW_CHAR
|
||||||
|
' Dec XC
|
||||||
|
|
||||||
Paint.End
|
Paint.End
|
||||||
|
|
||||||
hRect.Move(XC, HC)
|
hRect.Move(XC, HC)
|
||||||
Paint.DrawImage(hFontCache, XT, 0, CW, LH,, hRect)
|
Paint.DrawImage(hFontCache, XT, 0, CW, LH,, hRect)
|
||||||
|
|
||||||
$cCharCache[C] = $cCharCache.Count
|
$cCharCache[C] = OC
|
||||||
|
|
||||||
Else
|
Else
|
||||||
|
|
||||||
'Paint.DrawText(String.Chr(C), XT, 0, CW, LH, Align.Center)
|
'Paint.DrawText(String.Chr(C), XT, 0, CW, LH, Align.Center)
|
||||||
XC = XT
|
XC = XT
|
||||||
YC = 0
|
YC = 0
|
||||||
Paint.Background = Color.White
|
'Paint.Background = Color.White
|
||||||
GoSub DRAW_CHAR
|
Paint.Operator = Paint.OperatorDestATop
|
||||||
If hAttr.Bold Then
|
If hAttr.Bold Then
|
||||||
'Paint.DrawText(String.Chr(C), XT + 1, 0, CW, LH, Align.Center)
|
GoSub DRAW_BOLD_CHAR
|
||||||
Inc XC
|
Else
|
||||||
Paint.Background = Color.SetAlpha(Color.White, 64)
|
|
||||||
GoSub DRAW_CHAR
|
GoSub DRAW_CHAR
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
@ -924,7 +944,7 @@ DRAW_TEXT:
|
|||||||
XT += CW
|
XT += CW
|
||||||
|
|
||||||
Next
|
Next
|
||||||
|
|
||||||
Paint.End
|
Paint.End
|
||||||
|
|
||||||
XT = X
|
XT = X
|
||||||
@ -932,18 +952,9 @@ DRAW_TEXT:
|
|||||||
Paint.FillRect(XT, Y, W, LH, iBg)
|
Paint.FillRect(XT, Y, W, LH, iBg)
|
||||||
Paint.DrawImage($hLineCache, XT, Y, W, LH,, Rect(0, 0, W, LH))
|
Paint.DrawImage($hLineCache, XT, Y, W, LH,, Rect(0, 0, W, LH))
|
||||||
|
|
||||||
Else
|
|
||||||
|
|
||||||
XT = X
|
|
||||||
|
|
||||||
Paint.FillRect(XT, Y, W, LH, iBg)
|
|
||||||
Paint.Background = iFg
|
|
||||||
Paint.DrawText(String.Mid$(hLine.Text, P, iLen), XT, Y + LA)
|
|
||||||
If hAttr.Bold Then Paint.DrawText(String.Mid$(hLine.Text, P, iLen), XT + 1, Y + LA)
|
|
||||||
|
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
If hAttr.Underscore Then Paint.FillRect(XT, Y + LH - 1, W, 1, Color.SetAlpha(iFg, 64))
|
If hAttr.Underscore Then Paint.FillRect(X, Y + LH - 1, W, 1, Color.SetAlpha(iFg, 64))
|
||||||
|
|
||||||
X += W
|
X += W
|
||||||
P += iLen
|
P += iLen
|
||||||
@ -961,6 +972,26 @@ DRAW_CHAR:
|
|||||||
Paint.DrawText(String.Chr(C), XC, YC, CW, LH, Align.Center)
|
Paint.DrawText(String.Chr(C), XC, YC, CW, LH, Align.Center)
|
||||||
Return
|
Return
|
||||||
|
|
||||||
|
DRAW_BOLD_CHAR:
|
||||||
|
|
||||||
|
GoSub DRAW_CHAR
|
||||||
|
|
||||||
|
XB = XC
|
||||||
|
WB = CW \ 8 + 1
|
||||||
|
|
||||||
|
For K = 1 To WB \ 2
|
||||||
|
Inc XC
|
||||||
|
GoSub DRAW_CHAR
|
||||||
|
Next
|
||||||
|
If Odd(WB) Then
|
||||||
|
Paint.Background = Color.SetAlpha(Color.White, 64)
|
||||||
|
Inc XC
|
||||||
|
GoSub DRAW_CHAR
|
||||||
|
Endif
|
||||||
|
|
||||||
|
XC = XB
|
||||||
|
Return
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Private Sub GetSelection(ByRef X1 As Integer, ByRef Y1 As Integer, ByRef X2 As Integer, ByRef Y2 As Integer) As Boolean
|
Private Sub GetSelection(ByRef X1 As Integer, ByRef Y1 As Integer, ByRef X2 As Integer, ByRef Y2 As Integer) As Boolean
|
||||||
@ -1001,7 +1032,7 @@ Public Sub Paint(SY As Integer, LH As Integer, CW As Float, LA As Integer, bHide
|
|||||||
|
|
||||||
For L = L1 To L2
|
For L = L1 To L2
|
||||||
|
|
||||||
If L < Lines.Count Then DrawLine(L, 0, Y, LH, CW, LA, hFont)
|
If L < Lines.Count Then DrawLine(hView, L, 0, Y, LH, CW, LA, hFont)
|
||||||
|
|
||||||
' Cursor
|
' Cursor
|
||||||
|
|
||||||
@ -1228,7 +1259,7 @@ Private Sub DrawLineChar(C As Integer, X As Integer, Y As Integer, W As Integer,
|
|||||||
hBold = hChar.Copy()
|
hBold = hChar.Copy()
|
||||||
Paint.Begin(hChar)
|
Paint.Begin(hChar)
|
||||||
If L >= 2 Then Paint.DrawImage(hBold, DL, 0)
|
If L >= 2 Then Paint.DrawImage(hBold, DL, 0)
|
||||||
If Odd(L) Then Paint.DrawImage(hBold, DL + 2, 0,,, 0.75)
|
If Odd(L) Then Paint.DrawImage(hBold, DL + 1, 0,,, 0.75)
|
||||||
Paint.End
|
Paint.End
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ Private $bSuspend As Boolean
|
|||||||
Private $iMouseX As Integer
|
Private $iMouseX As Integer
|
||||||
Private $iMouseY As Integer
|
Private $iMouseY As Integer
|
||||||
|
|
||||||
|
'Private $bDoubleFont As Boolean = True
|
||||||
|
|
||||||
Public Sub _new()
|
Public Sub _new()
|
||||||
|
|
||||||
Me.Font = Font["monospace"]
|
Me.Font = Font["monospace"]
|
||||||
@ -161,6 +163,8 @@ Private Sub UpdateFont()
|
|||||||
Dim I As Integer
|
Dim I As Integer
|
||||||
Dim L As Integer
|
Dim L As Integer
|
||||||
Dim W As Integer
|
Dim W As Integer
|
||||||
|
' Dim hZoom As Image
|
||||||
|
Dim X As Integer
|
||||||
|
|
||||||
With $hView.Font
|
With $hView.Font
|
||||||
|
|
||||||
@ -168,7 +172,7 @@ Private Sub UpdateFont()
|
|||||||
$iAscent = .Ascent
|
$iAscent = .Ascent
|
||||||
sText = String$(8, "mM0_@$#W")
|
sText = String$(8, "mM0_@$#W")
|
||||||
$CW = CInt(.TextWidth(sText) / Len(sText))
|
$CW = CInt(.TextWidth(sText) / Len(sText))
|
||||||
|
|
||||||
$hCacheFont = New Image($CW * 256, $LH * 2, Color.Transparent)
|
$hCacheFont = New Image($CW * 256, $LH * 2, Color.Transparent)
|
||||||
Paint.Begin($hCacheFont)
|
Paint.Begin($hCacheFont)
|
||||||
Paint.Font = $hView.Font
|
Paint.Font = $hView.Font
|
||||||
@ -180,6 +184,29 @@ Private Sub UpdateFont()
|
|||||||
Next
|
Next
|
||||||
Paint.End
|
Paint.End
|
||||||
|
|
||||||
|
' If $bDoubleFont Then
|
||||||
|
' hZoom = New Image($hCacheFont.W * 2, $hCacheFont.H * 2, Color.Transparent)
|
||||||
|
' Paint.Begin(hZoom)
|
||||||
|
' Paint.ZoomImage($hCacheFont, 2, 0, 0)
|
||||||
|
' Paint.End
|
||||||
|
' $hCacheFont = hZoom
|
||||||
|
' $CW *= 2
|
||||||
|
' $LH *= 2
|
||||||
|
' Endif
|
||||||
|
|
||||||
|
' Make bold font
|
||||||
|
|
||||||
|
Paint.Begin($hCacheFont)
|
||||||
|
|
||||||
|
For I = 33 To 126
|
||||||
|
GoSub DRAW_BOLD_CHAR
|
||||||
|
Next
|
||||||
|
For I = 160 To 255
|
||||||
|
GoSub DRAW_BOLD_CHAR
|
||||||
|
Next
|
||||||
|
|
||||||
|
Paint.End
|
||||||
|
|
||||||
'$hCacheFont.Save("~/cache.png")
|
'$hCacheFont.Save("~/cache.png")
|
||||||
|
|
||||||
End With
|
End With
|
||||||
@ -196,17 +223,24 @@ DRAW_CHAR:
|
|||||||
Paint.ClipRect = Rect(I * $CW, 0, $CW, $LH)
|
Paint.ClipRect = Rect(I * $CW, 0, $CW, $LH)
|
||||||
Paint.Background = Color.White
|
Paint.Background = Color.White
|
||||||
Paint.DrawText(String.Chr(I), I * $CW, 0, $CW, $LH, Align.Center)
|
Paint.DrawText(String.Chr(I), I * $CW, 0, $CW, $LH, Align.Center)
|
||||||
|
|
||||||
|
Return
|
||||||
|
|
||||||
|
DRAW_BOLD_CHAR:
|
||||||
|
|
||||||
Paint.ClipRect = Rect(I * $CW, $LH, $CW, $LH)
|
X = I * $CW
|
||||||
Paint.DrawText(String.Chr(I), I * $CW, $LH, $CW, $LH, Align.Center)
|
|
||||||
|
Paint.ClipRect = Rect(X, $LH, $CW, $LH)
|
||||||
|
|
||||||
|
Paint.DrawImage($hCacheFont, X, $LH, $CW, $LH,, Rect(X, 0, $CW, $LH))
|
||||||
|
|
||||||
W = $CW \ 8 + 1
|
W = $CW \ 8 + 1
|
||||||
For L = 1 To W \ 2
|
For L = 1 To W \ 2
|
||||||
Paint.DrawText(String.Chr(I), I * $CW + L, $LH, $CW, $LH, Align.Center)
|
Paint.DrawImage($hCacheFont, X + L, $LH, $CW, $LH,, Rect(X, 0, $CW, $LH))
|
||||||
Next
|
Next
|
||||||
If Odd(W) Then
|
If Odd(W) Then
|
||||||
Paint.Background = Color.SetAlpha(Color.White, 64)
|
Paint.Background = Color.SetAlpha(Color.White, 64)
|
||||||
Paint.DrawText(String.Chr(I), I * $CW + L, $LH, $CW, $LH, Align.Center)
|
Paint.DrawImage($hCacheFont, X + L, $LH, $CW, $LH,, Rect(X, 0, $CW, $LH))
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
Return
|
Return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user