added vim-like fast jumping between current and last index (ctrl-6 / ctrl-^)...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2018-11-29 13:27:59 +03:00
parent 38b43cef81
commit 96594be0db
3 changed files with 35 additions and 3 deletions

View File

@ -287,6 +287,18 @@ var URLHistoryActions = actions.Actions({
} }
} }
}], }],
openPreviousLoadedURL: ['History/Load previously loaded url',
core.doc`
NOTE: this will only work if .config['url-history-last-loaded'] is
present in .url_history, otherwise this is a no-op.
`,
function(){
var last = this.config['url-history-last-loaded']
last in this.url_history
&& this.openURLFromHistory(last)
}],
clearURLHistory: ['History/', clearURLHistory: ['History/',
function(){ this.url_history = null }], function(){ this.url_history = null }],
}) })
@ -308,6 +320,20 @@ module.URLHistory = core.ImageGridFeatures.Feature({
], ],
actions: URLHistoryActions, actions: URLHistoryActions,
handlers: [
// maintain .config['url-history-last-loaded']
['load.pre',
function(){
var prev = (this.location && this.location.path) ?
this.location.path
: null
return prev
&& function(){
prev != this.config['url-history-last-loaded']
&& (this.config['url-history-last-loaded'] = prev) }
}],
],
}) })
@ -321,6 +347,8 @@ var URLHistoryLocalStorageActions = actions.Actions({
'url-history-local-storage-key': 'url-history', 'url-history-local-storage-key': 'url-history',
'url-history-loaded-local-storage-key': 'url-history-loaded', 'url-history-loaded-local-storage-key': 'url-history-loaded',
'url-history-load-current': true, 'url-history-load-current': true,
'url-history-last-loaded': null,
}, },
__url_history: null, __url_history: null,
@ -405,7 +433,7 @@ var URLHistoryLocalStorageActions = actions.Actions({
} else { } else {
this.openURLFromHistory(0) this.openURLFromHistory(0)
} }
}] }],
}) })
var URLHistoryLocalStorage = var URLHistoryLocalStorage =

View File

@ -239,6 +239,8 @@ module.GLOBAL_KEYBOARD = {
// history... // history...
ctrl_H: 'listURLHistory', ctrl_H: 'listURLHistory',
ctrl_shift_H: 'listSaveHistory', ctrl_shift_H: 'listSaveHistory',
'ctrl_#6': 'openPreviousLoadedURL',
U: 'undo', U: 'undo',
ctrl_Z: 'undo', ctrl_Z: 'undo',

View File

@ -366,9 +366,11 @@ var ImageMarkEditActions = actions.Actions({
toggleMarkLoaded: ['Mark/Invert marks', toggleMarkLoaded: ['Mark/Invert marks',
'toggleMark: "loaded" ...' ], 'toggleMark: "loaded" ...' ],
markRibbon: ['Mark/Mark $ribbon', // NOTE: we do not need a menu hotkey as these are easy to access
// directly (via ctrl-a/ctrl-shift-a)
markRibbon: ['Mark/Mark ribbon',
'toggleMark: "ribbon" "on"' ], 'toggleMark: "ribbon" "on"' ],
markLoaded: ['Mark/Mark $all', markLoaded: ['Mark/Mark all',
'toggleMark: "loaded" "on"' ], 'toggleMark: "loaded" "on"' ],
markTagged: ['- Mark/Mark images by tags', markTagged: ['- Mark/Mark images by tags',