add "r"
This commit is contained in:
parent
12a5a7681d
commit
5d6cf029e7
|
@ -10,6 +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`
|
||||||
|
- Replace: `r`
|
||||||
- Deletion: `x`, `d`, `c`, `s`, `D`, `C`, `S`, `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`
|
||||||
|
|
|
@ -105,6 +105,15 @@ Function samePos(oPos1, oPos2)
|
||||||
samePos = oPos1.X() = oPos2.X() And oPos1.Y() = oPos2.Y()
|
samePos = oPos1.X() = oPos2.X() And oPos1.Y() = oPos2.Y()
|
||||||
End FUnction
|
End FUnction
|
||||||
|
|
||||||
|
Function genString(sChar, iLen)
|
||||||
|
dim sResult, i
|
||||||
|
sResult = ""
|
||||||
|
For i = 1 To iLen
|
||||||
|
sResult = sResult & sChar
|
||||||
|
Next i
|
||||||
|
genString = sResult
|
||||||
|
End Function
|
||||||
|
|
||||||
|
|
||||||
' -----------------------------------
|
' -----------------------------------
|
||||||
' Special Mode (for chained commands)
|
' Special Mode (for chained commands)
|
||||||
|
@ -240,6 +249,12 @@ function KeyHandler_KeyPressed(oEvent) as boolean
|
||||||
ElseIf ProcessModeKey(oEvent) Then
|
ElseIf ProcessModeKey(oEvent) Then
|
||||||
' Pass
|
' Pass
|
||||||
|
|
||||||
|
' Replace Key
|
||||||
|
ElseIf getSpecial() = "r" And Not bIsModified Then
|
||||||
|
dim iLen
|
||||||
|
iLen = Len(getCursor().getString())
|
||||||
|
getCursor().setString(genString(oEvent.KeyChar, iLen))
|
||||||
|
|
||||||
' Multiplier Key
|
' Multiplier Key
|
||||||
ElseIf ProcessNumberKey(oEvent) Then
|
ElseIf ProcessNumberKey(oEvent) Then
|
||||||
bIsMultiplier = True
|
bIsMultiplier = True
|
||||||
|
@ -259,7 +274,6 @@ function KeyHandler_KeyPressed(oEvent) as boolean
|
||||||
delaySpecialReset()
|
delaySpecialReset()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
' If bIsSpecial but nothing matched, return to normal mode
|
' If bIsSpecial but nothing matched, return to normal mode
|
||||||
ElseIf bIsSpecial Then
|
ElseIf bIsSpecial Then
|
||||||
gotoMode("NORMAL")
|
gotoMode("NORMAL")
|
||||||
|
@ -398,10 +412,10 @@ Function ProcessNormalKey(keyChar, modifiers)
|
||||||
|
|
||||||
|
|
||||||
' --------------------
|
' --------------------
|
||||||
' 2. Check Delete Key
|
' 2. Check Special/Delete Key
|
||||||
' --------------------
|
' --------------------
|
||||||
|
|
||||||
' There are no delete keys with modifier keys, so exit early
|
' There are no special/delete keys with modifier keys, so exit early
|
||||||
If modifiers > 1 Then
|
If modifiers > 1 Then
|
||||||
ProcessNormalKey = False
|
ProcessNormalKey = False
|
||||||
Exit Function
|
Exit Function
|
||||||
|
@ -412,21 +426,19 @@ Function ProcessNormalKey(keyChar, modifiers)
|
||||||
iIterations = 1
|
iIterations = 1
|
||||||
End If
|
End If
|
||||||
For i = 1 To iIterations
|
For i = 1 To iIterations
|
||||||
dim bMatchedDelete
|
dim bMatchedSpecial
|
||||||
|
|
||||||
' Delete Key
|
' Special/Delete Key
|
||||||
bMatchedDelete = ProcessDeleteKey(keyChar)
|
bMatchedSpecial = ProcessSpecialKey(keyChar)
|
||||||
|
|
||||||
' Selection Modifier Key ??
|
bMatched = bMatched or bMatchedSpecial
|
||||||
|
|
||||||
bMatched = bMatched or bMatchedDelete
|
|
||||||
Next i
|
Next i
|
||||||
|
|
||||||
ProcessNormalKey = bMatched
|
ProcessNormalKey = bMatched
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
Function ProcessDeleteKey(keyChar)
|
Function ProcessSpecialKey(keyChar)
|
||||||
dim oTextCursor, bMatched, bIsSpecial
|
dim oTextCursor, bMatched, bIsSpecial
|
||||||
bMatched = True
|
bMatched = True
|
||||||
bIsSpecial = getSpecial() <> ""
|
bIsSpecial = getSpecial() <> ""
|
||||||
|
@ -481,6 +493,9 @@ Function ProcessDeleteKey(keyChar)
|
||||||
End If
|
End If
|
||||||
End If
|
End If
|
||||||
|
|
||||||
|
' If is 'r' for replace
|
||||||
|
ElseIf keyChar = "r" Then
|
||||||
|
setSpecial("r")
|
||||||
|
|
||||||
' Otherwise, ignore if bIsSpecial
|
' Otherwise, ignore if bIsSpecial
|
||||||
ElseIf bIsSpecial Then
|
ElseIf bIsSpecial Then
|
||||||
|
@ -530,7 +545,7 @@ Function ProcessDeleteKey(keyChar)
|
||||||
bMatched = False
|
bMatched = False
|
||||||
End If
|
End If
|
||||||
|
|
||||||
ProcessDeleteKey = bMatched
|
ProcessSpecialKey = bMatched
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|
||||||
|
@ -811,7 +826,6 @@ Sub initVibreoffice
|
||||||
VIBREOFFICE_STARTED = True
|
VIBREOFFICE_STARTED = True
|
||||||
VIEW_CURSOR = thisComponent.getCurrentController.getViewCursor
|
VIEW_CURSOR = thisComponent.getCurrentController.getViewCursor
|
||||||
|
|
||||||
|
|
||||||
resetMultiplier()
|
resetMultiplier()
|
||||||
gotoMode("NORMAL")
|
gotoMode("NORMAL")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue