From dc28e9ba97aaa02c42699a76ee22dd2cf399d24f Mon Sep 17 00:00:00 2001 From: crc Date: Thu, 30 May 2019 19:18:06 +0000 Subject: [PATCH] the start of a new listener... FossilOrigin-Name: 8759fd23c7c94e38a6d4b8073cda18cd6a0e9dd13fdb0594ed7906f0efe3f9bf --- RELEASE_NOTES.md | 5 +-- example/alternate-listener.forth | 57 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 example/alternate-listener.forth diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index eea8fe6..c94b702 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -2,11 +2,11 @@ This is the changelog for the development builds of Retro. The version number is likely to change; I'm targetting a -July - September window for this release. +July window for this release. ## Bug Fixes -- (all) strl* functions now only compiled if using GLIBC. +- (all) strl* functions now renamed, included on all builds - (all) `d:add-header` is extended by retro.forth to remap spaces back to underscores - (doc) fixed stack comments in glossary - (ex ) fixed issue in mail.forth @@ -16,6 +16,7 @@ July - September window for this release. ## Build - Merged Linux & BSD Makefiles +- Now builds on Solaris ## Core Language diff --git a/example/alternate-listener.forth b/example/alternate-listener.forth new file mode 100644 index 0000000..95cac02 --- /dev/null +++ b/example/alternate-listener.forth @@ -0,0 +1,57 @@ +# A New Listener + +The basic listener is very minimalistic. This is the start of +something a little nicer. + +# Features + +- character breaking input +- suggestions on hitting TAB +- show stack on hitting ESC + +# Loading + + retro -i -f alternate-listener.forth + new-listener + +# The Code + +~~~ +{{ + #1025 'TIB const + + :eol? (c-f) + { ASCII:CR ASCII:LF ASCII:SPACE } a:contains? ; + + :valid? (s-sf) + dup s:length n:-zero? ; + + :bs (c-c) + dup { #8 #127 } a:contains? [ buffer:get buffer:get drop-pair ] if ; + + :hint + nl TIB d:words-beginning-with nl TIB s:put ; + + :hints (c-c) + dup ASCII:HT eq? [ buffer:get drop hint ] if ; + + :stack (c-c) + dup ASCII:ESC eq? [ buffer:get drop nl &dump-stack dip nl TIB s:put ] if ; + + :check (a-) + [ call ] a:for-each ; + + :c:get (-c) as{ 'liii.... i #1 d }as ; + + :s:get (-s) [ TIB buffer:set + [ c:get dup buffer:add { &bs &hints &stack } check eol? ] until + buffer:start s:chop ] buffer:preserve ; + + :forever (q-) + repeat &call sip again ; +---reveal--- + :new-listener (-) + 'stty_cbreak unix:system + [ s:get valid? &interpret &drop choose ] forever ; +}} +~~~