Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jun 2018 13:08:35 +0000 (UTC)
From:      Steve Wills <swills@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r472687 - in head/x11/sterm: . files
Message-ID:  <201806181308.w5ID8ZVL031265@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: swills
Date: Mon Jun 18 13:08:35 2018
New Revision: 472687
URL: https://svnweb.freebsd.org/changeset/ports/472687

Log:
  x11/sterm: add SOLARIZED, SCROLLBACK options
  
  PR:		229099
  Submitted by:	Piotr Kubaj <pkubaj@anongoth.pl> (maintainer)

Added:
  head/x11/sterm/files/.gitattributes   (contents, props changed)
  head/x11/sterm/files/extra-scrollback-patch-config.def.h   (contents, props changed)
  head/x11/sterm/files/extra-scrollback-patch-st.c   (contents, props changed)
  head/x11/sterm/files/extra-scrollback-patch-st.h   (contents, props changed)
  head/x11/sterm/files/extra-solarized-patch-config.def.h   (contents, props changed)
  head/x11/sterm/files/extra-solarized-patch-st.h   (contents, props changed)
  head/x11/sterm/files/extra-solarized-patch-x.c   (contents, props changed)
Modified:
  head/x11/sterm/Makefile   (contents, props changed)

Modified: head/x11/sterm/Makefile
==============================================================================
--- head/x11/sterm/Makefile	Mon Jun 18 13:06:38 2018	(r472686)
+++ head/x11/sterm/Makefile	Mon Jun 18 13:08:35 2018	(r472687)
@@ -28,6 +28,18 @@ PORTDATA=	config.def.h st.info
 PORTDOCS=	FAQ LEGACY README TODO
 
 OPTIONS_DEFINE=	DOCS
+OPTIONS_RADIO=	PATCHES
+OPTIONS_RADIO_PATCHES=	SCROLLBACK SOLARIZED
+SCROLLBACK_DESC=	Scroll back through terminal output
+SOLARIZED_DESC=	Use Solarized color scheme
+
+SCROLLBACK_EXTRA_PATCHES=	${PATCHDIR}/extra-scrollback-patch-config.def.h \
+		${PATCHDIR}/extra-scrollback-patch-st.c \
+		${PATCHDIR}/extra-scrollback-patch-st.h
+
+SOLARIZED_EXTRA_PATCHES=	${PATCHDIR}/extra-solarized-patch-config.def.h \
+		${PATCHDIR}/extra-solarized-patch-x.c \
+		${PATCHDIR}/extra-solarized-patch-st.h
 
 SUB_FILES=	pkg-message
 

Added: head/x11/sterm/files/.gitattributes
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/.gitattributes	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,6 @@
+extra-scrollback-patch-config.def.h svn-properties=fbsd:nokeywords=yes
+extra-scrollback-patch-st.c svn-properties=fbsd:nokeywords=yes
+extra-scrollback-patch-st.h svn-properties=fbsd:nokeywords=yes
+extra-solarized-patch-config.def.h svn-properties=fbsd:nokeywords=yes
+extra-solarized-patch-st.h svn-properties=fbsd:nokeywords=yes
+extra-solarized-patch-x.c svn-properties=fbsd:nokeywords=yes

