|
|
@ -259,6 +259,7 @@ static void tsetattr(int*, int); |
|
|
|
static void tsetchar(char*); |
|
|
|
static void tsetchar(char*); |
|
|
|
static void tsetscroll(int, int); |
|
|
|
static void tsetscroll(int, int); |
|
|
|
static void tswapscreen(void); |
|
|
|
static void tswapscreen(void); |
|
|
|
|
|
|
|
static void tsetdirt(int, int); |
|
|
|
static void tfulldirt(void); |
|
|
|
static void tfulldirt(void); |
|
|
|
|
|
|
|
|
|
|
|
static void ttynew(void); |
|
|
|
static void ttynew(void); |
|
|
@ -446,8 +447,8 @@ utf8size(char *s) { |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
selinit(void) { |
|
|
|
selinit(void) { |
|
|
|
sel.tclick1.tv_sec = 0; |
|
|
|
memset(&sel.tclick1, 0, sizeof(sel.tclick1)); |
|
|
|
sel.tclick1.tv_usec = 0; |
|
|
|
memset(&sel.tclick2, 0, sizeof(sel.tclick2)); |
|
|
|
sel.mode = 0; |
|
|
|
sel.mode = 0; |
|
|
|
sel.bx = -1; |
|
|
|
sel.bx = -1; |
|
|
|
sel.clip = NULL; |
|
|
|
sel.clip = NULL; |
|
|
@ -520,8 +521,7 @@ bpress(XEvent *e) { |
|
|
|
mousereport(e); |
|
|
|
mousereport(e); |
|
|
|
else if(e->xbutton.button == Button1) { |
|
|
|
else if(e->xbutton.button == Button1) { |
|
|
|
if(sel.bx != -1) |
|
|
|
if(sel.bx != -1) |
|
|
|
for(int i=sel.b.y; i<=sel.e.y; i++) |
|
|
|
tsetdirt(sel.b.y, sel.e.y); |
|
|
|
term.dirty[i] = 1; |
|
|
|
|
|
|
|
sel.mode = 1; |
|
|
|
sel.mode = 1; |
|
|
|
sel.ex = sel.bx = X2COL(e->xbutton.x); |
|
|
|
sel.ex = sel.bx = X2COL(e->xbutton.x); |
|
|
|
sel.ey = sel.by = Y2ROW(e->xbutton.y); |
|
|
|
sel.ey = sel.by = Y2ROW(e->xbutton.y); |
|
|
@ -531,21 +531,28 @@ bpress(XEvent *e) { |
|
|
|
void |
|
|
|
void |
|
|
|
selcopy(void) { |
|
|
|
selcopy(void) { |
|
|
|
char *str, *ptr; |
|
|
|
char *str, *ptr; |
|
|
|
int x, y, sz, sl, ls = 0; |
|
|
|
int x, y, bufsize, is_selected = 0; |
|
|
|
|
|
|
|
|
|
|
|
if(sel.bx == -1) |
|
|
|
if(sel.bx == -1) |
|
|
|
str = NULL; |
|
|
|
str = NULL; |
|
|
|
|
|
|
|
|
|
|
|
else { |
|
|
|
else { |
|
|
|
sz = (term.col+1) * (sel.e.y-sel.b.y+1) * UTF_SIZ; |
|
|
|
bufsize = (term.col+1) * (sel.e.y-sel.b.y+1) * UTF_SIZ; |
|
|
|
ptr = str = malloc(sz); |
|
|
|
ptr = str = malloc(bufsize); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* append every set & selected glyph to the selection */ |
|
|
|
for(y = 0; y < term.row; y++) { |
|
|
|
for(y = 0; y < term.row; y++) { |
|
|
|
for(x = 0; x < term.col; x++) |
|
|
|
for(x = 0; x < term.col; x++) { |
|
|
|
if(term.line[y][x].state & GLYPH_SET && (ls = selected(x, y))) { |
|
|
|
is_selected = selected(x, y); |
|
|
|
sl = utf8size(term.line[y][x].c); |
|
|
|
if((term.line[y][x].state & GLYPH_SET) && is_selected) { |
|
|
|
memcpy(ptr, term.line[y][x].c, sl); |
|
|
|
int size = utf8size(term.line[y][x].c); |
|
|
|
ptr += sl; |
|
|
|
memcpy(ptr, term.line[y][x].c, size); |
|
|
|
|
|
|
|
ptr += size; |
|
|
|
} |
|
|
|
} |
|
|
|
if(ls && y < sel.e.y) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* \n at the end of every selected line except for the last one */ |
|
|
|
|
|
|
|
if(is_selected && y < sel.e.y) |
|
|
|
*ptr++ = '\n'; |
|
|
|
*ptr++ = '\n'; |
|
|
|
} |
|
|
|
} |
|
|
|
*ptr = 0; |
|
|
|
*ptr = 0; |
|
|
@ -687,8 +694,7 @@ bmotion(XEvent *e) { |
|
|
|
if(oldey != sel.ey || oldex != sel.ex) { |
|
|
|
if(oldey != sel.ey || oldex != sel.ex) { |
|
|
|
int starty = MIN(oldey, sel.ey); |
|
|
|
int starty = MIN(oldey, sel.ey); |
|
|
|
int endy = MAX(oldey, sel.ey); |
|
|
|
int endy = MAX(oldey, sel.ey); |
|
|
|
for(int i = starty; i <= endy; i++) |
|
|
|
tsetdirt(starty, endy); |
|
|
|
term.dirty[i] = 1; |
|
|
|
|
|
|
|
draw(); |
|
|
|
draw(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -813,13 +819,23 @@ ttyresize(int x, int y) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
tfulldirt(void) |
|
|
|
tsetdirt(int top, int bot) |
|
|
|
{ |
|
|
|
{ |
|
|
|
int i; |
|
|
|
int i; |
|
|
|
for(i = 0; i < term.row; i++) |
|
|
|
|
|
|
|
|
|
|
|
LIMIT(top, 0, term.row-1); |
|
|
|
|
|
|
|
LIMIT(bot, 0, term.row-1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = top; i <= bot; i++) |
|
|
|
term.dirty[i] = 1; |
|
|
|
term.dirty[i] = 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
tfulldirt(void) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
tsetdirt(0, term.row-1); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void |
|
|
|
void |
|
|
|
tcursor(int mode) { |
|
|
|
tcursor(int mode) { |
|
|
|
static TCursor c; |
|
|
|
static TCursor c; |
|
|
|