From a55630d9ed7349e68958feefb166039097c93251 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 14:24:46 +0900 Subject: [PATCH 01/11] Check whether target is undefined. --- coffee/tab.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coffee/tab.coffee b/coffee/tab.coffee index cce9ea1..eab3e06 100644 --- a/coffee/tab.coffee +++ b/coffee/tab.coffee @@ -154,7 +154,7 @@ class g.TabHistory chrome.tabs.onUpdated.addListener( (tabId, info, tab) => target = @openTabs[tab.windowId][tabId] - if info.url + if target && info.url target.tab.url = info.url target.history.push info.url if info.pinned From 822795f142992df586ece115ece2fbd86dc27faf Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 14:30:47 +0900 Subject: [PATCH 02/11] Use `KeyboardEvent.key` instead of `KeyboardEvent.keyIdentifier` Because KeyboardEvent.keyIdentifier is deprecated in chrome 54. --- coffee/commandbox.coffee | 4 ++-- coffee/eventhandler.coffee | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coffee/commandbox.coffee b/coffee/commandbox.coffee index f7ced66..87b6c32 100644 --- a/coffee/commandbox.coffee +++ b/coffee/commandbox.coffee @@ -81,11 +81,11 @@ class g.CommandBox return onKeyDown : (e) -> - if g.KeyManager.isOnlyModifier( e.keyIdentifier, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) + if g.KeyManager.isOnlyModifier( e.key, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) g.logger.d "getHandlableKey:only modefier" return - code = g.KeyManager.getLocalKeyCode( e.keyIdentifier, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) + code = g.KeyManager.getLocalKeyCode( e.key, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) unless code? g.logger.d "getHandlableKey:cant be handled" return diff --git a/coffee/eventhandler.coffee b/coffee/eventhandler.coffee index bc9551d..47380f2 100644 --- a/coffee/eventhandler.coffee +++ b/coffee/eventhandler.coffee @@ -21,11 +21,11 @@ class g.EventHandler # decide whether to post the key event and do some pre-post process # return true if the key event can be posted. getHandlableKey : (e) -> - if g.KeyManager.isOnlyModifier( e.keyIdentifier, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) + if g.KeyManager.isOnlyModifier( e.key, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) g.logger.d "getHandlableKey:only modifier" return undefined - code = g.KeyManager.getLocalKeyCode( e.keyIdentifier, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) + code = g.KeyManager.getLocalKeyCode( e.key, e.ctrlKey, e.shiftKey, e.altKey, e.metaKey ) unless code? g.logger.d "getHandlableKey:cant be handled" return undefined From fcc58f4c88ff7d385af3244e1648666ead7f0668 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 14:37:09 +0900 Subject: [PATCH 03/11] Change key identifier names for using KeyboardEvent.key. * ESC -> Escape * UP -> ArrowUp * DOWN -> ArrowDown * RIGHT -> ArrowRight * LEFT -> ArrowLeft * TAB -> Tab * SHIFT -> Shift * BS -> Backspace * ALT -> Alt * CTRL -> Control * META -> Meta * DEL -> Delete * CR -> Enter * SPACE -> Space --- coffee/key.coffee | 40 +++++++------- coffee/mode.coffee | 2 +- coffee/settings.coffee | 120 ++++++++++++++++++++--------------------- 3 files changed, 81 insertions(+), 81 deletions(-) diff --git a/coffee/key.coffee b/coffee/key.coffee index e79aff1..261aa65 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -2,21 +2,21 @@ this.vichrome ?= {} g = this.vichrome g.key = {} -g.key.keyCodes = - ESC : 27 - TAB : 9 - SHIFT : 16 - BS : 8 - ALT : 18 - CTRL : 17 - META : 91 - DEL : 46 - CR : 13 - SPACE : 32 - LEFT : 128 - UP : 129 - RIGHT : 130 - DOWN : 131 +g.key.keyCodes = + Escape : 27 + Tab : 9 + Shift : 16 + Backspace : 8 + Alt : 18 + Control : 17 + Meta : 91 + Delete : 46 + Enter : 13 + Space : 32 + ArrowRight: 128 + ArrowUp : 129 + ArrowLeft : 130 + ArrowDown : 131 F1 : 132 F2 : 133 F3 : 134 @@ -101,10 +101,10 @@ g.key.keyIdentifier = "U+003F" : "?" "U+005F" : "_" "U+0020" : "SPACE" - "Left" : "LEFT" - "Down" : "DOWN" - "Up" : "UP" - "Right" : "RIGHT" + "ArrowLeft" : "LEFT" + "ArrowDown" : "DOWN" + "ArrowUp" : "UP" + "ArrowRight": "RIGHT" "Enter" : "CR" "U+0008" : "BS" "U+007F" : "DEL" @@ -121,7 +121,7 @@ g.key.keyIdentifier = "F10" : "F10" "F11" : "F11" "F12" : "F12" - "U+001B" : "ESC" + "U+001B" : "Escape" "Home" : "HOME" "End" : "END" "Control" : "CTRL" diff --git a/coffee/mode.coffee b/coffee/mode.coffee index db59a56..c46b15d 100644 --- a/coffee/mode.coffee +++ b/coffee/mode.coffee @@ -424,7 +424,7 @@ class g.FMode extends g.Mode g.view.hideStatusLine() prePostKeyEvent : (key, ctrl, alt, meta) -> - if key == "ESC" then return true + if key == "Escape" then return true if ctrl or alt or meta then return true key = key.toUpperCase() if g.model.getSetting("fModeIgnoreCase") diff --git a/coffee/settings.coffee b/coffee/settings.coffee index fe01263..8670e1d 100644 --- a/coffee/settings.coffee +++ b/coffee/settings.coffee @@ -66,7 +66,7 @@ nmap m :TabOpenNew https://mail.google.com/mail/#inbox\n \n # if you want to change the key used to escape EmergencyMode mode,\n # use emap like the following\n -#emap :Escape\n +#emap :Escape\n \n ## pagecmd offers you page specific key mapping.\n # in this example you can use , for moving between tabs\n @@ -84,71 +84,71 @@ pagecmd *.pdf nmap \n #pagecmd http*://twitter.com/* nmap r " "keyMappingNormal" : - "j" : "ScrollDown" - "" : "ScrollDown" - "k" : "ScrollUp" - "" : "ScrollUp" - "h" : "ScrollLeft" - "l" : "ScrollRight" - "" : "PageDown" - "" : "PageUp" - "" : "PageHalfDown" - "" : "PageHalfUp" - "gg" : "GoTop" - "G" : "GoBottom" - "t" : "TabOpenNew" - "x" : "TabCloseCurrent" - "X" : "TabCloseCurrent --focusprev" - "n" : "NextSearch" - "N" : "PrevSearch" - "gt" : "TabFocusNext" - "gT" : "TabFocusPrev" - "" : "TabFocusNext" - "" : "TabFocusPrev" - "r" : "TabReload" - "H" : "BackHist" - "L" : "ForwardHist" - ":" : "GoCommandMode" - "/" : "GoSearchModeForward" - "?" : "GoSearchModeBackward" - "a" : "GoLinkTextSearchMode" - "f" : "GoFMode" - "F" : "GoFMode --newtab" - ";" : "GoExtFMode" - "i" : "FocusOnFirstInput" - "u" : "RestoreTab" - "gp" : "WinOpenNew --pop" - "gs" : "TabOpenNew --next view-source:%url" - "yy" : "copyurl" - "p" : "Open %clipboard" - "P" : "TabOpenNew %clipboard" - "o" : "Open -i" - "O" : "TabOpenNew -i" - "s" : "Open -i g" - "S" : "TabOpenNew -i g" - "b" : "Open -b" - "B" : "TabOpenNew -b" - "''" : "BackToPageMark" - "" : "TabSwitchLast" - "" : "GoEmergencyMode" - "" : "Escape" - "" : "Escape" - ",z" : "ToggleImageSize" + "j" : "ScrollDown" + "" : "ScrollDown" + "k" : "ScrollUp" + "" : "ScrollUp" + "h" : "ScrollLeft" + "l" : "ScrollRight" + "" : "PageDown" + "" : "PageUp" + "" : "PageHalfDown" + "" : "PageHalfUp" + "gg" : "GoTop" + "G" : "GoBottom" + "t" : "TabOpenNew" + "x" : "TabCloseCurrent" + "X" : "TabCloseCurrent --focusprev" + "n" : "NextSearch" + "N" : "PrevSearch" + "gt" : "TabFocusNext" + "gT" : "TabFocusPrev" + "" : "TabFocusNext" + "" : "TabFocusPrev" + "r" : "TabReload" + "H" : "BackHist" + "L" : "ForwardHist" + ":" : "GoCommandMode" + "/" : "GoSearchModeForward" + "?" : "GoSearchModeBackward" + "a" : "GoLinkTextSearchMode" + "f" : "GoFMode" + "F" : "GoFMode --newtab" + ";" : "GoExtFMode" + "i" : "FocusOnFirstInput" + "u" : "RestoreTab" + "gp" : "WinOpenNew --pop" + "gs" : "TabOpenNew --next view-source:%url" + "yy" : "copyurl" + "p" : "Open %clipboard" + "P" : "TabOpenNew %clipboard" + "o" : "Open -i" + "O" : "TabOpenNew -i" + "s" : "Open -i g" + "S" : "TabOpenNew -i g" + "b" : "Open -b" + "B" : "TabOpenNew -b" + "''" : "BackToPageMark" + "" : "TabSwitchLast" + "" : "GoEmergencyMode" + "" : "Escape" + "" : "Escape" + ",z" : "ToggleImageSize" "keyMappingInsert" : - "" : "Escape" - "" : "Escape" + "" : "Escape" + "" : "Escape" "keyMappingCommand" : - "" : "FocusNextCandidate" - "" : "FocusPrevCandidate" - "" : "FocusNextCandidate" - "" : "FocusPrevCandidate" - "" : "Escape" - "" : "Escape" + "" : "FocusNextCandidate" + "" : "FocusPrevCandidate" + "": "FocusNextCandidate" + "" : "FocusPrevCandidate" + "" : "Escape" + "" : "Escape" "keyMappingEmergency" : - "" : "Escape" + "" : "Escape" "aliases" : "o" : "Open" From 737e0bd11897ed1442602dc07d7e051486b31319 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 14:39:37 +0900 Subject: [PATCH 04/11] Remove conversion of keyIdentifier. Because KeyboardEvent.key can get original key name, so not need to conversion. --- coffee/key.coffee | 105 +--------------------------------------------- 1 file changed, 1 insertion(+), 104 deletions(-) diff --git a/coffee/key.coffee b/coffee/key.coffee index 261aa65..3c44279 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -30,108 +30,6 @@ g.key.keyCodes = F11 : 142 F12 : 143 -g.key.keyIdentifier = - "U+0031" : "1" - "U+0032" : "2" - "U+0033" : "3" - "U+0034" : "4" - "U+0035" : "5" - "U+0036" : "6" - "U+0037" : "7" - "U+0038" : "8" - "U+0039" : "9" - "U+0030" : "0" - "U+0021" : "!" - "U+0022" : '"' - "U+0023" : "#" - "U+0024" : "$" - "U+0025" : "%" - "U+0026" : "&" - "U+0027" : "'" - "U+0028" : "(" - "U+0029" : ")" - "U+002D" : "-" - "U+003D" : "=" - "U+005E" : "^" - "U+007E" : "~" - "U+00A5" : "\\" - "U+005C" : "\\" - "U+007C" : "|" - "U+0041" : "a" - "U+0042" : "b" - "U+0043" : "c" - "U+0044" : "d" - "U+0045" : "e" - "U+0046" : "f" - "U+0047" : "g" - "U+0048" : "h" - "U+0049" : "i" - "U+004A" : "j" - "U+004B" : "k" - "U+004C" : "l" - "U+004D" : "m" - "U+004E" : "n" - "U+004F" : "o" - "U+0050" : "p" - "U+0051" : "q" - "U+0052" : "r" - "U+0053" : "s" - "U+0054" : "t" - "U+0055" : "u" - "U+0056" : "v" - "U+0057" : "w" - "U+0058" : "x" - "U+0059" : "y" - "U+005A" : "z" - "U+0040" : "@" - "U+0060" : "`" - "U+005B" : "[" - "U+007B" : "{" - "U+003B" : ";" - "U+002B" : "+" - "U+003A" : ":" - "U+002A" : "*" - "U+005D" : "]" - "U+007D" : "}" - "U+002C" : "," - "U+003C" : "<" - "U+002E" : "." - "U+003E" : ">" - "U+002F" : "/" - "U+003F" : "?" - "U+005F" : "_" - "U+0020" : "SPACE" - "ArrowLeft" : "LEFT" - "ArrowDown" : "DOWN" - "ArrowUp" : "UP" - "ArrowRight": "RIGHT" - "Enter" : "CR" - "U+0008" : "BS" - "U+007F" : "DEL" - "U+0009" : "TAB" - "F1" : "F1" - "F2" : "F2" - "F3" : "F3" - "F4" : "F4" - "F5" : "F5" - "F6" : "F6" - "F7" : "F7" - "F8" : "F8" - "F9" : "F9" - "F10" : "F10" - "F11" : "F11" - "F12" : "F12" - "U+001B" : "Escape" - "Home" : "HOME" - "End" : "END" - "Control" : "CTRL" - "Shift" : "SHIFT" - "Alt" : "ALT" - "Meta" : "META" - "PageDown" : "PAGEDOWN" - "PageUp" : "PAGEUP" - "CapsLock" : "CAPSLOCK" - g.key.winKeyIdentifier_ja = "U+00BC":"," "U+00BE":"." @@ -206,7 +104,6 @@ g.key.shiftWinKeyIdentifier_us = "U+0030":")" keyCodes = g.key.keyCodes -keyIdentifier = g.key.keyIdentifier winKeyIdentifier_ja = g.key.winKeyIdentifier_ja shiftWinKeyIdentifier_ja = g.key.shiftWinKeyIdentifier_ja winKeyIdentifier_us = g.key.winKeyIdentifier_us @@ -247,7 +144,7 @@ g.KeyManager = result getLocalKeyCode : (code, ctrl, shift, alt, meta) -> - result = keyIdentifier[code] + result = code # bull shit! fxxk windows and linux if util.getPlatform() != "Mac" From d624232021e43d96855d0d92cfaa42bd47690043 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 16:56:12 +0900 Subject: [PATCH 05/11] Return `SPACE` if space is detected --- coffee/key.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/coffee/key.coffee b/coffee/key.coffee index 3c44279..e709432 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -169,4 +169,5 @@ g.KeyManager = else result = result.toLowerCase() + result = "Space" if result == " " result From 99edaf643105cc88e306b2ed08fd4365c9eb17d3 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 15:39:59 +0900 Subject: [PATCH 06/11] Add mapping to convert special codes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * You can enter special code with ALT + {any key} in mac * `KeyboardEvent.key` returns special codes when you enter ALT + {any key} * e.g. you write settings file `A-≈` instead of `A-x` * The specification breaks old settings. so convert special codes. --- coffee/key.coffee | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/coffee/key.coffee b/coffee/key.coffee index e709432..ec1789a 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -30,6 +30,51 @@ g.key.keyCodes = F11 : 142 F12 : 143 +g.key.macOptionWithKeyIdentifier = + "¡" : "1" + "™" : "2" + "£" : "3" + "¢" : "4" + "∞" : "5" + "§" : "6" + "¶" : "7" + "•" : "8" + "ª" : "9" + "º" : "0" + "–" : "-" + "≠" : "^" + "\\" : "¥" + "œ" : "q" + "∑" : "w" + "®" : "r" + "†" : "t" + "¥" : "y" + "ø" : "o" + "π" : "p" + "“" : "@" + "‘" : "[" + "å" : "a" + "ß" : "s" + "∂" : "d" + "ƒ" : "f" + "©" : "g" + "˙" : "h" + "∆" : "j" + "˚" : "k" + "¬" : "l" + "…" : ";" + "æ" : ":" + "«" : "]" + "Ω" : "z" + "≈" : "x" + "ç" : "c" + "√" : "v" + "∫" : "b" + "µ" : "m" + "≤" : "," + "≥" : "." + "÷" : "/" + g.key.winKeyIdentifier_ja = "U+00BC":"," "U+00BE":"." From a6a85b513405b7e7162cc98944cdf72fdfee3dd7 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 16:03:32 +0900 Subject: [PATCH 07/11] Convert special code for mac --- coffee/key.coffee | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/coffee/key.coffee b/coffee/key.coffee index ec1789a..8713e00 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -149,6 +149,7 @@ g.key.shiftWinKeyIdentifier_us = "U+0030":")" keyCodes = g.key.keyCodes +macOptionWithKeyIdentifier = g.key.macOptionWithKeyIdentifier winKeyIdentifier_ja = g.key.winKeyIdentifier_ja shiftWinKeyIdentifier_ja = g.key.shiftWinKeyIdentifier_ja winKeyIdentifier_us = g.key.winKeyIdentifier_us @@ -207,6 +208,10 @@ g.KeyManager = else if winKeyIdentifier_us[code]? result = winKeyIdentifier_us[code] + else + if alt + if macOptionWithKeyIdentifier[code]? + result = g.key.macOptionWithKeyIdentifier[code] if result? and @isAlphabet result if shift From 5afc113eb820db54341071ec46a1aa07f5371ba1 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 20:29:20 +0900 Subject: [PATCH 08/11] Refactor. Align `=` --- coffee/key.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/coffee/key.coffee b/coffee/key.coffee index 8713e00..92813d3 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -150,10 +150,10 @@ g.key.shiftWinKeyIdentifier_us = keyCodes = g.key.keyCodes macOptionWithKeyIdentifier = g.key.macOptionWithKeyIdentifier -winKeyIdentifier_ja = g.key.winKeyIdentifier_ja -shiftWinKeyIdentifier_ja = g.key.shiftWinKeyIdentifier_ja -winKeyIdentifier_us = g.key.winKeyIdentifier_us -shiftWinKeyIdentifier_us = g.key.shiftWinKeyIdentifier_us +winKeyIdentifier_ja = g.key.winKeyIdentifier_ja +shiftWinKeyIdentifier_ja = g.key.shiftWinKeyIdentifier_ja +winKeyIdentifier_us = g.key.winKeyIdentifier_us +shiftWinKeyIdentifier_us = g.key.shiftWinKeyIdentifier_us util = g.util g.KeyManager = From e20dd3f2b58a262f8ac2539ee53ad604a64f2000 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 20:50:49 +0900 Subject: [PATCH 09/11] Change code value to fix the no execution on command mode. * KeyboardEvent.code return `Enter` string when you enter the `Enter` key. --- coffee/commandbox.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coffee/commandbox.coffee b/coffee/commandbox.coffee index 87b6c32..4548015 100644 --- a/coffee/commandbox.coffee +++ b/coffee/commandbox.coffee @@ -71,7 +71,7 @@ class g.CommandBox @reqEscape() return - if key.code == "CR" + if key.code == "Enter" @fixedListener?( @value() ) @detachFrom() return From c8a8c0688a42b44f5bc7b5f717ee620b184400f6 Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sat, 12 Nov 2016 21:18:00 +0900 Subject: [PATCH 10/11] Check KeyboardEvent.key value whether key is modifer. --- coffee/key.coffee | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/coffee/key.coffee b/coffee/key.coffee index 92813d3..58c8a02 100644 --- a/coffee/key.coffee +++ b/coffee/key.coffee @@ -170,8 +170,8 @@ g.KeyManager = ( 48 <= c <= 57 ) isOnlyModifier : (code, ctrl, shift, alt, meta) -> - switch keyCodes[@getLocalKeyCode(code, ctrl, shift, alt, meta)] - when keyCodes.CTRL, keyCodes.SHIFT, keyCodes.META, keyCodes.ALT + switch code + when "Control", "Shift", "Alt", "Meta" return true else return false From 08191d0beeabc295c843b503a35efd3ae03fb34d Mon Sep 17 00:00:00 2001 From: mgi166 Date: Sun, 12 Mar 2017 09:17:32 +0900 Subject: [PATCH 11/11] Use `Backspace` instead of `BS`, `Delete` instead of `DEL` --- coffee/commandbox.coffee | 2 +- coffee/mode.coffee | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/coffee/commandbox.coffee b/coffee/commandbox.coffee index 4548015..fae8282 100644 --- a/coffee/commandbox.coffee +++ b/coffee/commandbox.coffee @@ -66,7 +66,7 @@ class g.CommandBox handleKey : (key) -> event.stopPropagation() - if @value().length == 0 and ( key.code == "BS" or key.code == "DEL" ) + if @value().length == 0 and ( key.code == "Backspace" or key.code == "Delete" ) event.preventDefault() @reqEscape() return diff --git a/coffee/mode.coffee b/coffee/mode.coffee index c46b15d..165ddc2 100644 --- a/coffee/mode.coffee +++ b/coffee/mode.coffee @@ -387,8 +387,8 @@ class g.FMode extends g.Mode isValidKey : (key) -> return ( @keys.indexOf( key ) >= 0 && key.length == 1 ) || - ( key == 'BS' ) || - ( key == 'DEL' ) + ( key == 'Backspace' ) || + ( key == 'Delete' ) searchTarget : -> for elem, i in @hints @@ -397,7 +397,7 @@ class g.FMode extends g.Mode return null treatNewInput : (key) -> - if key == "BS" || key == "DEL" + if key == "Backspace" || key == "Delete" if @currentInput.length == 0 g.model.enterNormalMode() return