mirror of
https://github.com/mintycube/st.git
synced 2024-10-22 14:05:49 +02:00
keyboardselect: style changes
This commit is contained in:
parent
d7b6b1c1c6
commit
6c42872476
@ -1,4 +1,5 @@
|
|||||||
void set_notifmode(int type, KeySym ksym) {
|
void set_notifmode(int type, KeySym ksym)
|
||||||
|
{
|
||||||
static char *lib[] = { " MOVE ", " SEL "};
|
static char *lib[] = { " MOVE ", " SEL "};
|
||||||
static Glyph *g, *deb, *fin;
|
static Glyph *g, *deb, *fin;
|
||||||
static int col, bot;
|
static int col, bot;
|
||||||
@ -9,8 +10,7 @@ void set_notifmode(int type, KeySym ksym) {
|
|||||||
g = xmalloc(col * sizeof(Glyph));
|
g = xmalloc(col * sizeof(Glyph));
|
||||||
memcpy(g, term.line[bot], col * sizeof(Glyph));
|
memcpy(g, term.line[bot], col * sizeof(Glyph));
|
||||||
|
|
||||||
}
|
} else if (ksym == -2)
|
||||||
else if ( ksym == -2 )
|
|
||||||
memcpy(term.line[bot], g, col * sizeof(Glyph));
|
memcpy(term.line[bot], g, col * sizeof(Glyph));
|
||||||
|
|
||||||
if ( type < 2 ) {
|
if ( type < 2 ) {
|
||||||
@ -19,8 +19,7 @@ void set_notifmode(int type, KeySym ksym) {
|
|||||||
deb->mode = ATTR_REVERSE,
|
deb->mode = ATTR_REVERSE,
|
||||||
deb->u = *z,
|
deb->u = *z,
|
||||||
deb->fg = defaultfg, deb->bg = defaultbg;
|
deb->fg = defaultfg, deb->bg = defaultbg;
|
||||||
}
|
} else if (type < 5)
|
||||||
else if ( type < 5 )
|
|
||||||
memcpy(term.line[bot], g, col * sizeof(Glyph));
|
memcpy(term.line[bot], g, col * sizeof(Glyph));
|
||||||
else {
|
else {
|
||||||
for (deb = &term.line[bot][0], fin = &term.line[bot][col]; deb < fin; deb++)
|
for (deb = &term.line[bot][0], fin = &term.line[bot][col]; deb < fin; deb++)
|
||||||
@ -34,14 +33,14 @@ void set_notifmode(int type, KeySym ksym) {
|
|||||||
drawregion(0, bot, col, bot + 1);
|
drawregion(0, bot, col, bot + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void select_or_drawcursor(int selectsearch_mode, int type) {
|
void select_or_drawcursor(int selectsearch_mode, int type)
|
||||||
|
{
|
||||||
int done = 0;
|
int done = 0;
|
||||||
|
|
||||||
if (selectsearch_mode & 1) {
|
if (selectsearch_mode & 1) {
|
||||||
selextend(term.c.x, term.c.y, type, done);
|
selextend(term.c.x, term.c.y, type, done);
|
||||||
xsetsel(getsel());
|
xsetsel(getsel());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
#if LIGATURES_PATCH
|
#if LIGATURES_PATCH
|
||||||
xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x],
|
xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x],
|
||||||
term.ocx, term.ocy, term.line[term.ocy][term.ocx],
|
term.ocx, term.ocy, term.line[term.ocy][term.ocx],
|
||||||
@ -49,23 +48,27 @@ void select_or_drawcursor(int selectsearch_mode, int type) {
|
|||||||
#else
|
#else
|
||||||
xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x],
|
xdrawcursor(term.c.x, term.c.y, term.line[term.c.y][term.c.x],
|
||||||
term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
|
term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
|
||||||
#endif
|
#endif // LIGATURES_PATCH
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void search(int selectsearch_mode, Rune *target, int ptarget, int incr, int type, TCursor *cu) {
|
void search(int selectsearch_mode, Rune *target, int ptarget, int incr, int type, TCursor *cu)
|
||||||
|
{
|
||||||
Rune *r;
|
Rune *r;
|
||||||
int i, bound = (term.col * cu->y + cu->x) * (incr > 0) + incr;
|
int i, bound = (term.col * cu->y + cu->x) * (incr > 0) + incr;
|
||||||
|
|
||||||
for (i = term.col * term.c.y + term.c.x + incr; i != bound; i += incr) {
|
for (i = term.col * term.c.y + term.c.x + incr; i != bound; i += incr) {
|
||||||
for (r = target; r - target < ptarget; r++) {
|
for (r = target; r - target < ptarget; r++) {
|
||||||
if (*r == term.line[(i + r - target) / term.col][(i + r - target) % term.col].u) {
|
if (*r == term.line[(i + r - target) / term.col][(i + r - target) % term.col].u) {
|
||||||
if ( r - target == ptarget - 1 ) break;
|
if (r - target == ptarget - 1)
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
r = NULL;
|
r = NULL;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( r != NULL ) break;
|
if (r != NULL)
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i != bound) {
|
if (i != bound) {
|
||||||
@ -74,7 +77,8 @@ void search(int selectsearch_mode, Rune *target, int ptarget, int incr, int type
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int trt_kbdselect(KeySym ksym, char *buf, int len) {
|
int trt_kbdselect(KeySym ksym, char *buf, int len)
|
||||||
|
{
|
||||||
static TCursor cu;
|
static TCursor cu;
|
||||||
static Rune target[64];
|
static Rune target[64];
|
||||||
static int type = 1, ptarget, in_use;
|
static int type = 1, ptarget, in_use;
|
||||||
@ -82,25 +86,22 @@ int trt_kbdselect(KeySym ksym, char *buf, int len) {
|
|||||||
static char selectsearch_mode;
|
static char selectsearch_mode;
|
||||||
int i, bound, *xy;
|
int i, bound, *xy;
|
||||||
|
|
||||||
|
|
||||||
if (selectsearch_mode & 2) {
|
if (selectsearch_mode & 2) {
|
||||||
if (ksym == XK_Return) {
|
if (ksym == XK_Return) {
|
||||||
selectsearch_mode ^= 2;
|
selectsearch_mode ^= 2;
|
||||||
set_notifmode(selectsearch_mode, -2);
|
set_notifmode(selectsearch_mode, -2);
|
||||||
if ( ksym == XK_Escape ) ptarget = 0;
|
if (ksym == XK_Escape)
|
||||||
|
ptarget = 0;
|
||||||
|
return 0;
|
||||||
|
} else if (ksym == XK_BackSpace) {
|
||||||
|
if (!ptarget)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
else if ( ksym == XK_BackSpace ) {
|
|
||||||
if ( !ptarget ) return 0;
|
|
||||||
term.line[term.bot][ptarget--].u = ' ';
|
term.line[term.bot][ptarget--].u = ' ';
|
||||||
}
|
} else if (len < 1) {
|
||||||
else if ( len < 1 ) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (ptarget == term.col || ksym == XK_Escape) {
|
||||||
else if ( ptarget == term.col || ksym == XK_Escape ) {
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
utf8decode(buf, &target[ptarget++], len);
|
utf8decode(buf, &target[ptarget++], len);
|
||||||
term.line[term.bot][ptarget].u = target[ptarget - 1];
|
term.line[term.bot][ptarget].u = target[ptarget - 1];
|
||||||
}
|
}
|
||||||
@ -140,7 +141,8 @@ int trt_kbdselect(KeySym ksym, char *buf, int len) {
|
|||||||
selectsearch_mode ^= 2;
|
selectsearch_mode ^= 2;
|
||||||
break;
|
break;
|
||||||
case XK_Escape:
|
case XK_Escape:
|
||||||
if ( !in_use ) break;
|
if (!in_use)
|
||||||
|
break;
|
||||||
selclear();
|
selclear();
|
||||||
case XK_Return:
|
case XK_Return:
|
||||||
set_notifmode(4, ksym);
|
set_notifmode(4, ksym);
|
||||||
@ -189,12 +191,10 @@ int trt_kbdselect(KeySym ksym, char *buf, int len) {
|
|||||||
if (ksym >= XK_0 && ksym <= XK_9) { /* 0-9 keyboard */
|
if (ksym >= XK_0 && ksym <= XK_9) { /* 0-9 keyboard */
|
||||||
quant = (quant * 10) + (ksym ^ XK_0);
|
quant = (quant * 10) + (ksym ^ XK_0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (ksym >= XK_KP_0 && ksym <= XK_KP_9) { /* 0-9 numpad */
|
||||||
else if ( ksym >= XK_KP_0 && ksym <= XK_KP_9 ) { /* 0-9 numpad */
|
|
||||||
quant = (quant * 10) + (ksym ^ XK_KP_0);
|
quant = (quant * 10) + (ksym ^ XK_KP_0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (ksym == XK_k || ksym == XK_h)
|
||||||
else if ( ksym == XK_k || ksym == XK_h )
|
|
||||||
i = ksym & 1;
|
i = ksym & 1;
|
||||||
else if (ksym == XK_l || ksym == XK_j)
|
else if (ksym == XK_l || ksym == XK_j)
|
||||||
i = ((ksym & 6) | 4) >> 1;
|
i = ((ksym & 6) | 4) >> 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user