[GB.FORM.TERMINAL]

* NEW: Implement "Insert space" escape sequence.
* NEW: Detect blink escape sequences.
* BUG: Fix Return and Enter key support.
* BUG: Fix selection on void lines.


git-svn-id: svn://localhost/gambas/trunk@7709 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Benoît Minisini 2016-04-02 00:01:53 +00:00
parent e2245b80ef
commit 781882c601
3 changed files with 59 additions and 35 deletions

View file

@ -48,14 +48,14 @@ Public Sub Button5_Click()
End
Public Sub TerminalView1_KeyPress()
Debug Key.Code
End
Public Sub Form_Close()
TerminalView1.Kill
End
Public Sub TerminalView1_Kill()
Me.Close
End

View file

@ -155,6 +155,11 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
Case "[" ' >>>>>> CSI
Select Case Right(sStr)
Case "@"
GoSub GET_COUNT
hScreen.InsertSpace(N)
Case "A"
@ -398,28 +403,26 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
Case n ' Device Status Report
Select Case Mid(sStr, 2, -1)
Case "5"
Print #hProcess, "\e[0n"; 'Report Status OK
Case "6"
Print #hProcess, Subst("\e[&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
Case "?6"
Print #hProcess, Subst("\e[?&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
Case "?15"
Print #hProcess, "\0[?11n" 'Printer not ready (10 for ready)"
Case "?25" 'Report UDK statu
Print #hProcess, "\0[?20n" 'UDK status as CSI ? 2 0 n (unlocked) or CSI ? 2 1 n (locked)
Case "?26" 'Report Keyboard status as
Print #hProcess, "\0[?50n" 'No Locator, if not.
End Select
Select Case Mid(sStr, 2, -1)
Case "5"
Print #hProcess, "\e[0n"; 'Report Status OK
Case "6"
Print #hProcess, Subst("\e[&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
Case "?6"
Print #hProcess, Subst("\e[?&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
Case "?15"
Print #hProcess, "\0[?11n" 'Printer not ready (10 for ready)"
Case "?25" 'Report UDK statu
Print #hProcess, "\0[?20n" 'UDK status as CSI ? 2 0 n (unlocked) or CSI ? 2 1 n (locked)
Case "?26" 'Report Keyboard status as
Print #hProcess, "\0[?50n" 'No Locator, if not.
End Select
Case "m" ' Set attribute
GoSub GET_ARGS
If aArg Then
For i = 0 To aArg.Max
For I = 0 To aArg.Max
sArg = aArg[i]
'For Each sArg In aArg
@ -435,6 +438,8 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
hScreen.Attr.Dim = True
Case 4
hScreen.Attr.Underscore = True
Case 5
hScreen.Attr.Blink = True
Case 7
hScreen.Attr.Reverse = True
Case 21
@ -443,6 +448,8 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
hScreen.Attr.Dim = False
Case 24
hScreen.Attr.Underscore = False
Case 25
hScreen.Attr.Blink = False
Case 27
hScreen.Attr.Reverse = False
Case 30
@ -460,9 +467,9 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
Case 100 To 107
hScreen.Attr.Background = iArg - 100
Case 38
If (aArg.max - i) >= 2 And If aArg[i + 1] = "5" Then
Try hScreen.Attr.Background = CInt(aArg[i + 2])
i += 2
If (aArg.max - i) >= 2 And If aArg[I + 1] = "5" Then
Try hScreen.Attr.Background = CInt(aArg[I + 2])
I += 2
Endif
'TODO: Implement support for RGB Colors
' If (aArg.max - i) >= 4 And If aArg[i + 1] = "2" Then
@ -470,9 +477,9 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
' i += 4
' Endif
Case 48
If (aArg.max - i) >= 2 And If aArg[i + 1] = "5" Then
Try hScreen.Attr.Foreground = CInt(aArg[i + 2])
i += 2
If (aArg.max - I) >= 2 And If aArg[I + 1] = "5" Then
Try hScreen.Attr.Foreground = CInt(aArg[I + 2])
I += 2
Endif
'TODO: Implement support for RGB Colors
' If (aArg.max - i) >= 4 And If aArg[i + 1] = "2" Then
@ -505,7 +512,6 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
hScreen.RestoreCursor
Default
Goto NOT_IMPLEMENTED
@ -564,7 +570,7 @@ Public Sub InputTo(hView As TerminalView, hProcess As Process, iCode As Integer,
sText = If(hScreen.AppCursorKey, "\eOD", "\e[D")
Case Key.Enter, Key.Return
sText = If(hScreen.AppCursorKey, "\eOM", Key.Text)
sText = If(hScreen.NewlineMode, "\r\n", "\n")
Case Key.Insert
sText = "\e[2~"

View file

@ -427,6 +427,23 @@ Public Sub CursorRight(Optional Count As Integer = 1)
End
Public Sub InsertSpace(N As Integer)
Dim hLine As CTerminalLine
hLine = GetLine($Y)
If $X < hLine.Length Then
hLine.Text = String.Left(String.Left(hLine.Text, $X) & Space$(N) & String.Mid$(hLine.Text, $X + 1), $W)
hLine.Length = String.Len(hLine.Text)
Endif
If Not $hAttr.IsVoid() Then
hLine.SetAttr($hAttr, $X, N, True)
Endif
GetView()._RefreshLine($Y)
End
Public Sub DeleteChar(Optional N As Integer = 1)
Dim hLine As CTerminalLine
@ -439,6 +456,7 @@ Public Sub DeleteChar(Optional N As Integer = 1)
If Not $hAttr.IsVoid() Then
Insert(Space$(N), hLine.Length)
Endif
GetView()._RefreshLine($Y)
End
@ -1009,13 +1027,13 @@ Public Sub GetSelectedText() As String
If Not GetSelection(ByRef X1, ByRef Y1, ByRef X2, ByRef Y2) Then Return
If Y2 = Y1 Then
sText = String.Mid$(Lines[Y1].Text, X1 + 1, X2 - X1)
sText = String.Mid$(GetLine(Y1).Text, X1 + 1, X2 - X1)
Else
sText = String.Mid$(Lines[Y1].Text, X1 + 1) & "\n"
sText = String.Mid$(GetLine(Y1).Text, X1 + 1) & "\n"
For Y = Y1 + 1 To Y2 - 1
sText &= Lines[Y].Text & "\n"
sText &= GetLine(Y).Text & "\n"
Next
sText &= String.Left$(Lines[Y2].Text, X2)
sText &= String.Left$(GetLine(Y2).Text, X2)
Endif
Return sText