diff options
| author | Stephen Blott | 2016-12-14 05:39:53 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2016-12-14 05:39:53 +0000 | 
| commit | 9fb755929f5b629c57f77e6407c5c24ccd06e4a4 (patch) | |
| tree | 4a34346643151973e5d73d22625a079cbdfcc2de | |
| parent | 9225b2a1b9baa96ca94c2fa23e4a293478223c7e (diff) | |
| download | vimium-9fb755929f5b629c57f77e6407c5c24ccd06e4a4.tar.bz2 | |
Add "swap" command option for marks.
In a browser, I find global marks considerably more useful than local
marks; for example, I use marks to quickly jump back to my email tab.
Unfortunately, inheriting vim's approach, global marks require capital
letters, so the `<Shift>` key.
This PR implements:
    map m Marks.activateCreateMode swap
    map ' Marks.activateGotoMode swap
which inverts the `isGlobalMark()` test for the `<Shift>` key.
Is the name `swap` the best one?  It could be `invert` instead, or
perhaps there's something better.
| -rw-r--r-- | content_scripts/marks.coffee | 12 | 
1 files changed, 9 insertions, 3 deletions
| diff --git a/content_scripts/marks.coffee b/content_scripts/marks.coffee index 808f0a1d..73191b1b 100644 --- a/content_scripts/marks.coffee +++ b/content_scripts/marks.coffee @@ -2,6 +2,7 @@  Marks =    previousPositionRegisters: [ "`", "'" ]    localRegisters: {} +  currentRegistryEntry: null    mode: null    exit: (continuation = null) -> @@ -26,10 +27,14 @@ Marks =    # If <Shift> is depressed, then it's a global mark, otherwise it's a local mark.  This is consistent    # vim's [A-Z] for global marks and [a-z] for local marks.  However, it also admits other non-Latin    # characters.  The exceptions are "`" and "'", which are always considered local marks. +  # The "swap" command option inverts global and local marks.    isGlobalMark: (event, keyChar) -> -    event.shiftKey and keyChar not in @previousPositionRegisters +    shiftKey = event.shiftKey +    shiftKey = not shiftKey if @currentRegistryEntry.options.swap +    shiftKey and keyChar not in @previousPositionRegisters -  activateCreateMode: -> +  activateCreateMode: (count, {registryEntry}) -> +    @currentRegistryEntry = registryEntry      @mode = new Mode        name: "create-mark"        indicator: "Create mark..." @@ -52,7 +57,8 @@ Marks =              localStorage[@getLocationKey keyChar] = @getMarkString()              @showMessage "Created local mark", keyChar -  activateGotoMode: -> +  activateGotoMode: (count, {registryEntry}) -> +    @currentRegistryEntry = registryEntry      @mode = new Mode        name: "goto-mark"        indicator: "Go to mark..." | 
