dd, cc
This commit is contained in:
parent
fd2ba6873a
commit
802146e937
|
@ -6,8 +6,8 @@ vibreoffice currently supports:
|
||||||
- Insert (`i`, `I`, `a`, `A`), Visual (`v`), Normal modes
|
- Insert (`i`, `I`, `a`, `A`), Visual (`v`), Normal modes
|
||||||
- Movement keys: `hjkl`, `w/W`, `b/B`, `e`, `$`, `^`, `{}`, `()`, `ctrl+d`, `ctrl+u`
|
- Movement keys: `hjkl`, `w/W`, `b/B`, `e`, `$`, `^`, `{}`, `()`, `ctrl+d`, `ctrl+u`
|
||||||
- Number modifiers: e.g. `5w`
|
- Number modifiers: e.g. `5w`
|
||||||
- Deletion: `x`, `d`, `c`
|
- Deletion: `x`, `d`, `c`, `dd`, `cc`
|
||||||
- Plus movement and number modifiers: e.g. `dw`, `c$`, `d2}`, `3cj`
|
- Plus movement and number modifiers: e.g. `dw`, `c$`, `5dd`, `c3j`
|
||||||
- More to come!
|
- More to come!
|
||||||
|
|
||||||
### License
|
### License
|
||||||
|
|
|
@ -354,10 +354,11 @@ Function ProcessNormalKey(oEvent)
|
||||||
' --------------------
|
' --------------------
|
||||||
' 2. Check Delete Key
|
' 2. Check Delete Key
|
||||||
' --------------------
|
' --------------------
|
||||||
bMatched = False
|
|
||||||
|
|
||||||
' Only 'x' can be done more than once
|
' Only 'x' or Special (dd, cc) can be done more than once
|
||||||
If oEvent.KeyChar <> "x" Then iIterations = 1
|
If oEvent.KeyChar <> "x" and getSpecial() = "" Then
|
||||||
|
iIterations = 1
|
||||||
|
End If
|
||||||
For i = 1 To iIterations
|
For i = 1 To iIterations
|
||||||
dim bMatchedDelete
|
dim bMatchedDelete
|
||||||
|
|
||||||
|
@ -374,60 +375,92 @@ End Function
|
||||||
|
|
||||||
|
|
||||||
Function ProcessDeleteKey(keyChar)
|
Function ProcessDeleteKey(keyChar)
|
||||||
dim oTextCursor, bMatched
|
dim oTextCursor, bMatched, bIsSpecial
|
||||||
bMatched = True
|
bMatched = True
|
||||||
|
bIsSpecial = getSpecial() <> ""
|
||||||
|
|
||||||
Select Case keyChar
|
|
||||||
Case "x":
|
If keyChar = "d" Or keyChar = "c" Then
|
||||||
|
' Special Cases: 'dd' and 'cc'
|
||||||
|
If bIsSpecial Then
|
||||||
|
dim bIsSpecialCase
|
||||||
|
bIsSpecialCase = (keyChar = "d" And getSpecial() = "d") Or (keyChar = "c" And getSpecial() = "c")
|
||||||
|
|
||||||
|
If bIsSpecialCase Then
|
||||||
|
ProcessMovementKey("^", False)
|
||||||
|
ProcessMovementKey("j", True)
|
||||||
|
|
||||||
|
oTextCursor = getTextCursor()
|
||||||
|
thisComponent.getCurrentController.Select(oTextCursor)
|
||||||
|
oTextCursor.setString("")
|
||||||
|
Else
|
||||||
|
bMatched = False
|
||||||
|
End If
|
||||||
|
|
||||||
|
' Go to INSERT mode after 'cc', otherwise NORMAL
|
||||||
|
If bIsSpecialCase And keyChar = "c" Then
|
||||||
|
gotoMode("INSERT")
|
||||||
|
Else
|
||||||
|
gotoMode("NORMAL")
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
' d or c in visual mode: delete selection
|
||||||
|
ElseIf MODE = "VISUAL" Then
|
||||||
oTextCursor = getTextCursor()
|
oTextCursor = getTextCursor()
|
||||||
thisComponent.getCurrentController.Select(oTextCursor)
|
thisComponent.getCurrentController.Select(oTextCursor)
|
||||||
oTextCursor.setString("")
|
oTextCursor.setString("")
|
||||||
|
|
||||||
' Reset Cursor
|
If keyChar = "c" Then gotoMode("INSERT")
|
||||||
cursorReset(oTextCursor)
|
If keyChar = "d" Then gotoMode("NORMAL")
|
||||||
|
|
||||||
' Goto NORMAL mode (in the case of VISUAL mode)
|
' Enter Special mode: 'd' or 'c'
|
||||||
|
ElseIf MODE = "NORMAL" Then
|
||||||
|
setSpecial(keyChar)
|
||||||
|
gotoMode("VISUAL")
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
' Otherwise, ignore if bIsSpecial
|
||||||
|
ElseIf bIsSpecial Then
|
||||||
|
bMatched = False
|
||||||
|
|
||||||
|
|
||||||
|
ElseIf keyChar = "x" Then
|
||||||
|
oTextCursor = getTextCursor()
|
||||||
|
thisComponent.getCurrentController.Select(oTextCursor)
|
||||||
|
oTextCursor.setString("")
|
||||||
|
|
||||||
|
' Reset Cursor
|
||||||
|
cursorReset(oTextCursor)
|
||||||
|
|
||||||
|
' Goto NORMAL mode (in the case of VISUAL mode)
|
||||||
|
gotoMode("NORMAL")
|
||||||
|
|
||||||
|
ElseIf keyChar = "D" Or keyChar = "C" Then
|
||||||
|
If MODE = "VISUAL" Then
|
||||||
|
ProcessMovementKey("^", False)
|
||||||
|
ProcessMovementKey("$", True)
|
||||||
|
ProcessMovementKey("l", True)
|
||||||
|
Else
|
||||||
|
' Deselect
|
||||||
|
oTextCursor = getTextCursor()
|
||||||
|
oTextCursor.gotoRange(oTextCursor.getStart(), False)
|
||||||
|
thisComponent.getCurrentController.Select(oTextCursor)
|
||||||
|
ProcessMovementKey("$", True)
|
||||||
|
End If
|
||||||
|
|
||||||
|
getTextCursor().setString("")
|
||||||
|
|
||||||
|
If keyChar = "D" Then
|
||||||
gotoMode("NORMAL")
|
gotoMode("NORMAL")
|
||||||
|
ElseIf keyChar = "C" Then
|
||||||
|
gotoMode("INSERT")
|
||||||
|
End IF
|
||||||
|
|
||||||
Case "D", "C":
|
Else
|
||||||
If MODE = "VISUAL" Then
|
bMatched = False
|
||||||
ProcessMovementKey("^", False)
|
End If
|
||||||
ProcessMovementKey("$", True)
|
|
||||||
ProcessMovementKey("l", True)
|
|
||||||
Else
|
|
||||||
' Deselect
|
|
||||||
oTextCursor = getTextCursor()
|
|
||||||
oTextCursor.gotoRange(oTextCursor.getStart(), False)
|
|
||||||
thisComponent.getCurrentController.Select(oTextCursor)
|
|
||||||
ProcessMovementKey("$", True)
|
|
||||||
End If
|
|
||||||
|
|
||||||
getTextCursor().setString("")
|
|
||||||
|
|
||||||
If keyChar = "D" Then
|
|
||||||
gotoMode("NORMAL")
|
|
||||||
ElseIf keyChar = "C" Then
|
|
||||||
gotoMode("INSERT")
|
|
||||||
End IF
|
|
||||||
|
|
||||||
Case "d", "c":
|
|
||||||
If MODE = "VISUAL" Then
|
|
||||||
oTextCursor = getTextCursor()
|
|
||||||
thisComponent.getCurrentController.Select(oTextCursor)
|
|
||||||
oTextCursor.setString("")
|
|
||||||
|
|
||||||
If keyChar = "c" Then gotoMode("INSERT")
|
|
||||||
If keyChar = "d" Then gotoMode("NORMAL")
|
|
||||||
|
|
||||||
ElseIf MODE = "NORMAL" Then
|
|
||||||
setSpecial(keyChar)
|
|
||||||
gotoMode("VISUAL")
|
|
||||||
End If
|
|
||||||
|
|
||||||
|
|
||||||
Case Else:
|
|
||||||
bMatched = False
|
|
||||||
End Select
|
|
||||||
|
|
||||||
ProcessDeleteKey = bMatched
|
ProcessDeleteKey = bMatched
|
||||||
End Function
|
End Function
|
||||||
|
@ -518,6 +551,7 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers)
|
||||||
oTextCursor.gotoNextParagraph(bExpand)
|
oTextCursor.gotoNextParagraph(bExpand)
|
||||||
Case "{":
|
Case "{":
|
||||||
oTextCursor.gotoPreviousParagraph(bExpand)
|
oTextCursor.gotoPreviousParagraph(bExpand)
|
||||||
|
|
||||||
Case Else:
|
Case Else:
|
||||||
bSetCursor = False
|
bSetCursor = False
|
||||||
bMatched = False
|
bMatched = False
|
||||||
|
|
Loading…
Reference in New Issue