From b31034d39354b59ce2a48503d41d9290b6a611b7 Mon Sep 17 00:00:00 2001 From: Petter Rodhelind Date: Mon, 23 Oct 2017 10:16:17 +0200 Subject: samterm: Add sendcmd for arbitrary input in the command window. --- src/cmd/samterm/main.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'src/cmd/samterm/main.c') diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c index 5b645e84..726cba2d 100644 --- a/src/cmd/samterm/main.c +++ b/src/cmd/samterm/main.c @@ -483,6 +483,48 @@ flushtyping(int clearesc) typeend = -1; } +void +sendcmd(char *c, int n, Text *t) { + Text *to = t; + Rune buf[100]; + Rune *p = buf; + Flayer *l; + long a; + + t = &cmd; + for(l=t->l; l->textfn==0; l++) + ; + current(l); + flushtyping(0); + a = t->rasp.nrunes; + flsetselect(l, a, a); + center(l, a); + + for(int x = 0; x < n; x++){ + chartorune(p++,c++); + } + *p++ = '\n'; + if(typestart < 0) + typestart = a; + if(typeesc < 0) + typeesc = a; + hgrow(t->tag, a, p-buf, 0); + t->lock++; /* pretend we Trequest'ed for hdatarune*/ + hdatarune(t->tag, a, buf, p-buf); + a += p-buf; + l->p0 = a; + l->p1 = a; + typeend = a; + flushtyping(0); + onethird(l, a); + + t = to; + for(l=t->l; l->textfn==0; l++) + ; + current(l); + flushtyping(1); +} + #define BACKSCROLLKEY Kup #define ENDKEY Kend #define ESC 0x1B -- cgit v1.2.3