From 63424e9709751108c564f884cb4fdffab77c933d Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Fri, 26 Jun 2020 16:11:15 +0200 Subject: patched term to allow for arbitrary sizes --- sys/cmd/term/config.h | 6 ++--- sys/cmd/term/term.h | 13 ++++++----- sys/cmd/term/x.c | 65 ++++++++++++++++++++++++++------------------------- 3 files changed, 43 insertions(+), 41 deletions(-) (limited to 'sys/cmd/term') diff --git a/sys/cmd/term/config.h b/sys/cmd/term/config.h index 1002e17..4cd1a09 100644 --- a/sys/cmd/term/config.h +++ b/sys/cmd/term/config.h @@ -95,7 +95,7 @@ char *termname = "term-256color"; uint tabspaces = 4; /* bg opacity */ -float alpha = 0.95; +float alpha = 0.98; /* Terminal colors (16 first used in escape sequence) */ static char *colorname[] = { @@ -196,8 +196,8 @@ static Shortcut shortcuts[] = { { ControlMask, XK_Print, toggleprinter, {.i = 0} }, { ShiftMask, XK_Print, printscreen, {.i = 0} }, { XK_ANY_MOD, XK_Print, printsel, {.i = 0} }, - { TERMMOD, XK_Prior, zoom, {.f = +1} }, - { TERMMOD, XK_Next, zoom, {.f = -1} }, + { TERMMOD, XK_plus, zoom, {.f = +1} }, + { ControlMask, XK_minus, zoom, {.f = -1} }, { TERMMOD, XK_Home, zoomreset, {.f = 0} }, { TERMMOD, XK_C, clipcopy, {.i = 0} }, { TERMMOD, XK_V, clippaste, {.i = 0} }, diff --git a/sys/cmd/term/term.h b/sys/cmd/term/term.h index 3c7e3ca..11c28c7 100644 --- a/sys/cmd/term/term.h +++ b/sys/cmd/term/term.h @@ -228,12 +228,13 @@ typedef struct { typedef struct TermWindow TermWindow; struct TermWindow { - int tw, th; /* tty width and height */ - int w, h; /* window width and height */ - int ch; /* char height */ - int cw; /* char width */ - int mode; /* window state/mode flags */ - int cursor; /* cursor style */ + int tw, th; /* tty width and height */ + int w, h; /* window width and height */ + int hb, vb; /* horizontal and vertical border (in pix) */ + int ch; /* char height */ + int cw; /* char width */ + int mode; /* window state/mode flags */ + int cursor; /* cursor style */ }; /* used for user hooks */ diff --git a/sys/cmd/term/x.c b/sys/cmd/term/x.c index d6ec1bb..cdf82d7 100644 --- a/sys/cmd/term/x.c +++ b/sys/cmd/term/x.c @@ -315,7 +315,7 @@ ttysend(Arg *arg) int evcol(XEvent *e) { - int x = e->xbutton.x - borderpx; + int x = e->xbutton.x - win.hb; LIMIT(x, 0, win.tw - 1); return x / win.cw; } @@ -323,7 +323,7 @@ evcol(XEvent *e) int evrow(XEvent *e) { - int y = e->xbutton.y - borderpx; + int y = e->xbutton.y - win.vb; LIMIT(y, 0, win.th - 1); return y / win.ch; } @@ -705,6 +705,9 @@ cresize(int width, int height) col = MAX(1, col); row = MAX(1, row); + win.hb = (win.w - col*win.cw)/2; + win.vb = (win.h - col*win.ch)/2; + tresize(col, row); xresize(col, row); ttyresize(win.tw, win.th); @@ -824,14 +827,13 @@ xhints(void) sizeh = XAllocSizeHints(); sizeh->flags = PSize | PResizeInc | PBaseSize | PMinSize; - sizeh->height = win.h; - sizeh->width = win.w; - sizeh->height_inc = win.ch; - sizeh->width_inc = win.cw; + sizeh->height = win.h, sizeh->width = win.w; + sizeh->height_inc = 1; + sizeh->width_inc = 1; sizeh->base_height = 2 * borderpx; - sizeh->base_width = 2 * borderpx; + sizeh->base_width = 2 * borderpx; sizeh->min_height = win.ch + 2 * borderpx; - sizeh->min_width = win.cw + 2 * borderpx; + sizeh->min_width = win.cw + 2 * borderpx; if (xw.isfixed) { sizeh->flags |= PMaxSize; sizeh->min_width = sizeh->max_width = win.w; @@ -1121,8 +1123,8 @@ xinit(int cols, int rows) xloadcols(); /* adjust fixed window geometry */ - win.w = 2 * borderpx + cols * win.cw; - win.h = 2 * borderpx + rows * win.ch; + win.w = 2 * win.hb + cols * win.cw; + win.h = 2 * win.vb + rows * win.ch; if (xw.gm & XNegative) xw.l += DisplayWidth(xw.dpy, xw.scr) - win.w - 2; if (xw.gm & YNegative) @@ -1207,7 +1209,7 @@ xinit(int cols, int rows) int xmakeglyphfontspecs(XftGlyphFontSpec *specs, Letter *glyphs, int len, int x, int y) { - float winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, xp, yp; + float winx = win.hb + x * win.cw, winy = win.vb + y * win.ch, xp, yp; ushort mode, prevmode = USHRT_MAX; Font *font = &dc.font; int frcflags = FRC_NORMAL; @@ -1340,8 +1342,7 @@ void xdrawglyphfontspecs(XftGlyphFontSpec *specs, Letter base, int len, int x, int y) { int charlen = len * ((base.mode & Gwide) ? 2 : 1); - int winx = borderpx + x * win.cw, winy = borderpx + y * win.ch, - width = charlen * win.cw; + int winx = win.hb + x * win.cw, winy = win.vb + y * win.ch, width = charlen * win.cw; Color *fg, *bg, *temp, revfg, revbg, truefg, truebg; XRenderColor colfg, colbg; XRectangle r; @@ -1425,17 +1426,17 @@ xdrawglyphfontspecs(XftGlyphFontSpec *specs, Letter base, int len, int x, int y) /* Intelligent cleaning up of the borders. */ if (x == 0) { - xclear(0, (y == 0)? 0 : winy, borderpx, + xclear(0, (y == 0)? 0 : winy, win.vb, winy + win.ch + - ((winy + win.ch >= borderpx + win.th)? win.h : 0)); + ((winy + win.ch >= win.vb + win.th)? win.h : 0)); } - if (winx + width >= borderpx + win.tw) { + if (winx + width >= win.hb + win.tw) { xclear(winx + width, (y == 0)? 0 : winy, win.w, - ((winy + win.ch >= borderpx + win.th)? win.h : (winy + win.ch))); + ((winy + win.ch >= win.vb + win.th)? win.h : (winy + win.ch))); } if (y == 0) - xclear(winx, 0, winx + width, borderpx); - if (winy + win.ch >= borderpx + win.th) + xclear(winx, 0, winx + width, win.hb); + if (winy + win.ch >= win.hb + win.th) xclear(winx, winy + win.ch, winx + width, win.h); /* Clean up the region we want to draw to. */ @@ -1530,35 +1531,35 @@ drawnew: break; case 3: /* Blinking Underline */ case 4: /* Steady Underline */ - XftDrawRect(xw.draw, &drawcol, - borderpx + cx * win.cw, - borderpx + (cy + 1) * win.ch - cursorthickness, + XftDrawRect(xw.draw, &drawcol, + win.hb + cx * win.cw, + win.vb + (cy + 1) * win.ch - cursorthickness, win.cw, cursorthickness); break; case 5: /* Blinking bar */ case 6: /* Steady bar */ XftDrawRect(xw.draw, &drawcol, - borderpx + cx * win.cw, - borderpx + cy * win.ch, + win.hb + cx * win.cw, + win.vb + cy * win.ch, cursorthickness, win.ch); break; } } else { XftDrawRect(xw.draw, &drawcol, - borderpx + cx * win.cw, - borderpx + cy * win.ch, + win.hb + cx * win.cw, + win.vb + cy * win.ch, win.cw - 1, 1); XftDrawRect(xw.draw, &drawcol, - borderpx + cx * win.cw, - borderpx + cy * win.ch, + win.hb + cx * win.cw, + win.vb + cy * win.ch, 1, win.ch - 1); XftDrawRect(xw.draw, &drawcol, - borderpx + (cx + 1) * win.cw - 1, - borderpx + cy * win.ch, + win.hb + (cx + 1) * win.cw - 1, + win.vb + cy * win.ch, 1, win.ch - 1); XftDrawRect(xw.draw, &drawcol, - borderpx + cx * win.cw, - borderpx + (cy + 1) * win.ch - 1, + win.hb + cx * win.cw, + win.vb + (cy + 1) * win.ch - 1, win.cw, 1); } } -- cgit v1.2.1