Skip to content

Commit

Permalink
Add Ctrl+U shortcut
Browse files Browse the repository at this point in the history
  • Loading branch information
nuckle committed Dec 13, 2024
1 parent b6c7dc8 commit e91236c
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/views/Commands.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@keydown.ctrl.65.prevent="jumpToStart"
@keydown.ctrl.75.prevent="removeAfterCursor"
@keydown.ctrl.76.prevent="clearTerminal"
@keydown.ctrl.85.prevent="deleteBeforeCursorAndJumpToStart"
>
<input v-model="autocompleteSuggestion" type="text" spellcheck="false" class="terminal__input terminal__input--autocomplete">
</div>
Expand Down Expand Up @@ -341,18 +342,29 @@
this.log = [];
},
jumpToStart() {
this.$refs['terminal-input'].setSelectionRange(0, 0);
const el = this.$refs['terminal-input'];
if (el.setSelectionRange) setTimeout(() => el.setSelectionRange(0, 0), 0);
},
removeAfterCursor() {
const pos = this.$refs['terminal-input'].selectionStart;
this.command = this.command.substr(0, pos);
},
removeBeforeCursor() {
const pos = this.$refs['terminal-input'].selectionStart;
const inputLength = this.$refs['terminal-input'].value.length;
this.command = this.command.substr(pos, inputLength);
},
moveCursorToEnd() {
const el = this.$refs['terminal-input'];
const len = this.command.length;
if (el.setSelectionRange) setTimeout(() => el.setSelectionRange(len, len), 0);
},
deleteBeforeCursorAndJumpToStart() {
this.removeBeforeCursor();
this.jumpToStart();
},
parseCommandsHTML(commandsWikiRaw) {
const virtualDOM = createVirtualDOM(commandsWikiRaw);
const commandsTableHTML = virtualDOM.querySelector('.markdown-heading > h2').parentElement.nextElementSibling;
Expand Down

0 comments on commit e91236c

Please sign in to comment.