Delete line command (#866)

pull/873/head
pihentagy 2024-05-25 23:12:48 +02:00 committed by GitHub
parent 827b08c21f
commit 0e3c5587f5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 19 additions and 2 deletions

View File

@ -1,4 +1,4 @@
This folder contains two things: This folder contains two things:
* Wrappers for `syscall`s to be used by Plugs * Wrappers for `syscall`s to be used by Plugs
* Reusablee library code that plugs may find useful * Reusable library code that plugs may find useful

View File

@ -211,3 +211,7 @@ export function openSearchPanel() {
export function copyToClipboard(data: string | Blob): Promise<void> { export function copyToClipboard(data: string | Blob): Promise<void> {
return syscall("editor.copyToClipboard", data); return syscall("editor.copyToClipboard", data);
} }
export function deleteLine() {
return syscall("editor.deleteLine");
}

View File

@ -163,6 +163,12 @@ functions:
name: "Navigate: Center Cursor" name: "Navigate: Center Cursor"
key: "Ctrl-Alt-l" key: "Ctrl-Alt-l"
requireMode: rw requireMode: rw
deleteLine:
path: "./editor.ts:deleteLineCommand"
command:
name: "Delete Line"
key: "Ctrl-d"
requireMode: rw
# Debug commands # Debug commands
parseCommand: parseCommand:

View File

@ -64,3 +64,7 @@ export function undoCommand() {
export function redoCommand() { export function redoCommand() {
return editor.redo(); return editor.redo();
} }
export function deleteLineCommand() {
return editor.deleteLine();
}

View File

@ -6,7 +6,7 @@ import {
unfoldAll, unfoldAll,
unfoldCode, unfoldCode,
} from "@codemirror/language"; } from "@codemirror/language";
import { redo, undo } from "@codemirror/commands"; import { deleteLine, redo, undo } from "@codemirror/commands";
import { Transaction } from "@codemirror/state"; import { Transaction } from "@codemirror/state";
import { EditorView } from "@codemirror/view"; import { EditorView } from "@codemirror/view";
import { getCM as vimGetCm, Vim } from "@replit/codemirror-vim"; import { getCM as vimGetCm, Vim } from "@replit/codemirror-vim";
@ -272,6 +272,9 @@ export function editorSyscalls(client: Client): SysCallMapping {
context: client.getContext(), context: client.getContext(),
}); });
}, },
"editor.deleteLine": () => {
deleteLine(client.editorView);
},
// Folding // Folding
"editor.fold": () => { "editor.fold": () => {
foldCode(client.editorView); foldCode(client.editorView);