[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:
parent
e2245b80ef
commit
781882c601
3 changed files with 59 additions and 35 deletions
|
@ -48,14 +48,14 @@ Public Sub Button5_Click()
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
Public Sub TerminalView1_KeyPress()
|
|
||||||
|
|
||||||
Debug Key.Code
|
|
||||||
|
|
||||||
End
|
|
||||||
|
|
||||||
Public Sub Form_Close()
|
Public Sub Form_Close()
|
||||||
|
|
||||||
TerminalView1.Kill
|
TerminalView1.Kill
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
Public Sub TerminalView1_Kill()
|
||||||
|
|
||||||
|
Me.Close
|
||||||
|
|
||||||
|
End
|
||||||
|
|
|
@ -155,6 +155,11 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
|
||||||
Case "[" ' >>>>>> CSI
|
Case "[" ' >>>>>> CSI
|
||||||
|
|
||||||
Select Case Right(sStr)
|
Select Case Right(sStr)
|
||||||
|
|
||||||
|
Case "@"
|
||||||
|
|
||||||
|
GoSub GET_COUNT
|
||||||
|
hScreen.InsertSpace(N)
|
||||||
|
|
||||||
Case "A"
|
Case "A"
|
||||||
|
|
||||||
|
@ -398,28 +403,26 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
|
||||||
|
|
||||||
Case n ' Device Status Report
|
Case n ' Device Status Report
|
||||||
|
|
||||||
Select Case Mid(sStr, 2, -1)
|
Select Case Mid(sStr, 2, -1)
|
||||||
Case "5"
|
Case "5"
|
||||||
Print #hProcess, "\e[0n"; 'Report Status OK
|
Print #hProcess, "\e[0n"; 'Report Status OK
|
||||||
Case "6"
|
Case "6"
|
||||||
Print #hProcess, Subst("\e[&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
|
Print #hProcess, Subst("\e[&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
|
||||||
Case "?6"
|
Case "?6"
|
||||||
Print #hProcess, Subst("\e[?&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
|
Print #hProcess, Subst("\e[?&1;&2R", hScreen.Line, hScreen.Column); 'Report Cursor Position
|
||||||
Case "?15"
|
Case "?15"
|
||||||
Print #hProcess, "\0[?11n" 'Printer not ready (10 for ready)"
|
Print #hProcess, "\0[?11n" 'Printer not ready (10 for ready)"
|
||||||
Case "?25" 'Report UDK statu
|
Case "?25" 'Report UDK statu
|
||||||
Print #hProcess, "\0[?20n" 'UDK status as CSI ? 2 0 n (unlocked) or CSI ? 2 1 n (locked)
|
Print #hProcess, "\0[?20n" 'UDK status as CSI ? 2 0 n (unlocked) or CSI ? 2 1 n (locked)
|
||||||
Case "?26" 'Report Keyboard status as
|
Case "?26" 'Report Keyboard status as
|
||||||
Print #hProcess, "\0[?50n" 'No Locator, if not.
|
Print #hProcess, "\0[?50n" 'No Locator, if not.
|
||||||
End Select
|
End Select
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Case "m" ' Set attribute
|
Case "m" ' Set attribute
|
||||||
|
|
||||||
GoSub GET_ARGS
|
GoSub GET_ARGS
|
||||||
If aArg Then
|
If aArg Then
|
||||||
For i = 0 To aArg.Max
|
For I = 0 To aArg.Max
|
||||||
sArg = aArg[i]
|
sArg = aArg[i]
|
||||||
'For Each sArg In aArg
|
'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
|
hScreen.Attr.Dim = True
|
||||||
Case 4
|
Case 4
|
||||||
hScreen.Attr.Underscore = True
|
hScreen.Attr.Underscore = True
|
||||||
|
Case 5
|
||||||
|
hScreen.Attr.Blink = True
|
||||||
Case 7
|
Case 7
|
||||||
hScreen.Attr.Reverse = True
|
hScreen.Attr.Reverse = True
|
||||||
Case 21
|
Case 21
|
||||||
|
@ -443,6 +448,8 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
|
||||||
hScreen.Attr.Dim = False
|
hScreen.Attr.Dim = False
|
||||||
Case 24
|
Case 24
|
||||||
hScreen.Attr.Underscore = False
|
hScreen.Attr.Underscore = False
|
||||||
|
Case 25
|
||||||
|
hScreen.Attr.Blink = False
|
||||||
Case 27
|
Case 27
|
||||||
hScreen.Attr.Reverse = False
|
hScreen.Attr.Reverse = False
|
||||||
Case 30
|
Case 30
|
||||||
|
@ -460,9 +467,9 @@ Private Sub Escape(hView As TerminalView, hProcess As Process, sData As String,
|
||||||
Case 100 To 107
|
Case 100 To 107
|
||||||
hScreen.Attr.Background = iArg - 100
|
hScreen.Attr.Background = iArg - 100
|
||||||
Case 38
|
Case 38
|
||||||
If (aArg.max - i) >= 2 And If aArg[i + 1] = "5" Then
|
If (aArg.max - i) >= 2 And If aArg[I + 1] = "5" Then
|
||||||
Try hScreen.Attr.Background = CInt(aArg[i + 2])
|
Try hScreen.Attr.Background = CInt(aArg[I + 2])
|
||||||
i += 2
|
I += 2
|
||||||
Endif
|
Endif
|
||||||
'TODO: Implement support for RGB Colors
|
'TODO: Implement support for RGB Colors
|
||||||
' If (aArg.max - i) >= 4 And If aArg[i + 1] = "2" Then
|
' 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
|
' i += 4
|
||||||
' Endif
|
' Endif
|
||||||
Case 48
|
Case 48
|
||||||
If (aArg.max - i) >= 2 And If aArg[i + 1] = "5" Then
|
If (aArg.max - I) >= 2 And If aArg[I + 1] = "5" Then
|
||||||
Try hScreen.Attr.Foreground = CInt(aArg[i + 2])
|
Try hScreen.Attr.Foreground = CInt(aArg[I + 2])
|
||||||
i += 2
|
I += 2
|
||||||
Endif
|
Endif
|
||||||
'TODO: Implement support for RGB Colors
|
'TODO: Implement support for RGB Colors
|
||||||
' If (aArg.max - i) >= 4 And If aArg[i + 1] = "2" Then
|
' 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
|
hScreen.RestoreCursor
|
||||||
|
|
||||||
|
|
||||||
Default
|
Default
|
||||||
|
|
||||||
Goto NOT_IMPLEMENTED
|
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")
|
sText = If(hScreen.AppCursorKey, "\eOD", "\e[D")
|
||||||
|
|
||||||
Case Key.Enter, Key.Return
|
Case Key.Enter, Key.Return
|
||||||
sText = If(hScreen.AppCursorKey, "\eOM", Key.Text)
|
sText = If(hScreen.NewlineMode, "\r\n", "\n")
|
||||||
|
|
||||||
Case Key.Insert
|
Case Key.Insert
|
||||||
sText = "\e[2~"
|
sText = "\e[2~"
|
||||||
|
|
|
@ -427,6 +427,23 @@ Public Sub CursorRight(Optional Count As Integer = 1)
|
||||||
|
|
||||||
End
|
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)
|
Public Sub DeleteChar(Optional N As Integer = 1)
|
||||||
|
|
||||||
Dim hLine As CTerminalLine
|
Dim hLine As CTerminalLine
|
||||||
|
@ -439,6 +456,7 @@ Public Sub DeleteChar(Optional N As Integer = 1)
|
||||||
If Not $hAttr.IsVoid() Then
|
If Not $hAttr.IsVoid() Then
|
||||||
Insert(Space$(N), hLine.Length)
|
Insert(Space$(N), hLine.Length)
|
||||||
Endif
|
Endif
|
||||||
|
GetView()._RefreshLine($Y)
|
||||||
|
|
||||||
End
|
End
|
||||||
|
|
||||||
|
@ -1009,13 +1027,13 @@ Public Sub GetSelectedText() As String
|
||||||
If Not GetSelection(ByRef X1, ByRef Y1, ByRef X2, ByRef Y2) Then Return
|
If Not GetSelection(ByRef X1, ByRef Y1, ByRef X2, ByRef Y2) Then Return
|
||||||
|
|
||||||
If Y2 = Y1 Then
|
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
|
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
|
For Y = Y1 + 1 To Y2 - 1
|
||||||
sText &= Lines[Y].Text & "\n"
|
sText &= GetLine(Y).Text & "\n"
|
||||||
Next
|
Next
|
||||||
sText &= String.Left$(Lines[Y2].Text, X2)
|
sText &= String.Left$(GetLine(Y2).Text, X2)
|
||||||
Endif
|
Endif
|
||||||
|
|
||||||
Return sText
|
Return sText
|
||||||
|
|
Loading…
Reference in a new issue