repo: rxvt-unicode-sixel action: commit revision: path_from: revision_from: 2d62d1b130c8a7f7cc22355cecd4e075603ce2e7: path_to: revision_to:
commit 2d62d1b130c8a7f7cc22355cecd4e075603ce2e7 Author: Marc LehmannDate: Tue Mar 16 05:51:38 2004 +0000 *** empty log message *** diff --git a/src/defaultfont.C b/src/defaultfont.C
--- a/src/defaultfont.C
+++ b/src/defaultfont.C
@@ -202,7 +202,10 @@ rxvt_font::clear_rect (rxvt_drawable &d, int x, int y, int w, int h, int color)
}
}
+#include "table/linedraw.h"
+
struct rxvt_font_default : rxvt_font {
+
rxvt_fontprop properties ()
{
rxvt_fontprop p;
@@ -219,7 +222,7 @@ struct rxvt_font_default : rxvt_font {
width = 1; height = 1;
ascent = 1; descent = 0;
- set_name ("built-in pseudofont");
+ set_name (strdup ("built-in pseudofont"));
return true;
}
@@ -232,7 +235,8 @@ struct rxvt_font_default : rxvt_font {
if (unicode >= 0x0080 && unicode <= 0x009f)
return true;
- if (unicode >= 0x2500 && unicode <= 0x259f)
+ if (unicode >= 0x2500 && unicode <= 0x259f
+ && linedraw_offs[unicode - 0x2500] & 15)
return true;
if (IS_COMPOSE (unicode))
@@ -252,35 +256,12 @@ struct rxvt_font_default : rxvt_font {
int fg, int bg);
};
-static void rect_stipple (Display *display, Drawable d, GC gc, int s1, int s2, int x, int y, int w, int h)
-{
- XGCValues gcv;
- char bm[2] = { s1, s2 };
-
- gcv.fill_style = FillStippled;
- gcv.stipple = XCreateBitmapFromData (display, d, bm, 2, 2);
- gcv.ts_x_origin = x;
- gcv.ts_y_origin = y;
-
- if (!gcv.stipple)
- return;
-
- XChangeGC (display, gc, GCFillStyle | GCStipple | GCTileStipXOrigin | GCTileStipYOrigin, &gcv);
- XFillRectangle (display, d, gc, x, y, w, h);
-
- XFreePixmap (display, gcv.stipple);
-
- gcv.fill_style = FillSolid;
- XChangeGC (display, gc, GCFillStyle, &gcv);
-}
-
-#include "table/linedraw.h"
-
void
rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
const text_t *text, int len,
int fg, int bg)
{
+return;
clear_rect (d, x, y, r->TermWin.fwidth * len, r->TermWin.fheight, bg);
XSetForeground (d.display->display, TGC, r->PixColors[fg]);
@@ -292,37 +273,39 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
#endif
text_t t = *text++;
- int x_[16];
- int y_[16];
-
int W = r->TermWin.fwidth , w = (W - 1) / 2;
int H = r->TermWin.fheight, h = (H - 1) / 2;
int x0 = x, x1 = x + w, x2 = x + r->TermWin.fwidth ;
int y0 = y, y1 = y + h, y2 = y + r->TermWin.fheight;
- for (int i = 0; i <= 8; i++)
+ if (0x2500 <= t && t <= 0x259f
+ && linedraw_offs[t - 0x2500] & 15)
{
- x_[i] = x + ((W-1) * i + (i*7/8)) / 8;
- y_[i] = y + ((H-1) * i + (i*7/8)) / 8;
- }
+ uint16_t offs = linedraw_offs[t - 0x2500];
+ uint32_t *a = linedraw_command + (offs >> 4);
+ uint32_t *b = a + (offs & 15);
- x_[10] = x + (W - 1) / 2; x_[9] = x_[10] - 1; x_[11] = x_[10] + 1;
- y_[10] = y + (H - 1) / 2; y_[9] = y_[10] - 1; y_[11] = y_[10] + 1;
+ int x_[16];
+ int y_[16];
- int i1 = linedraw_offs[t - 0x2500];
- int i2 = linedraw_offs[t - 0x2500 + 1];
+ for (int i = 0; i <= 8; i++)
+ {
+ x_[i] = x + ((W-1) * i + (i*7/8)) / 8;
+ y_[i] = y + ((H-1) * i + (i*7/8)) / 8;
+ }
- XGCValues gcv;
+ x_[10] = x + (W - 1) / 2; x_[9] = x_[10] - 1; x_[11] = x_[10] + 1;
+ y_[10] = y + (H - 1) / 2; y_[9] = y_[10] - 1; y_[11] = y_[10] + 1;
- gcv.cap_style = CapButt;
- gcv.line_width = 0;
- XChangeGC (d.display->display, TGC, GCLineWidth | GCCapStyle, &gcv);
+ XGCValues gcv;
- if (i1 != i2)
- {
- while (i1 < i2)
+ gcv.cap_style = CapButt;
+ gcv.line_width = 0;
+ XChangeGC (d.display->display, TGC, GCLineWidth | GCCapStyle, &gcv);
+
+ while (a < b)
{
- uint32_t command = linedraw_command [i1++];
+ uint32_t command = *a++;
int op = (command >> 24) & 255;
int a = (command >> 20) & 15;
@@ -341,7 +324,7 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
case 1: // rectangle, possibly stippled
if (a)
{
- static char bm[] = { 0,0 , 1,3 , 2,1 , 0,1 };
+ static char bm[] = { 0,0 , 3,1 , 1,2 , 1,0 };
gcv.fill_style = FillStippled;
gcv.stipple = XCreateBitmapFromData (d.display->display, d, bm + a * 2, 2, 2);
@@ -359,30 +342,19 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
if (a)
{
XFreePixmap (d.display->display, gcv.stipple);
+ gcv.stipple = 0;
gcv.fill_style = FillSolid;
XChangeGC (d.display->display, TGC, GCFillStyle, &gcv);
}
break;
case 2: // arc
+ XDrawArc (d.display->display, d, TGC,
+ x1 - W/2, y1 - H/2, W-1, H-1,
+ (a - 1) * 90*64, (b - 1) * 90*64);
break;
}
}
-
-#if 0
- case 'A': XDrawArc (d.display->display, d, TGC, x1 , y1 , W-1, H-1, 90*64, 90*64); break;
- case 'B': XDrawArc (d.display->display, d, TGC, x1-W+1, y1 , W-1, H-1, 0*64, 90*64); break;
- case 'C': XDrawArc (d.display->display, d, TGC, x1-W+1, y1-H+1, W-1, H-1, 0*64, -90*64); break;
- case 'D': XDrawArc (d.display->display, d, TGC, x1 , y1-H+1, W-1, H-1, -90*64, -90*64); break;
-
- case 'i': XFillRectangle (d.display->display, d, TGC, x0, y0, x1 - x0 + 1, y1 - y0 + 1); break;
- case 'j': XFillRectangle (d.display->display, d, TGC, x1, y0, x2 - x1, y1 - y0 + 1); break;
- case 'k': XFillRectangle (d.display->display, d, TGC, x0, y1, x1 - x0 + 1, y2 - y1); break;
- case 'l': XFillRectangle (d.display->display, d, TGC, x1, y1, x2 - x1, y2 - y1); break;
- }
- }
-#endif
-
}
#if ENABLE_COMBINING
else if (IS_COMPOSE (t) && (cc = rxvt_composite[t]))
@@ -406,33 +378,6 @@ rxvt_font_default::draw (rxvt_drawable &d, int x, int y,
case ZERO_WIDTH_CHAR:
break;
-#if 0
- case 0x2580: XFillRectangle (d.display->display, d, TGC, x0, y0, W, y1 - y0 + 1); break;
- case 0x2581: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 7 - 1) / 8, W, H - (H * 7 - 1) / 8); break;
- case 0x2582: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 6 - 2) / 8, W, H - (H * 6 - 2) / 8); break;
- case 0x2583: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 5 - 3) / 8, W, H - (H * 5 - 3) / 8); break;
- case 0x2584: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 4 - 4) / 8, W, H - (H * 4 - 4) / 8); break;
- case 0x2585: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 3 - 5) / 8, W, H - (H * 3 - 5) / 8); break;
- case 0x2586: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 2 - 6) / 8, W, H - (H * 2 - 6) / 8); break;
- case 0x2587: XFillRectangle (d.display->display, d, TGC, x0, y0 + (H * 1 - 7) / 8, W, H - (H * 1 - 7) / 8); break;
- case 0x2588: XFillRectangle (d.display->display, d, TGC, x0, y0, W, H); break;
- case 0x2589: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 7 - 1) / 8, H); break;
- case 0x258a: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 6 - 2) / 8, H); break;
- case 0x258b: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 5 - 3) / 8, H); break;
- case 0x258c: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 4 - 4) / 8, H); break;
- case 0x258d: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 3 - 5) / 8, H); break;
- case 0x258e: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 2 - 6) / 8, H); break;
- case 0x258f: XFillRectangle (d.display->display, d, TGC, x0, y0, (W * 1 - 7) / 8, H); break;
- case 0x2590: XFillRectangle (d.display->display, d, TGC, x1, y0, x2 - x1, H); break;
-
- case 0x2591: rect_stipple (d.display->display, d, TGC, 0x00, 0x01, x0, y0, W, H); break;
- case 0x2592: rect_stipple (d.display->display, d, TGC, 0x02, 0x01, x0, y0, W, H); break;
- case 0x2593: rect_stipple (d.display->display, d, TGC, 0x01, 0x03, x0, y0, W, H); break;
-
- case 0x2594: XFillRectangle (d.display->display, d, TGC, x0, y0, W, (H * 1 - 7) / 8); break;
- case 0x2595: XFillRectangle (d.display->display, d, TGC, x0 + (W * 7 - 1) / 8, y0, W - (W * 7 - 1) / 8, H); break;
-#endif
-
default:
int w = 0;
while (len > 0 && *text == NOCHAR)
diff --git a/src/genlinedraw b/src/genlinedraw
new file mode 100755
index 0000000000000000000000000000000000000000..1d302be5b0c7a7b7f89f83d1c076259224ff0956
--- /dev/null
+++ b/src/genlinedraw
@@ -0,0 +1,350 @@
+#!/usr/bin/perl
+
+open TABLE, ">", "table/linedraw.h";
+select TABLE;
+
+my $ch = 0x2500;
+
+# coordinate system:
+#
+# 0..8 (equally spaced) 9,11 mid-1,mid+1, makes 4 bit
+# one point = 8 bit, two points = 16 bit
+
+# 8 bit opcode 0 line, 1 rect, 2 arc
+# 8 bit opcode arg
+
+# OOOOOOOO AAAABBBB X1X1Y1Y1 X2X2Y2Y2
+
+my $offs = 0;
+my @offs;
+
+sub emit {
+ my ($code, $x1, $y1, $x2, $y2, $a, $b) = @_;
+ $offs++;
+ printf " 0x%08lx,", ($code << 24)
+ | ($x1 << 12)
+ | ($y1 << 8)
+ | ($x2 << 4)
+ | ($y2 << 0)
+ | ($a << 20)
+ | ($b << 16);
+}
+
+print "static uint32_t linedraw_command[] = {\n";
+
+while () {
+ next if /^\//;
+ next unless /\S/;
+
+ push @offs, $offs;
+
+ my ($v, $V, $h, $H, $s);
+
+ for (;;) {
+ /\G-/gc and last;
+ /\G$/gc and last;
+
+ /\G([123])/gc and $w = $1;
+
+ /\Gh/gc and $h = $w;
+ /\GH/gc and $H = $w;
+ /\Gv/gc and $v = $w;
+ /\GV/gc and $V = $w;
+
+ /\G\//gc and emit 0, 0, 8, 8, 0;
+ /\G\\/gc and emit 0, 0, 0, 8, 8;
+
+ /\GA/gc and emit 2, 8, 8, 0, 0, 2, 2;
+ /\GB/gc and emit 2, 0, 8, 0, 0, 1, 2;
+ /\GC/gc and emit 2, 0, 0, 0, 0, 1, 0;
+ /\GD/gc and emit 2, 8, 0, 0, 0, 0, 0;
+
+ /\Gi/gc and emit 1, 0, 0, 4, 4;
+ /\Gj/gc and emit 1, 4, 0, 8, 4;
+ /\Gk/gc and emit 1, 0, 4, 4, 8;
+ /\Gl/gc and emit 1, 4, 4, 8, 8;
+
+ /\Gs(\d)/gc and $s = $1;
+
+ /\Gr(\d+),(\d+),(\d+),(\d+)/gc and emit 1, $1, $2, $3, $4, $s;
+
+ /\G\s/gc;
+ }
+
+ if ($h) {
+ emit 0, 0, 9,10, 9 if $h > 1;
+ emit 0, 0, 10,10, 10 if $h & 1;
+ emit 0, 0, 11,10, 11 if $h > 1;
+ }
+
+ if ($H) {
+ emit 0,10, 9, 8, 9 if $H > 1;
+ emit 0,10, 10, 8, 10 if $H & 1;
+ emit 0,10, 11, 8, 11 if $H > 1;
+ }
+
+ if ($v) {
+ emit 0, 9, 0, 9, 10 if $v > 1;
+ emit 0,10, 0,10, 10 if $v & 1;
+ emit 0,11, 0,11, 10 if $v > 1;
+ }
+
+ if ($V) {
+ emit 0, 9, 10, 9, 8 if $V > 1;
+ emit 0,10, 10,10, 8 if $V & 1;
+ emit 0,11, 10,11, 8 if $V > 1;
+ }
+
+ $offs[-1] = ($offs[-1] << 4) | ($offs - $offs[-1]);
+
+ printf " // %04x\n", $ch;
+ $ch++;
+}
+
+print <
-----END OF PAGE-----