#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <termios.h>
#include <time.h>
#include <unistd.h>
#include <libgen.h>
static void printsel(const Arg *);
static void printscreen(const Arg *) ;
static void toggleprinter(const Arg *);
+static void sendbreak(const Arg *);
/* Config.h for applying patches and the configuration. */
#include "config.h"
/* append every set & selected glyph to the selection */
for (y = sel.nb.y; y <= sel.ne.y; y++) {
- linelen = tlinelen(y);
+ if ((linelen = tlinelen(y)) == 0) {
+ *ptr++ = '\n';
+ continue;
+ }
if (sel.type == SEL_RECTANGULAR) {
gp = &term.line[y][sel.nb.x];
*repl++ = '\r';
}
- if (IS_SET(MODE_BRCKTPASTE))
+ if (IS_SET(MODE_BRCKTPASTE) && ofs == 0)
ttywrite("\033[200~", 6);
ttysend((char *)data, nitems * format / 8);
- if (IS_SET(MODE_BRCKTPASTE))
+ if (IS_SET(MODE_BRCKTPASTE) && rem == 0)
ttywrite("\033[201~", 6);
XFree(data);
/* number of 32-bit chunks returned */
if (opt_line) {
if ((cmdfd = open(opt_line, O_RDWR)) < 0)
die("open line failed: %s\n", strerror(errno));
- close(0);
- dup(cmdfd);
+ dup2(cmdfd, 0);
stty();
return;
}
* This means the buffer is getting full
* again. Empty it.
*/
- ttyread();
+ if (n < 256)
+ ttyread();
n -= r;
s += r;
} else {
break;
case ' ':
switch (csiescseq.mode[1]) {
- case 'q': /* DECSCUSR -- Set Cursor Style */
- DEFAULT(csiescseq.arg[0], 1);
- if (!BETWEEN(csiescseq.arg[0], 0, 6)) {
- goto unknown;
- }
- xw.cursor = csiescseq.arg[0];
- break;
- default:
+ case 'q': /* DECSCUSR -- Set Cursor Style */
+ DEFAULT(csiescseq.arg[0], 1);
+ if (!BETWEEN(csiescseq.arg[0], 0, 6)) {
goto unknown;
+ }
+ xw.cursor = csiescseq.arg[0];
+ break;
+ default:
+ goto unknown;
}
break;
}
memset(&strescseq, 0, sizeof(strescseq));
}
+void
+sendbreak(const Arg *arg)
+{
+ if (tcsendbreak(cmdfd, 0))
+ perror("Error sending break");
+}
+
void
tprinter(char *s, size_t len)
{
case '\023': /* XOFF (IGNORED) */
case 0177: /* DEL (IGNORED) */
return;
+ case 0x80: /* TODO: PAD */
+ case 0x81: /* TODO: HOP */
+ case 0x82: /* TODO: BPH */
+ case 0x83: /* TODO: NBH */
case 0x84: /* TODO: IND */
break;
case 0x85: /* NEL -- Next line */
tnewline(1); /* always go to first col */
break;
+ case 0x86: /* TODO: SSA */
+ case 0x87: /* TODO: ESA */
+ break;
case 0x88: /* HTS -- Horizontal tab stop */
term.tabs[term.c.x] = 1;
break;
+ case 0x89: /* TODO: HTJ */
+ case 0x8a: /* TODO: VTS */
+ case 0x8b: /* TODO: PLD */
+ case 0x8c: /* TODO: PLU */
case 0x8d: /* TODO: RI */
case 0x8e: /* TODO: SS2 */
case 0x8f: /* TODO: SS3 */
+ case 0x91: /* TODO: PU1 */
+ case 0x92: /* TODO: PU2 */
+ case 0x93: /* TODO: STS */
+ case 0x94: /* TODO: CCH */
+ case 0x95: /* TODO: MW */
+ case 0x96: /* TODO: SPA */
+ case 0x97: /* TODO: EPA */
case 0x98: /* TODO: SOS */
+ case 0x99: /* TODO: SGCI */
break;
case 0x9a: /* DECID -- Identify Terminal */
ttywrite(vtiden, sizeof(vtiden) - 1);
case 0x9c: /* TODO: ST */
break;
case 0x90: /* DCS -- Device Control String */
- case 0x9f: /* APC -- Application Program Command */
- case 0x9e: /* PM -- Privacy Message */
case 0x9d: /* OSC -- Operating System Command */
+ case 0x9e: /* PM -- Privacy Message */
+ case 0x9f: /* APC -- Application Program Command */
tstrsequence(ascii);
return;
}
int width, len;
Glyph *gp;
+ control = ISCONTROL(u);
len = utf8encode(u, c);
- if ((width = wcwidth(u)) == -1) {
+ if (!control && (width = wcwidth(u)) == -1) {
memcpy(c, "\357\277\275", 4); /* UTF_INVALID */
width = 1;
}
if (IS_SET(MODE_PRINT))
tprinter(c, len);
- control = ISCONTROL(u);
/*
* STR sequence must be checked before anything else
Cursor cursor;
Window parent;
pid_t thispid = getpid();
+ XColor xmousefg, xmousebg;
if (!(xw.dpy = XOpenDisplay(NULL)))
die("Can't open display\n");
die("XCreateIC failed. Could not obtain input method.\n");
/* white cursor, black outline */
- cursor = XCreateFontCursor(xw.dpy, XC_xterm);
+ cursor = XCreateFontCursor(xw.dpy, mouseshape);
XDefineCursor(xw.dpy, xw.win, cursor);
- XRecolorCursor(xw.dpy, cursor,
- &(XColor){.red = 0xffff, .green = 0xffff, .blue = 0xffff},
- &(XColor){.red = 0x0000, .green = 0x0000, .blue = 0x0000});
+
+ if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
+ xmousefg.red = 0xffff;
+ xmousefg.green = 0xffff;
+ xmousefg.blue = 0xffff;
+ }
+
+ if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
+ xmousebg.red = 0x0000;
+ xmousebg.green = 0x0000;
+ xmousebg.blue = 0x0000;
+ }
+
+ XRecolorCursor(xw.dpy, cursor, &xmousefg, &xmousebg);
xw.xembed = XInternAtom(xw.dpy, "_XEMBED", False);
xw.wmdeletewin = XInternAtom(xw.dpy, "WM_DELETE_WINDOW", False);
{
int numspecs;
XftGlyphFontSpec spec;
+
numspecs = xmakeglyphfontspecs(&spec, &g, 1, x, y);
xdrawglyphfontspecs(&spec, g, numspecs, x, y);
}
{
static int oldx = 0, oldy = 0;
int curx;
- Glyph g = {' ', ATTR_NULL, defaultbg, defaultcs};
+ Glyph g = {' ', ATTR_NULL, defaultbg, defaultcs}, og;
+ int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN);
+ Color drawcol;
+ XRenderColor dccol;
LIMIT(oldx, 0, term.col-1);
LIMIT(oldy, 0, term.row-1);
if (term.line[term.c.y][curx].mode & ATTR_WDUMMY)
curx--;
+ /* remove the old cursor */
+ og = term.line[oldy][oldx];
+ if (ena_sel && selected(oldx, oldy))
+ og.mode ^= ATTR_REVERSE;
+ xdrawglyph(og, oldx, oldy);
+
g.u = term.line[term.c.y][term.c.x].u;
+ if (ena_sel && selected(term.c.x, term.c.y)) {
+ /*
+ * Allocate the drawing color which is the reverse of
+ * defaultcs, if we are selected.
+ */
+ dccol.red = ~dc.col[defaultcs].color.red;
+ dccol.green = ~dc.col[defaultcs].color.green;
+ dccol.blue = ~dc.col[defaultcs].color.blue;
+ dccol.alpha = ~dc.col[defaultcs].color.alpha;
+ XftColorAllocValue(xw.dpy, xw.vis, xw.cmap, &dccol, &drawcol);
- /* remove the old cursor */
- xdrawglyph(term.line[oldy][oldx], oldx, oldy);
+ g.mode ^= ATTR_REVERSE;
+ } else {
+ drawcol = dc.col[defaultcs];
+ }
if (IS_SET(MODE_HIDE))
return;
/* draw the new one */
if (xw.state & WIN_FOCUSED) {
switch (xw.cursor) {
- case 0: /* Blinking Block */
- case 1: /* Blinking Block (Default) */
- case 2: /* Steady Block */
- if (IS_SET(MODE_REVERSE)) {
- g.mode |= ATTR_REVERSE;
- g.fg = defaultcs;
- g.bg = defaultfg;
- }
+ case 0: /* Blinking Block */
+ case 1: /* Blinking Block (Default) */
+ case 2: /* Steady Block */
+ if (IS_SET(MODE_REVERSE)) {
+ g.mode |= ATTR_REVERSE;
+ g.fg = defaultcs;
+ g.bg = defaultfg;
+ }
- g.mode |= term.line[term.c.y][curx].mode & ATTR_WIDE;
- xdrawglyph(g, term.c.x, term.c.y);
- break;
- case 3: /* Blinking Underline */
- case 4: /* Steady Underline */
- XftDrawRect(xw.draw, &dc.col[defaultcs],
- borderpx + curx * xw.cw,
- borderpx + (term.c.y + 1) * xw.ch - cursorthickness,
- xw.cw, cursorthickness);
- break;
- case 5: /* Blinking bar */
- case 6: /* Steady bar */
- XftDrawRect(xw.draw, &dc.col[defaultcs],
- borderpx + curx * xw.cw,
- borderpx + term.c.y * xw.ch,
- cursorthickness, xw.ch);
- break;
+ g.mode |= term.line[term.c.y][curx].mode & ATTR_WIDE;
+ xdrawglyph(g, term.c.x, term.c.y);
+ break;
+ case 3: /* Blinking Underline */
+ case 4: /* Steady Underline */
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + curx * xw.cw,
+ borderpx + (term.c.y + 1) * xw.ch - cursorthickness,
+ xw.cw, cursorthickness);
+ break;
+ case 5: /* Blinking bar */
+ case 6: /* Steady bar */
+ XftDrawRect(xw.draw, &drawcol,
+ borderpx + curx * xw.cw,
+ borderpx + term.c.y * xw.ch,
+ cursorthickness, xw.ch);
+ break;
}
} else {
- XftDrawRect(xw.draw, &dc.col[defaultcs],
+ XftDrawRect(xw.draw, &drawcol,
borderpx + curx * xw.cw,
borderpx + term.c.y * xw.ch,
xw.cw - 1, 1);
- XftDrawRect(xw.draw, &dc.col[defaultcs],
+ XftDrawRect(xw.draw, &drawcol,
borderpx + curx * xw.cw,
borderpx + term.c.y * xw.ch,
1, xw.ch - 1);
- XftDrawRect(xw.draw, &dc.col[defaultcs],
+ XftDrawRect(xw.draw, &drawcol,
borderpx + (curx + 1) * xw.cw - 1,
borderpx + term.c.y * xw.ch,
1, xw.ch - 1);
- XftDrawRect(xw.draw, &dc.col[defaultcs],
+ XftDrawRect(xw.draw, &drawcol,
borderpx + curx * xw.cw,
borderpx + (term.c.y + 1) * xw.ch - 1,
xw.cw, 1);
{
int i, x, y, ox, numspecs;
Glyph base, new;
- XftGlyphFontSpec* specs;
+ XftGlyphFontSpec *specs;
int ena_sel = sel.ob.x != -1 && sel.alt == IS_SET(MODE_ALTSCREEN);
if (!(xw.state & WIN_VISIBLE))
{
die("%s " VERSION " (c) 2010-2015 st engineers\n"
"usage: st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n"
- " [-i] [-t title] [-w windowid] [-e command ...] [command ...]\n"
+ " [-i] [-t title] [-T title] [-w windowid] [-e command ...]"
+ " [command ...]\n"
" st [-a] [-v] [-c class] [-f font] [-g geometry] [-o file]\n"
- " [-i] [-t title] [-w windowid] [-l line] [stty_args ...]\n",
+ " [-i] [-t title] [-T title] [-w windowid] -l line"
+ " [stty_args ...]\n",
argv0);
}
xw.l = xw.t = 0;
xw.isfixed = False;
- xw.cursor = 0;
+ xw.cursor = cursorshape;
ARGBEGIN {
case 'a':
opt_line = EARGF(usage());
break;
case 't':
+ case 'T':
opt_title = EARGF(usage());
break;
case 'w':