mirror of
https://github.com/hymkor/lispect.git
synced 2026-08-27 20:36:34 -04:00
Implement (send)
This commit is contained in:
+6
-3
@@ -4,14 +4,17 @@
|
||||
(while t
|
||||
(case (expect* 'timeout 10 "xxx" "yyy")
|
||||
((0)
|
||||
(sendln (string-append ctrlc "exit"))
|
||||
(send ctrlc)
|
||||
(sendln "exit")
|
||||
(return-from main nil)
|
||||
)
|
||||
((1)
|
||||
(sendln (string-append ctrlc "rem"))
|
||||
(send ctrlc)
|
||||
(sendln "rem")
|
||||
)
|
||||
((-1)
|
||||
(sendln (string-append ctrlc "exit"))
|
||||
(send ctrlc)
|
||||
(sendln "exit")
|
||||
(return-from main nil)
|
||||
)
|
||||
)
|
||||
|
||||
@@ -21,6 +21,11 @@ func (g *Global) Close() {
|
||||
g.closer = nil
|
||||
}
|
||||
|
||||
func (g *Global) send(ctx context.Context, w *gmnlisp.World, arg gmnlisp.Node) (gmnlisp.Node, error) {
|
||||
io.WriteString(g.term, arg.String())
|
||||
return gmnlisp.Null, nil
|
||||
}
|
||||
|
||||
func (g *Global) sendln(ctx context.Context, w *gmnlisp.World, arg gmnlisp.Node) (gmnlisp.Node, error) {
|
||||
io.WriteString(g.term, arg.String())
|
||||
g.term.Write([]byte{'\r'})
|
||||
|
||||
@@ -28,6 +28,7 @@ func mains(args []string) error {
|
||||
|
||||
lisp = lisp.Flet(
|
||||
gmnlisp.Functions{
|
||||
gmnlisp.NewSymbol("send"): gmnlisp.Function1(g.send),
|
||||
gmnlisp.NewSymbol("sendln"): gmnlisp.Function1(g.sendln),
|
||||
gmnlisp.NewSymbol("spawn"): &gmnlisp.Function{Min: 1, F: g.spawn},
|
||||
gmnlisp.NewSymbol("expect*"): gmnlisp.SpecialF(g.expect),
|
||||
|
||||
Reference in New Issue
Block a user