Added: head/x11/sterm/files/extra-scrollback-patch-config.def.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/extra-scrollback-patch-config.def.h	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,11 @@
+--- config.def.h.orig	2018-06-18 05:54:16 UTC
++++ config.def.h
+@@ -178,6 +178,8 @@ static Shortcut shortcuts[] = {
+ 	{ TERMMOD,              XK_Y,           selpaste,       {.i =  0} },
+ 	{ TERMMOD,              XK_Num_Lock,    numlock,        {.i =  0} },
+ 	{ TERMMOD,              XK_I,           iso14755,       {.i =  0} },
++	{ ShiftMask,            XK_Page_Up,     kscrollup,      {.i = -1} },
++	{ ShiftMask,            XK_Page_Down,   kscrolldown,    {.i = -1} },
+ };
+ 
+ /*

Added: head/x11/sterm/files/extra-scrollback-patch-st.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/extra-scrollback-patch-st.c	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,300 @@
+--- st.c.orig	2018-03-20 20:29:59 UTC
++++ st.c
+@@ -121,6 +121,9 @@ typedef struct {
+ 	int col;      /* nb col */
+ 	Line *line;   /* screen */
+ 	Line *alt;    /* alternate screen */
++	Line hist[HISTSIZE]; /* history buffer */
++	int histi;    /* history index */
++	int scr;      /* scroll back */
+ 	int *dirty;   /* dirtyness of lines */
+ 	TCursor c;    /* cursor */
+ 	int ocx;      /* old cursor col */
+@@ -188,8 +191,8 @@ static void tnewline(int);
+ static void tputtab(int);
+ static void tputc(Rune);
+ static void treset(void);
+-static void tscrollup(int, int);
+-static void tscrolldown(int, int);
++static void tscrollup(int, int, int);
++static void tscrolldown(int, int, int);
+ static void tsetattr(int *, int);
+ static void tsetchar(Rune, Glyph *, int, int);
+ static void tsetdirt(int, int);
+@@ -431,10 +434,10 @@ tlinelen(int y)
+ {
+ 	int i = term.col;
+ 
+-	if (term.line[y][i - 1].mode & ATTR_WRAP)
++	if (TLINE(y)[i - 1].mode & ATTR_WRAP)
+ 		return i;
+ 
+-	while (i > 0 && term.line[y][i - 1].u == ' ')
++	while (i > 0 && TLINE(y)[i - 1].u == ' ')
+ 		--i;
+ 
+ 	return i;
+@@ -543,7 +546,7 @@ selsnap(int *x, int *y, int direction)
+ 		 * Snap around if the word wraps around at the end or
+ 		 * beginning of a line.
+ 		 */
+-		prevgp = &term.line[*y][*x];
++		prevgp = &TLINE(*y)[*x];
+ 		prevdelim = ISDELIM(prevgp->u);
+ 		for (;;) {
+ 			newx = *x + direction;
+@@ -558,14 +561,14 @@ selsnap(int *x, int *y, int direction)
+ 					yt = *y, xt = *x;
+ 				else
+ 					yt = newy, xt = newx;
+-				if (!(term.line[yt][xt].mode & ATTR_WRAP))
++				if (!(TLINE(yt)[xt].mode & ATTR_WRAP))
+ 					break;
+ 			}
+ 
+ 			if (newx >= tlinelen(newy))
+ 				break;
+ 
+-			gp = &term.line[newy][newx];
++			gp = &TLINE(newy)[newx];
+ 			delim = ISDELIM(gp->u);
+ 			if (!(gp->mode & ATTR_WDUMMY) && (delim != prevdelim
+ 					|| (delim && gp->u != prevgp->u)))
+@@ -586,14 +589,14 @@ selsnap(int *x, int *y, int direction)
+ 		*x = (direction < 0) ? 0 : term.col - 1;
+ 		if (direction < 0) {
+ 			for (; *y > 0; *y += direction) {
+-				if (!(term.line[*y-1][term.col-1].mode
++				if (!(TLINE(*y-1)[term.col-1].mode
+ 						& ATTR_WRAP)) {
+ 					break;
+ 				}
+ 			}
+ 		} else if (direction > 0) {
+ 			for (; *y < term.row-1; *y += direction) {
+-				if (!(term.line[*y][term.col-1].mode
++				if (!(TLINE(*y)[term.col-1].mode
+ 						& ATTR_WRAP)) {
+ 					break;
+ 				}
+@@ -624,13 +627,13 @@ getsel(void)
+ 		}
+ 
+ 		if (sel.type == SEL_RECTANGULAR) {
+-			gp = &term.line[y][sel.nb.x];
++			gp = &TLINE(y)[sel.nb.x];
+ 			lastx = sel.ne.x;
+ 		} else {
+-			gp = &term.line[y][sel.nb.y == y ? sel.nb.x : 0];
++			gp = &TLINE(y)[sel.nb.y == y ? sel.nb.x : 0];
+ 			lastx = (sel.ne.y == y) ? sel.ne.x : term.col-1;
+ 		}
+-		last = &term.line[y][MIN(lastx, linelen-1)];
++		last = &TLINE(y)[MIN(lastx, linelen-1)];
+ 		while (last >= gp && last->u == ' ')
+ 			--last;
+ 
+@@ -835,6 +838,9 @@ ttyread(void)
+ 	if (buflen > 0)
+ 		memmove(buf, buf + written, buflen);
+ 
++	if (term.scr > 0 && term.scr < HISTSIZE-1)
++		term.scr++;
++
+ 	return ret;
+ }
+ 
+@@ -842,6 +848,9 @@ void
+ ttywrite(const char *s, size_t n, int may_echo)
+ {
+ 	const char *next;
++	Arg arg = (Arg) { .i = term.scr };
++
++	kscrolldown(&arg);
+ 
+ 	if (may_echo && IS_SET(MODE_ECHO))
+ 		twrite(s, n, 1);
+@@ -1053,13 +1062,54 @@ tswapscreen(void)
+ }
+ 
+ void
+-tscrolldown(int orig, int n)
++kscrolldown(const Arg* a)
++{
++	int n = a->i;
++
++	if (n < 0)
++		n = term.row + n;
++
++	if (n > term.scr)
++		n = term.scr;
++
++	if (term.scr > 0) {
++		term.scr -= n;
++		selscroll(0, -n);
++		tfulldirt();
++	}
++}
++
++void
++kscrollup(const Arg* a)
++{
++	int n = a->i;
++
++	if (n < 0)
++		n = term.row + n;
++
++	if (term.scr <= HISTSIZE-n) {
++		term.scr += n;
++		selscroll(0, n);
++		tfulldirt();
++	}
++}
++
++
++void
++tscrolldown(int orig, int n, int copyhist)
+ {
+ 	int i;
+ 	Line temp;
+ 
+ 	LIMIT(n, 0, term.bot-orig+1);
+ 
++	if (copyhist) {
++		term.histi = (term.histi - 1 + HISTSIZE) % HISTSIZE;
++		temp = term.hist[term.histi];
++		term.hist[term.histi] = term.line[term.bot];
++		term.line[term.bot] = temp;
++	}
++
+ 	tsetdirt(orig, term.bot-n);
+ 	tclearregion(0, term.bot-n+1, term.col-1, term.bot);
+ 
+@@ -1073,13 +1123,20 @@ tscrolldown(int orig, int n)
+ }
+ 
+ void
+-tscrollup(int orig, int n)
++tscrollup(int orig, int n, int copyhist)
+ {
+ 	int i;
+ 	Line temp;
+ 
+ 	LIMIT(n, 0, term.bot-orig+1);
+ 
++	if (copyhist) {
++		term.histi = (term.histi + 1) % HISTSIZE;
++		temp = term.hist[term.histi];
++		term.hist[term.histi] = term.line[orig];
++		term.line[orig] = temp;
++	}
++
+ 	tclearregion(0, orig, term.col-1, orig+n-1);
+ 	tsetdirt(orig+n, term.bot);
+ 
+@@ -1128,7 +1185,7 @@ tnewline(int first_col)
+ 	int y = term.c.y;
+ 
+ 	if (y == term.bot) {
+-		tscrollup(term.top, 1);
++		tscrollup(term.top, 1, 1);
+ 	} else {
+ 		y++;
+ 	}
+@@ -1293,14 +1350,14 @@ void
+ tinsertblankline(int n)
+ {
+ 	if (BETWEEN(term.c.y, term.top, term.bot))
+-		tscrolldown(term.c.y, n);
++		tscrolldown(term.c.y, n, 0);
+ }
+ 
+ void
+ tdeleteline(int n)
+ {
+ 	if (BETWEEN(term.c.y, term.top, term.bot))
+-		tscrollup(term.c.y, n);
++		tscrollup(term.c.y, n, 0);
+ }
+ 
+ int32_t
+@@ -1729,11 +1786,11 @@ csihandle(void)
+ 		break;
+ 	case 'S': /* SU -- Scroll <n> line up */
+ 		DEFAULT(csiescseq.arg[0], 1);
+-		tscrollup(term.top, csiescseq.arg[0]);
++		tscrollup(term.top, csiescseq.arg[0], 0);
+ 		break;
+ 	case 'T': /* SD -- Scroll <n> line down */
+ 		DEFAULT(csiescseq.arg[0], 1);
+-		tscrolldown(term.top, csiescseq.arg[0]);
++		tscrolldown(term.top, csiescseq.arg[0], 0);
+ 		break;
+ 	case 'L': /* IL -- Insert <n> blank lines */
+ 		DEFAULT(csiescseq.arg[0], 1);
+@@ -2257,7 +2314,7 @@ eschandle(uchar ascii)
+ 		return 0;
+ 	case 'D': /* IND -- Linefeed */
+ 		if (term.c.y == term.bot) {
+-			tscrollup(term.top, 1);
++			tscrollup(term.top, 1, 1);
+ 		} else {
+ 			tmoveto(term.c.x, term.c.y+1);
+ 		}
+@@ -2270,7 +2327,7 @@ eschandle(uchar ascii)
+ 		break;
+ 	case 'M': /* RI -- Reverse index */
+ 		if (term.c.y == term.top) {
+-			tscrolldown(term.top, 1);
++			tscrolldown(term.top, 1, 1);
+ 		} else {
+ 			tmoveto(term.c.x, term.c.y-1);
+ 		}
+@@ -2489,7 +2546,7 @@ twrite(const char *buf, int buflen, int 
+ void
+ tresize(int col, int row)
+ {
+-	int i;
++	int i, j;
+ 	int minrow = MIN(row, term.row);
+ 	int mincol = MIN(col, term.col);
+ 	int *bp;
+@@ -2526,7 +2583,15 @@ tresize(int col, int row)
+ 	term.dirty = xrealloc(term.dirty, row * sizeof(*term.dirty));
+ 	term.tabs = xrealloc(term.tabs, col * sizeof(*term.tabs));
+ 
+-	/* resize each row to new width, zero-pad if needed */
++	for (i = 0; i < HISTSIZE; i++) {
++		term.hist[i] = xrealloc(term.hist[i], col * sizeof(Glyph));
++		for (j = mincol; j < col; j++) {
++			term.hist[i][j] = term.c.attr;
++			term.hist[i][j].u = ' ';
++		}
++	}
++
++	/* resize each r w to new width, zero-pad if needed */
+ 	for (i = 0; i < minrow; i++) {
+ 		term.line[i] = xrealloc(term.line[i], col * sizeof(Glyph));
+ 		term.alt[i]  = xrealloc(term.alt[i],  col * sizeof(Glyph));
+@@ -2583,7 +2648,7 @@ drawregion(int x1, int y1, int x2, int y
+ 			continue;
+ 
+ 		term.dirty[y] = 0;
+-		xdrawline(term.line[y], x1, y, x2);
++		xdrawline(TLINE(y), x1, y, x2);
+ 	}
+ }
+ 
+@@ -2604,8 +2669,10 @@ draw(void)
+ 		cx--;
+ 
+ 	drawregion(0, 0, term.col, term.row);
+-	xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
+-			term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
++	if (term.scr == 0) {
++		xdrawcursor(cx, term.c.y, term.line[term.c.y][cx],
++				term.ocx, term.ocy, term.line[term.ocy][term.ocx]);
++	}
+ 	term.ocx = cx, term.ocy = term.c.y;
+ 	xfinishdraw();
+ }

Added: head/x11/sterm/files/extra-scrollback-patch-st.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/extra-scrollback-patch-st.h	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,31 @@
+--- st.h.orig	2018-03-20 20:29:59 UTC
++++ st.h
+@@ -3,6 +3,9 @@
+ #include <stdint.h>
+ #include <sys/types.h>
+ 
++/* Arbitrary size */
++#define HISTSIZE      2000
++
+ /* macros */
+ #define MIN(a, b)		((a) < (b) ? (a) : (b))
+ #define MAX(a, b)		((a) < (b) ? (b) : (a))
+@@ -19,6 +22,8 @@
+ 
+ #define TRUECOLOR(r,g,b)	(1 << 24 | (r) << 16 | (g) << 8 | (b))
+ #define IS_TRUECOL(x)		(1 << 24 & (x))
++#define TLINE(y)       ((y) < term.scr ? term.hist[((y) + term.histi - term.scr \
++               + HISTSIZE + 1) % HISTSIZE] : term.line[(y) - term.scr])
+ 
+ enum glyph_attribute {
+ 	ATTR_NULL       = 0,
+@@ -111,6 +116,9 @@ void *xmalloc(size_t);
+ void *xrealloc(void *, size_t);
+ char *xstrdup(char *);
+ 
++void kscrolldown(const Arg *);
++void kscrollup(const Arg *);
++
+ /* config.h globals */
+ extern char *utmp;
+ extern char *stty_args;

Added: head/x11/sterm/files/extra-solarized-patch-config.def.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/extra-solarized-patch-config.def.h	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,95 @@
+--- config.def.h.orig	2018-03-20 20:29:59 UTC
++++ config.def.h
+@@ -84,31 +84,44 @@ unsigned int tabspaces = 8;
+ 
+ /* Terminal colors (16 first used in escape sequence) */
+ static const char *colorname[] = {
+-	/* 8 normal colors */
+-	"black",
+-	"red3",
+-	"green3",
+-	"yellow3",
+-	"blue2",
+-	"magenta3",
+-	"cyan3",
+-	"gray90",
+-
+-	/* 8 bright colors */
+-	"gray50",
+-	"red",
+-	"green",
+-	"yellow",
+-	"#5c5cff",
+-	"magenta",
+-	"cyan",
+-	"white",
+-
+-	[255] = 0,
+-
+-	/* more colors can be added after 255 to use with DefaultXX */
+-	"#cccccc",
+-	"#555555",
++	/* solarized dark */
++	"#073642",  /*  0: black    */
++	"#dc322f",  /*  1: red      */
++	"#859900",  /*  2: green    */
++	"#b58900",  /*  3: yellow   */
++	"#268bd2",  /*  4: blue     */
++	"#d33682",  /*  5: magenta  */
++	"#2aa198",  /*  6: cyan     */
++	"#eee8d5",  /*  7: white    */
++	"#002b36",  /*  8: brblack  */
++	"#cb4b16",  /*  9: brred    */
++	"#586e75",  /* 10: brgreen  */
++	"#657b83",  /* 11: bryellow */
++	"#839496",  /* 12: brblue   */
++	"#6c71c4",  /* 13: brmagenta*/
++	"#93a1a1",  /* 14: brcyan   */
++	"#fdf6e3",  /* 15: brwhite  */
++};
++ 
++/* Terminal colors for alternate (light) palette */
++static const char *altcolorname[] = {
++	/* solarized light */
++	"#eee8d5",  /*  0: black    */
++	"#dc322f",  /*  1: red      */
++	"#859900",  /*  2: green    */
++	"#b58900",  /*  3: yellow   */
++	"#268bd2",  /*  4: blue     */
++	"#d33682",  /*  5: magenta  */
++	"#2aa198",  /*  6: cyan     */
++	"#073642",  /*  7: white    */
++	"#fdf6e3",  /*  8: brblack  */
++	"#cb4b16",  /*  9: brred    */
++	"#93a1a1",  /* 10: brgreen  */
++	"#839496",  /* 11: bryellow */
++	"#657b83",  /* 12: brblue   */
++	"#6c71c4",  /* 13: brmagenta*/
++	"#586e75",  /* 14: brcyan   */
++	"#002b36",  /* 15: brwhite  */
+ };
+ 
+ 
+@@ -116,10 +129,10 @@ static const char *colorname[] = {
+  * Default colors (colorname index)
+  * foreground, background, cursor, reverse cursor
+  */
+-unsigned int defaultfg = 7;
+-unsigned int defaultbg = 0;
+-static unsigned int defaultcs = 256;
+-static unsigned int defaultrcs = 257;
++unsigned int defaultfg = 12;
++unsigned int defaultbg = 8;
++static unsigned int defaultcs = 14;
++static unsigned int defaultrcs = 15;
+ 
+ /*
+  * Default shape of cursor
+@@ -178,6 +191,7 @@ static Shortcut shortcuts[] = {
+ 	{ TERMMOD,              XK_Y,           selpaste,       {.i =  0} },
+ 	{ TERMMOD,              XK_Num_Lock,    numlock,        {.i =  0} },
+ 	{ TERMMOD,              XK_I,           iso14755,       {.i =  0} },
++	{ XK_ANY_MOD,           XK_F6,          swapcolors,     {.i =  0} },
+ };
+ 
+ /*

Added: head/x11/sterm/files/extra-solarized-patch-st.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/extra-solarized-patch-st.h	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,10 @@
+--- st.h.orig	2018-03-20 20:29:59 UTC
++++ st.h
+@@ -118,6 +118,7 @@ extern char *vtiden;
+ extern char *worddelimiters;
+ extern int allowaltscreen;
+ extern char *termname;
++extern int usealtcolors;
+ extern unsigned int tabspaces;
+ extern unsigned int defaultfg;
+ extern unsigned int defaultbg;

Added: head/x11/sterm/files/extra-solarized-patch-x.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/x11/sterm/files/extra-solarized-patch-x.c	Mon Jun 18 13:08:35 2018	(r472687)
@@ -0,0 +1,100 @@
+--- x.c.orig	2018-03-20 20:29:59 UTC
++++ x.c
+@@ -53,6 +53,7 @@ static void clipcopy(const Arg *);
+ static void clippaste(const Arg *);
+ static void numlock(const Arg *);
+ static void selpaste(const Arg *);
++static void swapcolors(const Arg *);
+ static void zoom(const Arg *);
+ static void zoomabs(const Arg *);
+ static void zoomreset(const Arg *);
+@@ -240,6 +241,8 @@ static char *opt_title = NULL;
+ 
+ static int oldbutton = 3; /* button event on startup: 3 = release */
+ 
++int usealtcolors = 0; /* 1 to use alternate palette */
++
+ void
+ clipcopy(const Arg *dummy)
+ {
+@@ -279,6 +282,14 @@ numlock(const Arg *dummy)
+ }
+ 
+ void
++swapcolors(const Arg *dummy)
++{
++	usealtcolors = !usealtcolors;
++	xloadcols();
++	redraw();
++}
++
++void
+ zoom(const Arg *arg)
+ {
+ 	Arg larg;
+@@ -700,6 +711,11 @@ sixd_to_16bit(int x)
+ 	return x == 0 ? 0 : 0x3737 + 0x2828 * x;
+ }
+ 
++const char* getcolorname(int i)
++{
++    return (usealtcolors) ?  altcolorname[i] : colorname[i];
++}
++
+ int
+ xloadcolor(int i, const char *name, Color *ncolor)
+ {
+@@ -718,7 +734,7 @@ xloadcolor(int i, const char *name, Colo
+ 			return XftColorAllocValue(xw.dpy, xw.vis,
+ 			                          xw.cmap, &color, ncolor);
+ 		} else
+-			name = colorname[i];
++			name = getcolorname(i);
+ 	}
+ 
+ 	return XftColorAllocName(xw.dpy, xw.vis, xw.cmap, name, ncolor);
+@@ -731,7 +747,7 @@ xloadcols(void)
+ 	static int loaded;
+ 	Color *cp;
+ 
+-	dc.collen = MAX(LEN(colorname), 256);
++	dc.collen = MAX(LEN(colorname), LEN(altcolorname));
+ 	dc.col = xmalloc(dc.collen * sizeof(Color));
+ 
+ 	if (loaded) {
+@@ -741,8 +757,8 @@ xloadcols(void)
+ 
+ 	for (i = 0; i < dc.collen; i++)
+ 		if (!xloadcolor(i, NULL, &dc.col[i])) {
+-			if (colorname[i])
+-				die("Could not allocate color '%s'\n", colorname[i]);
++			if (getcolorname(i))
++				die("Could not allocate color '%s'\n", getcolorname(i));
+ 			else
+ 				die("Could not allocate color %d\n", i);
+ 		}
+@@ -1079,13 +1095,13 @@ xinit(int cols, int rows)
+ 	cursor = XCreateFontCursor(xw.dpy, mouseshape);
+ 	XDefineCursor(xw.dpy, xw.win, cursor);
+ 
+-	if (XParseColor(xw.dpy, xw.cmap, colorname[mousefg], &xmousefg) == 0) {
++	if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousefg), &xmousefg) == 0) {
+ 		xmousefg.red   = 0xffff;
+ 		xmousefg.green = 0xffff;
+ 		xmousefg.blue  = 0xffff;
+ 	}
+ 
+-	if (XParseColor(xw.dpy, xw.cmap, colorname[mousebg], &xmousebg) == 0) {
++	if (XParseColor(xw.dpy, xw.cmap, getcolorname(mousebg), &xmousebg) == 0) {
+ 		xmousebg.red   = 0x0000;
+ 		xmousebg.green = 0x0000;
+ 		xmousebg.blue  = 0x0000;
+@@ -1295,7 +1311,7 @@ xdrawglyphfontspecs(const XftGlyphFontSp
+ 
+ 	/* Change basic system colors [0-7] to bright system colors [8-15] */
+ 	if ((base.mode & ATTR_BOLD_FAINT) == ATTR_BOLD && BETWEEN(base.fg, 0, 7))
+-		fg = &dc.col[base.fg + 8];
++		fg = &dc.col[base.fg];
+ 
+ 	if (IS_SET(MODE_REVERSE)) {
+ 		if (fg == &dc.col[defaultfg]) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806181308.w5ID8ZVL031265>