Skip to content

Commit a244d25

Browse files
committed
added command prompt searching letters and not whole words
1 parent df4c4a8 commit a244d25

File tree

13 files changed

+408
-343
lines changed

13 files changed

+408
-343
lines changed

package-lock.json

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

public/bundle.bin

9.02 KB
Binary file not shown.

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/index.html

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@
88

99
<link rel='stylesheet' href='/global.css'>
1010
<link rel='stylesheet' href='/bundle.css'>
11+
12+
<script defer src='/bundle.js'></script>
1113
</head>
1214

1315
<body>
14-
<script>
15-
nw.Window.get().evalNWBin(null,'./bundle.bin');
16-
</script>
1716
</body>
1817
</html>

src/Start.svelte

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,26 @@
1+
<svelte:window
2+
on:keydown={(e) => {
3+
$ctrlKey = e.ctrlKey;
4+
$shiftKey = e.shiftKey;
5+
$metaKey = e.metaKey;
6+
if(($skipKey && (e.key === 'Enter'))||(showComponent !== 'filemanager')) {
7+
$keyProcess = true;
8+
} else {
9+
if($keyProcess) {
10+
if($processKey !== null) $processKey(e);
11+
}
12+
}
13+
$skipKey = false;
14+
}}
15+
on:keyup={(e) => {
16+
$ctrlKey = e.ctrlKey;
17+
$shiftKey = e.shiftKey;
18+
$metaKey = e.metaKey;
19+
}}
20+
/>
21+
122
<FileManager
223
on:switchView={switchView}
3-
component={showComponent}
424
/>
525
{#if showComponent === 'preferences'}
626
<Preferences
@@ -22,6 +42,13 @@
2242
<script>
2343
import FileManager from "./components/FileManager.svelte";
2444
import Preferences from "./components/Preferences.svelte";
45+
import { shiftKey } from "./stores/shiftKey.js";
46+
import { ctrlKey } from "./stores/ctrlKey.js";
47+
import { metaKey } from "./stores/metaKey.js";
48+
import { altKey } from "./stores/altKey.js";
49+
import { skipKey } from "./stores/skipKey.js";
50+
import { processKey } from "./stores/processKey.js";
51+
import { keyProcess } from './stores/keyProcess.js';
2552
2653
let showComponent = 'filemanager';
2754

src/components/CommandPrompt.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,8 @@
191191
192192
function processInput(e) {
193193
if(commands !== null) filtered = commands.commandList;
194-
filtered = filtered.filter(item => item.name.toLowerCase().includes(promptValue.toLowerCase()));
194+
var newPrompt = promptValue.toLowerCase().split('').join('.*');
195+
filtered = filtered.filter(item => item.name.toLowerCase().match(newPrompt) !== null);
195196
current = 0;
196197
}
197198

src/components/FileManager.svelte

Lines changed: 50 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,3 @@
1-
<svelte:window
2-
on:keydown={(e) => {
3-
lctrlKey = e.ctrlKey;
4-
lshiftKey = e.shiftKey;
5-
lmetaKey = e.metaKey;
6-
if((skipKey && (e.key === 'Enter'))||(component !== 'filemanager')) {
7-
skipKey = false;
8-
keyProcess.set(true);
9-
localKeyProcess = true;
10-
} else {
11-
skipKey = false;
12-
if(localKeyProcess) {
13-
processKey(e);
14-
}
15-
}
16-
}}
17-
on:keyup={(e) => {
18-
lctrlKey = e.ctrlKey;
19-
lshiftKey = e.shiftKey;
20-
lmetaKey = e.metaKey;
21-
}}
22-
/>
23-
241
<div id='container'
252
style="background-color: {$theme.backgroundColor};
263
color: {$theme.textColor};
@@ -43,14 +20,14 @@
4320

4421
{#if showCommandPrompt}
4522
<CommandPrompt
46-
commands={commands}
23+
24+
commands={commands}
4725
on:closeCommandPrompt={(e) => {
4826
showCommandPrompt = false;
4927
if(!showMessageBox) {
50-
keyProcess.set(true);
51-
localKeyProcess = true;
28+
$keyProcess = true;
5229
}
53-
if(e.detail.skip) skipKey = true;
30+
if(e.detail.skip) $skipKey = true;
5431
}}
5532
/>
5633
{/if}
@@ -63,9 +40,8 @@
6340
on:msgReturn={msgReturn}
6441
on:closeMsgBox={(e) => {
6542
showMessageBox = false;
66-
keyProcess.set(true);
67-
localKeyProcess = true;
68-
if(e.detail.skip) skipKey = true;
43+
$keyProcess = true;
44+
if(e.detail.skip) $skipKey = true;
6945
}}
7046
/>
7147
{/if}
@@ -79,9 +55,8 @@
7955
on:changeEntries={qsChangeEntries}
8056
on:closeQuickSearch={(e) => {
8157
showQuickSearch = false;
82-
keyProcess.set(true);
83-
localKeyProcess = true;
84-
if(e.detail.skip) skipKey = true;
58+
$keyProcess = true;
59+
if(e.detail.skip) $skipKey = true;
8560
}}
8661
/>
8762
{/if}
@@ -198,9 +173,13 @@
198173
import macOS from '../modules/macOS.js';
199174
import linux from '../modules/linux.js';
200175
import windows from '../modules/windows.js';
176+
import { altKey } from '../stores/altKey.js';
177+
import { ctrlKey } from '../stores/ctrlKey.js';
178+
import { metaKey } from '../stores/metaKey.js';
179+
import { skipKey } from '../stores/skipKey.js';
180+
import { shiftKey } from '../stores/shiftKey.js';
181+
import { processKey } from "../stores/processKey.js";
201182
202-
export let component;
203-
204183
const dispatch = createEventDispatcher();
205184
const os = require('os');
206185
@@ -216,7 +195,6 @@
216195
let setEditDirFlagRight = false;
217196
let showExtra = false;
218197
let showCommandPrompt = false;
219-
let skipKey = false;
220198
let leftEntries = {};
221199
let rightEntries = {};
222200
let localCurrentCursor = {
@@ -240,7 +218,6 @@
240218
let rightDOM = null;
241219
let leftDOM = null;
242220
let containerDOM = null;
243-
let localKeyProcess = true;
244221
let mdown = false;
245222
let lastError = null;
246223
let userEditor = '.myeditorchoice';
@@ -251,27 +228,25 @@
251228
let localStateMapColors = [];
252229
let showGitHub = false;
253230
let numberAcc = '';
254-
let lshiftKey = false;
255-
let lctrlKey = false;
256-
let lmetaKey = false;
257231
let lastCommand = '';
258232
let flagFilter = 1;
259233
260234
onMount(() => {
261235
//
262236
// Initialize all the stores with minimal settings.
263237
//
264-
keyProcess.set(true);
265-
inputState.set('normal');
266-
theme.set({});
267-
currentCursor.set({});
268-
currentRightFile.set({});
269-
currentLeftFile.set({});
270-
rightDir.set({});
271-
leftDir.set({});
272-
directoryListeners.set([]);
273-
stateMapColors.set([]);
274-
config.set({});
238+
$keyProcess = true;
239+
$inputState = 'normal';
240+
$theme = {};
241+
$currentCursor = {};
242+
$currentRightFile = {};
243+
$currentLeftFile = {};
244+
$rightDir = {};
245+
$leftDir = {};
246+
$directoryListeners = [];
247+
$stateMapColors = [];
248+
$config = {};
249+
$processKey = processKeyFunction;
275250
276251
//
277252
// reset all the extensions and commands.
@@ -363,28 +338,28 @@
363338
//
364339
// Set the stores to their proper value.
365340
//
366-
leftDir.set(localLeftDir);
367-
rightDir.set(localRightDir);
341+
$leftDir = localLeftDir;
342+
$rightDir = localRightDir;
368343
369344
var unsubscribeCurrentCursor = currentCursor.subscribe(value => {
370345
localCurrentCursor = value;
371346
});
372-
currentCursor.set({
347+
$currentCursor = {
373348
pane: 'left',
374349
entry: leftEntries[0]
375-
});
350+
};
376351
var unsubscribeCurrentLeftFile = currentLeftFile.subscribe(value => {
377352
localCurrentLeftFile = value;
378353
});
379-
currentLeftFile.set({
354+
$currentLeftFile = {
380355
entry: leftEntries[0]
381-
});
356+
};
382357
var unsubscribeCurrentRightFile = currentRightFile.subscribe(value => {
383358
localCurrentRightFile = value;
384359
});
385-
currentRightFile.set({
360+
$currentRightFile = {
386361
entry: rightEntries[0]
387-
});
362+
};
388363
var unsubscribeTheme = theme.subscribe(value => {
389364
//
390365
// Make sure a proper theme is being set.
@@ -406,7 +381,7 @@
406381
localStateMapColors['normal'] = localTheme.normalbackgroundColor;
407382
localStateMapColors['insert'] = localTheme.insertbackgroundColor;
408383
localStateMapColors['visual'] = localTheme.visualbackgroundColor;
409-
stateMapColors.set(localStateMapColors);
384+
$stateMapColors = localStateMapColors;
410385
}
411386
});
412387
var unsubscriptStateMapColors = stateMapColors.subscribe(value => {
@@ -415,10 +390,7 @@
415390
var unsubscribeInputState = inputState.subscribe(value => {
416391
localState = value;
417392
});
418-
inputState.set(localState);
419-
var unsubscribeKeyProcess = keyProcess.subscribe(value => {
420-
localKeyProcess = value;
421-
});
393+
$inputState = localState;
422394
423395
//
424396
// Setup the user editor data file.
@@ -445,14 +417,14 @@
445417
//
446418
// Set the configuration store.
447419
//
448-
config.set({
420+
$config = {
449421
configDir: configDir,
450422
localFS: localFS,
451423
configuration: localConfig,
452424
commands: commands,
453425
extensions: extensions,
454426
userEditor: userEditor
455-
});
427+
};
456428
localFS.setConfig(localConfig);
457429
extensions.setConfig(localConfig);
458430
@@ -461,7 +433,7 @@
461433
//
462434
var dhist = get(dirHistory);
463435
dhist.loadHistory();
464-
dirHistory.set(dhist);
436+
$dirHistory = dhist;
465437
466438
//
467439
// return a command to unsubscribe from everything.
@@ -706,7 +678,7 @@
706678
commands.addCommand('Reload Extensions', 'reloadExtensions', 'Reload the extensions, keyboard maps, and theme.', reloadExtensions);
707679
}
708680
709-
function processKey(e) {
681+
function processKeyFunction(e) {
710682
//
711683
// Stop the system for propgating the keystroke.
712684
//
@@ -715,7 +687,7 @@
715687
//
716688
// Send to the processor.
717689
//
718-
keyProcessor(e.key, lctrlKey, lshiftKey, lmetaKey);
690+
keyProcessor(e.key, $ctrlKey, $shiftKey, $metaKey);
719691
}
720692
721693
function stringKeyProcessor(str) {
@@ -732,7 +704,7 @@
732704
stringKeyProcessor(lastCommand);
733705
}
734706
735-
function keyProcessor(key, ctrlKey, shiftKey, metaKey) {
707+
function keyProcessor(key, cKey, sKey, mKey) {
736708
737709
if((key >= 0)&&(key <=9)) {
738710
//
@@ -744,7 +716,7 @@
744716
// Get the command for the current state in the stateMaps.
745717
//
746718
747-
const command = getCommand(stateMaps[localState], key, ctrlKey, shiftKey, metaKey);
719+
const command = getCommand(stateMaps[localState], key, cKey, sKey, mKey);
748720
749721
//
750722
// Figure the number of times to run the command.
@@ -777,12 +749,12 @@
777749
stateMapColors.set(localStateMapColors);
778750
}
779751
780-
function getCommand(map, key, ctrlKey, shiftKey, metaKey) {
752+
function getCommand(map, key, cKey, sKey, mKey) {
781753
var result = {
782754
command: () => {},
783755
name: 'empty'
784756
};
785-
var rmap = map.find(item => ((item.key == key) && (item.meta == metaKey) && (item.ctrl == ctrlKey) && (item.shift == shiftKey)));
757+
var rmap = map.find(item => ((item.key == key) && (item.meta == mKey) && (item.ctrl == cKey) && (item.shift == sKey)));
786758
if(typeof rmap !== 'undefined') {
787759
result = rmap;
788760
}
@@ -1236,8 +1208,7 @@
12361208
}
12371209
if(key >= (arr.length-1)) {
12381210
showMessageBox = false;
1239-
keyProcess.set(true);
1240-
localKeyProcess = true;
1211+
$keyProcess = true;
12411212
12421213
//
12431214
// Refresh the side deleted from.
@@ -1302,8 +1273,7 @@
13021273
item.fileSystem.copyEntries(item, otherPane, false, (err, stdout)=>{
13031274
if(key >= (arr.length-1)) {
13041275
showMessageBox = false;
1305-
keyProcess.set(true);
1306-
localKeyProcess = true;
1276+
$keyProcess = true;
13071277
13081278
//
13091279
// Refresh the side copied to.
@@ -1452,8 +1422,7 @@
14521422
item.fileSystem.moveEntries(item, otherPane, (err, stdout)=>{
14531423
if(key >= (arr.length-1)) {
14541424
showMessageBox = false;
1455-
keyProcess.set(true);
1456-
localKeyProcess = true;
1425+
$keyProcess = true;
14571426
14581427
//
14591428
// Refresh both sides.
@@ -1886,11 +1855,9 @@
18861855
function toggleGitHub() {
18871856
showGitHub = !showGitHub;
18881857
if(showGitHub) {
1889-
keyProcess.set(false);
1890-
localKeyProcess = false;
1858+
$keyProcess = false;
18911859
} else {
1892-
keyProcess.set(true);
1893-
localKeyProcess = true;
1860+
$keyProcess = true;
18941861
}
18951862
}
18961863

src/stores/altKey.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { writable } from 'svelte/store';
2+
3+
export const altKey = writable(false);

src/stores/ctrlKey.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { writable } from 'svelte/store';
2+
3+
export const ctrlKey = writable(false);

src/stores/metaKey.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { writable } from 'svelte/store';
2+
3+
export const metaKey = writable(false);

0 commit comments

Comments
 (0)