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