Add function key file swap
parent
42fe902da4
commit
455a9887ac
|
|
@ -57,6 +57,7 @@
|
||||||
$: focusedFile = files[focusedFileIndex] ?? null
|
$: focusedFile = files[focusedFileIndex] ?? null
|
||||||
|
|
||||||
function selectFile(file: LoadedFile, index: number) {
|
function selectFile(file: LoadedFile, index: number) {
|
||||||
|
if (index < 0 || index >= files.length) return
|
||||||
focusedFileIndex = index
|
focusedFileIndex = index
|
||||||
refresh = {}
|
refresh = {}
|
||||||
}
|
}
|
||||||
|
|
@ -70,6 +71,9 @@
|
||||||
}
|
}
|
||||||
function closeFile(index: number) {
|
function closeFile(index: number) {
|
||||||
files = files.filter((_,i)=>i!==index)
|
files = files.filter((_,i)=>i!==index)
|
||||||
|
if (focusedFileIndex === index) {
|
||||||
|
focusedFileIndex = Math.min(files.length-1, focusedFileIndex)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -123,7 +127,7 @@
|
||||||
<NumberInput size="sm" min={1} max={100} step={1} bind:value={brushSize}/>
|
<NumberInput size="sm" min={1} max={100} step={1} bind:value={brushSize}/>
|
||||||
{/if}
|
{/if}
|
||||||
</menu>
|
</menu>
|
||||||
<Tabs>
|
<Tabs bind:selected={focusedFileIndex}>
|
||||||
{#each files as file, index}
|
{#each files as file, index}
|
||||||
<Tab on:click={()=>selectFile(file, index)}>
|
<Tab on:click={()=>selectFile(file, index)}>
|
||||||
<span class='tab'>
|
<span class='tab'>
|
||||||
|
|
@ -133,10 +137,11 @@
|
||||||
</Tab>
|
</Tab>
|
||||||
{/each}
|
{/each}
|
||||||
<svelte:fragment slot="content">
|
<svelte:fragment slot="content">
|
||||||
{#each files as file}
|
{#each files as file, index}
|
||||||
<Shortcuts group='editor2D' active={focusedFile===file}>
|
<Shortcuts group='editor2D' active={focusedFile===file}>
|
||||||
<Shortcut cmd='undo' keys={['ctrl+z']} on:trigger={()=>file.undo()} />
|
<Shortcut cmd='undo' keys={['ctrl+z']} on:trigger={()=>file.undo()} />
|
||||||
<Shortcut cmd='redo' keys={['ctrl+y', 'ctrl+shift+z']} on:trigger={()=>file.redo()} />
|
<Shortcut cmd='redo' keys={['ctrl+y', 'ctrl+shift+z']} on:trigger={()=>file.redo()} />
|
||||||
|
<Shortcut global cmd={'swapFile'+index} keys={['F'+(index+1)]} on:trigger={()=>selectFile(file, index)} />
|
||||||
</Shortcuts>
|
</Shortcuts>
|
||||||
<TabContent>
|
<TabContent>
|
||||||
<Editor2D bind:file={file} refresh={refresh} bind:primaryColorIndex={primaryColorIndex} bind:secondaryColorIndex={secondaryColorIndex} bind:currentTool={currentTool} brushSize={brushSize} brushType={brushType} />
|
<Editor2D bind:file={file} refresh={refresh} bind:primaryColorIndex={primaryColorIndex} bind:secondaryColorIndex={secondaryColorIndex} bind:currentTool={currentTool} brushSize={brushSize} brushType={brushType} />
|
||||||
|
|
@ -228,6 +233,7 @@
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
:global(.middle .bx--tabs__nav-link) {
|
:global(.middle .bx--tabs__nav-link) {
|
||||||
|
position: relative;
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
}
|
}
|
||||||
:global(.middle .bx--tabs) {
|
:global(.middle .bx--tabs) {
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@
|
||||||
let keys = opts.keys.map(v => {
|
let keys = opts.keys.map(v => {
|
||||||
return v.replaceAll('ctrl', 'control')
|
return v.replaceAll('ctrl', 'control')
|
||||||
})
|
})
|
||||||
shortcuts.push({id, cmd: opts.cmd, group: group, global: opts.global, keys: keys.map(v=>keysToString(v.split('+'))), callback: opts.callback})
|
shortcuts.push({id, cmd: opts.cmd, group: group, global: opts.global, keys: keys.map(v=>keysToString(v.toLowerCase().split('+'))), callback: opts.callback})
|
||||||
return shortcuts
|
return shortcuts
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue