diff options
-rw-r--r-- | src/cmd/9term/9term.c | 41 | ||||
-rw-r--r-- | src/lib9/mkfile | 1 | ||||
-rw-r--r-- | src/mkcommon | 4 | ||||
-rw-r--r-- | src/mkhdr | 2 |
4 files changed, 33 insertions, 15 deletions
diff --git a/src/cmd/9term/9term.c b/src/cmd/9term/9term.c index fe6c50b5..1b65b88c 100644 --- a/src/cmd/9term/9term.c +++ b/src/cmd/9term/9term.c @@ -361,6 +361,8 @@ mouse(void) wordclick(&q0, &q1); if(q0 == q1) break; + t.q0 = t.q1 = t.nr; + updatesel(); paste(t.r+q0, q1-q0, 1); if(t.r[q1-1] != '\n') paste(Lnl, 1, 1); @@ -384,7 +386,7 @@ mselect(void) b = t.m.buttons; q0 = frcharofpt(t.f, t.m.xy) + t.org; - if(t.m.msec-clickmsec<500 && clickq0 == q0 && t.q0==t.q1 && b==1){ + if(t.m.msec-clickmsec<500 && clickq0==q0 && t.q0==t.q1 && b==1){ doubleclick(&t.q0, &t.q1); updatesel(); /* t.t.i->flush(); */ @@ -408,19 +410,19 @@ mselect(void) clickmsec = t.m.msec; clickq0 = t.q0; } - if((t.m.buttons != b) && (b&1)){ - enum {Cancut = 1, Canpaste = 2} state = Cancut | Canpaste; + if((t.m.buttons != b) &&(b&1)){ + enum{Cancut = 1, Canpaste = 2} state = Cancut | Canpaste; while(t.m.buttons){ - if(t.m.buttons&2) { - if (state&Cancut) { + if(t.m.buttons&2){ + if(state&Cancut){ snarf(); cut(); state = Canpaste; } - } else if (t.m.buttons&4) { - if (state&Canpaste) { + }else if(t.m.buttons&4){ + if(state&Canpaste){ snarfupdate(); - if (t.nsnarf) { + if(t.nsnarf){ paste(t.snarf, t.nsnarf, 0); } state = Cancut|Canpaste; @@ -841,7 +843,6 @@ cut(void) void snarfupdate(void) { - char *pp; int n, i; Rune *p; @@ -861,29 +862,31 @@ snarfupdate(void) } +char sbuf[SnarfSize]; void snarf(void) { - char buf[SnarfSize], *p; + char *p; int i, n; Rune *rp; if(t.q1 == t.q0) return; n = t.q1-t.q0; - t.snarf = runerealloc(t.snarf, n); - for(i=0,p=buf,rp=t.snarf; i<n && p < buf + SnarfSize-UTFmax; i++){ + t.snarf = runerealloc(t.snarf, n); + for(i=0,p=sbuf,rp=t.snarf; i<n && p < sbuf+SnarfSize-UTFmax; i++){ *rp++ = *(t.r+t.q0+i); p += runetochar(p, t.r+t.q0+i); } t.nsnarf = rp-t.snarf; *p = '\0'; - putsnarf(buf); + putsnarf(sbuf); } void paste(Rune *r, int n, int advance) { + Rune *rbuf; uint m; uint q0; @@ -908,6 +911,17 @@ paste(Rune *r, int n, int advance) t.nr -= m; runemove(t.r, t.r+m, t.nr); } + + /* + * if this is a button2 execute then we might have been passed + * runes inside the buffer. must save them before realloc. + */ + rbuf = nil; + if(t.r <= r && r < t.r+n){ + rbuf = runemalloc(n); + runemove(rbuf, r, n); + r = rbuf; + } t.r = runerealloc(t.r, t.nr+n); q0 = t.q0; runemove(t.r+q0+n, t.r+q0, t.nr-q0); @@ -925,6 +939,7 @@ paste(Rune *r, int n, int advance) t.q0 += n; t.q1 += n; updatesel(); + free(rbuf); } void diff --git a/src/lib9/mkfile b/src/lib9/mkfile index a34cdc69..3dbd6b4a 100644 --- a/src/lib9/mkfile +++ b/src/lib9/mkfile @@ -42,6 +42,7 @@ OFILES=\ main.$O\ malloctag.$O\ mallocz.$O\ + nan.$O\ needsrcquote.$O\ netmkaddr.$O\ notify.$O\ diff --git a/src/mkcommon b/src/mkcommon index 90131bce..b9507578 100644 --- a/src/mkcommon +++ b/src/mkcommon @@ -14,10 +14,10 @@ clean:V: clean-common %.clean:V: %.clean-common nuke-common:V: - rm -f *.[$OS] [$OS].out $CLEANFILES $NUKEFILES + rm -f *.[$OS] [$OS].out $CLEANFILES y.tab.[ch] $NUKEFILES clean-common: - rm -f *.[$OS] [$OS].out $CLEANFILES + rm -f *.[$OS] [$OS].out $CLEANFILES y.tab.[ch] %.clean-common:V: rm -f $stem.[$OS] [$OS].$stem $stem.acid $stem @@ -20,6 +20,8 @@ LDFLAGS= AFLAGS= CLEANFILES= NUKEFILES= +YACC=yacc +YFLAGS=-d <|cat $PLAN9/src/mk.$SYSNAME-$OBJTYPE 2>/dev/null || true |