Skip to content

Commit

Permalink
toplevel
Browse files Browse the repository at this point in the history
  • Loading branch information
borkdude committed Nov 21, 2023
1 parent 7ccbd43 commit c3a8a36
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions public/squint/js/demo.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { default_extensions, complete_keymap } from '@nextjournal/clojure-mode';
import { extension as eval_ext, cursor_node_string } from '@nextjournal/clojure-mode/extensions/eval_region';
import { extension as eval_ext, cursor_node_string, top_level_string } from '@nextjournal/clojure-mode/extensions/eval_region';
import { EditorView, drawSelection, keymap } from '@codemirror/view';
import { EditorState } from '@codemirror/state';
import { syntaxHighlighting, defaultHighlightStyle, foldGutter } from '@codemirror/language';
Expand Down Expand Up @@ -48,6 +48,12 @@ let evalCell = (opts) => {
evalCode(code);
}

let evalToplevel = function (opts) {
let state = opts.state;
let code = top_level_string(state);
evalCode(code);
}

function JSONstringify(json) {
json = JSON.stringify(json, function(key, value) {
if (!value) return value;
Expand All @@ -74,7 +80,9 @@ let evalAtCursor = function (opts) {
let squintExtension = ( opts ) => {
return keymap.of([{key: "Alt-Enter", run: evalCell},
{key: opts.modifier + "-Enter",
run: evalAtCursor}])}
run: evalAtCursor,
shift: evalToplevel
}])}


let extensions = [ theme, foldGutter(),
Expand Down

0 comments on commit c3a8a36

Please sign in to comment.