Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
st.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add DSR cursor position sequence
[st.git]
/
st.c
diff --git
a/st.c
b/st.c
index
96d45bf
..
05e285c
100644
(file)
--- a/
st.c
+++ b/
st.c
@@
-132,6
+132,7
@@
enum term_mode {
MODE_FOCUS = 65536,
MODE_MOUSEX10 = 131072,
MODE_MOUSEMANY = 262144,
MODE_FOCUS = 65536,
MODE_MOUSEX10 = 131072,
MODE_MOUSEMANY = 262144,
+ MODE_BRCKTPASTE = 524288,
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
MODE_MOUSE = MODE_MOUSEBTN|MODE_MOUSEMOTION|MODE_MOUSEX10\
|MODE_MOUSEMANY,
};
@@
-823,18
+824,23
@@
mousereport(XEvent *e) {
button = oldbutton + 32;
ox = x;
oy = y;
button = oldbutton + 32;
ox = x;
oy = y;
- } else if(!IS_SET(MODE_MOUSESGR)
- && (e->xbutton.type == ButtonRelease
- || button == AnyButton)) {
- button = 3;
} else {
} else {
- button -= Button1;
- if(button >= 3)
- button += 64 - 3;
+ if(!IS_SET(MODE_MOUSESGR) && e->xbutton.type == ButtonRelease) {
+ button = 3;
+ } else {
+ button -= Button1;
+ if(button >= 3)
+ button += 64 - 3;
+ }
if(e->xbutton.type == ButtonPress) {
oldbutton = button;
ox = x;
oy = y;
if(e->xbutton.type == ButtonPress) {
oldbutton = button;
ox = x;
oy = y;
+ } else if(e->xbutton.type == ButtonRelease) {
+ oldbutton = 3;
+ /* MODE_MOUSEX10: no button release reporting */
+ if(IS_SET(MODE_MOUSEX10))
+ return;
}
}
}
}
@@
-851,8
+857,7
@@
mousereport(XEvent *e) {
e->xbutton.type == ButtonRelease ? 'm' : 'M');
} else if(x < 223 && y < 223) {
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
e->xbutton.type == ButtonRelease ? 'm' : 'M');
} else if(x < 223 && y < 223) {
len = snprintf(buf, sizeof(buf), "\033[M%c%c%c",
- IS_SET(MODE_MOUSEX10)? button-1 : 32+button,
- 32+x+1, 32+y+1);
+ 32+button, 32+x+1, 32+y+1);
} else {
return;
}
} else {
return;
}
@@
-957,7
+962,7
@@
selcopy(void) {
* st.
* FIXME: Fix the computer world.
*/
* st.
* FIXME: Fix the computer world.
*/
- if(y < sel.ne.y && !((gp-1)->mode & ATTR_WRAP))
+ if(y < sel.ne.y && x > 0 && !((gp-1)->mode & ATTR_WRAP))
*ptr++ = '\n';
/*
*ptr++ = '\n';
/*
@@
-1009,7
+1014,11
@@
selnotify(XEvent *e) {
*repl++ = '\r';
}
*repl++ = '\r';
}
+ if(IS_SET(MODE_BRCKTPASTE))
+ ttywrite("\033[200~", 6);
ttywrite((const char *)data, nitems * format / 8);
ttywrite((const char *)data, nitems * format / 8);
+ if(IS_SET(MODE_BRCKTPASTE))
+ ttywrite("\033[201~", 6);
XFree(data);
/* number of 32-bit chunks returned */
ofs += nitems * format / 32;
XFree(data);
/* number of 32-bit chunks returned */
ofs += nitems * format / 32;
@@
-1864,6
+1873,9
@@
tsetmode(bool priv, bool set, int *args, int narg) {
case 1048:
tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
break;
case 1048:
tcursor((set) ? CURSOR_SAVE : CURSOR_LOAD);
break;
+ case 2004: /* 2004: bracketed paste mode */
+ MODBIT(term.mode, set, MODE_BRCKTPASTE);
+ break;
/* Not implemented mouse modes. See comments there. */
case 1001: /* mouse highlight mode; can hang the
terminal by design when implemented. */
/* Not implemented mouse modes. See comments there. */
case 1001: /* mouse highlight mode; can hang the
terminal by design when implemented. */
@@
-2055,6
+2067,13
@@
csihandle(void) {
case 'm': /* SGR -- Terminal attribute (color) */
tsetattr(csiescseq.arg, csiescseq.narg);
break;
case 'm': /* SGR -- Terminal attribute (color) */
tsetattr(csiescseq.arg, csiescseq.narg);
break;
+ case 'n': /* DSR – Device Status Report (cursor position) */
+ if (csiescseq.arg[0] == 6) {
+ char buf[40];
+ int len = snprintf(buf, sizeof(buf),"\033[%i;%iR", term.c.y+1, term.c.x+1);
+ ttywrite(buf, len);
+ break;
+ }
case 'r': /* DECSTBM -- Set Scrolling Region */
if(csiescseq.priv) {
goto unknown;
case 'r': /* DECSTBM -- Set Scrolling Region */
if(csiescseq.priv) {
goto unknown;
@@
-2320,6
+2339,8
@@
tputc(char *c, int len) {
case '\a': /* BEL */
if(!(xw.state & WIN_FOCUSED))
xseturgency(1);
case '\a': /* BEL */
if(!(xw.state & WIN_FOCUSED))
xseturgency(1);
+ if (bellvolume)
+ XBell(xw.dpy, bellvolume);
return;
case '\033': /* ESC */
csireset();
return;
case '\033': /* ESC */
csireset();