diff options
Diffstat (limited to 'src/cmd/samterm/main.c')
-rw-r--r-- | src/cmd/samterm/main.c | 78 |
1 files changed, 69 insertions, 9 deletions
diff --git a/src/cmd/samterm/main.c b/src/cmd/samterm/main.c index de951845..8bd02ca0 100644 --- a/src/cmd/samterm/main.c +++ b/src/cmd/samterm/main.c @@ -108,19 +108,21 @@ threadmain(int argc, char *argv[]) continue; } nwhich = flwhich(mousep->xy); - scr = which && ptinrect(mousep->xy, which->scroll); + //scr = which && ptinrect(mousep->xy, which->scroll); + scr = which && (ptinrect(mousep->xy, which->scroll) || mousep->buttons&(8|16)); if(mousep->buttons) flushtyping(1); if(chording && chord==1 && !mousep->buttons) chord = 0; if(chording && chord) chord |= mousep->buttons; - else if(mousep->buttons&1){ + else if(mousep->buttons&(1|8)){ if(nwhich){ if(nwhich!=which) current(nwhich); else if(scr) - scroll(which, 1); + //scroll(which, 1); + scroll(which, (mousep->buttons&8) ? 4 : 1); else{ t=(Text *)which->user1; if(flselect(which)){ @@ -137,9 +139,10 @@ threadmain(int argc, char *argv[]) scroll(which, 2); else menu2hit(); - }else if((mousep->buttons&4)){ + }else if((mousep->buttons&(4|16))){ if(scr) - scroll(which, 3); + //scroll(which, 3); + scroll(which, (mousep->buttons&16) ? 5 : 3); else menu3hit(); } @@ -483,6 +486,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 @@ -497,6 +542,8 @@ flushtyping(int clearesc) #define CUT (Kcmd+'x') #define COPY (Kcmd+'c') #define PASTE (Kcmd+'v') +#define UNDO (Kcmd+'z') +#define REDO (Kcmd+'Z') int nontypingkey(int c) @@ -619,16 +666,29 @@ type(Flayer *l, int res) /* what a bloody mess this is */ center(l, t->rasp.nrunes); }else if(c == LINESTART || c == LINEEND){ flushtyping(1); - if(c == LINESTART) - while(a > 0 && raspc(&t->rasp, a-1)!='\n') + if(c == LINESTART){ + if (a > 0 && raspc(&t->rasp, a-1)=='\n') a--; - else - while(a < t->rasp.nrunes && raspc(&t->rasp, a)!='\n') + else{ + while(a > 0 && raspc(&t->rasp, a-1)!='\n') + a--; + } + }else{ + if(a < t->rasp.nrunes && raspc(&t->rasp, a)=='\n') a++; + else{ + while(a < t->rasp.nrunes && raspc(&t->rasp, a)!='\n') + a++; + } + } l->p0 = l->p1 = a; for(l=t->l; l<&t->l[NL]; l++) if(l->textfn) flsetselect(l, l->p0, l->p1); + }else if(c == UNDO) { + sendcmd("u", 1, t); + }else if(c == REDO) { + sendcmd("u-1", 3, t); }else if(backspacing && !hostlock){ /* backspacing immediately after outcmd(): sorry */ if(l->f.p0>0 && a>0){ |