the start of a new listener...
FossilOrigin-Name: 8759fd23c7c94e38a6d4b8073cda18cd6a0e9dd13fdb0594ed7906f0efe3f9bf
This commit is contained in:
parent
d2547a9107
commit
dc28e9ba97
2 changed files with 60 additions and 2 deletions
|
@ -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
|
||||
|
||||
|
|
57
example/alternate-listener.forth
Normal file
57
example/alternate-listener.forth
Normal file
|
@ -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 ;
|
||||
}}
|
||||
~~~
|
Loading…
Reference in a new issue