commit
e400365688
|
@ -8,8 +8,8 @@ both vi/vim neophytes and experts alike.
|
|||
### Installation/Usage
|
||||
|
||||
The easiest way to install is to download the
|
||||
[latest extension file](https://raw.github.com/linuxmage/vibreoffice/master/dist/vibreoffice-1.1.1.oxt)
|
||||
and open it with LibreOffice/OpenOffice.
|
||||
[latest extension file](https://raw.github.com/linuxmage/vibreoffice/master/dist/vibreoffice-1.1.4.oxt)
|
||||
and open it with LibreOffice/OpenOffice. LibreOffice/OpenOffice will need to be restarted before this extension can be used.
|
||||
|
||||
To enable/disable vibreoffice, simply select Tools -> Add-Ons -> vibreoffice.
|
||||
|
||||
|
@ -59,6 +59,7 @@ my patience.
|
|||
word processing.
|
||||
- Using `d`, `c` (or any of their variants) will temporarily bring you into
|
||||
Visual mode. This is intentional and should not have any noticeable effects.
|
||||
- In OS X, repeating commands by holding down keys can have strange behavior.
|
||||
|
||||
vibreoffice is new, so it is bound to have plenty of bugs. Please let me know
|
||||
if you run into anything!
|
||||
|
|
Binary file not shown.
|
@ -89,20 +89,15 @@ Function formatVisualBase()
|
|||
oTextCursor = getTextCursor()
|
||||
VISUAL_BASE = getCursor().getPosition()
|
||||
|
||||
' If current line is empty then select it.
|
||||
If oTextCursor.isStartOfParagraph() And oTextCursor.isEndOfParagraph() Then
|
||||
getCursor().goRight(1, False)
|
||||
getCursor().goLeft(1, True)
|
||||
Else
|
||||
' Select the current line by moving cursor to end of line and then
|
||||
' back to the start of line.
|
||||
getCursor().gotoEndOfLine(False)
|
||||
' Move cursor back if gotoEndOfLine moved cursor down.
|
||||
If getCursor().getPosition().Y() > VISUAL_BASE.Y() Then
|
||||
' Select the current line by moving cursor to start of the bellow line and
|
||||
' then back to the start of the current line.
|
||||
getCursor().gotoEndOfLine(False)
|
||||
If getCursor().getPosition().Y() = VISUAL_BASE.Y() Then
|
||||
If getCursor().goRight(1, False) Then
|
||||
getCursor().goLeft(1, True)
|
||||
End If
|
||||
getCursor().gotoStartOfLine(True)
|
||||
End If
|
||||
getCursor().gotoStartOfLine(True)
|
||||
End Function
|
||||
|
||||
Function gotoMode(sMode)
|
||||
|
@ -476,12 +471,13 @@ Function ProcessModeKey(oEvent)
|
|||
End If
|
||||
|
||||
' Mode matching
|
||||
dim bMatched
|
||||
dim bMatched, oTextCursor
|
||||
bMatched = True
|
||||
oTextCursor = getTextCursor()
|
||||
Select Case oEvent.KeyChar
|
||||
' Insert modes
|
||||
Case "i", "a", "I", "A", "o", "O":
|
||||
If oEvent.KeyChar = "a" Then getCursor().goRight(1, False)
|
||||
If oEvent.KeyChar = "a" And NOT oTextCursor.isEndOfParagraph() Then getCursor().goRight(1, False)
|
||||
If oEvent.KeyChar = "I" Then ProcessMovementKey("^")
|
||||
If oEvent.KeyChar = "A" Then ProcessMovementKey("$")
|
||||
|
||||
|
@ -496,7 +492,7 @@ Function ProcessModeKey(oEvent)
|
|||
End If
|
||||
|
||||
If oEvent.KeyChar = "O" Then
|
||||
ProcessMovementKey("^")
|
||||
ProcessMovementKey("0")
|
||||
getCursor().setString(chr(13))
|
||||
If Not getCursor().isAtStartOfLine() Then
|
||||
ProcessMovementKey("h")
|
||||
|
@ -576,8 +572,10 @@ Function ProcessNormalKey(keyChar, modifiers)
|
|||
' after that. Fix?
|
||||
' --------------------
|
||||
If keyChar = "p" or keyChar = "P" Then
|
||||
dim oTextCursor
|
||||
oTextCursor = getTextCursor()
|
||||
' Move cursor right if "p" to paste after cursor
|
||||
If keyChar = "p" Then
|
||||
If keyChar = "p" And NOT oTextCursor().isEndOfParagraph() Then
|
||||
ProcessMovementKey("l", False)
|
||||
End If
|
||||
|
||||
|
@ -650,7 +648,7 @@ Function ProcessSpecialKey(keyChar)
|
|||
bIsSpecialCase = (keyChar = "d" And getSpecial() = "d") Or (keyChar = "c" And getSpecial() = "c")
|
||||
|
||||
If bIsSpecialCase Then
|
||||
ProcessMovementKey("^", False)
|
||||
ProcessMovementKey("0", False)
|
||||
ProcessMovementKey("j", True)
|
||||
|
||||
oTextCursor = getTextCursor()
|
||||
|
@ -756,7 +754,7 @@ Function ProcessSpecialKey(keyChar)
|
|||
|
||||
ElseIf keyChar = "D" Or keyChar = "C" Then
|
||||
If MODE = "VISUAL" Or MODE = "VISUAL_LINE" Then
|
||||
ProcessMovementKey("^", False)
|
||||
ProcessMovementKey("0", False)
|
||||
ProcessMovementKey("$", True)
|
||||
ProcessMovementKey("l", True)
|
||||
Else
|
||||
|
@ -777,7 +775,7 @@ Function ProcessSpecialKey(keyChar)
|
|||
|
||||
' S only valid in NORMAL mode
|
||||
ElseIf keyChar = "S" And MODE = "NORMAL" Then
|
||||
ProcessMovementKey("^", False)
|
||||
ProcessMovementKey("0", False)
|
||||
ProcessMovementKey("$", True)
|
||||
yankSelection(True)
|
||||
gotoMode("INSERT")
|
||||
|
@ -1008,6 +1006,12 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers)
|
|||
' lines.
|
||||
If VISUAL_BASE.Y() = getCursor().getPosition().Y() Then
|
||||
getCursor().gotoEndOfLine(False)
|
||||
' Make sure that cursor is on the start of the line bellow
|
||||
' the Visual base line. This is needed to make sure the
|
||||
' new line character will be selected.
|
||||
If getCursor().getPosition().Y() = VISUAL_BASE.Y() Then
|
||||
getCursor().goRight(1, False)
|
||||
End If
|
||||
End If
|
||||
|
||||
' Move cursor to start of the line above last selected line.
|
||||
|
@ -1097,9 +1101,48 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers)
|
|||
|
||||
' ----------
|
||||
|
||||
ElseIf keyChar = "0" or keyChar = "^" Then
|
||||
ElseIf keyChar = "0" Then
|
||||
getCursor().gotoStartOfLine(bExpand)
|
||||
bSetCursor = False
|
||||
ElseIf keyChar = "^" Then
|
||||
dim oldLine
|
||||
oldLine = getCursor().getPosition().Y()
|
||||
|
||||
' Select all of the current line and put it into a string.
|
||||
getCursor().gotoEndOfLine(False)
|
||||
If getCursor().getPosition.Y() > oldLine Then
|
||||
' If gotoEndOfLine moved cursor to next line then move it back.
|
||||
getCursor().goLeft(1, False)
|
||||
End If
|
||||
getCursor().gotoStartOfLine(True)
|
||||
dim s as String
|
||||
s = getCursor().String
|
||||
|
||||
' Undo any changes made to the view cursor, then move to start of
|
||||
' line. This way any previous selction made by the user will remain.
|
||||
getCursor().gotoRange(oTextCursor, False)
|
||||
getCursor().gotoStartOfLine(bExpand)
|
||||
|
||||
' This integer will be used to determine the position of the first
|
||||
' character in the line that is not a space or a tab.
|
||||
dim i as Integer
|
||||
i = 1
|
||||
|
||||
' Iterate through the characters in the string until a character that
|
||||
' is not a space or a tab is found.
|
||||
Do While i <= Len(s)
|
||||
dim c
|
||||
c = Mid(s,i,1)
|
||||
If c <> " " And c <> Chr(9) Then
|
||||
Exit Do
|
||||
End If
|
||||
i = i + 1
|
||||
Loop
|
||||
|
||||
' Move the cursor to the first non space/tab character.
|
||||
getCursor().goRight(i - 1, bExpand)
|
||||
bSetCursor = False
|
||||
|
||||
ElseIf keyChar = "$" Then
|
||||
dim oldPos, newPos
|
||||
oldPos = getCursor().getPosition()
|
||||
|
|
Loading…
Reference in New Issue