/* Globals */
Term term;
-Selection sel;
int cmdfd;
pid_t pid;
int oldbutton = 3; /* button event on startup: 3 = release */
+static Selection sel;
static CSIEscape csiescseq;
static STREscape strescseq;
static int iofd = 1;
}
void
-selextend(int col, int row, int type)
+selextend(int col, int row, int type, int done)
{
int oldey, oldex, oldsby, oldsey, oldtype;
+
+ if (!sel.mode)
+ return;
+ if (done && sel.mode == SEL_EMPTY) {
+ selclear();
+ return;
+ }
+
oldey = sel.oe.y;
oldex = sel.oe.x;
oldsby = sel.nb.y;
if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type)
tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
+
+ sel.mode = done ? SEL_IDLE : SEL_READY;
}
void
void selclear(void);
void selinit(void);
void selstart(int, int, int);
-void selextend(int, int, int);
+void selextend(int, int, int, int);
void selnormalize(void);
int selected(int, int);
char *getsel(void);
/* Globals */
extern Term term;
-extern Selection sel;
extern int cmdfd;
extern pid_t pid;
extern int oldbutton;
static void selclear_(XEvent *);
static void selrequest(XEvent *);
static void setsel(char *, Time);
-static void mousesel(XEvent *);
+static void mousesel(XEvent *, int);
static void mousereport(XEvent *);
static char *kmap(KeySym, uint);
static int match(uint, uint);
}
void
-mousesel(XEvent *e)
+mousesel(XEvent *e, int done)
{
int type, seltype = SEL_REGULAR;
uint state = e->xbutton.state & ~(Button1Mask | forceselmod);
break;
}
}
-
- selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype);
+ selextend(x2col(e->xbutton.x), y2row(e->xbutton.y), seltype, done);
+ if (done)
+ setsel(getsel(), e->xbutton.time);
}
void
return;
}
- if (e->xbutton.button == Button2) {
+ if (e->xbutton.button == Button2)
selpaste(NULL);
- } else if (e->xbutton.button == Button1) {
- if (sel.mode == SEL_READY) {
- mousesel(e);
- setsel(getsel(), e->xbutton.time);
- } else
- selclear_(NULL);
- sel.mode = SEL_IDLE;
- }
+ else if (e->xbutton.button == Button1)
+ mousesel(e, 1);
}
void
return;
}
- if (!sel.mode)
- return;
-
- sel.mode = SEL_READY;
- mousesel(e);
+ mousesel(e, 0);
}
void