Skip to content

Commit 3f956e6

Browse files
committed
✨ Open in Opposite Panel
The capital O in normal mode will open either the directory the cursor is on or the directory the cursor is in if not on a directory in the opposite panel.
1 parent 075109f commit 3f956e6

File tree

6 files changed

+94
-10
lines changed

6 files changed

+94
-10
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,7 @@ file in the default file editor.
213213
| `:` | toggleCommandPrompt |
214214
| `.` | reRunLastCommand |
215215
| `,` | toggleFilter |
216+
| `O` | openOppositePanel |
216217

217218
### Visual Mode
218219

@@ -275,6 +276,7 @@ These commands can be ran from the command prompt. They all act upon the current
275276
|`Toggle Filter` | Toggles the show all and default filters. | toggleFilter |
276277
| `Show All Filter` | Sets to show all Entries. | setShowAllFilter |
277278
| `Show Only Non-System Files/Folders | Sets the default filter of not showing system files/folders. | setDefaultFilter |
279+
| `Open in Opposite Panel` | Opens the directory the cursor is on or the directory the cursor is in in the opposite panel. | openOppositePanel |
278280

279281
### Extension Commands
280282

public/bundle.css.map

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/bundle.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/bundle.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/FileManager.svelte

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
{#if showGitHub}
3737
<GitHub
3838
on:closeGitHub={(e) => {
39-
showGitHub = false;
39+
toggleGitHub();
4040
}}
4141
/>
4242
{/if}
@@ -397,6 +397,8 @@
397397
inputState.set(localState);
398398
var unsubscribeKeyProcess = keyProcess.subscribe(value => {
399399
localKeyProcess = value;
400+
console.log('Key Process changed...');
401+
console.log(value);
400402
});
401403
402404
//
@@ -617,6 +619,7 @@
617619
commands.addCommand('Toggle Filter', 'toggleFilter', 'Toggles the show all and default filters.', toggleFilter );
618620
commands.addCommand('Show All Filter', 'setShowAllFilter', 'Sets to show all Entries.', setShowAllFilter);
619621
commands.addCommand('Show Only Non-System Files/Folders', 'setDefaultFilter', 'Sets the default filter of not showing system files/folders.', setDefaultFilter);
622+
commands.addCommand('Open in Opposite Panel', 'openOppositePanel', 'Set the opposite panel to the directory under the current cursor or the directory of the current cursor.', openOppositePanel);
620623
}
621624
622625
function processKey(e) {
@@ -898,6 +901,24 @@
898901
changeMode('visual');
899902
}
900903
904+
function openOppositePanel() {
905+
var nEntry = localCurrentCursor.entry.dir;
906+
if(localCurrentCursor.entry.type === 1) {
907+
nEntry = localCurrentCursor.entry.fileSystem.appendPath(localCurrentCursor.entry.dir, localCurrentCursor.entry.name);
908+
}
909+
if(localCurrentCursor.pane === 'right') {
910+
changeDir({
911+
path: nEntry,
912+
cursor: true
913+
},'left');
914+
} else {
915+
changeDir({
916+
path: nEntry,
917+
cursor: true
918+
},'right');
919+
}
920+
}
921+
901922
function cursorToPane(npane) {
902923
if(npane == 'right') {
903924
currentCursor.set({
@@ -1748,6 +1769,13 @@
17481769
17491770
function toggleGitHub() {
17501771
showGitHub = !showGitHub;
1772+
if(showGitHub) {
1773+
keyProcess.set(false);
1774+
localKeyProcess = false;
1775+
} else {
1776+
keyProcess.set(true);
1777+
localKeyProcess = true;
1778+
}
17511779
}
17521780
17531781
function setShowAllFilter() {
@@ -1936,6 +1964,12 @@
19361964
meta: false,
19371965
key: ',',
19381966
command: "toggleFilter"
1967+
}, {
1968+
ctrl: false,
1969+
shift: true,
1970+
meta: false,
1971+
key: 'O',
1972+
command: "openOppositePanel"
19391973
}];
19401974
19411975
//

src/components/GitHub.svelte

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
max-height: {getHeight()}px;
55
width: {width !== null ? width : 100}px;
66
color: {$theme.textColor};"
7-
on:blur={(e) => { exitGitHub(); }}
7+
on:blur={(e) => { exitGitHub(); }}
88
>
99
<div id='GitHubHeader'>
1010
<h3>GitHub Themes and Extensions Importer</h3>
@@ -17,7 +17,10 @@
1717
X
1818
</span>
1919
</div>
20-
<div id='GitHubList'>
20+
<div id='GitHubList'
21+
bind:this={pickerDOM}
22+
on:keydown={inputChange}
23+
>
2124
{#await repos}
2225
<h3>Loading Extensions Repositories....</h3>
2326
{:then value}
@@ -208,10 +211,11 @@
208211
</style>
209212

210213
<script>
211-
import { createEventDispatcher, onMount } from 'svelte';
214+
import { createEventDispatcher, onMount, afterUpdate } from 'svelte';
212215
import { get } from 'svelte/store';
213216
import { theme } from '../stores/theme.js';
214217
import { config } from '../stores/config.js';
218+
import { keyProcess } from '../stores/keyProcess.js';
215219
import util from '../modules/util.js';
216220
import { Octokit } from "@octokit/rest";
217221
@@ -222,11 +226,23 @@
222226
var themes;
223227
var width = null;
224228
var msgs = [];
229+
var pickerDOM;
225230
226231
onMount(() => {
232+
keyProcess.set(false);
227233
width = window.innerWidth - 30;
228234
octok = new Octokit();
229235
loadRepoInfo();
236+
setTimeout(() => {
237+
keyProcess.set(false);
238+
if(typeof pickerDOM !== 'undefined') pickerDOM.focus();
239+
}, 1000);
240+
});
241+
242+
afterUpdate(() => {
243+
if(typeof pickerDOM !== 'undefined') {
244+
pickerDOM.focus();
245+
}
230246
});
231247
232248
function loadRepoInfo() {
@@ -252,6 +268,7 @@
252268
}
253269
254270
function exitGitHub() {
271+
keyProcess.set(true);
255272
dispatch('closeGitHub',{});
256273
}
257274
@@ -369,5 +386,36 @@
369386
themes = themes;
370387
repos = repos;
371388
}
389+
390+
function inputChange(e) {
391+
console.log('GitHub key Processing...');
392+
393+
if((e.key === 'ArrowUp')||(e.key === 'k')) {
394+
//
395+
// Go up the list. Zero is at the top.
396+
//
397+
scrollDOM(-1);
398+
} else if((e.key === 'ArrowDown')||(e.key === 'j')) {
399+
//
400+
// Go down the list. The largest index is at the bottom.
401+
//
402+
scrollDOM(1);
403+
} else if(e.key === 'Escape') {
404+
//
405+
// Escape key. Just exit without doing anything.
406+
//
407+
exitGitHub();
408+
}
409+
}
410+
411+
function scrollDOM(amount) {
412+
var adj = amount * 20;
413+
414+
if(pickerDOM !== null) {
415+
pickerDOM.scrollTop += adj;
416+
if(pickerDOM.scrollTop < 0) pickerDOM.scrollTop = 0;
417+
if(pickerDOM.scrollTop > pickerDOM.clientHeight) pickerDOM.scrollTop = pickerDOM.clientHeight;
418+
}
419+
}
372420
</script>
373421

0 commit comments

Comments
 (0)