Add comand-panel:set-selection-as-regex-address

This commit is contained in:
Corey Johnson
2012-06-13 16:30:29 -07:00
parent f11aaa2d22
commit 5d552d3df3
2 changed files with 20 additions and 0 deletions

View File

@@ -1,8 +1,12 @@
{View} = require 'space-pen'
CommandInterpreter = require 'command-interpreter'
RegexAddress = require 'command-interpreter/regex-address'
CompositeCommand = require 'command-interpreter/composite-command'
Editor = require 'editor'
{SyntaxError} = require('pegjs').parser
_ = require 'underscore'
module.exports =
class CommandPanel extends View
@activate: (rootView, state) ->
@@ -38,6 +42,7 @@ class CommandPanel extends View
@rootView.on 'command-panel:execute', => @execute()
@rootView.on 'command-panel:find-in-file', => @show("/")
@rootView.on 'command-panel:repeat-relative-address', => @repeatRelativeAddress()
@rootView.on 'command-panel:set-selection-as-regex-address', => @useSelectionAsLastRelativeAddress()
@miniEditor.off 'move-up move-down'
@miniEditor.on 'move-up', => @navigateBackwardInHistory()
@@ -82,3 +87,8 @@ class CommandPanel extends View
repeatRelativeAddress: ->
@commandInterpreter.repeatRelativeAddress(@rootView.activeEditor())
useSelectionAsLastRelativeAddress: ->
selection = @rootView.activeEditor().getSelectedText()
regex = _.escapeRegExp(selection)
@commandInterpreter.lastRelativeAddress = new CompositeCommand([new RegexAddress(regex)])