From 5c104a8f15c3e56b7066326ce73fe71853bc14fb Mon Sep 17 00:00:00 2001 From: crc <> Date: Mon, 25 Jul 2022 13:14:27 +0000 Subject: [PATCH] retro/ilo editor port: now able to run code in a block! FossilOrigin-Name: ea26b50243276e68a62cdf64db13d958aa7621539c8abe52a27c0361582f12c6 --- example/rilo-editor.retro | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/example/rilo-editor.retro b/example/rilo-editor.retro index ee27d84..75ee254 100644 --- a/example/rilo-editor.retro +++ b/example/rilo-editor.retro @@ -111,7 +111,34 @@ data store limits. ~~~ ~~~ -:run &block:buffer ; +{{ + 'max-length var + 'source var + 'index var + 'token d:create #65 allot + + :eoi? &index &max-length &fetch bi@ gt? ; + :eow? &token fetch &token n:add fetch + [ #32 eq? ] [ #0 eq? ] bi or ; + :set-input + #0 &index store + [ &source store ] [ a:length &max-length store ] bi ; + :get-char + &source fetch &index fetch a:fetch + &token v:inc &index v:inc + &token fetch &token n:add store ; + :parse-word + #0 &token store + [ get-char eow? eoi? or ] until + &token dup v:dec ; + :count-words #1 swap [ #32 eq? &n:inc if ] a:for-each ; + :valid? dup a:length n:-zero? ; + :s:evaluate + &set-input &count-words bi + [ parse-word valid? [ a:to-string interpret ] &drop choose ] times ; +---reveal--- + :run &block:buffer n:dec #1024 over store s:evaluate ; +}} :use (block) set load run ;