[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemacs-commit] qemacs Makefile cfb.c display.c display.h fbfre...
From: |
Charlie Gordon |
Subject: |
[Qemacs-commit] qemacs Makefile cfb.c display.c display.h fbfre... |
Date: |
Tue, 11 Apr 2017 02:46:14 -0400 (EDT) |
CVSROOT: /sources/qemacs
Module name: qemacs
Changes by: Charlie Gordon <chqrlie> 17/04/11 02:46:13
Modified files:
. : Makefile cfb.c display.c display.h fbfrender.c
haiku.cpp html2png.c qe.c qestyles.h tty.c
util.c x11.c
libqhtml : css.c
tests : 16colors.pl color-spaces.pl
Added files:
tests : 24-bit-color.sh 7936-colors.sh mandelbrot.sh
xterm-palette.sh
Log message:
styles: improve consistency
- rename font styles QE_STYLE_xxx to QE_FONT_STYLE_xxx
- rename font family QE_FAMILY_xxx to QE_FONT_FAMILY_xxx
- improve tests/16colors.pl: display bold italics combination
- improve tests/color-spaces.pl: compare true color and palette dumps
- add colortest target in Makefile to produce various color patterns
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/Makefile?cvsroot=qemacs&r1=1.96&r2=1.97
http://cvs.savannah.gnu.org/viewcvs/qemacs/cfb.c?cvsroot=qemacs&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/qemacs/display.c?cvsroot=qemacs&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/qemacs/display.h?cvsroot=qemacs&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/qemacs/fbfrender.c?cvsroot=qemacs&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/qemacs/haiku.cpp?cvsroot=qemacs&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/qemacs/html2png.c?cvsroot=qemacs&r1=1.18&r2=1.19
http://cvs.savannah.gnu.org/viewcvs/qemacs/qe.c?cvsroot=qemacs&r1=1.261&r2=1.262
http://cvs.savannah.gnu.org/viewcvs/qemacs/qestyles.h?cvsroot=qemacs&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/qemacs/tty.c?cvsroot=qemacs&r1=1.76&r2=1.77
http://cvs.savannah.gnu.org/viewcvs/qemacs/util.c?cvsroot=qemacs&r1=1.78&r2=1.79
http://cvs.savannah.gnu.org/viewcvs/qemacs/x11.c?cvsroot=qemacs&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/qemacs/libqhtml/css.c?cvsroot=qemacs&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/qemacs/tests/16colors.pl?cvsroot=qemacs&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qemacs/tests/color-spaces.pl?cvsroot=qemacs&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/qemacs/tests/24-bit-color.sh?cvsroot=qemacs&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qemacs/tests/7936-colors.sh?cvsroot=qemacs&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qemacs/tests/mandelbrot.sh?cvsroot=qemacs&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/qemacs/tests/xterm-palette.sh?cvsroot=qemacs&rev=1.1
Patches:
Index: Makefile
===================================================================
RCS file: /sources/qemacs/qemacs/Makefile,v
retrieving revision 1.96
retrieving revision 1.97
diff -u -b -r1.96 -r1.97
--- Makefile 28 Mar 2017 12:53:15 -0000 1.96
+++ Makefile 11 Apr 2017 06:46:13 -0000 1.97
@@ -574,6 +574,15 @@
FILE=qemacs-$(shell cat VERSION)
+colortest:
+ tests/16colors.pl
+ tests/256colors2.pl
+ tests/truecolors.sh
+ tests/color-spaces.pl
+ tests/mandelbrot.sh
+ tests/xterm-colour-chart.py
+ tests/7936-colors.sh
+
tar: $(FILES)
rm -f $(HOME)/$(FILE).tar.gz
rm -rf /tmp/$(FILE)
Index: cfb.c
===================================================================
RCS file: /sources/qemacs/qemacs/cfb.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- cfb.c 13 Oct 2015 20:54:00 -0000 1.12
+++ cfb.c 11 Apr 2017 06:46:13 -0000 1.13
@@ -282,17 +282,17 @@
}
/* underline synthesis */
- if (font->style & (QE_STYLE_UNDERLINE | QE_STYLE_LINE_THROUGH)) {
+ if (font->style & (QE_FONT_STYLE_UNDERLINE | QE_FONT_STYLE_LINE_THROUGH)) {
int dy, h, w;
h = (font->descent + 2) / 4;
if (h < 1)
h = 1;
w = x - x_start;
- if (font->style & QE_STYLE_UNDERLINE) {
+ if (font->style & QE_FONT_STYLE_UNDERLINE) {
dy = (font->descent + 1) / 3;
fill_rectangle(s, x_start, y + dy, w, h, color);
}
- if (font->style & QE_STYLE_LINE_THROUGH) {
+ if (font->style & QE_FONT_STYLE_LINE_THROUGH) {
dy = -(font->ascent / 2 - 1);
fill_rectangle(s, x_start, y + dy, w, h, color);
}
Index: display.c
===================================================================
RCS file: /sources/qemacs/qemacs/display.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- display.c 15 Mar 2017 07:24:31 -0000 1.19
+++ display.c 11 Apr 2017 06:46:13 -0000 1.20
@@ -291,7 +291,7 @@
}
fc = open_font(s, style, size);
if (!fc) {
- if (style & QE_FAMILY_FALLBACK_MASK)
+ if (style & QE_FONT_FAMILY_FALLBACK_MASK)
return NULL;
put_error(NULL, "open_font: cannot open style=%X size=%d",
Index: display.h
===================================================================
RCS file: /sources/qemacs/qemacs/display.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- display.h 2 Apr 2017 01:12:01 -0000 1.19
+++ display.h 11 Apr 2017 06:46:13 -0000 1.20
@@ -25,25 +25,24 @@
#define MAX_SCREEN_WIDTH 1024 /* in chars */
#define MAX_SCREEN_LINES 256 /* in text lines */
-/* XXX: use different name prefix to avoid conflict */
-#define QE_STYLE_NORM 0x0001
-#define QE_STYLE_BOLD 0x0002
-#define QE_STYLE_ITALIC 0x0004
-#define QE_STYLE_UNDERLINE 0x0008
-#define QE_STYLE_LINE_THROUGH 0x0010
-#define QE_STYLE_BLINK 0x0020
-#define QE_STYLE_MASK 0x00ff
+#define QE_FONT_STYLE_NORM 0x0001
+#define QE_FONT_STYLE_BOLD 0x0002
+#define QE_FONT_STYLE_ITALIC 0x0004
+#define QE_FONT_STYLE_UNDERLINE 0x0008
+#define QE_FONT_STYLE_LINE_THROUGH 0x0010
+#define QE_FONT_STYLE_BLINK 0x0020
+#define QE_FONT_STYLE_MASK 0x00ff
#define NB_FONT_FAMILIES 3
-#define QE_FAMILY_SHIFT 8
-#define QE_FAMILY_MASK 0xff00
-#define QE_FAMILY_FIXED 0x0100
-#define QE_FAMILY_SERIF 0x0200
-#define QE_FAMILY_SANS 0x0300 /* sans serif */
+#define QE_FONT_FAMILY_SHIFT 8
+#define QE_FONT_FAMILY_MASK 0xff00
+#define QE_FONT_FAMILY_FIXED 0x0100
+#define QE_FONT_FAMILY_SERIF 0x0200
+#define QE_FONT_FAMILY_SANS 0x0300 /* sans serif */
/* fallback font handling */
-#define QE_FAMILY_FALLBACK_SHIFT 16
-#define QE_FAMILY_FALLBACK_MASK 0xff0000
+#define QE_FONT_FAMILY_FALLBACK_SHIFT 16
+#define QE_FONT_FAMILY_FALLBACK_MASK 0xff0000
typedef struct QEFont {
int refcount;
Index: fbfrender.c
===================================================================
RCS file: /sources/qemacs/qemacs/fbfrender.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- fbfrender.c 16 Sep 2015 22:18:23 -0000 1.14
+++ fbfrender.c 11 Apr 2017 06:46:13 -0000 1.15
@@ -183,7 +183,7 @@
g = fbf_decode_glyph1(font, code);
if (!g) {
/* try with fallback font */
- font1 = select_font(s, font->style | (1 <<
QE_FAMILY_FALLBACK_SHIFT),
+ font1 = select_font(s, font->style | (1 <<
QE_FONT_FAMILY_FALLBACK_SHIFT),
font->size);
g = fbf_decode_glyph1(font1, code);
release_font(s, font1);
@@ -241,11 +241,11 @@
if (!font)
return NULL;
- if ((style & QE_FAMILY_FALLBACK_MASK) != 0) {
+ if ((style & QE_FONT_FAMILY_FALLBACK_MASK) != 0) {
uf_found = fallback_font;
} else {
/* convert to unifont family types */
- style = ((style & QE_FAMILY_MASK) >> QE_FAMILY_SHIFT) - 1;
+ style = ((style & QE_FONT_FAMILY_MASK) >> QE_FONT_FAMILY_SHIFT) - 1;
/* first match style */
nb_fonts = 0;
Index: haiku.cpp
===================================================================
RCS file: /sources/qemacs/qemacs/haiku.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- haiku.cpp 28 Mar 2017 12:53:15 -0000 1.15
+++ haiku.cpp 11 Apr 2017 06:46:13 -0000 1.16
@@ -672,28 +672,28 @@
BFont *f;
uint16 face = 0;
- switch (style & QE_FAMILY_MASK) {
+ switch (style & QE_FONT_FAMILY_MASK) {
default:
- case QE_FAMILY_FIXED:
+ case QE_FONT_FAMILY_FIXED:
f = new BFont(be_fixed_font);
break;
- case QE_FAMILY_SANS:
- case QE_FAMILY_SERIF:
+ case QE_FONT_FAMILY_SANS:
+ case QE_FONT_FAMILY_SERIF:
/* There isn't a separate default sans and serif font */
/* for now just only use fixed font */
//f = new BFont(be_plain_font);
f = new BFont(be_fixed_font);
break;
}
- if (style & QE_STYLE_NORM)
+ if (style & QE_FONT_STYLE_NORM)
face |= B_REGULAR_FACE;
- if (style & QE_STYLE_BOLD)
+ if (style & QE_FONT_STYLE_BOLD)
face |= B_BOLD_FACE;
- if (style & QE_STYLE_ITALIC)
+ if (style & QE_FONT_STYLE_ITALIC)
face |= B_ITALIC_FACE;
- if (style & QE_STYLE_UNDERLINE)
+ if (style & QE_FONT_STYLE_UNDERLINE)
face |= B_UNDERSCORE_FACE; // not really supported IIRC
- if (style & QE_STYLE_LINE_THROUGH)
+ if (style & QE_FONT_STYLE_LINE_THROUGH)
face |= B_STRIKEOUT_FACE; // not really supported IIRC
if (face)
f->SetFace(face);
@@ -770,18 +770,18 @@
ctx->v->DrawString(text.String());
/* underline synthesis */
- if (font->style & (QE_STYLE_UNDERLINE | QE_STYLE_LINE_THROUGH)) {
+ if (font->style & (QE_FONT_STYLE_UNDERLINE | QE_FONT_STYLE_LINE_THROUGH)) {
int dy, h, w;
BFont *f = (BFont *)font->priv_data;
h = (font->descent + 2) / 4 - 1;
if (h < 0)
h = 0;
w = (int)f->StringWidth(text.String()) - 1;
- if (font->style & QE_STYLE_UNDERLINE) {
+ if (font->style & QE_FONT_STYLE_UNDERLINE) {
dy = (font->descent + 1) / 3;
ctx->v->FillRect(BRect(x1, y + dy, x1 + w, y + dy + h));
}
- if (font->style & QE_STYLE_LINE_THROUGH) {
+ if (font->style & QE_FONT_STYLE_LINE_THROUGH) {
dy = -(font->ascent / 2 - 1);
ctx->v->FillRect(BRect(x1, y + dy, x1 + w, y + dy + h));
}
Index: html2png.c
===================================================================
RCS file: /sources/qemacs/qemacs/html2png.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -b -r1.18 -r1.19
--- html2png.c 15 Mar 2017 07:24:31 -0000 1.18
+++ html2png.c 11 Apr 2017 06:46:13 -0000 1.19
@@ -315,7 +315,7 @@
QERGB(0xff, 0x00, 0x00));
len = utf8_to_unicode(buf, sizeof(buf), "Hello World !");
- font = select_font(screen, QE_FAMILY_FIXED | QE_STYLE_NORM, 12);
+ font = select_font(screen, QE_FONT_FAMILY_FIXED | QE_FONT_STYLE_NORM, 12);
draw_text(screen, font, screen->width / 2, screen->height / 2,
buf, len, QERGB(0x00, 0x00, 0x00));
Index: qe.c
===================================================================
RCS file: /sources/qemacs/qemacs/qe.c,v
retrieving revision 1.261
retrieving revision 1.262
diff -u -b -r1.261 -r1.262
--- qe.c 3 Apr 2017 08:33:57 -0000 1.261
+++ qe.c 11 Apr 2017 06:46:13 -0000 1.262
@@ -2762,13 +2762,13 @@
stp->fg_color = xterm_colors[QE_TERM_GET_FG(style)];
stp->bg_color = xterm_colors[QE_TERM_GET_BG(style)];
if (style & QE_TERM_UNDERLINE)
- stp->font_style |= QE_STYLE_UNDERLINE;
+ stp->font_style |= QE_FONT_STYLE_UNDERLINE;
if (style & QE_TERM_BOLD)
- stp->font_style |= QE_STYLE_BOLD;
+ stp->font_style |= QE_FONT_STYLE_BOLD;
if (style & QE_TERM_ITALIC)
- stp->font_style |= QE_STYLE_ITALIC;
+ stp->font_style |= QE_FONT_STYLE_ITALIC;
if (style & QE_TERM_BLINK)
- stp->font_style |= QE_STYLE_BLINK;
+ stp->font_style |= QE_FONT_STYLE_BLINK;
} else {
s = &qe_styles[style & QE_STYLE_NUM];
if (s->fg_color != COLOR_TRANSPARENT)
@@ -2913,16 +2913,16 @@
return;
case CSS_PROP_FONT_FAMILY:
v = css_get_font_family(value);
- stp->font_style = (stp->font_style & ~QE_FAMILY_MASK) | v;
+ stp->font_style = (stp->font_style & ~QE_FONT_FAMILY_MASK) | v;
break;
case CSS_PROP_FONT_STYLE:
/* XXX: cannot handle inherit correctly */
v = stp->font_style;
if (strequal(value, "italic")) {
- v |= QE_STYLE_ITALIC;
+ v |= QE_FONT_STYLE_ITALIC;
} else
if (strequal(value, "normal")) {
- v &= ~QE_STYLE_ITALIC;
+ v &= ~QE_FONT_STYLE_ITALIC;
}
stp->font_style = v;
break;
@@ -2930,10 +2930,10 @@
/* XXX: cannot handle inherit correctly */
v = stp->font_style;
if (strequal(value, "bold")) {
- v |= QE_STYLE_BOLD;
+ v |= QE_FONT_STYLE_BOLD;
} else
if (strequal(value, "normal")) {
- v &= ~QE_STYLE_BOLD;
+ v &= ~QE_FONT_STYLE_BOLD;
}
stp->font_style = v;
break;
@@ -2947,10 +2947,10 @@
case CSS_PROP_TEXT_DECORATION:
/* XXX: cannot handle inherit correctly */
if (strequal(value, "none")) {
- stp->font_style &= ~QE_STYLE_UNDERLINE;
+ stp->font_style &= ~QE_FONT_STYLE_UNDERLINE;
} else
if (strequal(value, "underline")) {
- stp->font_style |= QE_STYLE_UNDERLINE;
+ stp->font_style |= QE_FONT_STYLE_UNDERLINE;
}
break;
}
Index: qestyles.h
===================================================================
RCS file: /sources/qemacs/qemacs/qestyles.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- qestyles.h 19 Aug 2015 20:33:01 -0000 1.11
+++ qestyles.h 11 Apr 2017 06:46:13 -0000 1.12
@@ -1,7 +1,7 @@
/* root style, must be complete */
STYLE_DEF(QE_STYLE_DEFAULT, "default",
QERGB(0xf8, 0xd8, 0xb0), QERGB(0x00, 0x00, 0x00),
- QE_FAMILY_FIXED, 12)
+ QE_FONT_FAMILY_FIXED, 12)
/* system styles */
STYLE_DEF(QE_STYLE_MODE_LINE, "mode-line",
@@ -20,7 +20,7 @@
/* default style for HTML/CSS2 pages */
STYLE_DEF(QE_STYLE_CSS_DEFAULT, "css-default",
QERGB(0x00, 0x00, 0x00), QERGB(0xbb, 0xbb, 0xbb),
- QE_FAMILY_SERIF, 12)
+ QE_FONT_FAMILY_SERIF, 12)
/* coloring styles */
STYLE_DEF(QE_STYLE_HIGHLIGHT, "highlight",
Index: tty.c
===================================================================
RCS file: /sources/qemacs/qemacs/tty.c,v
retrieving revision 1.76
retrieving revision 1.77
diff -u -b -r1.76 -r1.77
--- tty.c 3 Apr 2017 08:33:57 -0000 1.76
+++ tty.c 11 Apr 2017 06:46:13 -0000 1.77
@@ -825,7 +825,7 @@
#define comb_cache_describe(s, b)
#endif
-static void tty_term_draw_text(QEditScreen *s, qe__unused__ QEFont *font,
+static void tty_term_draw_text(QEditScreen *s, QEFont *font,
int x, int y, const unsigned int *str0, int len,
QEColor color)
{
@@ -840,13 +840,13 @@
ts->line_updated[y] = 1;
fgcolor = qe_map_color(color, ts->term_colors, ts->term_fg_colors_count,
NULL);
- if (font->style & QE_STYLE_UNDERLINE)
+ if (font->style & QE_FONT_STYLE_UNDERLINE)
fgcolor |= TTY_UNDERLINE;
- if (font->style & QE_STYLE_BOLD)
+ if (font->style & QE_FONT_STYLE_BOLD)
fgcolor |= TTY_BOLD;
- if (font->style & QE_STYLE_BLINK)
+ if (font->style & QE_FONT_STYLE_BLINK)
fgcolor |= TTY_BLINK;
- if (font->style & QE_STYLE_ITALIC)
+ if (font->style & QE_FONT_STYLE_ITALIC)
fgcolor |= TTY_ITALIC;
ptr = ts->screen + y * s->width;
@@ -1027,7 +1027,6 @@
ch = TTY_CHAR_GET_CH(cc);
if ((unsigned int)ch != TTY_CHAR_NONE) {
/* output attributes */
- again:
if (bgcolor != (int)TTY_CHAR_GET_BG(cc)) {
int lastbg = bgcolor;
bgcolor = TTY_CHAR_GET_BG(cc);
@@ -1042,11 +1041,9 @@
} else {
if (lastbg > 7) {
TTY_FPUTS("\033[25m", s->STDOUT);
- //fgcolor = -1;
}
}
- TTY_FPRINTF(s->STDOUT, "\033[%dm",
- 40 + (bgcolor & 7));
+ TTY_FPRINTF(s->STDOUT, "\033[%dm", 40 + (bgcolor &
7));
} else {
TTY_FPRINTF(s->STDOUT, "\033[%dm",
bgcolor > 7 ? 100 + bgcolor - 8 :
@@ -1069,20 +1066,15 @@
} else {
if (lastfg > 7) {
TTY_FPUTS("\033[22m", s->STDOUT);
- //fgcolor = -1;
- //bgcolor = -1;
- goto again;
}
}
- TTY_FPRINTF(s->STDOUT, "\033[%dm",
- 30 + (fgcolor & 7));
+ TTY_FPRINTF(s->STDOUT, "\033[%dm", 30 + (fgcolor &
7));
} else {
TTY_FPRINTF(s->STDOUT, "\033[%dm",
fgcolor > 8 ? 90 + fgcolor - 8 :
30 + fgcolor);
}
}
-#if 1
if (attr != (int)TTY_CHAR_GET_COL(cc)) {
int lastattr = attr;
attr = TTY_CHAR_GET_COL(cc);
@@ -1115,7 +1107,6 @@
TTY_FPUTS("\033[23m", s->STDOUT);
}
}
-#endif
}
if (shifted) {
/* Kludge for linedrawing chars */
@@ -1147,7 +1138,7 @@
TTY_PUTC(ch - 32, s->STDOUT);
}
} else
-#if MAX_UNICODE_DISPLAY > 0xFFFF
+#if COMB_CACHE_SIZE > 1
if (ch >= TTY_CHAR_COMB && ch < TTY_CHAR_COMB +
COMB_CACHE_SIZE - 1) {
u8 buf[10], *q;
unsigned int *ip = ts->comb_cache + (ch -
TTY_CHAR_COMB);
Index: util.c
===================================================================
RCS file: /sources/qemacs/qemacs/util.c,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -b -r1.78 -r1.79
--- util.c 3 Apr 2017 08:33:57 -0000 1.78
+++ util.c 11 Apr 2017 06:46:13 -0000 1.79
@@ -1709,17 +1709,17 @@
if (!strcasecmp(str, "serif") ||
!strcasecmp(str, "times"))
- v = QE_FAMILY_SERIF;
+ v = QE_FONT_FAMILY_SERIF;
else
if (!strcasecmp(str, "sans") ||
!strcasecmp(str, "arial") ||
!strcasecmp(str, "helvetica"))
- v = QE_FAMILY_SANS;
+ v = QE_FONT_FAMILY_SANS;
else
if (!strcasecmp(str, "fixed") ||
!strcasecmp(str, "monospace") ||
!strcasecmp(str, "courier"))
- v = QE_FAMILY_FIXED;
+ v = QE_FONT_FAMILY_FIXED;
else
v = 0; /* inherit */
return v;
Index: x11.c
===================================================================
RCS file: /sources/qemacs/qemacs/x11.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- x11.c 26 Mar 2017 15:57:24 -0000 1.47
+++ x11.c 11 Apr 2017 06:46:13 -0000 1.48
@@ -233,7 +233,7 @@
xsize = w;
ysize = h;
} else {
- xsize = 80;
+ xsize = 128;
ysize = 50;
if (geometry_str) {
@@ -541,23 +541,23 @@
if (!font)
return NULL;
- switch (style & QE_FAMILY_MASK) {
+ switch (style & QE_FONT_FAMILY_MASK) {
default:
- case QE_FAMILY_FIXED:
+ case QE_FONT_FAMILY_FIXED:
family = font_family_str;
break;
- case QE_FAMILY_SANS:
+ case QE_FONT_FAMILY_SANS:
family = "sans";
break;
- case QE_FAMILY_SERIF:
+ case QE_FONT_FAMILY_SERIF:
family = "serif";
break;
}
weight = XFT_WEIGHT_MEDIUM;
- if (style & QE_STYLE_BOLD)
+ if (style & QE_FONT_STYLE_BOLD)
weight = XFT_WEIGHT_BOLD;
slant = XFT_SLANT_ROMAN;
- if (style & QE_STYLE_ITALIC)
+ if (style & QE_FONT_STYLE_ITALIC)
slant = XFT_SLANT_ITALIC;
renderFont = XftFontOpen(display, xscreen,
@@ -683,7 +683,7 @@
return NULL;
/* get font name */
- font_index = ((style & QE_FAMILY_MASK) >> QE_FAMILY_SHIFT) - 1;
+ font_index = ((style & QE_FONT_FAMILY_MASK) >> QE_FONT_FAMILY_SHIFT) - 1;
if ((unsigned)font_index >= NB_FONT_FAMILIES)
font_index = 0; /* fixed font is default */
family_list = qe_state.system_fonts[font_index];
@@ -691,7 +691,7 @@
family_list = default_x11_fonts[font_index];
/* take the nth font number in family list */
- font_fallback = (style & QE_FAMILY_FALLBACK_MASK) >>
QE_FAMILY_FALLBACK_SHIFT;
+ font_fallback = (style & QE_FONT_FAMILY_FALLBACK_MASK) >>
QE_FONT_FAMILY_FALLBACK_SHIFT;
p = family_list;
for (i = 0; i < font_fallback; i++) {
p = strchr(p, ',');
@@ -742,13 +742,13 @@
get_entry(NULL, 0, &p);
get_entry(NULL, 0, &p); /* family */
get_entry(buf, sizeof(buf), &p); /* weight */
- if (!((strequal(buf, "bold") && (style & QE_STYLE_BOLD)) ||
- (strequal(buf, "medium") && !(style & QE_STYLE_BOLD))))
+ if (!((strequal(buf, "bold") && (style & QE_FONT_STYLE_BOLD)) ||
+ (strequal(buf, "medium") && !(style & QE_FONT_STYLE_BOLD))))
dist += 3;
get_entry(buf, sizeof(buf), &p); /* slant */
- if (!((strequal(buf, "o") && (style & QE_STYLE_ITALIC)) ||
- (strequal(buf, "i") && (style & QE_STYLE_ITALIC)) ||
- (strequal(buf, "r") && !(style & QE_STYLE_ITALIC))))
+ if (!((strequal(buf, "o") && (style & QE_FONT_STYLE_ITALIC)) ||
+ (strequal(buf, "i") && (style & QE_FONT_STYLE_ITALIC)) ||
+ (strequal(buf, "r") && !(style & QE_FONT_STYLE_ITALIC))))
dist += 3;
get_entry(NULL, 0, &p); /* swidth */
get_entry(NULL, 0, &p); /* adstyle */
@@ -858,7 +858,7 @@
/* fallback case */
for (fallback_count = 1; fallback_count < 5; fallback_count++) {
font1 = select_font(s, font->style |
- (fallback_count << QE_FAMILY_FALLBACK_SHIFT),
+ (fallback_count << QE_FONT_FAMILY_FALLBACK_SHIFT),
font->size);
if (!font1)
break;
@@ -973,17 +973,17 @@
update_rect(x_start, y - last_font->ascent, x, y + last_font->descent);
}
/* underline synthesis */
- if (font->style & (QE_STYLE_UNDERLINE | QE_STYLE_LINE_THROUGH)) {
+ if (font->style & (QE_FONT_STYLE_UNDERLINE | QE_FONT_STYLE_LINE_THROUGH)) {
int dy, h, w;
h = (font->descent + 2) / 4;
if (h < 1)
h = 1;
w = x - x1;
- if (font->style & QE_STYLE_UNDERLINE) {
+ if (font->style & QE_FONT_STYLE_UNDERLINE) {
dy = (font->descent + 1) / 3;
XFillRectangle(display, dbuffer, gc, x1, y + dy, w, h);
}
- if (font->style & QE_STYLE_LINE_THROUGH) {
+ if (font->style & QE_FONT_STYLE_LINE_THROUGH) {
dy = -(font->ascent / 2 - 1);
XFillRectangle(display, dbuffer, gc, x1, y + dy, w, h);
}
Index: libqhtml/css.c
===================================================================
RCS file: /sources/qemacs/qemacs/libqhtml/css.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- libqhtml/css.c 25 Mar 2017 18:04:51 -0000 1.29
+++ libqhtml/css.c 11 Apr 2017 06:46:13 -0000 1.30
@@ -812,7 +812,7 @@
/* size of 12 points */
props->font_size = (12 * s->dots_per_inch) / 72;
- props->font_family = QE_FAMILY_SERIF;
+ props->font_family = QE_FONT_FAMILY_SERIF;
props->border_colors[0] = COLOR_TRANSPARENT;
props->border_colors[1] = COLOR_TRANSPARENT;
props->border_colors[2] = COLOR_TRANSPARENT;
@@ -2047,14 +2047,14 @@
/* select the correct font */
style = 0;
if (props->font_style == CSS_FONT_STYLE_ITALIC)
- style |= QE_STYLE_ITALIC;
+ style |= QE_FONT_STYLE_ITALIC;
if (props->font_weight == CSS_FONT_WEIGHT_BOLD ||
props->font_weight == CSS_FONT_WEIGHT_BOLDER)
- style |= QE_STYLE_BOLD;
+ style |= QE_FONT_STYLE_BOLD;
if (props->text_decoration == CSS_TEXT_DECORATION_UNDERLINE)
- style |= QE_STYLE_UNDERLINE;
+ style |= QE_FONT_STYLE_UNDERLINE;
else if (props->text_decoration == CSS_TEXT_DECORATION_LINE_THROUGH)
- style |= QE_STYLE_LINE_THROUGH;
+ style |= QE_FONT_STYLE_LINE_THROUGH;
style |= props->font_family;
return select_font(screen, style, props->font_size);
Index: tests/16colors.pl
===================================================================
RCS file: /sources/qemacs/qemacs/tests/16colors.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tests/16colors.pl 3 Apr 2017 08:33:57 -0000 1.1
+++ tests/16colors.pl 11 Apr 2017 06:46:13 -0000 1.2
@@ -49,6 +49,14 @@
}
print "\x1b[0m\n\n";
+print "Bold+Italic colors:\n";
+print "\x1b[1m\x1b[3m";
+for ($color = 0; $color < 16; $color++) {
+ $n = $color > 7 ? 90 + $color - 8 : $color + 30;
+ printf("\x1b[%dm %02d ", $n, $color);
+}
+print "\x1b[0m\n\n";
+
print "Underline colors:\n";
print "\x1b[4m";
for ($color = 0; $color < 16; $color++) {
Index: tests/color-spaces.pl
===================================================================
RCS file: /sources/qemacs/qemacs/tests/color-spaces.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- tests/color-spaces.pl 3 Apr 2017 08:33:57 -0000 1.1
+++ tests/color-spaces.pl 11 Apr 2017 06:46:13 -0000 1.2
@@ -42,6 +42,7 @@
print "\x1b[0m\n\n";
}
+if (0) {
print "Examples for the 3-byte color mode\n\n";
for ($fgbg = 38; $fgbg <= 48; $fgbg +=10) {
@@ -66,26 +67,46 @@
print "\x1b[${fgbg};2;255;255;255m::";
print "\x1b[0m\n\n";
}
+}
-print "Combined direct palette and RGB color modes\n\n";
+print "Compare direct palette and RGB color modes\n\n";
-$s = " x ";
+$s = "::";
for ($fgbg = 38; $fgbg <= 48; $fgbg +=10) {
# the color cube
- print "Color cube\n";
- for ($green = 0; $green < 256; $green += 51) {
- for ($red = 0; $red < 256; $red += 51) {
- for ($blue = 0; $blue < 256; $blue += 51) {
- print "\x1b[${fgbg};2;${red};${green};${blue}m$s";
+ print "RGB color cube\n";
+ for ($green = 0; $green < 6; $green += 1) {
+ for ($red = 0; $red < 6; $red += 1) {
+ for ($blue = 0; $blue < 6; $blue += 1) {
+ $r = $red * 51;
+ $g = $green * 51;
+ $b = $blue * 51;
+ print "\x1b[${fgbg};2;${r};${g};${b}m${s}";
}
print "\x1b[0m ";
}
print "\n";
- for ($red = 0; $red < 256; $red += 51) {
- for ($blue = 0; $blue < 256; $blue += 51) {
- $color = 16 + ($red / 51) * 36 + ($green / 51) * 6 + ($blue /
51);
- print "\x1b[${fgbg};5;${color}m$s";
+ }
+ print "Xterm palette color cube\n";
+ for ($green = 0; $green < 6; $green += 1) {
+ for ($red = 0; $red < 6; $red += 1) {
+ for ($blue = 0; $blue < 6; $blue += 1) {
+ $r = $red ? $red * 40 + 55 : 0;
+ $g = $green ? $green * 40 + 55 : 0;
+ $b = $blue ? $blue * 40 + 55 : 0;
+ print "\x1b[${fgbg};2;${r};${g};${b}m${s}";
+ }
+ print "\x1b[0m ";
+ }
+ print "\n";
+ }
+ print "Local palette color cube\n";
+ for ($green = 0; $green < 6; $green += 1) {
+ for ($red = 0; $red < 6; $red += 1) {
+ for ($blue = 0; $blue < 6; $blue += 1) {
+ $color = 16 + $red * 36 + $green * 6 + $blue;
+ print "\x1b[${fgbg};5;${color}m${s}";
}
print "\x1b[0m ";
}
@@ -94,17 +115,19 @@
# the grayscale ramp
print "Grayscale ramp:\n";
- print "\x1b[${fgbg};2;0;0;0m$s";
+ print " RGB: ";
+ print "\x1b[${fgbg};2;0;0;0m${s}";
for ($gray = 8; $gray < 256; $gray += 10) {
- print "\x1b[${fgbg};2;${gray};${gray};${gray}m$s";
+ print "\x1b[${fgbg};2;${gray};${gray};${gray}m${s}";
}
- print "\x1b[${fgbg};2;255;255;255m$s";
+ print "\x1b[${fgbg};2;255;255;255m${s}";
print "\x1b[0m\n";
- print "\x1b[${fgbg};2;0;0;0m$s";
+ print "Palette: ";
+ print "\x1b[${fgbg};2;0;0;0m${s}";
for ($gray = 8; $gray < 256; $gray += 10) {
- print "\x1b[${fgbg};2;${gray};${gray};${gray}m$s";
+ print "\x1b[${fgbg};2;${gray};${gray};${gray}m${s}";
}
- print "\x1b[${fgbg};2;255;255;255m$s";
+ print "\x1b[${fgbg};2;255;255;255m${s}";
print "\x1b[0m\n";
print "\n";
}
Index: tests/24-bit-color.sh
===================================================================
RCS file: tests/24-bit-color.sh
diff -N tests/24-bit-color.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/24-bit-color.sh 11 Apr 2017 06:46:13 -0000 1.1
@@ -0,0 +1,100 @@
+#!/bin/bash
+# This file was originally taken from iterm2
+# https://github.com/gnachman/iTerm2/blob/master/tests/24-bit-color.sh
+#
+# This file echoes a bunch of 24-bit color codes
+# to the terminal to demonstrate its functionality.
+# The foreground escape sequence is ^[38;2;<r>;<g>;<b>m
+# The background escape sequence is ^[48;2;<r>;<g>;<b>m
+# <r> <g> <b> range from 0 to 255 inclusive.
+# The escape sequence ^[0m returns output to default
+
+setBackgroundColor() {
+ echo -ne "\033[48;2;$1;$2;$3m$4"
+}
+
+resetColor() {
+ echo -ne "\033[0m\n"
+}
+
+# Gives a color $1/255 % along HSV
+# Who knows what happens when $1 is outside 0-255
+# Echoes "$red $green $blue" where
+# $red $green and $blue are integers
+# ranging between 0 and 255 inclusive
+rainbowColor() {
+ let h=$1/43
+ let f=$1-43*$h
+ let t=$f*255/43
+ let q=255-t
+
+ if [ $h -eq 0 ] ; then echo "255 $t 0" ;
+ elif [ $h -eq 1 ] ; then echo "$q 255 0" ;
+ elif [ $h -eq 2 ] ; then echo "0 255 $t" ;
+ elif [ $h -eq 3 ] ; then echo "0 $q 255" ;
+ elif [ $h -eq 4 ] ; then echo "$t 0 255" ;
+ elif [ $h -eq 5 ] ; then echo "255 0 $q" ;
+ else echo "0 0 0" ; # never reached
+ fi
+}
+
+colorRamp() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 64 ] ; then let v=$i ;
+ elif [ $i -lt 128 ] ; then let v=192-$i ;
+ elif [ $i -lt 192 ] ; then let v=$i ;
+ else let v=255+192-$i ;
+ fi
+ let r=$v*$1
+ let g=$v*$2
+ let b=$v*$3
+ setBackgroundColor $r $g $b $' '
+ if [ $i -eq 63 ] ; then resetColor ; fi
+ if [ $i -eq 127 ] ; then resetColor ; fi
+ if [ $i -eq 191 ] ; then resetColor ; fi
+ done
+ resetColor
+}
+
+colorRamp2() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 64 ] ; then let v=$i ;
+ elif [ $i -lt 128 ] ; then let v=192-$i ;
+ elif [ $i -lt 192 ] ; then let v=$i ;
+ else let v=255+192-$i ;
+ fi
+ let r="($v*$4+(255-$v)*$1)/255"
+ let g="($v*$5+(255-$v)*$2)/255"
+ let b="($v*$6+(255-$v)*$3)/255"
+ setBackgroundColor $r $g $b $' '
+ if [ $i -eq 63 ] ; then resetColor ; fi
+ if [ $i -eq 127 ] ; then resetColor ; fi
+ if [ $i -eq 191 ] ; then resetColor ; fi
+ done
+ resetColor
+}
+
+rainbowRamp() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 64 ] ; then let v=$i ;
+ elif [ $i -lt 128 ] ; then let v=127+64-$i ;
+ elif [ $i -lt 192 ] ; then let v=$i ;
+ else let v=255+192-$i ;
+ fi
+ setBackgroundColor `rainbowColor $v` $' '
+ if [ $i -eq 63 ] ; then resetColor ; fi
+ if [ $i -eq 127 ] ; then resetColor ; fi
+ if [ $i -eq 191 ] ; then resetColor ; fi
+ done
+ resetColor
+}
+
+colorRamp 1 0 0
+colorRamp 0 1 0
+colorRamp 0 0 1
+colorRamp 0 1 1
+colorRamp 1 0 1
+colorRamp 1 1 0
+colorRamp 1 1 1
+
+rainbowRamp 1 1 1
Index: tests/7936-colors.sh
===================================================================
RCS file: tests/7936-colors.sh
diff -N tests/7936-colors.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/7936-colors.sh 11 Apr 2017 06:46:13 -0000 1.1
@@ -0,0 +1,206 @@
+#!/bin/bash
+#
+# This file tests support for the 7936 color system
+# a full 4x4x4 4096-color cube is drawn using 24-bit
+# set background color escape sequences.
+# various color ramps are drawn:
+# - 256 level fade to back from pure colors
+# - 256 level fade to white from pure colors
+# - 256 level gray scales
+# - 256 shade fully saturated rainbow colors
+
+#export out=""
+
+output() {
+ echo -ne "$1"
+ #export out="$out$1"
+}
+
+flush() {
+ true;
+ #echo -ne "$out"
+}
+
+setBackgroundColor() {
+ # printf '\x1bPtmux;\x1b\x1b[48;2;%s;%s;%sm' $1 $2 $3
+ # printf '\x1b[48;2;%s;%s;%sm%s' $1 $2 $3 "$4"
+ #echo -ne "\033[48;2;$1;$2;$3m$4"
+ output "\033[48;2;$1;$2;$3m$4"
+}
+
+resetColor() {
+ # printf '\x1b[0m%s' "$1"
+ #echo -ne "\033[0m$1"
+ output "\033[0m$1"
+}
+
+# Gives a color $1/255 % along HSV
+# Who knows what happens when $1 is outside 0-255
+# Echoes "$red $green $blue" where
+# $red $green and $blue are integers
+# ranging between 0 and 255 inclusive
+rainbowColor() {
+ let h=$1/43
+ let f=$1-43*$h
+ let t=$f*255/43
+ let q=255-t
+
+ if [ $h -eq 0 ]
+ then
+ echo "255 $t 0"
+ elif [ $h -eq 1 ]
+ then
+ echo "$q 255 0"
+ elif [ $h -eq 2 ]
+ then
+ echo "0 255 $t"
+ elif [ $h -eq 3 ]
+ then
+ echo "0 $q 255"
+ elif [ $h -eq 4 ]
+ then
+ echo "$t 0 255"
+ elif [ $h -eq 5 ]
+ then
+ echo "255 0 $q"
+ else
+ # execution should never reach here
+ echo "0 0 0"
+ fi
+}
+
+colorRamp() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 64 ] ; then let v=$i ;
+ elif [ $i -lt 128 ] ; then let v=192-$i ;
+ elif [ $i -lt 192 ] ; then let v=$i ;
+ else let v=255+192-$i ; fi
+ let r=$v*$1
+ let g=$v*$2
+ let b=$v*$3
+ setBackgroundColor $r $g $b "$4"
+ if [ $i -eq 63 ] ; then resetColor $'\n' ; fi
+ if [ $i -eq 127 ] ; then resetColor $'\n' ; fi
+ if [ $i -eq 191 ] ; then resetColor $'\n' ; fi
+ done
+ resetColor $'\n'
+}
+
+colorRamp1() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 128 ] ; then let v=i ; else let v=255+128-i ; fi
+ let r=$v*$1
+ let g=$v*$2
+ let b=$v*$3
+ setBackgroundColor $r $g $b "$4"
+ if [ $i -eq 127 ] ; then resetColor $'\n' ; fi
+ done
+ resetColor $'\n'
+}
+
+colorRamp2() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 64 ] ; then let v=$i ;
+ elif [ $i -lt 128 ] ; then let v=192-$i ;
+ elif [ $i -lt 192 ] ; then let v=$i ;
+ else let v=255+192-$i ; fi
+ let r="($v*$4+(255-$v)*$1)/255"
+ let g="($v*$5+(255-$v)*$2)/255"
+ let b="($v*$6+(255-$v)*$3)/255"
+ setBackgroundColor $r $g $b " "
+ if [ $i -eq 63 ] ; then resetColor $'\n' ; fi
+ if [ $i -eq 127 ] ; then resetColor $'\n' ; fi
+ if [ $i -eq 191 ] ; then resetColor $'\n' ; fi
+ done
+ resetColor $'\n'
+}
+
+colorRamp3() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 128 ] ; then let v=i ; else let v=255+128-i ; fi
+ let r="($v*$4+(255-$v)*$1)/255"
+ let g="($v*$5+(255-$v)*$2)/255"
+ let b="($v*$6+(255-$v)*$3)/255"
+ setBackgroundColor $r $g $b "$7"
+ if [ $i -eq 127 ] ; then resetColor $'\n' ; fi
+ done
+ resetColor $'\n'
+}
+
+rainbowRamp() {
+ for i in `seq 0 255`; do
+ if [ $i -lt 64 ] ; then let v=$i ;
+ elif [ $i -lt 128 ] ; then let v=127+64-$i ;
+ elif [ $i -lt 192 ] ; then let v=$i ;
+ else let v=255+192-$i ; fi
+ setBackgroundColor `rainbowColor $v` ' '
+ if [ $i -eq 63 ] ; then resetColor $'\n' ; fi
+ if [ $i -eq 127 ] ; then resetColor $'\n' ; fi
+ if [ $i -eq 191 ] ; then resetColor $'\n' ; fi
+ done
+ resetColor $'\n'
+}
+
+output $'\n'
+output $'Color cube 4x4x4:\n';
+for i in `seq 0 3`; do
+ for g in `seq 0 15`; do
+ for r in `seq 0 3`; do
+ for b in `seq 0 15`; do
+ let r1=$r+$i*4
+ let rr=$r1*17
+ let gg=$g*17
+ let bb=$b*17
+ setBackgroundColor $rr $gg $bb $' '
+ done
+ resetColor $' '
+ done
+ resetColor $'\n'
+ done
+ resetColor $'\n'
+done
+
+output $'\n'
+output $'Color ramps: fade to black\n';
+colorRamp1 1 0 0 $' '
+colorRamp1 0 1 0 $' '
+colorRamp1 0 0 1 $' '
+colorRamp1 0 1 1 $' '
+colorRamp1 1 0 1 $' '
+colorRamp1 1 1 0 $' '
+
+# output $'Color edges\n';
+# colorRamp3 255 0 0 255 0 255 $' '
+# colorRamp3 0 255 0 255 255 0 $' '
+# colorRamp3 0 0 255 0 255 255 $' '
+
+output $'\n'
+output $'Color ramps: fade to white\n';
+colorRamp3 255 0 0 255 255 255 $' '
+colorRamp3 0 255 0 255 255 255 $' '
+colorRamp3 0 0 255 255 255 255 $' '
+colorRamp3 0 255 255 255 255 255 $' '
+colorRamp3 255 0 255 255 255 255 $' '
+colorRamp3 255 255 0 255 255 255 $' '
+
+output $'\n'
+output $'Grayscale ramp:\n';
+colorRamp3 0 0 0 255 255 255 $' '
+
+output $'\n'
+output $'Rainbow ramp:\n';
+rainbowRamp $' '
+
+output $'\n'
+output $'xterm palette:\n';
+{
+ for i in `seq 0 127`; do
+ output "\033[48;5;${i}m "
+ done
+ resetColor $'\n'
+ for i in `seq 128 255`; do
+ output "\033[48;5;${i}m "
+ done
+ resetColor $'\n'
+}
+flush;
Index: tests/mandelbrot.sh
===================================================================
RCS file: tests/mandelbrot.sh
diff -N tests/mandelbrot.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/mandelbrot.sh 11 Apr 2017 06:46:13 -0000 1.1
@@ -0,0 +1,50 @@
+#!/usr/bin/env ksh
+
+# Charles Cooke's 16-color Mandelbrot
+# http://earth.gkhs.net/ccooke/shell.html
+# Combined Bash/ksh93 flavors by Dan Douglas (ormaaj)
+
+function doBash {
+ typeset P Q X Y a b c i j v x y
+ for
((P=10**8,Q=P/100,X=320*Q/cols,Y=210*Q/lines,y=-105*Q,y1=y+Y/2,v=-220*Q,x=v;
y<105*Q; x=v,y+=Y,y1+=Y)); do
+ for ((;x<P;a=b=i=j=c=0,x+=X)); do
+ for ((; a**2+b**2<4*P**2&&i++<99;
a=((c=a)**2-b**2)/P+x,b=2*c*b/P+y)); do :
+ done
+ for ((; a**2+b**2<4*P**2&&j++<99;
a=((c=a)**2-b**2)/P+x,b=2*c*b/P+y1)); do :
+ done
+ colorBox $((i<99?i%16:0)) $((j<99?j%16:0))
+ done
+ echo
+ done
+}
+
+function doKsh {
+ integer i j
+ float a b c x=2.2 y=-1.05 y2=y+Y/2 X=3.2/cols Y=2.1/lines
+ while
+ for ((a=b=i=0;(c=a)**2+b**2<=2&&i++<99&&(a=a**2-b**2+x,b=2*c*b+y);));
do :
+ done
+ for ((a=b=j=0;(c=a)**2+b**2<=2&&j++<99&&(a=a**2-b**2+x,b=2*c*b+y2);));
do :
+ done
+ . colorBox $((i<99?i%16:0)) $((j<99?j%16:0))
+ if ((x<1?!(x+=X):(y+=Y,y2+=Y,x=-2.2))); then
+ print
+ ((y<1.05))
+ fi
+ do :
+ done
+}
+
+function colorBox {
+ printf "\033[48;5;$1m"
+ printf "\033[38;5;$2m"
+ #(($1==lastclr)) || printf %s "${colrs[lastclr=$1]:=$(tput setab "$1")}"
+ #(($2==lastclr2)) || printf %s "${colrs[lastclr2=$2]:=$(tput setaf "$2")}"
+ printf '\u2584'
+}
+
+unset -v lastclr
+((cols=$(tput cols)-2, lines=$(tput lines)))
+typeset -a colrs
+trap 'tput sgr0; echo' EXIT
+${KSH_VERSION+. doKsh} ${BASH_VERSION+doBash}
Index: tests/xterm-palette.sh
===================================================================
RCS file: tests/xterm-palette.sh
diff -N tests/xterm-palette.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ tests/xterm-palette.sh 11 Apr 2017 06:46:13 -0000 1.1
@@ -0,0 +1,132 @@
+#!/bin/bash
+
+resetColor() {
+ printf '\x1b[0m%s' "$1";
+}
+
+paletteColor() {
+ printf '\x1b[48;5;%sm%s' $1 "$2";
+}
+
+rgbColor() {
+ printf '\x1b[48;2;%s;%s;%sm%s' $1 $2 $3 "$4";
+}
+
+paletteColorRGB() {
+ let index=$1;
+ export rgb="0 0 0";
+
+ case $1 in
+ 0 ) export rgb="$[0x00] $[0x00] $[0x00]" ;;
+ 1 ) export rgb="$[0xbb] $[0x00] $[0x00]" ;;
+ 2 ) export rgb="$[0x00] $[0xbb] $[0x00]" ;;
+ 3 ) export rgb="$[0xbb] $[0xbb] $[0x00]" ;;
+ 4 ) export rgb="$[0x00] $[0x00] $[0xbb]" ;;
+ 5 ) export rgb="$[0xbb] $[0x00] $[0xbb]" ;;
+ 6 ) export rgb="$[0x00] $[0xbb] $[0xbb]" ;;
+ 7 ) export rgb="$[0xbb] $[0xbb] $[0xbb]" ;;
+
+ 8 ) export rgb="$[0x55] $[0x55] $[0x55]" ;;
+ 9 ) export rgb="$[0xff] $[0x55] $[0x55]" ;;
+ 10 ) export rgb="$[0x55] $[0xff] $[0x55]" ;;
+ 11 ) export rgb="$[0xff] $[0xff] $[0x55]" ;;
+ 12 ) export rgb="$[0x55] $[0x55] $[0xff]" ;;
+ 13 ) export rgb="$[0xff] $[0x55] $[0xff]" ;;
+ 14 ) export rgb="$[0x55] $[0xff] $[0xff]" ;;
+ 15 ) export rgb="$[0xff] $[0xff] $[0xff]" ;;
+ * )
+
+ if [ $index -ge 16 -a $index -lt 232 ] ; then
+ # xterm: 0,95,135,175,215,255
+ let i=index-16;
+ let r="(i / 36) ? ((i / 36) * 40 + 55) : 0";
+ let g="(i % 36) / 6 ? (((i % 36) / 6) * 40 + 55) : 0";
+ let b="(i % 6) ? ((i % 6) * 40 + 55) : 0";
+ export rgb="$r $g $b";
+ elif [ $index -ge 232 -a $index -le 255 ] ; then
+ let n="index-232";
+ let g="8+n*10";
+ export rgb="$g $g $g";
+ else
+ resetColor $'\n' ; echo "Invalid palette color $1" ; exit 1
+ fi ;;
+ esac
+ rgbColor $rgb "$2"
+}
+
+xtermLevel() {
+ # 0,95,135,175,215,255
+ # vim: 0,95,135,175,215,255 (00 5f 87 af d7 ff)
+ # emacs? 55,95,135,175,215,255
+ # OS/X? 22,95,135,175,215,255
+
+ # if (index >= 16 && index < 232) {
+ # int i = index - 16;
+ # r = (i / 36) ? ((i / 36) * 40 + 55) / 255.0 : 0.0;
+ # g = (i % 36) / 6 ? (((i % 36) / 6) * 40 + 55) / 255.0 : 0.0;
+ # b = (i % 6) ? ((i % 6) * 40 + 55) / 255.0 : 0.0;
+
+ case $1 in
+ 0 ) echo '22' ; return ;;
+ 1 ) echo '95' ; return ;;
+ 2 ) echo '135' ; return ;;
+ 3 ) echo '175' ; return ;;
+ 4 ) echo '215' ; return ;;
+ 5 ) echo '255' ; return ;;
+ * ) resetColor $'\n' ; echo "Invalid xtermLevel $1" ; exit 1 ;;
+ esac
+}
+
+ramp() {
+ for n in `seq $[$1+$2] $[$1+$3-1]`; do
+ paletteColor $n "$4";
+ done
+ resetColor $'\n';
+ for n in `seq $[$1+$2] $[$1+$3-1]`; do
+ paletteColorRGB $n "$4";
+ done
+# if [ $1 == 0 ] ; then
+# # System colors
+# for n in `seq $[$2] $[$3-1]`; do
+# paletteColor $n "$4";
+# done
+# elif [ $1 == 16 ] ; then
+# # Color cube
+# for n in `seq $[$2] $[$3-1]`; do
+# let r=$(xtermLevel $[$n/36])
+# let g=$(xtermLevel $[$n/6%6])
+# let b=$(xtermLevel $[$n%6])
+# rgbColor $r $g $b "$4";
+# done
+# else
+# # Gray scale
+# for n in `seq $[$2] $[$3-1]`; do
+# let g="8+n*10"
+# rgbColor $g $g $g "$4";
+# done
+# fi
+ resetColor $'\n';
+}
+
+{
+ export space=" ";
+ if [ "$1" == "-w" ] ; then export space=" "; shift; fi
+
+ printf "System colors:\n";
+ ramp 0 0 16 "$space";
+ printf "Color cube, 6x6x6:\n";
+ ramp 16 0 18 "$space";
+ ramp 16 36 54 "$space";
+ ramp 16 72 90 "$space";
+ ramp 16 108 126 "$space";
+ ramp 16 144 162 "$space";
+ ramp 16 180 198 "$space";
+ ramp 16 18 36 "$space";
+ ramp 16 54 72 "$space";
+ ramp 16 90 108 "$space";
+ ramp 16 126 144 "$space";
+ ramp 16 162 180 "$space";
+ ramp 16 198 216 "$space";
+ printf "Grayscale ramp:\n";
+ ramp 232 0 24 "$space";
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemacs-commit] qemacs Makefile cfb.c display.c display.h fbfre...,
Charlie Gordon <=