From e296ebc835a9d6572eb1c599c92362301bcc290a Mon Sep 17 00:00:00 2001 From: Me Date: Wed, 13 May 2020 21:25:41 -0500 Subject: [PATCH 1/4] Added multiwindow command Implemented suggestion from issue [#15](https://github.com/dcchambers/vb4c/issues/15). I attempted to make the main window come to the front but I think the PORT messages are destroyed by the time the function is called and `chrome.windows` is inaccessible. I also didn't want to modify messenger.js too much before the code gets refactored/rewritten. --- content_scripts/hints.js | 9 +++++++++ content_scripts/mappings.js | 6 ++++++ content_scripts/messenger.js | 6 ++++++ pages/mappings.html | 7 ++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/content_scripts/hints.js b/content_scripts/hints.js index 79a25a1..385a2b0 100644 --- a/content_scripts/hints.js +++ b/content_scripts/hints.js @@ -175,6 +175,13 @@ Hints.dispatchAction = function(link, shift) { noconvert: true }); break; + case 'multiwindow': + RUNTIME('openLinkWindow', { + focused: false, + url: link.href, + noconvert: true + }); + break; case 'script': eval(settings.FUNCTIONS[this.scriptFunction])(link); break; @@ -674,6 +681,7 @@ Hints.genHints = function(M) { return codes0.concat(codes1); }; +///NOTE: "type" is a string, "multi" is a boolean. "multi" seems to go unused; multi, multiyank, and multiimage don't use the multi param. The dispatchAction function only checks it when trying to make new tabs that have "tabbed" in the name of the type. Hints.create = function(type, multi) { var self = this; window.setTimeout(function() { @@ -742,6 +750,7 @@ Hints.create = function(type, multi) { tabbed: '(tabbed)', tabbedActive: '(tabbed)', window: '(window)', + multiwindow: '(multi-window)', edit: '(edit)', hover: '(hover)', unhover: '(unhover)', diff --git a/content_scripts/mappings.js b/content_scripts/mappings.js index a7de76f..bf4120e 100644 --- a/content_scripts/mappings.js +++ b/content_scripts/mappings.js @@ -426,6 +426,12 @@ Mappings.actions = { createActiveTabbedHint: function() { Hints.create('tabbedActive'); }, createMultiHint: function() { Hints.create('multi'); }, createHintWindow: function() { Hints.create('window'); }, + createHintMultiWindow: function() { + window.setTimeout(function() { + Hints.create('multiwindow'); + //PORT('bringCurrentWindowToFront'); //does not function; I think port listeners are destroyed by this point. + }, 0); + }, createEditHint: function() { Hints.create('edit'); }, createHoverHint: function() { Hints.create('hover'); }, createUnhoverHint: function() { Hints.create('unhover'); }, diff --git a/content_scripts/messenger.js b/content_scripts/messenger.js index 45b662c..6d942b9 100644 --- a/content_scripts/messenger.js +++ b/content_scripts/messenger.js @@ -161,6 +161,12 @@ port.onMessage.addListener(function(response) { Mappings.lastCommand = JSON.parse(request.data); } break; + /*Designed to be added to the "multiwindow" hint command. Don't want to heavily modify this before the code is refactored + case 'bringCurrentWindowToFront': + chrome.windows.getCurrent((function (win){ + chrome.windows.update(win.id, {drawAttention: true}); + })); + break;*/ } }); diff --git a/pages/mappings.html b/pages/mappings.html index 4a78fbe..91ff86b 100644 --- a/pages/mappings.html +++ b/pages/mappings.html @@ -687,6 +687,11 @@

Keybindings

createHintWindow +unmapped +open multiple links in new windows +createHintMultiWindow + + A repeat last hint command openLastHint @@ -1441,4 +1446,4 @@

History

cVim.

To understand why this fork was created, please see the discussion on the relevant GitHub Issue.

- \ No newline at end of file + From 82d03fb89fe190171fe9b7d9aa0645b4790ff222 Mon Sep 17 00:00:00 2001 From: LemonJuiz Date: Thu, 14 May 2020 09:05:32 -0500 Subject: [PATCH 2/4] Changed comment I had `drawAttention` in the window update because I was trying to get the port listener to work but I forgot to change it back to `focused` when committing. Doesn't affect functionality right now but later down the road if this does get added `focused` is the update param needed. --- content_scripts/messenger.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content_scripts/messenger.js b/content_scripts/messenger.js index 6d942b9..8501c32 100644 --- a/content_scripts/messenger.js +++ b/content_scripts/messenger.js @@ -161,10 +161,10 @@ port.onMessage.addListener(function(response) { Mappings.lastCommand = JSON.parse(request.data); } break; - /*Designed to be added to the "multiwindow" hint command. Don't want to heavily modify this before the code is refactored + /*Designed to be added to the "multiwindow" hint command. Don't want to heavily modify this file before the code is refactored case 'bringCurrentWindowToFront': chrome.windows.getCurrent((function (win){ - chrome.windows.update(win.id, {drawAttention: true}); + chrome.windows.update(win.id, {focused: true}); })); break;*/ } From 8797285d772b12a4b8a1ced5e949f73a15472102 Mon Sep 17 00:00:00 2001 From: LemonJuiz Date: Thu, 14 May 2020 18:21:02 -0500 Subject: [PATCH 3/4] Added subversion This is purely for this branch and should not be included in the main fork of vb4c. --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 124a7dc..9507a4d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "vb4c", - "version": "0.0.2", + "version": "0.0.2-multiwindow", "description": "vb4c: Vim Bindings For Chrome. A fork of cVim.", "icons": { "128": "icons/128.png", From 96e5646c0507533c5d31997e2d79cbfaed059dfc Mon Sep 17 00:00:00 2001 From: LemonJuiz Date: Thu, 14 May 2020 18:33:53 -0500 Subject: [PATCH 4/4] Revert "Added subversion" This reverts commit 8797285d772b12a4b8a1ced5e949f73a15472102. I don't want this included in the pull request but I can't "ignore" it as far as I can tell. I am reverting so it doesn't get included at all. --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 9507a4d..124a7dc 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "vb4c", - "version": "0.0.2-multiwindow", + "version": "0.0.2", "description": "vb4c: Vim Bindings For Chrome. A fork of cVim.", "icons": { "128": "icons/128.png",