Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
add GoExtFMode command
  • Loading branch information
k2nr committed May 25, 2013
1 parent a597bfd commit 436def8
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 16 deletions.
1 change: 1 addition & 0 deletions coffee/command.coffee
Expand Up @@ -84,6 +84,7 @@ class g.CommandExecuter
GoSearchModeBackward : triggerInsideContent
GoLinkTextSearchMode : triggerInsideContent
GoFMode : triggerInsideContent
GoExtFMode : triggerInsideContent
GoEmergencyMode : triggerInsideContent
FocusOnFirstInput : triggerInsideContent
BackToPageMark : triggerInsideContent
Expand Down
65 changes: 57 additions & 8 deletions coffee/mode.coffee
Expand Up @@ -139,6 +139,17 @@ class g.Mode
opt = { newTab : newTab, continuous : continuous }
g.model.enterFMode( opt )

reqGoExtFMode : (args) ->
opt = {}
for arg in args then switch arg
when "--yank" then opt.mode='yank'
when "--open" then opt.mode ='open'
when "--opentab" then opt.mode= 'opentab'

if opt.mode?
g.model.enterFMode(opt)
else
g.model.enterExtFMode()

reqGoCommandMode : (args) ->
sources = [
Expand Down Expand Up @@ -339,16 +350,22 @@ class g.FMode extends g.Mode
else if not @opt.continuous
g.model.enterNormalMode()

open: (target) ->
@hitMode.focus(target)
primary = @opt.newTab
open: (target, primary=false) ->
@hitMode.focus.call(this, target)
g.util.dispatchMouseClickEvent target, primary, false, false

opentab: (target) -> @hitMode.open.call(this, target, true)

yank: (target) ->

}
getName : -> "FMode"
setOption : (@opt) -> this
statusLineHeader : -> "f Mode (#{@opt.mode || ''}): "

hit : (target, mode='open') ->
@hitMode[mode].call(this, target)
hit : (target) ->
mode = @opt.mode || if @opt.newTab then 'opentab' else 'open'
@hitMode[mode]?.call(this, target)

isValidKey : (key) ->
return ( @keys.indexOf( key ) >= 0 && key.length == 1 ) ||
Expand All @@ -370,7 +387,7 @@ class g.FMode extends g.Mode
else
@currentInput += key

g.view.setStatusLineText( 'f Mode : ' + @currentInput )
g.view.setStatusLineText( @statusLineHeader() + @currentInput )

if @currentInput.length < @keyLength
@updateHints()
Expand All @@ -384,7 +401,7 @@ class g.FMode extends g.Mode

if @opt.continuous
@currentInput = ""
g.view.setStatusLineText 'f Mode : '
g.view.setStatusLineText(@statusLineHeader())
else
g.view.hideStatusLine()

Expand Down Expand Up @@ -502,12 +519,44 @@ class g.FMode extends g.Mode

@createHints( links )

g.view.setStatusLineText 'f Mode : '
g.view.setStatusLineText(@statusLineHeader())

exit : ->
$('span#vichromehint').remove()
$('.vichrome-fModeTarget').removeClass('vichrome-fModeTarget')

class g.ExtFMode extends g.Mode
modeTable : {
'f': 'focus'
'o': 'open'
'O': 'opentab'
'y': 'yank'
'Y': 'yanktext'
}
getName : -> "ExtFMode"
setOption : (@opt) -> this

prePostKeyEvent : (key, ctrl, alt, meta) ->
if ctrl or alt or meta then return true

if @modeTable[key]?
event.stopPropagation()
event.preventDefault()

@opt.mode = @modeTable[key]
g.model.enterFMode(@opt)
return false
else
return true

enter : ->
g.view.setStatusLineText 'f Mode : select ext mode'

exit : ->
$('span#vichromehint').remove()
$('.vichrome-fModeTarget').removeClass('vichrome-fModeTarget')


$.extend( $.expr[':'],
_visible : (elem) ->
winLeft = window.pageXOffset
Expand Down
4 changes: 4 additions & 0 deletions coffee/model.coffee
Expand Up @@ -145,6 +145,10 @@ g.model =
g.logger.d "enterFMode"
@changeMode( (new g.FMode).setOption( opt ) )

enterExtFMode : (opt) ->
g.logger.d "enterFMode"
@changeMode( (new g.ExtFMode).setOption( opt || {} ) )

isInNormalMode : -> @curMode.getName() == "NormalMode"
isInInsertMode : -> @curMode.getName() == "InsertMode"
isInSearchMode : -> @curMode.getName() == "SearchMode"
Expand Down
1 change: 1 addition & 0 deletions command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

97 changes: 89 additions & 8 deletions mode.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions model.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 436def8

Please sign in to comment.