aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/samterm
diff options
context:
space:
mode:
authorPetter Rodhelind <petter.rodhelind@gmail.com>2017-10-23 10:16:17 +0200
committerPetter Rodhelind <petter.rodhelind@gmail.com>2017-10-23 10:16:17 +0200
commitb31034d39354b59ce2a48503d41d9290b6a611b7 (patch)
treef9be51c0506d0c87a88c8420d8924b1e46e43f17 /src/cmd/samterm
parent1365290d24a712f9f3022fc442211133cccb54ef (diff)
downloadplan9port-b31034d39354b59ce2a48503d41d9290b6a611b7.tar.gz
plan9port-b31034d39354b59ce2a48503d41d9290b6a611b7.tar.bz2
plan9port-b31034d39354b59ce2a48503d41d9290b6a611b7.zip
samterm: Add sendcmd for arbitrary input in the command window.
Diffstat (limited to 'src/cmd/samterm')
-rw-r--r--src/cmd/samterm/main.c42
1 files changed, 42 insertions, 0 deletions
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