From 9a2df791b6c6edff85f53c1d91ec4dca81bb3f20 Mon Sep 17 00:00:00 2001 From: Anton Khodakivskiy Date: Thu, 5 Sep 2013 15:07:25 +0300 Subject: [PATCH] Enabled Shift-space to rotate hint markers backwards --- extension/locale/de/vimfx.properties | 2 +- extension/locale/el-GR/vimfx.properties | 2 +- extension/locale/en-US/vimfx.properties | 2 +- extension/locale/hu/vimfx.properties | 2 +- extension/locale/id/vimfx.properties | 2 +- extension/locale/nl/vimfx.properties | 2 +- extension/locale/pl/vimfx.properties | 2 +- extension/locale/ru/vimfx.properties | 2 +- extension/locale/zh-CN/vimfx.properties | 2 +- extension/packages/commands.coffee | 23 +++++++++++++++-------- extension/packages/vim.coffee | 3 ++- 11 files changed, 26 insertions(+), 18 deletions(-) diff --git a/extension/locale/de/vimfx.properties b/extension/locale/de/vimfx.properties index 65292bd..289a116 100644 --- a/extension/locale/de/vimfx.properties +++ b/extension/locale/de/vimfx.properties @@ -62,7 +62,7 @@ help_command_dev=Entwickler-Werkzeuge öffnen help=Hilfe help_version=Version -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Bitte geben Sie uns Feedback! help_enjoying=Mögen Sie VimFx? help_found_bug=Haben Sie einen Fehler gefunden? diff --git a/extension/locale/el-GR/vimfx.properties b/extension/locale/el-GR/vimfx.properties index 564e5da..a7e4991 100644 --- a/extension/locale/el-GR/vimfx.properties +++ b/extension/locale/el-GR/vimfx.properties @@ -63,7 +63,7 @@ help_command_dev=Άνοιγμα Developer Toolbar help=Βοήθεια help_version=Έκδοση -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Πες μας τη γνώμη σου! help_enjoying=Σου άρεσε το VimFx? help_found_bug=Βρήκες bug; diff --git a/extension/locale/en-US/vimfx.properties b/extension/locale/en-US/vimfx.properties index 0b480d0..9d68b70 100644 --- a/extension/locale/en-US/vimfx.properties +++ b/extension/locale/en-US/vimfx.properties @@ -63,7 +63,7 @@ help_command_dev=Open Developer Toolbar help=Help help_version=Version -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Leave us Feedback! help_enjoying=Enjoying VimFx? help_found_bug=Found a bug? diff --git a/extension/locale/hu/vimfx.properties b/extension/locale/hu/vimfx.properties index ed6c225..d8a114f 100644 --- a/extension/locale/hu/vimfx.properties +++ b/extension/locale/hu/vimfx.properties @@ -62,7 +62,7 @@ help_command_dev=Open Developer Toolbar(needs translation) help=Segítség help_version=Verzió -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Hagyj visszajelzést! help_enjoying=Kedveled a VimFX-et? help_found_bug=Találtál egy bugot? diff --git a/extension/locale/id/vimfx.properties b/extension/locale/id/vimfx.properties index b404959..0a6a41b 100644 --- a/extension/locale/id/vimfx.properties +++ b/extension/locale/id/vimfx.properties @@ -62,7 +62,7 @@ help_command_dev=Buka Toolbar Pengembang help=Bantuan help_version=Versi -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Tinggalkan umpan balik! help_enjoying=Nyaman dengan VimFx? help_found_bug=Menemukan bug? diff --git a/extension/locale/nl/vimfx.properties b/extension/locale/nl/vimfx.properties index 7f6abb8..86b2f1e 100644 --- a/extension/locale/nl/vimfx.properties +++ b/extension/locale/nl/vimfx.properties @@ -63,7 +63,7 @@ help_command_dev=Open ontwikkelaarswerkbalk help=Help help_version=Versie -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Geef ons feedback! help_enjoying=Gebruik je VimFx graag? help_found_bug=Fout gevonden? diff --git a/extension/locale/pl/vimfx.properties b/extension/locale/pl/vimfx.properties index 4993d3e..27d42a3 100644 --- a/extension/locale/pl/vimfx.properties +++ b/extension/locale/pl/vimfx.properties @@ -63,7 +63,7 @@ help_command_dev=Otwórz pasek programisty help=Pomoc help_version=Wersja -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space or shift-space! help_feedback=Powiedz nam co sądzisz! help_enjoying=Spodobał Ci się VimFx? help_found_bug=Znalazłeś błąd? diff --git a/extension/locale/ru/vimfx.properties b/extension/locale/ru/vimfx.properties index 1c65dab..8f63160 100644 --- a/extension/locale/ru/vimfx.properties +++ b/extension/locale/ru/vimfx.properties @@ -64,7 +64,7 @@ help=Справка help_version=Версия help_enjoying=Расширение понравилось? -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Маркеры ссылок перекрываются? Нажмите пробел или шифт-пробел! help_feedback=Оставьте отзыв! help_found_bug=Нашли ошибку? help_report_bug=Сообщите нам! diff --git a/extension/locale/zh-CN/vimfx.properties b/extension/locale/zh-CN/vimfx.properties index 711317f..58d3afd 100644 --- a/extension/locale/zh-CN/vimfx.properties +++ b/extension/locale/zh-CN/vimfx.properties @@ -63,7 +63,7 @@ help_command_dev=打开开发者工具栏 help=帮助 help_version=版本 -help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space! +help_overlapping_hints=Can't see a link hint, because it's overlapped by another? Try pressing space ro shift-space! help_feedback=向我们反馈! help_enjoying=喜欢 VimFx? help_found_bug=发现 bug? diff --git a/extension/packages/commands.coffee b/extension/packages/commands.coffee index 464092b..5abd9d7 100644 --- a/extension/packages/commands.coffee +++ b/extension/packages/commands.coffee @@ -390,7 +390,10 @@ commands = [ hintCharHandler = (vim, keyStr) -> if keyStr if keyStr == 'Space' - rotateOverlappingMarkers(vim.markers) + rotateOverlappingMarkers(vim.markers, true) + return + else if keyStr == 'Shift-Space' + rotateOverlappingMarkers(vim.markers, false) return # Get char and escape it to avoid problems with String.search @@ -427,7 +430,7 @@ maybeCommand = (keys) -> # Finds all stacks of markers that overlap each other (by using `getStackFor`) (#1), and rotates # their `z-index`:es (#2), thus alternating which markers are visible. -rotateOverlappingMarkers = (originalMarkers) -> +rotateOverlappingMarkers = (originalMarkers, forward) -> # Shallow working copy. This is necessary since `markers` will be mutated and eventually empty. markers = originalMarkers[..] @@ -439,13 +442,17 @@ rotateOverlappingMarkers = (originalMarkers) -> for stack in stacks when stack.length > 1 # This sort is not required, but makes the rotation more predictable. stack.sort((a, b) -> a.markerElement.style.zIndex - b.markerElement.style.zIndex) - firstZIndex = stack[0].markerElement.style.zIndex - for marker, index in stack - nextMarker = stack[index+1] - nextZIndex = nextMarker?.markerElement.style.zIndex ? firstZIndex - marker.markerElement.style.setProperty('z-index', nextZIndex, 'important') - null + # Array of z indices + indexStack = (m.markerElement.style.zIndex for m in stack) + # Shift the array of indices one item forward or back + if forward + indexStack.unshift(indexStack.pop()) + else + indexStack.push(indexStack.shift()) + + for marker, index in stack + marker.markerElement.style.setProperty('z-index', indexStack[index], 'important') # Get an array containing `marker` and all markers that overlap `marker`, if any, which is called a # "stack". All markers in the returned stack are spliced out from `markers`, thus mutating it. diff --git a/extension/packages/vim.coffee b/extension/packages/vim.coffee index 3ad7c18..5a02e60 100644 --- a/extension/packages/vim.coffee +++ b/extension/packages/vim.coffee @@ -48,7 +48,8 @@ class Vim else @keys.length = 0 else if @mode == MODE_HINTS and not (event.ctrlKey or event.metaKey) - if utils.getHintChars().search(utils.regexpEscape(keyStr)) > -1 or keyStr in ['Space', 'Backspace'] + specialKeys = ['Shift-Space', 'Space', 'Backspace'] + if utils.getHintChars().search(utils.regexpEscape(keyStr)) > -1 or keyStr in speciaKeys commands.hintCharHandler(@, keyStr) return true -- 2.39.3