mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-11 16:09:57 +03:00
Add $ address to command interpreter
This commit is contained in:
parent
d5479a0b60
commit
296a80160b
@ -21,6 +21,14 @@ describe "CommandInterpreter", ->
|
||||
interpreter.eval(editor, '4,7')
|
||||
expect(editor.selection.getBufferRange()).toEqual [[3, 0], [7, 0]]
|
||||
|
||||
describe "$", ->
|
||||
it "selects EOF", ->
|
||||
interpreter.eval(editor, '$')
|
||||
expect(editor.selection.getBufferRange()).toEqual [[12,2], [12,2]]
|
||||
|
||||
interpreter.eval(editor, '1,$')
|
||||
expect(editor.selection.getBufferRange()).toEqual [[0,0], [12,2]]
|
||||
|
||||
describe "substitution", ->
|
||||
it "does nothing if there are no matches", ->
|
||||
editor.selection.setBufferRange([[6, 0], [6, 44]])
|
||||
|
@ -5,5 +5,5 @@ module.exports =
|
||||
class AddressRange extends Address
|
||||
constructor: (@startAddress, @endAddress) ->
|
||||
|
||||
getRange: ->
|
||||
new Range(@startAddress.getRange().start, @endAddress.getRange().end)
|
||||
getRange: (editor) ->
|
||||
new Range(@startAddress.getRange(editor).start, @endAddress.getRange(editor).end)
|
||||
|
@ -1,4 +1,4 @@
|
||||
module.exports =
|
||||
class Address
|
||||
execute: (editor) ->
|
||||
editor.getSelection().setBufferRange(@getRange())
|
||||
editor.getSelection().setBufferRange(@getRange(editor))
|
||||
|
9
src/atom/command-interpreter/eof-address.coffee
Normal file
9
src/atom/command-interpreter/eof-address.coffee
Normal file
@ -0,0 +1,9 @@
|
||||
Address = require 'command-interpreter/address'
|
||||
Range = require 'range'
|
||||
|
||||
module.exports =
|
||||
class EofAddress extends Address
|
||||
getRange: (editor) ->
|
||||
lastRow = editor.getLastBufferRow()
|
||||
column = editor.getBufferLineLength(lastRow)
|
||||
new Range([lastRow, column], [lastRow, column])
|
@ -2,6 +2,7 @@
|
||||
var Substitution = require('command-interpreter/substitution');
|
||||
var LineAddress = require('command-interpreter/line-address');
|
||||
var AddressRange = require('command-interpreter/address-range');
|
||||
var EofAddress = require('command-interpreter/eof-address');
|
||||
}
|
||||
|
||||
start
|
||||
@ -19,6 +20,7 @@ addressRange
|
||||
|
||||
primitiveAddress
|
||||
= lineNumber:integer { return new LineAddress(lineNumber) }
|
||||
/ '$' { return new EofAddress() }
|
||||
|
||||
substitution
|
||||
= "s" _ "/" find:pattern "/" replace:pattern "/" _ options:[g]* {
|
||||
|
@ -341,7 +341,6 @@ class Editor extends View
|
||||
@lineHeight = fragment.outerHeight()
|
||||
fragment.remove()
|
||||
|
||||
|
||||
getCursor: -> @cursor
|
||||
moveCursorUp: -> @cursor.moveUp()
|
||||
moveCursorDown: -> @cursor.moveDown()
|
||||
@ -373,6 +372,8 @@ class Editor extends View
|
||||
|
||||
setText: (text) -> @buffer.setText(text)
|
||||
getText: -> @buffer.getText()
|
||||
getLastBufferRow: -> @buffer.lastRow()
|
||||
getBufferLineLength: (row) -> @buffer.getLineLength(row)
|
||||
|
||||
insertText: (text) ->
|
||||
{ text, shouldOutdent } = @autoIndentText(text)
|
||||
|
Loading…
Reference in New Issue
Block a user