@setoelkahfi / svara / commits / a4fc08b

feat: added copying filename and filepath from filetree

mellbacon committed May 29, 2023 at 11:38 UTC a4fc08bbca66bd04143ccb247b73ce4cdabea37b
5 files changed +16 -7
src-tauri/Cargo.toml
+1 -1
@@ -15,7 +15,7 @@ tauri-build = { version = "1.2.1", features = [] }
15 [dependencies]
16 serde_json = "1.0"
17 serde = { version = "1.0", features = ["derive"] }
18 -tauri = { version = "1.2.5", features = ["dialog-ask", "dialog-confirm", "dialog-open", "dialog-save", "fs-read-dir", "fs-read-file", "fs-rename-file", "fs-write-file", "path-all", "shell-execute", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
18 +tauri = { version = "1.2.5", features = ["clipboard-write-text", "dialog-ask", "dialog-confirm", "dialog-open", "dialog-save", "fs-read-dir", "fs-read-file", "fs-rename-file", "fs-write-file", "path-all", "shell-execute", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
19
20 [dev-dependencies]
21 windows = "0.32.0"
src-tauri/tauri.conf.json
+5
@@ -25,6 +25,11 @@
25 }
26 ]
27 },
28 + "clipboard": {
29 + "all": false,
30 + "readText": false,
31 + "writeText": true
32 + },
33 "fs": {
34 "all": false,
35 "copyFile": false,
src/lib/FileTree.svelte
+4 -2
@@ -3,6 +3,8 @@
3 import ContextMenu from "./utility/ContextMenu.svelte";
4 import { addEditorTab } from "./EditorTabList.svelte";
5 import { openFolder, openInExplorer } from "./File";
6 + import { clipboard } from "@tauri-apps/api";
7 +
8 let treeDom;
9 let contextmenu = false;
10
@@ -27,8 +29,8 @@
29 {name: "Copy", shortcut: "Ctrl + C", action: () => {console.warn("Feature not implemented yet.")}},
30 {name: "Cut", shortcut: "Ctrl + X", action: () => {console.warn("Feature not implemented yet.")}},
31 {name: "Paste", shortcut: "Ctrl + X", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
30 - {name: "Copy Filename", shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
31 - {name: "Copy Absolute Path", shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
32 + {name: "Copy Filename", shortcut: "", action: async () => {await clipboard.writeText(name)}},
33 + {name: "Copy Absolute Path", shortcut: "", action: async () => {await clipboard.writeText(path)}},
34 {name: "Rename...", shortcut: "F2", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
35 {name: "Delete", shortcut: "Delete", action: () => {console.warn("Feature not implemented yet.")}}
36 ]
src/lib/FileTree/FileTreeList.svelte
+3 -2
@@ -11,6 +11,7 @@
11 import {filetree} from "../FileTree.svelte";
12 import ContextMenu from "../utility/ContextMenu.svelte";
13 import { moveFile, openInExplorer } from "../File";
14 + import { clipboard } from "@tauri-apps/api";
15
16 export let root = false;
17 export let isroot = false;
@@ -34,8 +35,8 @@
35 {name: "Copy", shortcut: "Ctrl + C", action: () => {console.warn("Feature not implemented yet.")}},
36 {name: "Cut", shortcut: "Ctrl + X", action: () => {console.warn("Feature not implemented yet.")}},
37 {name: "Paste", shortcut: "Ctrl + X", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
37 - {name: "Copy Filename", shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
38 - {name: "Copy Absolute Path", shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
38 + {name: "Copy Filename", shortcut: "", action: async () => {await clipboard.writeText(name)}},
39 + {name: "Copy Absolute Path", shortcut: "", action: async () => {await clipboard.writeText(path)}},
40 {name: "Rename...", shortcut: "F2", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
41 {name: "Delete", shortcut: "Delete", action: () => {console.warn("Feature not implemented yet.")}}
42 ]
src/lib/FileTree/FileTreeNode.svelte
+3 -2
@@ -20,6 +20,7 @@
20 import ContextMenu from "../utility/ContextMenu.svelte";
21 import { openInExplorer } from "../File";
22 import { addEditorTab } from "../EditorTabList.svelte";
23 + import { clipboard } from "@tauri-apps/api";
24
25 export let id;
26 export let name;
@@ -36,8 +37,8 @@
37 {name: "Open in File Explorer", shortcut: "", action: async () => {await openInExplorer(path)}},
38 {name: "Copy", shortcut: "Ctrl + C", action: () => {console.warn("Feature not implemented yet.")}},
39 {name: "Cut", shortcut: "Ctrl + X", action: () => {console.warn("Feature not implemented yet.")}},
39 - {name: "Copy Filename", shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
40 - {name: "Copy Absolute Path", shortcut: "", action: () => {console.warn("Feature not implemented yet.")}},
40 + {name: "Copy Filename", shortcut: "", action: async () => {await clipboard.writeText(name)}},
41 + {name: "Copy Absolute Path", shortcut: "", action: async () => {await clipboard.writeText(path)}},
42 {name: "Edit", shortcut: "", action: () => {addEditorTab(path, name)}},
43 {name: "Rename...", shortcut: "F2", disabled: true, action: () => {console.warn("Feature not implemented yet.")}},
44 {name: "Delete", shortcut: "Delete", action: () => {console.warn("Feature not implemented yet.")}}