Is your feature request related to a problem? Please describe.
In an attempt to add shortcuts for copy/paste/cut/undo/redo/delete I had disabled the system functions and attempted to make my own so that the functions can be bounded to other key combinations as the user wishes.
Right now it is not ideal and so using these functions through the edit menu or triggering them through a custom key combination isn't possible.
Also, disabling system functions isn't a good idea anyways.
Describe the solution you'd like
When you press a button in the edit menu, paste for example, it should paste whatever content in the users clipboard into the editor area or any input field that is focused. This should also happen if you have a custom key combination. The default system shortcut should also still work.
Ideally what I need is a way to trigger these system input functions so that they can work via pressing a button or using a custom key combination.
Additional context
For context this was my solution to making my own functions for the editor area. This isn't a great solution, its very messy, and is only local to the editor area, not other input fields. This code will probably be deleted once the solution is found but it shows what I was going for.
|
export async function append(value: string) { |
|
let cursorpos = getCurrentEditor().getView().state.selection.main.head + value.length; |
|
const lines = value.split("\n").length - 1; |
|
if (lines > 0) { |
|
cursorpos -= lines; |
|
} |
|
getCurrentEditor().getView().dispatch({ |
|
changes: { |
|
from: getCurrentEditor().getView().state.selection.ranges[0].from, |
|
to: getCurrentEditor().getView().state.selection.ranges[0].to, |
|
insert: value, |
|
}, |
|
selection: {anchor: cursorpos, head: cursorpos}, |
|
scrollIntoView: true |
|
}) |
|
await getCurrentEditor().updateContent(); |
|
getCurrentEditor().updateLineInfo(); |
|
} |
|
export async function copy() { |
|
const selection = getCurrentEditor().getView().state.sliceDoc(getCurrentEditor().getView().state.selection.main.from, getCurrentEditor().getView().state.selection.main.to) |
|
await navigator.clipboard.writeText(selection); |
|
} |
|
export async function cut() { |
|
deleteToLineEnd(getCurrentEditor().getView()) |
|
await getCurrentEditor().updateContent(); |
|
getCurrentEditor().updateLineInfo(); |
|
} |
|
export async function undoChange() { |
|
undo(getCurrentEditor().getView()); |
|
await getCurrentEditor().updateContent(); |
|
getCurrentEditor().updateLineInfo(); |
|
} |
|
export async function redoChange() { |
|
redo(getCurrentEditor().getView()); |
|
await getCurrentEditor().updateContent(); |
|
getCurrentEditor().updateLineInfo(); |
|
} |
|
export async function deleteChars() { |
|
deleteCharForward(getCurrentEditor().getView()); |
|
await getCurrentEditor().updateContent(); |
|
getCurrentEditor().updateLineInfo(); |
|
} |
I'm not sure how possible it is to access copy/paste/cut/undo/redo/delete through the browser or in rust but I assume there is a way since VSCode seems to have figured it out.
Is your feature request related to a problem? Please describe.
In an attempt to add shortcuts for copy/paste/cut/undo/redo/delete I had disabled the system functions and attempted to make my own so that the functions can be bounded to other key combinations as the user wishes.
Right now it is not ideal and so using these functions through the edit menu or triggering them through a custom key combination isn't possible.
Also, disabling system functions isn't a good idea anyways.
Describe the solution you'd like
When you press a button in the edit menu, paste for example, it should paste whatever content in the users clipboard into the editor area or any input field that is focused. This should also happen if you have a custom key combination. The default system shortcut should also still work.
Ideally what I need is a way to trigger these system input functions so that they can work via pressing a button or using a custom key combination.
Additional context
For context this was my solution to making my own functions for the editor area. This isn't a great solution, its very messy, and is only local to the editor area, not other input fields. This code will probably be deleted once the solution is found but it shows what I was going for.
Nucleus/src/lib/Editor.svelte
Lines 151 to 192 in fb0a03d
I'm not sure how possible it is to access copy/paste/cut/undo/redo/delete through the browser or in rust but I assume there is a way since VSCode seems to have figured it out.