mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
refactor key bindings
This commit is contained in:
@@ -23,6 +23,10 @@ export class CallTree {
|
|||||||
// Do not scroll
|
// Do not scroll
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
||||||
|
if(e.key == 'Escape') {
|
||||||
|
this.ui.editor.focus()
|
||||||
|
}
|
||||||
|
|
||||||
if(e.key == 'F1') {
|
if(e.key == 'F1') {
|
||||||
this.ui.editor.focus_value_explorer(this.container)
|
this.ui.editor.focus_value_explorer(this.container)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -291,28 +291,10 @@ export class Editor {
|
|||||||
|
|
||||||
const VimApi = require("ace/keyboard/vim").CodeMirror.Vim
|
const VimApi = require("ace/keyboard/vim").CodeMirror.Vim
|
||||||
|
|
||||||
|
// Remove commands binded to function keys that we are going to redefine
|
||||||
this.ace_editor.commands.bindKey("F2", "switch_window");
|
this.ace_editor.commands.removeCommand('openCommandPallete')
|
||||||
VimApi._mapCommand({
|
this.ace_editor.commands.removeCommand('toggleFoldWidget')
|
||||||
keys: '<C-w>',
|
this.ace_editor.commands.removeCommand('goToNextError')
|
||||||
type: 'action',
|
|
||||||
action: 'aceCommand',
|
|
||||||
actionArgs: { name: "switch_window" }
|
|
||||||
})
|
|
||||||
this.ace_editor.commands.addCommand({
|
|
||||||
name: 'switch_window',
|
|
||||||
exec: (editor) => {
|
|
||||||
this.ui.set_active_tab('calltree')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
this.ace_editor.commands.bindKey("F3", "focus_logs");
|
|
||||||
this.ace_editor.commands.addCommand({
|
|
||||||
name: 'focus_logs',
|
|
||||||
exec: (editor) => {
|
|
||||||
this.ui.set_active_tab('logs')
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
this.ace_editor.commands.bindKey("F4", "goto_definition");
|
this.ace_editor.commands.bindKey("F4", "goto_definition");
|
||||||
@@ -329,14 +311,6 @@ export class Editor {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
this.ace_editor.commands.bindKey("F5", "fullscreen_editor");
|
|
||||||
this.ace_editor.commands.addCommand({
|
|
||||||
name: 'fullscreen_editor',
|
|
||||||
exec: (editor) => {
|
|
||||||
this.ui.fullscreen_editor()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
this.ace_editor.commands.bindKey("F1", "focus_value_explorer");
|
this.ace_editor.commands.bindKey("F1", "focus_value_explorer");
|
||||||
this.ace_editor.commands.addCommand({
|
this.ace_editor.commands.addCommand({
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ export class Logs {
|
|||||||
this.ui = ui
|
this.ui = ui
|
||||||
this.el.addEventListener('keydown', (e) => {
|
this.el.addEventListener('keydown', (e) => {
|
||||||
|
|
||||||
|
if(e.key == 'Escape') {
|
||||||
|
this.ui.editor.focus()
|
||||||
|
}
|
||||||
|
|
||||||
if(e.key == 'Enter') {
|
if(e.key == 'Enter') {
|
||||||
// TODO reselect call node that was selected previously by calling
|
// TODO reselect call node that was selected previously by calling
|
||||||
// 'calltree.navigate_logs_position'
|
// 'calltree.navigate_logs_position'
|
||||||
|
|||||||
@@ -114,35 +114,20 @@ export class UI {
|
|||||||
this.root.addEventListener('keydown', () => this.clear_status(), true)
|
this.root.addEventListener('keydown', () => this.clear_status(), true)
|
||||||
this.root.addEventListener('click', () => this.clear_status(), true)
|
this.root.addEventListener('click', () => this.clear_status(), true)
|
||||||
|
|
||||||
this.editor_container.addEventListener('keydown', e => {
|
this.root.addEventListener('keydown', e => {
|
||||||
// Bind F2 and F3 for embed_value_explorer
|
if(e.key == 'F2') {
|
||||||
if(
|
|
||||||
e.key.toLowerCase() == 'w' && e.ctrlKey == true
|
|
||||||
||
|
|
||||||
e.key == 'F2'
|
|
||||||
){
|
|
||||||
this.set_active_tab('calltree')
|
this.set_active_tab('calltree')
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == 'F3'){
|
if(e.key == 'F3'){
|
||||||
this.set_active_tab('logs')
|
this.set_active_tab('logs')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(e.key == 'F5'){
|
||||||
|
this.fullscreen_editor()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const escape = e => {
|
|
||||||
if(
|
|
||||||
(e.key.toLowerCase() == 'w' && e.ctrlKey == true)
|
|
||||||
||
|
|
||||||
e.key == 'Escape'
|
|
||||||
){
|
|
||||||
this.editor.focus()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.debugger.calltree.addEventListener('keydown', escape)
|
|
||||||
this.debugger.logs.addEventListener('keydown', escape)
|
|
||||||
|
|
||||||
|
|
||||||
if(!FLAGS.embed_value_explorer) {
|
if(!FLAGS.embed_value_explorer) {
|
||||||
this.eval = new Eval(this, this.eval_container)
|
this.eval = new Eval(this, this.eval_container)
|
||||||
} else {
|
} else {
|
||||||
@@ -270,12 +255,13 @@ export class UI {
|
|||||||
const options = [
|
const options = [
|
||||||
['Focus value explorer', 'F1'],
|
['Focus value explorer', 'F1'],
|
||||||
['Navigate value explorer', '← → ↑ ↓ or hjkl'],
|
['Navigate value explorer', '← → ↑ ↓ or hjkl'],
|
||||||
['Leave value explorer', 'Esc'],
|
['Leave value explorer', 'F1 or Esc'],
|
||||||
['Switch between editor and call tree view', 'F2 or Ctrl-w'],
|
['Focus call tree view', 'F2'],
|
||||||
['Navigate call tree view', '← → ↑ ↓ or hjkl'],
|
['Navigate call tree view', '← → ↑ ↓ or hjkl'],
|
||||||
['Leave call tree view', 'F2 or Esc'],
|
['Leave call tree view', 'F2 or Esc'],
|
||||||
['Focus console logs', 'F3'],
|
['Focus console logs', 'F3'],
|
||||||
['Navigate console logs', '↑ ↓ or jk'],
|
['Navigate console logs', '↑ ↓ or jk'],
|
||||||
|
['Leave console logs', 'F3 or Esc'],
|
||||||
['Jump to definition', 'F4', 'gd'],
|
['Jump to definition', 'F4', 'gd'],
|
||||||
['Expand selection to eval expression', 'Ctrl-↓ or Ctrl-j'],
|
['Expand selection to eval expression', 'Ctrl-↓ or Ctrl-j'],
|
||||||
['Collapse selection', 'Ctrl-↑ or Ctrl-k'],
|
['Collapse selection', 'Ctrl-↑ or Ctrl-k'],
|
||||||
@@ -318,6 +304,9 @@ export class UI {
|
|||||||
fullscreen_editor() {
|
fullscreen_editor() {
|
||||||
this.root.classList.toggle('fullscreen_editor')
|
this.root.classList.toggle('fullscreen_editor')
|
||||||
this.editor.ace_editor.resize()
|
this.editor.ace_editor.resize()
|
||||||
|
if(this.root.classList.contains('fullscreen_editor')) {
|
||||||
|
this.editor.focus()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,6 +130,11 @@ export class ValueExplorer {
|
|||||||
Click - select and toggles expand
|
Click - select and toggles expand
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
if(e.key == 'F1') {
|
||||||
|
this.on_escape()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const current_object = get_path(this.value, this.current_path)
|
const current_object = get_path(this.value, this.current_path)
|
||||||
|
|
||||||
if(e.key == 'ArrowDown' || e.key == 'j'){
|
if(e.key == 'ArrowDown' || e.key == 'j'){
|
||||||
|
|||||||
Reference in New Issue
Block a user