Adds "X" and small fix for "cw"

"X" (capital x) will delete to the left like it does vim. Small fixes
for "cw" and a few other improvements.
This commit is contained in:
LinuxMage 2015-11-24 01:05:46 -08:00
parent b9f70f71fe
commit df8d640204
1 changed files with 14 additions and 16 deletions

View File

@ -571,7 +571,7 @@ Function ProcessNormalKey(keyChar, modifiers)
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 keyChar <> "x" and getSpecial() = "" Then If keyChar <> "x" And keyChar <> "X" And getSpecial() = "" Then
iIterations = 1 iIterations = 1
End If End If
For i = 1 To iIterations For i = 1 To iIterations
@ -687,8 +687,12 @@ Function ProcessSpecialKey(keyChar)
bMatched = False bMatched = False
ElseIf keyChar = "x" Then ElseIf keyChar = "x" Or keyChar = "X" Then
oTextCursor = getTextCursor() oTextCursor = getTextCursor()
If keyChar = "X" And MODE <> "VISUAL" Then
oTextCursor.collapseToStart()
oTextCursor.goLeft(1, True)
End If
thisComponent.getCurrentController.Select(oTextCursor) thisComponent.getCurrentController.Select(oTextCursor)
yankSelection(True) yankSelection(True)
@ -980,18 +984,16 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers)
' If the cursor is on a word then delete from the current position to ' If the cursor is on a word then delete from the current position to
' the end of the word. ' the end of the word.
' If the cursor is not on a word then delete from the current position ' If the cursor is not on a word then delete from the current position
' to the start of the next word or until the end of the line. ' to the start of the next word or until the end of the paragraph.
If NOT getCursor().isAtEndOfLine() Then If NOT oTextCursor.isEndOfParagraph() Then
' Move cursor to right in case it is already at start or end of ' Move cursor to right in case it is already at start or end of
' word. ' word.
oTextCursor.goRight(1, bExpand) oTextCursor.goRight(1, bExpand)
getCursor().goRight(1, bExpand)
End If End If
Do Until oTextCursor.isEndOfWord() Or oTextCursor.isStartOfWord() Or getCursor().isAtEndOfLine() Do Until oTextCursor.isEndOfWord() Or oTextCursor.isStartOfWord() Or oTextCursor.isEndOfParagraph()
oTextCursor.goRight(1, bExpand) oTextCursor.goRight(1, bExpand)
getCursor().goRight(1, bExpand)
Loop Loop
' For the case when the user enters "w" or "dw": ' For the case when the user enters "w" or "dw":
@ -1002,28 +1004,26 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers)
' that the cursor would not skip over lines that only contain ' that the cursor would not skip over lines that only contain
' whitespace. ' whitespace.
If NOT (getSpecial() = "d" And getCursor().isAtEndOfLine()) Then If NOT (getSpecial() = "d" And oTextCursor.isEndOfParagraph()) Then
' Move cursor to right in case cursor is already at the start ' Move cursor to right in case cursor is already at the start
' of a word. ' of a word.
' Additionally for "w", move right in case already on an empty ' Additionally for "w", move right in case already on an empty
' line. ' line.
oTextCursor.goRight(1, bExpand) oTextCursor.goRight(1, bExpand)
getCursor().goRight(1, bExpand)
End If End If
' Stop looping when the cursor reaches the start of a word, an empty ' Stop looping when the cursor reaches the start of a word, an empty
' line, or cannot be moved further (reaches end of file). ' line, or cannot be moved further (reaches end of file).
' Additionally, if "dw" then stop looping if end of line is reached. ' Additionally, if "dw" then stop looping if end of paragraph is reached.
Do Until oTextCursor.isStartOfWord() Or (getCursor().isAtStartOfLine() And getCursor().isAtEndOfLine()) Do Until oTextCursor.isStartOfWord() Or (oTextCursor.isStartOfParagraph() And oTextCursor.isEndOfParagraph())
' If "dw" then do not delete past the end of the line ' If "dw" then do not delete past the end of the line
If getSpecial() = "d" And getCursor().isAtEndOfLine() Then If getSpecial() = "d" And oTextCursor.isEndOfParagraph() Then
Exit Do Exit Do
' If "w" then stop advancing cursor if cursor can no longer ' If "w" then stop advancing cursor if cursor can no longer
' move right ' move right
ElseIf NOT oTextCursor.goRight(1, bExpand) Then ElseIf NOT oTextCursor.goRight(1, bExpand) Then
Exit Do Exit Do
End If End If
getCursor().goRight(1, bExpand)
Loop Loop
End If End If
ElseIf keyChar = "b" or keyChar = "B" Then ElseIf keyChar = "b" or keyChar = "B" Then
@ -1039,16 +1039,14 @@ Function ProcessMovementKey(keyChar, Optional bExpand, Optional keyModifiers)
' Move cursor to left in case cursor is already at the start ' Move cursor to left in case cursor is already at the start
' of a word or on on an empty line. ' of a word or on on an empty line.
oTextCursor.goLeft(1, bExpand) oTextCursor.goLeft(1, bExpand)
getCursor().goLeft(1, bExpand)
' Stop looping when the cursor reaches the start of a word, an empty ' Stop looping when the cursor reaches the start of a word, an empty
' line, or cannot be moved further (reaches start of file). ' line, or cannot be moved further (reaches start of file).
Do Until oTextCursor.isStartOfWord() Or (getCursor().isAtStartOfLine() And getCursor().isAtEndOfLine()) Do Until oTextCursor.isStartOfWord() Or (oTextCursor.isStartOfParagraph() And oTextCursor.isEndOfParagraph())
' Stop moving cursor if cursor can no longer move left ' Stop moving cursor if cursor can no longer move left
If NOT oTextCursor.goLeft(1, bExpand) Then If NOT oTextCursor.goLeft(1, bExpand) Then
Exit Do Exit Do
End If End If
getCursor().goLeft(1, bExpand)
Loop Loop
ElseIf keyChar = "e" Then ElseIf keyChar = "e" Then
' When the user enters "e", "ce", or "de": ' When the user enters "e", "ce", or "de":