mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 21:14:28 -08:00
remove dead code
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import {exec} from '../index.js'
|
||||
import {el, stringify, fn_link, scrollIntoViewIfNeeded} from './domutils.js'
|
||||
import {FLAGS} from '../feature_flags.js'
|
||||
import {stringify_for_header} from './value_explorer.js'
|
||||
import {find_node} from '../ast_utils.js'
|
||||
import {is_expandable, root_calltree_node, get_deferred_calls, has_error}
|
||||
@@ -37,23 +36,11 @@ export class CallTree {
|
||||
}
|
||||
|
||||
if(e.key == 'a') {
|
||||
if(FLAGS.embed_value_explorer) {
|
||||
exec('calltree.select_arguments')
|
||||
} else {
|
||||
// TODO make clear that arguments are shown
|
||||
this.ui.eval.show_value(this.state.current_calltree_node.args)
|
||||
this.ui.eval.focus_value_or_error(this.container)
|
||||
}
|
||||
exec('calltree.select_arguments')
|
||||
}
|
||||
|
||||
if(e.key == 'r' || e.key == 'Enter') {
|
||||
if(FLAGS.embed_value_explorer) {
|
||||
exec('calltree.select_return_value')
|
||||
} else {
|
||||
// TODO make clear that return value is shown
|
||||
this.ui.eval.show_value_or_error(this.state.current_calltree_node)
|
||||
this.ui.eval.focus_value_or_error(this.container)
|
||||
}
|
||||
exec('calltree.select_return_value')
|
||||
}
|
||||
|
||||
if(e.key == 'ArrowDown' || e.key == 'j'){
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import {exec, get_state} from '../index.js'
|
||||
import {ValueExplorer, stringify_for_header} from './value_explorer.js'
|
||||
import {el, stringify, fn_link} from './domutils.js'
|
||||
import {FLAGS} from '../feature_flags.js'
|
||||
|
||||
/*
|
||||
normalize events 'change' and 'changeSelection':
|
||||
@@ -173,6 +172,8 @@ export class Editor {
|
||||
|
||||
update_value_explorer_margin() {
|
||||
if(this.widget != null) {
|
||||
// TODO: set margin left based on current line width, not on max line
|
||||
// width?
|
||||
this.widget.content.style.marginLeft =
|
||||
(this.ace_editor.getSession().getScreenWidth() + 1) + 'ch'
|
||||
}
|
||||
@@ -265,15 +266,9 @@ export class Editor {
|
||||
}
|
||||
|
||||
focus_value_explorer(return_to) {
|
||||
if(FLAGS.embed_value_explorer) {
|
||||
if(this.widget != null) {
|
||||
this.widget.return_to = return_to
|
||||
this.widget.content.focus({preventScroll: true})
|
||||
}
|
||||
} else {
|
||||
if(get_state().selection_state != null) {
|
||||
this.ui.eval.focus_value_or_error()
|
||||
}
|
||||
if(this.widget != null) {
|
||||
this.widget.return_to = return_to
|
||||
this.widget.content.focus({preventScroll: true})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,67 +0,0 @@
|
||||
import {ValueExplorer} from './value_explorer.js'
|
||||
import {el} from './domutils.js'
|
||||
|
||||
export class Eval {
|
||||
|
||||
constructor(ui, container) {
|
||||
this.ui = ui
|
||||
this.container = container
|
||||
|
||||
this.container.addEventListener('keydown', (e) => {
|
||||
if(e.key == 'Escape') {
|
||||
this.escape()
|
||||
}
|
||||
})
|
||||
|
||||
// TODO jump to fn location, view function calls
|
||||
// container.addEventListener('click', jump_to_fn_location)
|
||||
|
||||
}
|
||||
|
||||
escape() {
|
||||
if(this.focusedFrom == null) {
|
||||
this.ui.editor.focus()
|
||||
} else {
|
||||
this.focusedFrom.focus()
|
||||
this.focusedFrom = null
|
||||
}
|
||||
}
|
||||
|
||||
show_value(value){
|
||||
this.container.innerHTML = ''
|
||||
const container = el('div', {'class': 'eval_content', tabindex: 0})
|
||||
this.container.appendChild(container)
|
||||
const explorer = new ValueExplorer({
|
||||
container,
|
||||
on_escape: () => this.escape()
|
||||
})
|
||||
explorer.render(value)
|
||||
}
|
||||
|
||||
show_error(error){
|
||||
this.container.innerHTML = ''
|
||||
this.container.appendChild(el('span', 'eval_error', error.toString()))
|
||||
}
|
||||
|
||||
show_value_or_error({ok, value, error}){
|
||||
if(ok) {
|
||||
this.show_value(value)
|
||||
} else {
|
||||
this.show_error(error)
|
||||
}
|
||||
}
|
||||
|
||||
clear_value_or_error() {
|
||||
this.container.innerHTML = ''
|
||||
}
|
||||
|
||||
focus_value_or_error(from) {
|
||||
this.focusedFrom = from
|
||||
if(this.container.childElementCount != 1) {
|
||||
throw new Error('illegal state')
|
||||
}
|
||||
this.container.children[0].focus()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -4,9 +4,7 @@ import {Files} from './files.js'
|
||||
import {CallTree} from './calltree.js'
|
||||
import {Logs} from './logs.js'
|
||||
import {IO_Cache} from './io_cache.js'
|
||||
import {Eval} from './eval.js'
|
||||
import {el} from './domutils.js'
|
||||
import {FLAGS} from '../feature_flags.js'
|
||||
|
||||
export class UI {
|
||||
constructor(container, state){
|
||||
@@ -20,12 +18,8 @@ export class UI {
|
||||
this.debugger = {}
|
||||
|
||||
container.appendChild(
|
||||
(this.root = el('div',
|
||||
'root ' + (FLAGS.embed_value_explorer ? 'embed_value_explorer' : ''),
|
||||
(this.root = el('div', 'root',
|
||||
this.editor_container = el('div', 'editor_container'),
|
||||
FLAGS.embed_value_explorer
|
||||
? null
|
||||
: (this.eval_container = el('div', {class: 'eval'})),
|
||||
el('div', 'bottom',
|
||||
this.debugger_container = el('div', 'debugger',
|
||||
this.debugger_loaded = el('div', 'debugger_wrapper',
|
||||
@@ -173,17 +167,6 @@ export class UI {
|
||||
}
|
||||
})
|
||||
|
||||
if(!FLAGS.embed_value_explorer) {
|
||||
this.eval = new Eval(this, this.eval_container)
|
||||
} else {
|
||||
// Stub
|
||||
this.eval = {
|
||||
show_value_or_error(){},
|
||||
clear_value_or_error(){},
|
||||
focus_value_or_error(){},
|
||||
}
|
||||
}
|
||||
|
||||
this.editor = new Editor(this, this.editor_container)
|
||||
|
||||
this.calltree = new CallTree(this, this.debugger.calltree)
|
||||
|
||||
Reference in New Issue
Block a user