Can now save (apply) stuff from textEditor with annotations
This commit is contained in:
parent
479abf7996
commit
ef48a4f468
2 changed files with 5 additions and 3 deletions
|
|
@ -138,7 +138,8 @@ textEditor = name \
|
||||||
{ state = state, emit = [rebindAt [buffersKey, name] content] };
|
{ state = state, emit = [rebindAt [buffersKey, name] content] };
|
||||||
|
|
||||||
apply = state \
|
apply = state \
|
||||||
content = name & " = " & (join "\n" state.lines) & ";";
|
# content = name & " = " & (join "\n" state.lines) & ";";
|
||||||
|
content = (join "\n" state.lines);
|
||||||
result = eval! content;
|
result = eval! content;
|
||||||
_ = debug! "apply" [content, result];
|
_ = debug! "apply" [content, result];
|
||||||
result
|
result
|
||||||
|
|
|
||||||
|
|
@ -202,7 +202,7 @@ export const _rt = {
|
||||||
const trimmed = code.trim();
|
const trimmed = code.trim();
|
||||||
|
|
||||||
// is it a definition
|
// is it a definition
|
||||||
const defMatch = /^([a-z_][a-zA-Z0-9_]*)\s*=(?![=])/.exec(trimmed);
|
const defMatch = /^([a-z_][a-zA-Z0-9_]*)\s*[:=]/.exec(trimmed);
|
||||||
|
|
||||||
if (defMatch) {
|
if (defMatch) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -214,7 +214,8 @@ export const _rt = {
|
||||||
if (defs.length > 0) {
|
if (defs.length > 0) {
|
||||||
const def = defs[0];
|
const def = defs[0];
|
||||||
recompile(def.name, def.body!);
|
recompile(def.name, def.body!);
|
||||||
const source = prettyPrint({ kind: 'definition', name: def.name, body: def.body });
|
definitions.set(def.name, def);
|
||||||
|
const source = prettyPrint(def);
|
||||||
appendChangeLog(def.name, source);
|
appendChangeLog(def.name, source);
|
||||||
saveDefinitions();
|
saveDefinitions();
|
||||||
return { _tag: 'Defined', _0: def.name };
|
return { _tag: 'Defined', _0: def.name };
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue