mirror of
https://github.com/lllyasviel/stable-diffusion-webui-forge.git
synced 2025-12-28 05:35:00 +00:00
Add Joyride tools for VS Code automation
This commit is contained in:
parent
700daee4d7
commit
273f611cdb
7
.joyride/src/current_selection.cljs
Normal file
7
.joyride/src/current_selection.cljs
Normal file
@ -0,0 +1,7 @@
|
||||
(ns current-selection
|
||||
(:require ["vscode" :as vscode]))
|
||||
|
||||
(defn get-current-selection []
|
||||
(let [editor vscode/window.activeTextEditor]
|
||||
(when editor
|
||||
(.getText (.-document editor) (.-selection editor)))))
|
||||
5
.joyride/src/hello.cljs
Normal file
5
.joyride/src/hello.cljs
Normal file
@ -0,0 +1,5 @@
|
||||
(ns hello
|
||||
(:require ["vscode" :as vscode]))
|
||||
|
||||
(defn greet []
|
||||
(vscode/window.showInformationMessage "Hello from custom Joyride script!"))
|
||||
5
.joyride/src/open_editors.cljs
Normal file
5
.joyride/src/open_editors.cljs
Normal file
@ -0,0 +1,5 @@
|
||||
(ns open-editors
|
||||
(:require ["vscode" :as vscode]))
|
||||
|
||||
(defn get-open-editors []
|
||||
(map #(.-fileName (.-document %)) vscode/window.visibleTextEditors))
|
||||
9
.joyride/src/run_command.cljs
Normal file
9
.joyride/src/run_command.cljs
Normal file
@ -0,0 +1,9 @@
|
||||
(ns run_command
|
||||
(:require ["vscode" :as vscode]))
|
||||
|
||||
(defn execute-command [cmd & args]
|
||||
(apply vscode/commands.executeCommand cmd args))
|
||||
|
||||
(defn open-file [path]
|
||||
(let [uri (vscode/Uri.file path)]
|
||||
(vscode/window.showTextDocument uri)))
|
||||
56
.joyride/src/terminal_interaction.cljs
Normal file
56
.joyride/src/terminal_interaction.cljs
Normal file
@ -0,0 +1,56 @@
|
||||
(ns terminal.interaction
|
||||
(:require ["vscode" :as vscode]))
|
||||
|
||||
;; Helper function to find a terminal by name
|
||||
(defn- find-terminal [name]
|
||||
(first (filter #(= (.-name %) name) (.-terminals vscode/window))))
|
||||
|
||||
;; Helper function to notify user
|
||||
(defn- notify [message]
|
||||
(vscode/window.showInformationMessage message))
|
||||
|
||||
;; List all terminal names
|
||||
(defn list-terminals []
|
||||
(map #(.-name %) (.-terminals vscode/window)))
|
||||
|
||||
;; Create a new terminal and notify
|
||||
(defn create-terminal [name]
|
||||
(let [term (vscode/window.createTerminal name)]
|
||||
(notify (str "Created terminal: " name))
|
||||
term))
|
||||
|
||||
;; Send command to a terminal, creating it if it doesn't exist
|
||||
(defn send-command [cmd & [term-name]]
|
||||
(let [term (if term-name
|
||||
(or (find-terminal term-name)
|
||||
(let [new-term (create-terminal term-name)]
|
||||
new-term))
|
||||
(or (first (.-terminals vscode/window))
|
||||
(create-terminal "default")))]
|
||||
(when term
|
||||
(.sendText term cmd)
|
||||
(notify (str "Sent command: " cmd " to " (or term-name "default") " terminal")))))
|
||||
|
||||
;; Dispose a terminal by name and notify
|
||||
(defn dispose-terminal [name]
|
||||
(let [term (find-terminal name)]
|
||||
(if term
|
||||
(do (.dispose term)
|
||||
(notify (str "Disposed terminal: " name)))
|
||||
(notify (str "Terminal not found: " name)))))
|
||||
|
||||
;; Get the process ID of a terminal (promise)
|
||||
(defn get-terminal-pid [name]
|
||||
(when-let [term (find-terminal name)]
|
||||
(.-processId term)))
|
||||
|
||||
;; Get user input via input box (promise)
|
||||
(defn get-user-input [prompt]
|
||||
(vscode/window.showInputBox {:prompt prompt}))
|
||||
|
||||
;; Select a terminal via quick pick (promise)
|
||||
(defn select-terminal []
|
||||
(let [terms (list-terminals)]
|
||||
(vscode/window.showQuickPick (clj->js terms) {:placeHolder "Select a terminal"})))
|
||||
|
||||
;; Note: Output capture is event-based in VS Code API; use onDidWriteTerminalData for advanced cases
|
||||
9
.joyride/src/workspace_info.cljs
Normal file
9
.joyride/src/workspace_info.cljs
Normal file
@ -0,0 +1,9 @@
|
||||
(ns workspace-info
|
||||
(:require ["vscode" :as vscode]))
|
||||
|
||||
(defn get-workspace-folders []
|
||||
(map #(.-name %) (.-workspaceFolders vscode/workspace)))
|
||||
|
||||
(defn get-workspace-root []
|
||||
(when-let [folders (.-workspaceFolders vscode/workspace)]
|
||||
(.-fsPath (.-uri (first folders)))))
|
||||
Loading…
Reference in New Issue
Block a user