Skip to content

Commit

Permalink
#215 experimental super granular keycap scope for each commands
Browse files Browse the repository at this point in the history
  • Loading branch information
t9md committed Mar 31, 2016
1 parent 2e84489 commit c3363a5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/base.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ class Base
@getCommandName: ->
@commandPrefix + ':' + _.dasherize(@name)

@getCommandNameWithoutPrefix: ->
_.dasherize(@name)

@commandScope: 'atom-text-editor'
@getCommandScope: ->
@commandScope
Expand Down
10 changes: 8 additions & 2 deletions lib/operation-stack.coffee
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
_ = require 'underscore-plus'

{CompositeDisposable} = require 'atom'
{Disposable, CompositeDisposable} = require 'atom'
Base = require './base'
{moveCursorLeft} = require './utils'
settings = require './settings'
{CurrentSelection, Select, MoveToRelativeLine} = {}

class OperationStack
constructor: (@vimState) ->
{@editor} = @vimState
{@editor, @editorElement} = @vimState
CurrentSelection ?= Base.getClass('CurrentSelection')
Select ?= Base.getClass('Select')
MoveToRelativeLine ?= Base.getClass('MoveToRelativeLine')
Expand Down Expand Up @@ -36,6 +36,12 @@ class OperationStack
operation

run: (klass, properties) ->
# Temporary set while command is running
scope = klass.getCommandNameWithoutPrefix()
@editorElement.classList.add(scope)
@subscribe new Disposable =>
@editorElement.classList.remove(scope)

klass = Base.getClass(klass) if _.isString(klass)
try
# When identical operator repeated, it set target to MoveToRelativeLine.
Expand Down

0 comments on commit c3363a5

Please sign in to comment.