From 96594be0db75eb4e5e767eebb379ea1b26f14b48 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Thu, 29 Nov 2018 13:27:59 +0300 Subject: [PATCH] added vim-like fast jumping between current and last index (ctrl-6 / ctrl-^)... Signed-off-by: Alex A. Naanou --- ui (gen4)/features/history.js | 30 +++++++++++++++++++++++++++++- ui (gen4)/features/keyboard.js | 2 ++ ui (gen4)/features/marks.js | 6 ++++-- 3 files changed, 35 insertions(+), 3 deletions(-) diff --git a/ui (gen4)/features/history.js b/ui (gen4)/features/history.js index 9b3410ae..55f96775 100755 --- a/ui (gen4)/features/history.js +++ b/ui (gen4)/features/history.js @@ -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/', function(){ this.url_history = null }], }) @@ -308,6 +320,20 @@ module.URLHistory = core.ImageGridFeatures.Feature({ ], 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-loaded-local-storage-key': 'url-history-loaded', 'url-history-load-current': true, + + 'url-history-last-loaded': null, }, __url_history: null, @@ -405,7 +433,7 @@ var URLHistoryLocalStorageActions = actions.Actions({ } else { this.openURLFromHistory(0) } - }] + }], }) var URLHistoryLocalStorage = diff --git a/ui (gen4)/features/keyboard.js b/ui (gen4)/features/keyboard.js index eef5d1f3..8f5f3527 100755 --- a/ui (gen4)/features/keyboard.js +++ b/ui (gen4)/features/keyboard.js @@ -239,6 +239,8 @@ module.GLOBAL_KEYBOARD = { // history... ctrl_H: 'listURLHistory', ctrl_shift_H: 'listSaveHistory', + 'ctrl_#6': 'openPreviousLoadedURL', + U: 'undo', ctrl_Z: 'undo', diff --git a/ui (gen4)/features/marks.js b/ui (gen4)/features/marks.js index 82f0bfca..ccf260c6 100755 --- a/ui (gen4)/features/marks.js +++ b/ui (gen4)/features/marks.js @@ -366,9 +366,11 @@ var ImageMarkEditActions = actions.Actions({ toggleMarkLoaded: ['Mark/Invert marks', '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"' ], - markLoaded: ['Mark/Mark $all', + markLoaded: ['Mark/Mark all', 'toggleMark: "loaded" "on"' ], markTagged: ['- Mark/Mark images by tags',