summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/src/cmd/acme/dat.h2
-rw-r--r--sys/src/cmd/acme/text.c10
-rw-r--r--sys/src/cmd/rio/dat.h2
-rw-r--r--sys/src/cmd/rio/wind.c10
-rw-r--r--sys/src/cmd/samterm/flayer.c6
-rw-r--r--sys/src/cmd/samterm/flayer.h2
-rw-r--r--sys/src/cmd/samterm/main.c7
7 files changed, 23 insertions, 16 deletions
diff --git a/sys/src/cmd/acme/dat.h b/sys/src/cmd/acme/dat.h
index 9e8fe26ec..100488c64 100644
--- a/sys/src/cmd/acme/dat.h
+++ b/sys/src/cmd/acme/dat.h
@@ -203,7 +203,7 @@ void textcolumnate(Text*, Dirlist**, int);
void textcommit(Text*, int);
void textconstrain(Text*, uint, uint, uint*, uint*);
void textdelete(Text*, uint, uint, int);
-void textstretchsel(Text*, uint*, uint*, int);
+void textstretchsel(Text*, uint, uint*, uint*, int);
void textfill(Text*);
void textframescroll(Text*, int);
void textinit(Text*, File*, Rectangle, Reffont*, Image**);
diff --git a/sys/src/cmd/acme/text.c b/sys/src/cmd/acme/text.c
index 1987644b2..9611a2e4b 100644
--- a/sys/src/cmd/acme/text.c
+++ b/sys/src/cmd/acme/text.c
@@ -932,7 +932,7 @@ textselect(Text *t)
if(mouse->msec-clickmsec >= 500 || selecttext != t || clickcount > 3)
clickcount = 0;
if(clickcount >= 1 && selecttext==t && mouse->msec-clickmsec < 500){
- textstretchsel(t, &q0, &q1, clickcount);
+ textstretchsel(t, selectq, &q0, &q1, clickcount);
textsetselect(t, q0, q1);
flushimage(display, 1);
x = mouse->xy.x;
@@ -951,7 +951,7 @@ textselect(Text *t)
mouse->xy.y = y;
q0 = t->q0; /* may have changed */
q1 = t->q1;
- selectq = q0;
+ selectq = t->org+frcharofpt(t, mouse->xy);;
}
if(mouse->buttons == b && clickcount == 0){
t->Frame.scroll = framescroll;
@@ -971,7 +971,7 @@ textselect(Text *t)
}
if(q0 == q1){
if(q0==t->q0 && mouse->msec-clickmsec<500)
- textstretchsel(t, &q0, &q1, clickcount);
+ textstretchsel(t, selectq, &q0, &q1, clickcount);
else
clicktext = t;
clickmsec = mouse->msec;
@@ -1304,12 +1304,14 @@ inmode(Rune r, int mode)
}
void
-textstretchsel(Text *t, uint *q0, uint *q1, int mode)
+textstretchsel(Text *t, uint mp, uint *q0, uint *q1, int mode)
{
int c, i;
Rune *r, *l, *p;
uint q;
+ *q0 = mp;
+ *q1 = mp;
for(i=0; left[i]!=nil; i++){
q = *q0;
l = left[i];
diff --git a/sys/src/cmd/rio/dat.h b/sys/src/cmd/rio/dat.h
index 324698f7b..8ae7e41e2 100644
--- a/sys/src/cmd/rio/dat.h
+++ b/sys/src/cmd/rio/dat.h
@@ -195,7 +195,7 @@ void wclosewin(Window*);
void wcurrent(Window*);
void wcut(Window*);
void wdelete(Window*, uint, uint);
-void wstretchsel(Window*, uint*, uint*, int);
+void wstretchsel(Window*, uint, uint*, uint*, int);
void wfill(Window*);
void wframescroll(Window*, int);
void wkeyctl(Window*, Rune);
diff --git a/sys/src/cmd/rio/wind.c b/sys/src/cmd/rio/wind.c
index 2a5e065bf..a9cfd248e 100644
--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -1024,7 +1024,7 @@ wselect(Window *w)
clickcount = 0;
if(clickwin == w && clickcount >= 1 && w->mc.msec-clickmsec < 500){
mode = (clickcount > 2) ? 2 : clickcount;
- wstretchsel(w, &q0, &q1, mode);
+ wstretchsel(w, selectq, &q0, &q1, mode);
wsetselect(w, q0, q1);
x = w->mc.xy.x;
y = w->mc.xy.y;
@@ -1042,7 +1042,7 @@ wselect(Window *w)
w->mc.xy.y = y;
q0 = w->q0; /* may have changed */
q1 = w->q1;
- selectq = q0;
+ selectq = w->org+frcharofpt(w, w->mc.xy);
}
if(w->mc.buttons == b && clickcount == 0){
w->scroll = framescroll;
@@ -1063,7 +1063,7 @@ wselect(Window *w)
if(q0 == q1){
mode = (clickcount > 2) ? 2 : clickcount;
if(q0==w->q0 && clickwin==w && w->mc.msec-clickmsec<500)
- wstretchsel(w, &q0, &q1, mode);
+ wstretchsel(w, selectq, &q0, &q1, mode);
else
clickwin = w;
clickmsec = w->mc.msec;
@@ -1499,12 +1499,14 @@ inmode(Rune r, int mode)
}
void
-wstretchsel(Window *w, uint *q0, uint *q1, int mode)
+wstretchsel(Window *w, uint pt, uint *q0, uint *q1, int mode)
{
int c, i;
Rune *r, *l, *p;
uint q;
+ *q0 = pt;
+ *q1 = pt;
for(i=0; left[i]!=nil; i++){
q = *q0;
l = left[i];
diff --git a/sys/src/cmd/samterm/flayer.c b/sys/src/cmd/samterm/flayer.c
index 944fee699..86ae922cc 100644
--- a/sys/src/cmd/samterm/flayer.c
+++ b/sys/src/cmd/samterm/flayer.c
@@ -250,7 +250,7 @@ fldelete(Flayer *l, long p0, long p1)
}
int
-flselect(Flayer *l)
+flselect(Flayer *l, ulong *p)
{
static int clickcount;
static Point clickpt = {-10, -10};
@@ -261,6 +261,7 @@ flselect(Flayer *l)
dt = mousep->msec - l->click;
dx = abs(mousep->xy.x - clickpt.x);
dy = abs(mousep->xy.y - clickpt.y);
+ *p = frcharofpt(&l->f, mousep->xy) + l->origin;
l->click = mousep->msec;
clickpt = mousep->xy;
@@ -270,7 +271,8 @@ flselect(Flayer *l)
clickcount = 0;
frselect(&l->f, mousectl);
- l->p0 = l->f.p0+l->origin, l->p1 = l->f.p1+l->origin;
+ l->p0 = l->f.p0+l->origin;
+ l->p1 = l->f.p1+l->origin;
return 0;
}
diff --git a/sys/src/cmd/samterm/flayer.h b/sys/src/cmd/samterm/flayer.h
index 0967999e5..24aafc55a 100644
--- a/sys/src/cmd/samterm/flayer.h
+++ b/sys/src/cmd/samterm/flayer.h
@@ -36,7 +36,7 @@ int flprepare(Flayer*);
Rectangle flrect(Flayer*, Rectangle);
void flrefresh(Flayer*, Rectangle, int);
void flresize(Rectangle);
-int flselect(Flayer*);
+int flselect(Flayer*, ulong*);
void flsetselect(Flayer*, long, long);
void flstart(Rectangle);
void flupfront(Flayer*);
diff --git a/sys/src/cmd/samterm/main.c b/sys/src/cmd/samterm/main.c
index ec584f58e..fe5dbab93 100644
--- a/sys/src/cmd/samterm/main.c
+++ b/sys/src/cmd/samterm/main.c
@@ -35,6 +35,7 @@ threadmain(int argc, char *argv[])
Text *t;
Rectangle r;
Flayer *nwhich;
+ ulong p;
getscreen(argc, argv);
iconinit();
@@ -105,12 +106,12 @@ threadmain(int argc, char *argv[])
current(nwhich);
else{
t=(Text *)which->user1;
- nclick = flselect(which);
+ nclick = flselect(which, &p);
if(nclick > 0){
if(nclick > 1)
- outTsl(Ttclick, t->tag, which->p0);
+ outTsl(Ttclick, t->tag, p);
else
- outTsl(Tdclick, t->tag, which->p0);
+ outTsl(Tdclick, t->tag, p);
t->lock++;
}else if(t!=&cmd)
outcmd();