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
|
||||
e.preventDefault()
|
||||
|
||||
if(e.key == 'Escape') {
|
||||
this.ui.editor.focus()
|
||||
}
|
||||
|
||||
if(e.key == 'F1') {
|
||||
this.ui.editor.focus_value_explorer(this.container)
|
||||
}
|
||||
|
||||
@@ -291,28 +291,10 @@ export class Editor {
|
||||
|
||||
const VimApi = require("ace/keyboard/vim").CodeMirror.Vim
|
||||
|
||||
|
||||
this.ace_editor.commands.bindKey("F2", "switch_window");
|
||||
VimApi._mapCommand({
|
||||
keys: '<C-w>',
|
||||
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')
|
||||
}
|
||||
})
|
||||
// Remove commands binded to function keys that we are going to redefine
|
||||
this.ace_editor.commands.removeCommand('openCommandPallete')
|
||||
this.ace_editor.commands.removeCommand('toggleFoldWidget')
|
||||
this.ace_editor.commands.removeCommand('goToNextError')
|
||||
|
||||
|
||||
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.addCommand({
|
||||
|
||||
@@ -8,6 +8,10 @@ export class Logs {
|
||||
this.ui = ui
|
||||
this.el.addEventListener('keydown', (e) => {
|
||||
|
||||
if(e.key == 'Escape') {
|
||||
this.ui.editor.focus()
|
||||
}
|
||||
|
||||
if(e.key == 'Enter') {
|
||||
// TODO reselect call node that was selected previously by calling
|
||||
// 'calltree.navigate_logs_position'
|
||||
|
||||
@@ -114,34 +114,19 @@ export class UI {
|
||||
this.root.addEventListener('keydown', () => this.clear_status(), true)
|
||||
this.root.addEventListener('click', () => this.clear_status(), true)
|
||||
|
||||
this.editor_container.addEventListener('keydown', e => {
|
||||
// Bind F2 and F3 for embed_value_explorer
|
||||
if(
|
||||
e.key.toLowerCase() == 'w' && e.ctrlKey == true
|
||||
||
|
||||
e.key == 'F2'
|
||||
){
|
||||
this.root.addEventListener('keydown', e => {
|
||||
if(e.key == 'F2') {
|
||||
this.set_active_tab('calltree')
|
||||
}
|
||||
|
||||
if(e.key == 'F3'){
|
||||
this.set_active_tab('logs')
|
||||
}
|
||||
})
|
||||
|
||||
const escape = e => {
|
||||
if(
|
||||
(e.key.toLowerCase() == 'w' && e.ctrlKey == true)
|
||||
||
|
||||
e.key == 'Escape'
|
||||
){
|
||||
this.editor.focus()
|
||||
if(e.key == 'F5'){
|
||||
this.fullscreen_editor()
|
||||
}
|
||||
}
|
||||
|
||||
this.debugger.calltree.addEventListener('keydown', escape)
|
||||
this.debugger.logs.addEventListener('keydown', escape)
|
||||
|
||||
})
|
||||
|
||||
if(!FLAGS.embed_value_explorer) {
|
||||
this.eval = new Eval(this, this.eval_container)
|
||||
@@ -270,12 +255,13 @@ export class UI {
|
||||
const options = [
|
||||
['Focus value explorer', 'F1'],
|
||||
['Navigate value explorer', '← → ↑ ↓ or hjkl'],
|
||||
['Leave value explorer', 'Esc'],
|
||||
['Switch between editor and call tree view', 'F2 or Ctrl-w'],
|
||||
['Leave value explorer', 'F1 or Esc'],
|
||||
['Focus call tree view', 'F2'],
|
||||
['Navigate call tree view', '← → ↑ ↓ or hjkl'],
|
||||
['Leave call tree view', 'F2 or Esc'],
|
||||
['Focus console logs', 'F3'],
|
||||
['Navigate console logs', '↑ ↓ or jk'],
|
||||
['Leave console logs', 'F3 or Esc'],
|
||||
['Jump to definition', 'F4', 'gd'],
|
||||
['Expand selection to eval expression', 'Ctrl-↓ or Ctrl-j'],
|
||||
['Collapse selection', 'Ctrl-↑ or Ctrl-k'],
|
||||
@@ -318,6 +304,9 @@ export class UI {
|
||||
fullscreen_editor() {
|
||||
this.root.classList.toggle('fullscreen_editor')
|
||||
this.editor.ace_editor.resize()
|
||||
if(this.root.classList.contains('fullscreen_editor')) {
|
||||
this.editor.focus()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -129,6 +129,11 @@ export class ValueExplorer {
|
||||
|
||||
Click - select and toggles expand
|
||||
*/
|
||||
|
||||
if(e.key == 'F1') {
|
||||
this.on_escape()
|
||||
return
|
||||
}
|
||||
|
||||
const current_object = get_path(this.value, this.current_path)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user