This commit is contained in:
Sean Yeh 2014-12-20 09:27:11 -06:00
parent 199dbd57fe
commit 12a5a7681d
2 changed files with 29 additions and 13 deletions

View File

@ -10,7 +10,7 @@ vibreoffice currently supports:
- Movement keys: `hjkl`, `w`, `W`, `b`, `B`, `e`, `$`, `^`, `{}`, `()`, `C-d`, `C-u` - Movement keys: `hjkl`, `w`, `W`, `b`, `B`, `e`, `$`, `^`, `{}`, `()`, `C-d`, `C-u`
- Search movement: `f`, `F`, `t`, `T` - Search movement: `f`, `F`, `t`, `T`
- Number modifiers: e.g. `5w`, `4fa` - Number modifiers: e.g. `5w`, `4fa`
- Deletion: `x`, `d`, `c`, `D`, `C`, `dd`, `cc` - Deletion: `x`, `d`, `c`, `s`, `D`, `C`, `S`, `dd`, `cc`
- Plus movement and number modifiers: e.g. `5dw`, `c3j`, `2dfe` - Plus movement and number modifiers: e.g. `5dw`, `c3j`, `2dfe`
- Delete a/inner block: e.g. `di(`, `da{`, `ci[`, `ci"`, `ca'`, `dit` - Delete a/inner block: e.g. `di(`, `da{`, `ci[`, `ci"`, `ca'`, `dit`
- More to come! - More to come!

View File

@ -246,7 +246,7 @@ function KeyHandler_KeyPressed(oEvent) as boolean
delaySpecialReset() delaySpecialReset()
' Normal Key ' Normal Key
ElseIf ProcessNormalKey(oEvent) Then ElseIf ProcessNormalKey(oEvent.KeyChar, oEvent.Modifiers) Then
' Pass ' Pass
' If is modified but doesn't match a normal command, allow input ' If is modified but doesn't match a normal command, allow input
@ -360,7 +360,7 @@ Function ProcessModeKey(oEvent)
End Function End Function
Function ProcessNormalKey(oEvent) Function ProcessNormalKey(keyChar, modifiers)
dim i, bMatched, bIsVisual, iIterations dim i, bMatched, bIsVisual, iIterations
bIsVisual = (MODE = "VISUAL") ' is this hardcoding bad? what about visual block? bIsVisual = (MODE = "VISUAL") ' is this hardcoding bad? what about visual block?
@ -373,7 +373,7 @@ Function ProcessNormalKey(oEvent)
dim bMatchedMovement dim bMatchedMovement
' Movement Key ' Movement Key
bMatchedMovement = ProcessMovementKey(oEvent.KeyChar, bIsVisual, oEvent.Modifiers) bMatchedMovement = ProcessMovementKey(KeyChar, bIsVisual, modifiers)
bMatched = bMatched or bMatchedMovement bMatched = bMatched or bMatchedMovement
@ -402,20 +402,20 @@ Function ProcessNormalKey(oEvent)
' -------------------- ' --------------------
' There are no delete keys with modifier keys, so exit early ' There are no delete keys with modifier keys, so exit early
If oEvent.Modifiers > 1 Then If modifiers > 1 Then
ProcessNormalKey = False ProcessNormalKey = False
Exit Function Exit Function
End If End If
' Only 'x' or Special (dd, cc) can be done more than once ' Only 'x' or Special (dd, cc) can be done more than once
If oEvent.KeyChar <> "x" and getSpecial() = "" Then If keyChar <> "x" and getSpecial() = "" Then
iIterations = 1 iIterations = 1
End If End If
For i = 1 To iIterations For i = 1 To iIterations
dim bMatchedDelete dim bMatchedDelete
' Delete Key ' Delete Key
bMatchedDelete = ProcessDeleteKey(oEvent.KeyChar) bMatchedDelete = ProcessDeleteKey(keyChar)
' Selection Modifier Key ?? ' Selection Modifier Key ??
@ -432,7 +432,7 @@ Function ProcessDeleteKey(keyChar)
bIsSpecial = getSpecial() <> "" bIsSpecial = getSpecial() <> ""
If keyChar = "d" Or keyChar = "c" Then If keyChar = "d" Or keyChar = "c" Or keyChar = "s" Then
' Special Cases: 'dd' and 'cc' ' Special Cases: 'dd' and 'cc'
If bIsSpecial Then If bIsSpecial Then
dim bIsSpecialCase dim bIsSpecialCase
@ -457,19 +457,28 @@ Function ProcessDeleteKey(keyChar)
End If End If
' d or c in visual mode: delete selection ' visual mode: delete selection
ElseIf MODE = "VISUAL" Then ElseIf MODE = "VISUAL" Then
oTextCursor = getTextCursor() oTextCursor = getTextCursor()
thisComponent.getCurrentController.Select(oTextCursor) thisComponent.getCurrentController.Select(oTextCursor)
oTextCursor.setString("") oTextCursor.setString("")
If keyChar = "c" Then gotoMode("INSERT") If keyChar = "c" Or keyChar = "s" Then gotoMode("INSERT")
If keyChar = "d" Then gotoMode("NORMAL") If keyChar = "d" Then gotoMode("NORMAL")
' Enter Special mode: 'd' or 'c'
' Enter Special mode: 'd' or 'c', ('s' => 'cl')
ElseIf MODE = "NORMAL" Then ElseIf MODE = "NORMAL" Then
setSpecial(keyChar)
gotoMode("VISUAL") ' 's' => 'cl'
If keyChar = "s" Then
setSpecial("c")
gotoMode("VISUAL")
ProcessNormalKey("l", 0)
Else
setSpecial(keyChar)
gotoMode("VISUAL")
End If
End If End If
@ -510,6 +519,13 @@ Function ProcessDeleteKey(keyChar)
gotoMode("INSERT") gotoMode("INSERT")
End IF End IF
' S only valid in NORMAL mode
ElseIf keyChar = "S" And MODE = "NORMAL" Then
ProcessMovementKey("^", False)
ProcessMovementKey("$", True)
getTextCursor().setString("")
gotoMode("INSERT")
Else Else
bMatched = False bMatched = False
End If End If