|
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 | | - |
24 | 1 | <div id='container' |
25 | 2 | style="background-color: {$theme.backgroundColor}; |
26 | 3 | color: {$theme.textColor}; |
|
43 | 20 |
|
44 | 21 | {#if showCommandPrompt} |
45 | 22 | <CommandPrompt |
46 | | - commands={commands} |
| 23 | + |
| 24 | +commands={commands} |
47 | 25 | on:closeCommandPrompt={(e) => { |
48 | 26 | showCommandPrompt = false; |
49 | 27 | if(!showMessageBox) { |
50 | | - keyProcess.set(true); |
51 | | - localKeyProcess = true; |
| 28 | + $keyProcess = true; |
52 | 29 | } |
53 | | - if(e.detail.skip) skipKey = true; |
| 30 | + if(e.detail.skip) $skipKey = true; |
54 | 31 | }} |
55 | 32 | /> |
56 | 33 | {/if} |
|
63 | 40 | on:msgReturn={msgReturn} |
64 | 41 | on:closeMsgBox={(e) => { |
65 | 42 | 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; |
69 | 45 | }} |
70 | 46 | /> |
71 | 47 | {/if} |
|
79 | 55 | on:changeEntries={qsChangeEntries} |
80 | 56 | on:closeQuickSearch={(e) => { |
81 | 57 | 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; |
85 | 60 | }} |
86 | 61 | /> |
87 | 62 | {/if} |
|
198 | 173 | import macOS from '../modules/macOS.js'; |
199 | 174 | import linux from '../modules/linux.js'; |
200 | 175 | 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"; |
201 | 182 |
|
202 | | - export let component; |
203 | | - |
204 | 183 | const dispatch = createEventDispatcher(); |
205 | 184 | const os = require('os'); |
206 | 185 |
|
|
216 | 195 | let setEditDirFlagRight = false; |
217 | 196 | let showExtra = false; |
218 | 197 | let showCommandPrompt = false; |
219 | | - let skipKey = false; |
220 | 198 | let leftEntries = {}; |
221 | 199 | let rightEntries = {}; |
222 | 200 | let localCurrentCursor = { |
|
240 | 218 | let rightDOM = null; |
241 | 219 | let leftDOM = null; |
242 | 220 | let containerDOM = null; |
243 | | - let localKeyProcess = true; |
244 | 221 | let mdown = false; |
245 | 222 | let lastError = null; |
246 | 223 | let userEditor = '.myeditorchoice'; |
|
251 | 228 | let localStateMapColors = []; |
252 | 229 | let showGitHub = false; |
253 | 230 | let numberAcc = ''; |
254 | | - let lshiftKey = false; |
255 | | - let lctrlKey = false; |
256 | | - let lmetaKey = false; |
257 | 231 | let lastCommand = ''; |
258 | 232 | let flagFilter = 1; |
259 | 233 |
|
260 | 234 | onMount(() => { |
261 | 235 | // |
262 | 236 | // Initialize all the stores with minimal settings. |
263 | 237 | // |
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; |
275 | 250 |
|
276 | 251 | // |
277 | 252 | // reset all the extensions and commands. |
|
363 | 338 | // |
364 | 339 | // Set the stores to their proper value. |
365 | 340 | // |
366 | | - leftDir.set(localLeftDir); |
367 | | - rightDir.set(localRightDir); |
| 341 | + $leftDir = localLeftDir; |
| 342 | + $rightDir = localRightDir; |
368 | 343 | |
369 | 344 | var unsubscribeCurrentCursor = currentCursor.subscribe(value => { |
370 | 345 | localCurrentCursor = value; |
371 | 346 | }); |
372 | | - currentCursor.set({ |
| 347 | + $currentCursor = { |
373 | 348 | pane: 'left', |
374 | 349 | entry: leftEntries[0] |
375 | | - }); |
| 350 | + }; |
376 | 351 | var unsubscribeCurrentLeftFile = currentLeftFile.subscribe(value => { |
377 | 352 | localCurrentLeftFile = value; |
378 | 353 | }); |
379 | | - currentLeftFile.set({ |
| 354 | + $currentLeftFile = { |
380 | 355 | entry: leftEntries[0] |
381 | | - }); |
| 356 | + }; |
382 | 357 | var unsubscribeCurrentRightFile = currentRightFile.subscribe(value => { |
383 | 358 | localCurrentRightFile = value; |
384 | 359 | }); |
385 | | - currentRightFile.set({ |
| 360 | + $currentRightFile = { |
386 | 361 | entry: rightEntries[0] |
387 | | - }); |
| 362 | + }; |
388 | 363 | var unsubscribeTheme = theme.subscribe(value => { |
389 | 364 | // |
390 | 365 | // Make sure a proper theme is being set. |
|
406 | 381 | localStateMapColors['normal'] = localTheme.normalbackgroundColor; |
407 | 382 | localStateMapColors['insert'] = localTheme.insertbackgroundColor; |
408 | 383 | localStateMapColors['visual'] = localTheme.visualbackgroundColor; |
409 | | - stateMapColors.set(localStateMapColors); |
| 384 | + $stateMapColors = localStateMapColors; |
410 | 385 | } |
411 | 386 | }); |
412 | 387 | var unsubscriptStateMapColors = stateMapColors.subscribe(value => { |
|
415 | 390 | var unsubscribeInputState = inputState.subscribe(value => { |
416 | 391 | localState = value; |
417 | 392 | }); |
418 | | - inputState.set(localState); |
419 | | - var unsubscribeKeyProcess = keyProcess.subscribe(value => { |
420 | | - localKeyProcess = value; |
421 | | - }); |
| 393 | + $inputState = localState; |
422 | 394 |
|
423 | 395 | // |
424 | 396 | // Setup the user editor data file. |
|
445 | 417 | // |
446 | 418 | // Set the configuration store. |
447 | 419 | // |
448 | | - config.set({ |
| 420 | + $config = { |
449 | 421 | configDir: configDir, |
450 | 422 | localFS: localFS, |
451 | 423 | configuration: localConfig, |
452 | 424 | commands: commands, |
453 | 425 | extensions: extensions, |
454 | 426 | userEditor: userEditor |
455 | | - }); |
| 427 | + }; |
456 | 428 | localFS.setConfig(localConfig); |
457 | 429 | extensions.setConfig(localConfig); |
458 | 430 |
|
|
461 | 433 | // |
462 | 434 | var dhist = get(dirHistory); |
463 | 435 | dhist.loadHistory(); |
464 | | - dirHistory.set(dhist); |
| 436 | + $dirHistory = dhist; |
465 | 437 |
|
466 | 438 | // |
467 | 439 | // return a command to unsubscribe from everything. |
|
706 | 678 | commands.addCommand('Reload Extensions', 'reloadExtensions', 'Reload the extensions, keyboard maps, and theme.', reloadExtensions); |
707 | 679 | } |
708 | 680 | |
709 | | - function processKey(e) { |
| 681 | + function processKeyFunction(e) { |
710 | 682 | // |
711 | 683 | // Stop the system for propgating the keystroke. |
712 | 684 | // |
|
715 | 687 | // |
716 | 688 | // Send to the processor. |
717 | 689 | // |
718 | | - keyProcessor(e.key, lctrlKey, lshiftKey, lmetaKey); |
| 690 | + keyProcessor(e.key, $ctrlKey, $shiftKey, $metaKey); |
719 | 691 | } |
720 | 692 |
|
721 | 693 | function stringKeyProcessor(str) { |
|
732 | 704 | stringKeyProcessor(lastCommand); |
733 | 705 | } |
734 | 706 |
|
735 | | - function keyProcessor(key, ctrlKey, shiftKey, metaKey) { |
| 707 | + function keyProcessor(key, cKey, sKey, mKey) { |
736 | 708 |
|
737 | 709 | if((key >= 0)&&(key <=9)) { |
738 | 710 | // |
|
744 | 716 | // Get the command for the current state in the stateMaps. |
745 | 717 | // |
746 | 718 | |
747 | | - const command = getCommand(stateMaps[localState], key, ctrlKey, shiftKey, metaKey); |
| 719 | + const command = getCommand(stateMaps[localState], key, cKey, sKey, mKey); |
748 | 720 | |
749 | 721 | // |
750 | 722 | // Figure the number of times to run the command. |
|
777 | 749 | stateMapColors.set(localStateMapColors); |
778 | 750 | } |
779 | 751 |
|
780 | | - function getCommand(map, key, ctrlKey, shiftKey, metaKey) { |
| 752 | + function getCommand(map, key, cKey, sKey, mKey) { |
781 | 753 | var result = { |
782 | 754 | command: () => {}, |
783 | 755 | name: 'empty' |
784 | 756 | }; |
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))); |
786 | 758 | if(typeof rmap !== 'undefined') { |
787 | 759 | result = rmap; |
788 | 760 | } |
|
1236 | 1208 | } |
1237 | 1209 | if(key >= (arr.length-1)) { |
1238 | 1210 | showMessageBox = false; |
1239 | | - keyProcess.set(true); |
1240 | | - localKeyProcess = true; |
| 1211 | + $keyProcess = true; |
1241 | 1212 |
|
1242 | 1213 | // |
1243 | 1214 | // Refresh the side deleted from. |
|
1302 | 1273 | item.fileSystem.copyEntries(item, otherPane, false, (err, stdout)=>{ |
1303 | 1274 | if(key >= (arr.length-1)) { |
1304 | 1275 | showMessageBox = false; |
1305 | | - keyProcess.set(true); |
1306 | | - localKeyProcess = true; |
| 1276 | + $keyProcess = true; |
1307 | 1277 |
|
1308 | 1278 | // |
1309 | 1279 | // Refresh the side copied to. |
|
1452 | 1422 | item.fileSystem.moveEntries(item, otherPane, (err, stdout)=>{ |
1453 | 1423 | if(key >= (arr.length-1)) { |
1454 | 1424 | showMessageBox = false; |
1455 | | - keyProcess.set(true); |
1456 | | - localKeyProcess = true; |
| 1425 | + $keyProcess = true; |
1457 | 1426 |
|
1458 | 1427 | // |
1459 | 1428 | // Refresh both sides. |
|
1886 | 1855 | function toggleGitHub() { |
1887 | 1856 | showGitHub = !showGitHub; |
1888 | 1857 | if(showGitHub) { |
1889 | | - keyProcess.set(false); |
1890 | | - localKeyProcess = false; |
| 1858 | + $keyProcess = false; |
1891 | 1859 | } else { |
1892 | | - keyProcess.set(true); |
1893 | | - localKeyProcess = true; |
| 1860 | + $keyProcess = true; |
1894 | 1861 | } |
1895 | 1862 | } |
1896 | 1863 |
|
|
0 commit comments