mirror of
https://github.com/leporello-js/leporello-js
synced 2026-01-13 13:04:30 -08:00
remove dead code
This commit is contained in:
27
index.html
27
index.html
@@ -33,20 +33,12 @@
|
||||
.root {
|
||||
height: 100%;
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"code eval"
|
||||
"bottom bottom"
|
||||
"statusbar statusbar";
|
||||
grid-template-columns: 60% 40%;
|
||||
grid-template-rows: 1fr 0.7fr 2.5em;
|
||||
}
|
||||
|
||||
.root.embed_value_explorer {
|
||||
grid-template-areas:
|
||||
"code code"
|
||||
"bottom files"
|
||||
"statusbar statusbar";
|
||||
grid-template-columns: 70% 30%;
|
||||
grid-template-rows: 1fr 0.7fr 2.5em;
|
||||
}
|
||||
|
||||
.root.fullscreen_editor {
|
||||
@@ -54,17 +46,16 @@
|
||||
grid-template-rows: 1fr 0fr 2.5em;
|
||||
}
|
||||
|
||||
.editor_container, .bottom, .eval, .files_container, .statusbar {
|
||||
.editor_container, .bottom, .files_container, .statusbar {
|
||||
box-shadow: 1px 1px 3px 0px var(--shadow_color);
|
||||
}
|
||||
|
||||
.editor_container, .eval, .bottom, .statusbar, .files_container {
|
||||
.editor_container, .bottom, .statusbar, .files_container {
|
||||
margin: 8px;
|
||||
}
|
||||
|
||||
.editor_container:focus-within,
|
||||
.bottom:focus-within,
|
||||
.eval:focus-within,
|
||||
.files_container:focus-within,
|
||||
.help_dialog {
|
||||
outline: none;
|
||||
@@ -81,18 +72,6 @@
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.eval {
|
||||
display: grid;
|
||||
grid-area: eval;
|
||||
overflow: auto;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.eval_content {
|
||||
padding: 5px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* ace markers */
|
||||
|
||||
.selection {
|
||||
|
||||
@@ -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)
|
||||
|
||||
24
src/effects.js
vendored
24
src/effects.js
vendored
@@ -6,7 +6,6 @@ import {
|
||||
get_deferred_calls
|
||||
} from './calltree.js'
|
||||
import {current_cursor_position} from './calltree.js'
|
||||
import {FLAGS} from './feature_flags.js'
|
||||
import {exec, FILES_ROOT} from './index.js'
|
||||
|
||||
// Imports in the context of `run_window`, so global variables in loaded
|
||||
@@ -221,7 +220,6 @@ export const render_common_side_effects = (prev, next, command, ui) => {
|
||||
} else {
|
||||
// Rerender entire calltree
|
||||
ui.render_debugger(next)
|
||||
ui.eval.clear_value_or_error()
|
||||
clear_coloring(ui)
|
||||
render_coloring(ui, next)
|
||||
ui.logs.rerender_logs(next.logs)
|
||||
@@ -255,14 +253,6 @@ export const render_common_side_effects = (prev, next, command, ui) => {
|
||||
ui.calltree.render_select_node(prev, next)
|
||||
}
|
||||
|
||||
if(node_changed) {
|
||||
if(!next.current_calltree_node.toplevel) {
|
||||
ui.eval.show_value_or_error(next.current_calltree_node)
|
||||
} else {
|
||||
ui.eval.clear_value_or_error()
|
||||
}
|
||||
}
|
||||
|
||||
if(prev.calltree_node_by_loc != next.calltree_node_by_loc) {
|
||||
render_coloring(ui, next)
|
||||
}
|
||||
@@ -290,15 +280,11 @@ export const render_common_side_effects = (prev, next, command, ui) => {
|
||||
|
||||
const selresult = next.selection_state?.result
|
||||
if(selresult != null && prev.selection_state?.result != selresult) {
|
||||
if(FLAGS.embed_value_explorer) {
|
||||
const node = next.selection_state.node
|
||||
ui.editor.embed_value_explorer({
|
||||
index: node.index + node.length,
|
||||
result: next.selection_state.result,
|
||||
})
|
||||
} else {
|
||||
ui.eval.show_value_or_error(next.selection_state.result)
|
||||
}
|
||||
const node = next.selection_state.node
|
||||
ui.editor.embed_value_explorer({
|
||||
index: node.index + node.length,
|
||||
result: next.selection_state.result,
|
||||
})
|
||||
}
|
||||
|
||||
// Value explorer
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
export const FLAGS = {
|
||||
embed_value_explorer: true,
|
||||
}
|
||||
Reference in New Issue
Block a user