Close tabs
mellobacon committed
Nov 29, 2022 at 17:48 UTC
9cb33e200eaf720a8bf4fa45f83917fc99c2dfbc
3 files changed
+10
-5
src/components/Tabs/EditorTabs.svelte
+3
-3
@@ -2,7 +2,7 @@
2
import { Sortable } from "sortablejs";
3
import { onMount } from "svelte";
4
import Tab from "./Tab.svelte";
5
- import { hidden, tabs } from "./scripts/Tab";
5
+ import { closeAllTabs, hidden, tabs } from "./scripts/Tab";
6
import { Add, ChevronDown, OverflowMenuVertical, Play } from "carbon-icons-svelte";
7
import { OverflowMenu, OverflowMenuItem } from "carbon-components-svelte";
8
let tabcontainer;
@@ -18,7 +18,7 @@
18
})
19
20
let tabmenu = [
21
- { option: "Close All Tabs", onclick: () => { console.log("click"); } },
21
+ { option: "Close All Tabs", onclick: () => { closeAllTabs() } },
22
]
23
</script>
24
@@ -39,7 +39,7 @@
39
<Play />
40
{/if}
41
</div>
42
- <OverflowMenu style="width: auto;" size="sm" title="" class="tab-settings">
42
+ <OverflowMenu flipped style="width: auto;" size="sm" title="" class="tab-settings">
43
{#each tabmenu as option}
44
<OverflowMenuItem on:click={option.onclick}>
45
<span class="option">{option.option}</span>
src/components/Tabs/TabMenu.svelte
+2
-2
@@ -4,7 +4,7 @@
4
import CopyFile from "carbon-icons-svelte/lib/CopyFile.svelte";
5
import Cut from "carbon-icons-svelte/lib/Cut.svelte";
6
import { clipboard, path, invoke } from "@tauri-apps/api";
7
- import { closeTab, setActive } from "./scripts/Tab";
7
+ import { closeAllTabs, closeTab, setActive } from "./scripts/Tab";
8
export let id: number;
9
export let target;
10
export let filename: string;
@@ -35,7 +35,7 @@
35
<ContextMenuOption indented labelText="Close Saved Tabs" on:click={() => {}}>
36
<span class="contextshortcut" slot="shortcutText">Ctrl + X S</span>
37
</ContextMenuOption>
38
- <ContextMenuOption indented labelText="Close All Tabs" on:click={() => {}}>
38
+ <ContextMenuOption indented labelText="Close All Tabs" on:click={() => {closeAllTabs()}}>
39
<span class="contextshortcut" slot="shortcutText">Ctrl + X A</span>
40
</ContextMenuOption>
41
<!--TODO: Make this relative instead of file name. Am lazy-->
src/components/Tabs/scripts/Tab.ts
+5
@@ -99,6 +99,11 @@ export function closeTab(tabid: number) {
99
id = 0;
100
}
101
}
102
+export function closeAllTabs() {
103
+ for (const tab of tablist) {
104
+ closeTab(tab.id);
105
+ }
106
+}
107
108
function refreshTabs() {
109
if (tablist.length > 0) {