#include <time.h>
#include <unistd.h>
#include <libgen.h>
-#include <fontconfig/fontconfig.h>
#include <wchar.h>
-/* X11 */
-#include <X11/cursorfont.h>
-#include <X11/Xft/Xft.h>
-
#include "st.h"
#include "win.h"
static void tscrolldown(int, int);
static void tsetattr(int *, int);
static void tsetchar(Rune, Glyph *, int, int);
+static void tsetdirt(int, int);
static void tsetscroll(int, int);
static void tswapscreen(void);
static void tsetmode(int, int, int *, int);
void
selinit(void)
{
- clock_gettime(CLOCK_MONOTONIC, &sel.tclick1);
- clock_gettime(CLOCK_MONOTONIC, &sel.tclick2);
sel.mode = SEL_IDLE;
sel.snap = 0;
sel.ob.x = -1;
- sel.primary = NULL;
- sel.clipboard = NULL;
}
int
return i;
}
+void
+selstart(int col, int row, int snap)
+{
+ selclear();
+ sel.mode = SEL_EMPTY;
+ sel.type = SEL_REGULAR;
+ sel.snap = snap;
+ sel.oe.x = sel.ob.x = col;
+ sel.oe.y = sel.ob.y = row;
+ selnormalize();
+
+ if (sel.snap != 0)
+ sel.mode = SEL_READY;
+ tsetdirt(sel.nb.y, sel.ne.y);
+}
+
+void
+selextend(int col, int row, int type)
+{
+ int oldey, oldex, oldsby, oldsey, oldtype;
+ oldey = sel.oe.y;
+ oldex = sel.oe.x;
+ oldsby = sel.nb.y;
+ oldsey = sel.ne.y;
+ oldtype = sel.type;
+
+ sel.alt = IS_SET(MODE_ALTSCREEN);
+ sel.oe.x = col;
+ sel.oe.y = row;
+ selnormalize();
+ sel.type = type;
+
+ if (oldey != sel.oe.y || oldex != sel.oe.x || oldtype != sel.type)
+ tsetdirt(MIN(sel.nb.y, oldsby), MAX(sel.ne.y, oldsey));
+}
+
void
selnormalize(void)
{
int
selected(int x, int y)
{
- if (sel.mode == SEL_EMPTY)
+ if (sel.mode == SEL_EMPTY || sel.ob.x == -1 ||
+ sel.alt != IS_SET(MODE_ALTSCREEN))
return 0;
if (sel.type == SEL_RECTANGULAR)
ttynew(char *line, char *out, char **args)
{
int m, s;
- struct winsize w = {term.row, term.col, 0, 0};
if (out) {
term.mode |= MODE_PRINT;
}
/* seems to work fine on linux, openbsd and freebsd */
- if (openpty(&m, &s, NULL, NULL, &w) < 0)
+ if (openpty(&m, &s, NULL, NULL, NULL) < 0)
die("openpty failed: %s\n", strerror(errno));
switch (pid = fork()) {
dec = base64dec(strescseq.args[2]);
if (dec) {
- xsetsel(dec, CurrentTime);
+ xsetsel(dec);
xclipcopy();
} else {
fprintf(stderr, "erresc: invalid base64\n");