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:
27
index.html
27
index.html
@@ -33,20 +33,12 @@
|
|||||||
.root {
|
.root {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
display: grid;
|
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:
|
grid-template-areas:
|
||||||
"code code"
|
"code code"
|
||||||
"bottom files"
|
"bottom files"
|
||||||
"statusbar statusbar";
|
"statusbar statusbar";
|
||||||
grid-template-columns: 70% 30%;
|
grid-template-columns: 70% 30%;
|
||||||
|
grid-template-rows: 1fr 0.7fr 2.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root.fullscreen_editor {
|
.root.fullscreen_editor {
|
||||||
@@ -54,17 +46,16 @@
|
|||||||
grid-template-rows: 1fr 0fr 2.5em;
|
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);
|
box-shadow: 1px 1px 3px 0px var(--shadow_color);
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor_container, .eval, .bottom, .statusbar, .files_container {
|
.editor_container, .bottom, .statusbar, .files_container {
|
||||||
margin: 8px;
|
margin: 8px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.editor_container:focus-within,
|
.editor_container:focus-within,
|
||||||
.bottom:focus-within,
|
.bottom:focus-within,
|
||||||
.eval:focus-within,
|
|
||||||
.files_container:focus-within,
|
.files_container:focus-within,
|
||||||
.help_dialog {
|
.help_dialog {
|
||||||
outline: none;
|
outline: none;
|
||||||
@@ -81,18 +72,6 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.eval {
|
|
||||||
display: grid;
|
|
||||||
grid-area: eval;
|
|
||||||
overflow: auto;
|
|
||||||
white-space: pre;
|
|
||||||
}
|
|
||||||
|
|
||||||
.eval_content {
|
|
||||||
padding: 5px;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ace markers */
|
/* ace markers */
|
||||||
|
|
||||||
.selection {
|
.selection {
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import {exec} from '../index.js'
|
import {exec} from '../index.js'
|
||||||
import {el, stringify, fn_link, scrollIntoViewIfNeeded} from './domutils.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 {stringify_for_header} from './value_explorer.js'
|
||||||
import {find_node} from '../ast_utils.js'
|
import {find_node} from '../ast_utils.js'
|
||||||
import {is_expandable, root_calltree_node, get_deferred_calls, has_error}
|
import {is_expandable, root_calltree_node, get_deferred_calls, has_error}
|
||||||
@@ -37,23 +36,11 @@ export class CallTree {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == 'a') {
|
if(e.key == 'a') {
|
||||||
if(FLAGS.embed_value_explorer) {
|
|
||||||
exec('calltree.select_arguments')
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == 'r' || e.key == 'Enter') {
|
if(e.key == 'r' || e.key == 'Enter') {
|
||||||
if(FLAGS.embed_value_explorer) {
|
|
||||||
exec('calltree.select_return_value')
|
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)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(e.key == 'ArrowDown' || e.key == 'j'){
|
if(e.key == 'ArrowDown' || e.key == 'j'){
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import {exec, get_state} from '../index.js'
|
import {exec, get_state} from '../index.js'
|
||||||
import {ValueExplorer, stringify_for_header} from './value_explorer.js'
|
import {ValueExplorer, stringify_for_header} from './value_explorer.js'
|
||||||
import {el, stringify, fn_link} from './domutils.js'
|
import {el, stringify, fn_link} from './domutils.js'
|
||||||
import {FLAGS} from '../feature_flags.js'
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
normalize events 'change' and 'changeSelection':
|
normalize events 'change' and 'changeSelection':
|
||||||
@@ -173,6 +172,8 @@ export class Editor {
|
|||||||
|
|
||||||
update_value_explorer_margin() {
|
update_value_explorer_margin() {
|
||||||
if(this.widget != null) {
|
if(this.widget != null) {
|
||||||
|
// TODO: set margin left based on current line width, not on max line
|
||||||
|
// width?
|
||||||
this.widget.content.style.marginLeft =
|
this.widget.content.style.marginLeft =
|
||||||
(this.ace_editor.getSession().getScreenWidth() + 1) + 'ch'
|
(this.ace_editor.getSession().getScreenWidth() + 1) + 'ch'
|
||||||
}
|
}
|
||||||
@@ -265,16 +266,10 @@ export class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
focus_value_explorer(return_to) {
|
focus_value_explorer(return_to) {
|
||||||
if(FLAGS.embed_value_explorer) {
|
|
||||||
if(this.widget != null) {
|
if(this.widget != null) {
|
||||||
this.widget.return_to = return_to
|
this.widget.return_to = return_to
|
||||||
this.widget.content.focus({preventScroll: true})
|
this.widget.content.focus({preventScroll: true})
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if(get_state().selection_state != null) {
|
|
||||||
this.ui.eval.focus_value_or_error()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
set_keyboard_handler(type) {
|
set_keyboard_handler(type) {
|
||||||
|
|||||||
@@ -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 {CallTree} from './calltree.js'
|
||||||
import {Logs} from './logs.js'
|
import {Logs} from './logs.js'
|
||||||
import {IO_Cache} from './io_cache.js'
|
import {IO_Cache} from './io_cache.js'
|
||||||
import {Eval} from './eval.js'
|
|
||||||
import {el} from './domutils.js'
|
import {el} from './domutils.js'
|
||||||
import {FLAGS} from '../feature_flags.js'
|
|
||||||
|
|
||||||
export class UI {
|
export class UI {
|
||||||
constructor(container, state){
|
constructor(container, state){
|
||||||
@@ -20,12 +18,8 @@ export class UI {
|
|||||||
this.debugger = {}
|
this.debugger = {}
|
||||||
|
|
||||||
container.appendChild(
|
container.appendChild(
|
||||||
(this.root = el('div',
|
(this.root = el('div', 'root',
|
||||||
'root ' + (FLAGS.embed_value_explorer ? 'embed_value_explorer' : ''),
|
|
||||||
this.editor_container = el('div', 'editor_container'),
|
this.editor_container = el('div', 'editor_container'),
|
||||||
FLAGS.embed_value_explorer
|
|
||||||
? null
|
|
||||||
: (this.eval_container = el('div', {class: 'eval'})),
|
|
||||||
el('div', 'bottom',
|
el('div', 'bottom',
|
||||||
this.debugger_container = el('div', 'debugger',
|
this.debugger_container = el('div', 'debugger',
|
||||||
this.debugger_loaded = el('div', 'debugger_wrapper',
|
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.editor = new Editor(this, this.editor_container)
|
||||||
|
|
||||||
this.calltree = new CallTree(this, this.debugger.calltree)
|
this.calltree = new CallTree(this, this.debugger.calltree)
|
||||||
|
|||||||
14
src/effects.js
vendored
14
src/effects.js
vendored
@@ -6,7 +6,6 @@ import {
|
|||||||
get_deferred_calls
|
get_deferred_calls
|
||||||
} from './calltree.js'
|
} from './calltree.js'
|
||||||
import {current_cursor_position} from './calltree.js'
|
import {current_cursor_position} from './calltree.js'
|
||||||
import {FLAGS} from './feature_flags.js'
|
|
||||||
import {exec, FILES_ROOT} from './index.js'
|
import {exec, FILES_ROOT} from './index.js'
|
||||||
|
|
||||||
// Imports in the context of `run_window`, so global variables in loaded
|
// 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 {
|
} else {
|
||||||
// Rerender entire calltree
|
// Rerender entire calltree
|
||||||
ui.render_debugger(next)
|
ui.render_debugger(next)
|
||||||
ui.eval.clear_value_or_error()
|
|
||||||
clear_coloring(ui)
|
clear_coloring(ui)
|
||||||
render_coloring(ui, next)
|
render_coloring(ui, next)
|
||||||
ui.logs.rerender_logs(next.logs)
|
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)
|
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) {
|
if(prev.calltree_node_by_loc != next.calltree_node_by_loc) {
|
||||||
render_coloring(ui, next)
|
render_coloring(ui, next)
|
||||||
}
|
}
|
||||||
@@ -290,15 +280,11 @@ export const render_common_side_effects = (prev, next, command, ui) => {
|
|||||||
|
|
||||||
const selresult = next.selection_state?.result
|
const selresult = next.selection_state?.result
|
||||||
if(selresult != null && prev.selection_state?.result != selresult) {
|
if(selresult != null && prev.selection_state?.result != selresult) {
|
||||||
if(FLAGS.embed_value_explorer) {
|
|
||||||
const node = next.selection_state.node
|
const node = next.selection_state.node
|
||||||
ui.editor.embed_value_explorer({
|
ui.editor.embed_value_explorer({
|
||||||
index: node.index + node.length,
|
index: node.index + node.length,
|
||||||
result: next.selection_state.result,
|
result: next.selection_state.result,
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
ui.eval.show_value_or_error(next.selection_state.result)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Value explorer
|
// Value explorer
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
export const FLAGS = {
|
|
||||||
embed_value_explorer: true,
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user