From 6858d53e58291a4268b8539407c271f90a7c533a Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 5 Jun 2016 19:25:50 +0200 Subject: [PATCH] Improve Marks mode UX - Return to Normal mode if a mark key hasn't been pressed within `options.timeout` milliseconds. - Let `` return to Normal mode instead of creating or going to a mark named ``. Previously, if the user pressed `` as an attempt to exit Marks mode after accidentally pressing `m`, that would indeed exit Marks mode, but it would also set the `` mark. That meant that after that point, the user couldn't exit Marks mode using `` after having pressed `` ` `` without the side effect of scrolling to the `` mark. - Marks mode has been hidden from the help dialog, in order not to clutter it with unnecessary information. While at it, Find mode was removed from the help dialog as well, for the same reason. Both modes are still available in VimFx's settings page in the Add-ons Manager, though. Fixes #750. --- extension/lib/defaults.coffee | 4 ++++ extension/lib/help.coffee | 2 -- extension/lib/modes.coffee | 20 ++++++++++++++++---- extension/locale/de/vimfx.properties | 1 + extension/locale/en-US/vimfx.properties | 1 + extension/locale/es/vimfx.properties | 1 + extension/locale/fr/vimfx.properties | 1 + extension/locale/id/vimfx.properties | 1 + extension/locale/it/vimfx.properties | 1 + extension/locale/ja/vimfx.properties | 1 + extension/locale/nl/vimfx.properties | 1 + extension/locale/pt-BR/vimfx.properties | 1 + extension/locale/ru/vimfx.properties | 1 + extension/locale/sv-SE/vimfx.properties | 1 + extension/locale/zh-CN/vimfx.properties | 1 + extension/locale/zh-TW/vimfx.properties | 1 + extension/skin/style.css | 4 ++++ 17 files changed, 37 insertions(+), 6 deletions(-) diff --git a/extension/lib/defaults.coffee b/extension/lib/defaults.coffee index c9578c9..985a40b 100644 --- a/extension/lib/defaults.coffee +++ b/extension/lib/defaults.coffee @@ -147,6 +147,10 @@ shortcuts = '': ' ': 'exit' + 'marks': + '': + ' ': 'exit' + options = 'hint_chars': 'fjdkslaghrueiwonc mv' 'prev_patterns': 'prev previous ‹ « ◀ ← << < back newer' diff --git a/extension/lib/help.coffee b/extension/lib/help.coffee index ec26194..96e7524 100644 --- a/extension/lib/help.coffee +++ b/extension/lib/help.coffee @@ -105,8 +105,6 @@ createContent = (window, vimfx) -> for category, index in mode.categories categoryContainer = $('category', content) - # `data-` attributes are currently unused by VimFx, but provide a great - # way to customize the help dialog with custom CSS. utils.setAttributes(categoryContainer, { 'data-mode': mode._name 'data-category': category._name diff --git a/extension/lib/modes.coffee b/extension/lib/modes.coffee index aae78d1..d30800a 100644 --- a/extension/lib/modes.coffee +++ b/extension/lib/modes.coffee @@ -331,15 +331,27 @@ mode('find', { mode('marks', { - onEnter: ({storage}, callback) -> + onEnter: ({vim, storage}, callback) -> storage.callback = callback + storage.timeoutId = vim.window.setTimeout((-> + vim.hideNotification() + vim.enterMode('normal') + ), vim.options.timeout) - onLeave: ({storage}) -> + onLeave: ({vim, storage}) -> storage.callback = null + vim.window.clearTimeout(storage.timeoutId) if storage.timeoutId? + storage.timeoutId = null onInput: (args, match) -> {vim, storage} = args - storage.callback(match.keyStr) - vim.enterMode('normal') + if match.type == 'full' + match.command.run(args) + else + storage.callback(match.keyStr) + vim.enterMode('normal') return true +}, { + exit: ({vim}) -> + vim.enterMode('normal') }) diff --git a/extension/locale/de/vimfx.properties b/extension/locale/de/vimfx.properties index a1ea76f..493fda5 100644 --- a/extension/locale/de/vimfx.properties +++ b/extension/locale/de/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Suchmodus mode.find.exit=Suchleiste schließen mode.marks=Markiermodus +mode.marks.exit=Zum Normalmodus zurückkehren notification.focus_search_bar.none=Suchleiste nicht gefunden notification.copy_current_url.success=URL kopiert diff --git a/extension/locale/en-US/vimfx.properties b/extension/locale/en-US/vimfx.properties index 6f3fe20..8359710 100644 --- a/extension/locale/en-US/vimfx.properties +++ b/extension/locale/en-US/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Find mode mode.find.exit=Close find bar mode.marks=Marks mode +mode.marks.exit=Return to Normal mode notification.focus_search_bar.none=Cannot find the search bar notification.copy_current_url.success=URL copied diff --git a/extension/locale/es/vimfx.properties b/extension/locale/es/vimfx.properties index 19a98a6..b765ebf 100644 --- a/extension/locale/es/vimfx.properties +++ b/extension/locale/es/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Modo Buscar mode.find.exit=Cerrar barra de búsqueda mode.marks=Modo de Marcas +mode.marks.exit=Volver al modo Normal notification.focus_search_bar.none=No se puede encontrar la barra de búsqueda notification.copy_current_url.success=Se ha copiado la URL diff --git a/extension/locale/fr/vimfx.properties b/extension/locale/fr/vimfx.properties index 665b6e1..38ead53 100644 --- a/extension/locale/fr/vimfx.properties +++ b/extension/locale/fr/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Mode recherche mode.find.exit=Fermer la barre de recherche mode.marks=Mode marqueurs +mode.marks.exit=Retourner en mode Normal notification.focus_search_bar.none=Impossible de trouver la barre de recherche notification.copy_current_url.success=Adresse copiée diff --git a/extension/locale/id/vimfx.properties b/extension/locale/id/vimfx.properties index 925ec05..ddf5832 100644 --- a/extension/locale/id/vimfx.properties +++ b/extension/locale/id/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Mode Cari mode.find.exit=Tutup bar Cari mode.marks=Mode Penanda +mode.marks.exit=Kembali ke mode Normal notification.focus_search_bar.none=Tidak dapat mencari bar pencarian notification.copy_current_url.success=URL disalin diff --git a/extension/locale/it/vimfx.properties b/extension/locale/it/vimfx.properties index a5579b7..bd10495 100644 --- a/extension/locale/it/vimfx.properties +++ b/extension/locale/it/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Modalità trova mode.find.exit=Chiudi la barra di ricerca mode.marks=Marks mode +mode.marks.exit=Return to Normal mode notification.focus_search_bar.none=Cannot find the search bar notification.copy_current_url.success=URL copied diff --git a/extension/locale/ja/vimfx.properties b/extension/locale/ja/vimfx.properties index 8a3ef21..c94ff0b 100644 --- a/extension/locale/ja/vimfx.properties +++ b/extension/locale/ja/vimfx.properties @@ -126,6 +126,7 @@ mode.find=検索モード mode.find.exit=検索バーを閉じる mode.marks=マークモード +mode.marks.exit=ノーマルモードに戻る notification.focus_search_bar.none=検索バーが見つかりませんでした notification.copy_current_url.success=URLをコピーしました diff --git a/extension/locale/nl/vimfx.properties b/extension/locale/nl/vimfx.properties index 4aefe0f..6e893e5 100644 --- a/extension/locale/nl/vimfx.properties +++ b/extension/locale/nl/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Zoekmodus mode.find.exit=Sluit zoekbalk mode.marks=Markeermodus +mode.marks.exit=Ga terug naar normale modus notification.focus_search_bar.none=Kan de zoekbalk niet vinden notification.copy_current_url.success=URL gekopieerd diff --git a/extension/locale/pt-BR/vimfx.properties b/extension/locale/pt-BR/vimfx.properties index b8926fa..5f7e838 100644 --- a/extension/locale/pt-BR/vimfx.properties +++ b/extension/locale/pt-BR/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Modo de Busca mode.find.exit=Fechar barra de busca mode.marks=Marks mode +mode.marks.exit=Return to Normal mode notification.focus_search_bar.none=Cannot find the search bar notification.copy_current_url.success=URL copied diff --git a/extension/locale/ru/vimfx.properties b/extension/locale/ru/vimfx.properties index 967ef36..9ac72d0 100644 --- a/extension/locale/ru/vimfx.properties +++ b/extension/locale/ru/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Режим поиска mode.find.exit=Закрыть панель поиска mode.marks=Marks mode +mode.marks.exit=Return to Normal mode notification.focus_search_bar.none=Cannot find the search bar notification.copy_current_url.success=URL copied diff --git a/extension/locale/sv-SE/vimfx.properties b/extension/locale/sv-SE/vimfx.properties index 7b077dc..415dc8f 100644 --- a/extension/locale/sv-SE/vimfx.properties +++ b/extension/locale/sv-SE/vimfx.properties @@ -126,6 +126,7 @@ mode.find=Sökläge mode.find.exit=Stäng sökpanelen mode.marks=Markörläge +mode.marks.exit=Återvänd till Normalläge notification.focus_search_bar.none=Kan inte hitta sökfältet notification.copy_current_url.success=URL kopierad diff --git a/extension/locale/zh-CN/vimfx.properties b/extension/locale/zh-CN/vimfx.properties index 5fbd7b8..9622ac3 100644 --- a/extension/locale/zh-CN/vimfx.properties +++ b/extension/locale/zh-CN/vimfx.properties @@ -126,6 +126,7 @@ mode.find=查找模式 mode.find.exit=关闭查找栏 mode.marks=标记模式 +mode.marks.exit=返回普通模式 notification.focus_search_bar.none=找不到搜索栏 notification.copy_current_url.success=URL 已复制 diff --git a/extension/locale/zh-TW/vimfx.properties b/extension/locale/zh-TW/vimfx.properties index 74f2b54..10b26dc 100644 --- a/extension/locale/zh-TW/vimfx.properties +++ b/extension/locale/zh-TW/vimfx.properties @@ -126,6 +126,7 @@ mode.find=搜尋模式 mode.find.exit=關閉搜尋列 mode.marks=標記模式 +mode.marks.exit=返回普通模式 notification.focus_search_bar.none=找不到搜尋列 notification.copy_current_url.success=URL 已複製 diff --git a/extension/skin/style.css b/extension/skin/style.css index 78aec30..c56f94a 100644 --- a/extension/skin/style.css +++ b/extension/skin/style.css @@ -257,6 +257,10 @@ toolbarpaletteitem[place="palette"] > #VimFxButton { margin-bottom: calc(var(--page-padding) / 2); } + #VimFxHelpDialogContainer :-moz-any([data-mode="find"], [data-mode="marks"]) { + display: none; + } + #VimFxHelpDialogContainer .heading-mode, #VimFxHelpDialogContainer .category:not(.first)::before { font-size: 2em; -- 2.39.3