Skip to content

Commit

Permalink
Tek write-thru visualization (mintty#896)
Browse files Browse the repository at this point in the history
  • Loading branch information
mintty committed Jul 13, 2020
1 parent 0639e1c commit 5c8cefd
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 13 deletions.
5 changes: 4 additions & 1 deletion docs/mintty.1
Original file line number Diff line number Diff line change
Expand Up @@ -2706,13 +2706,16 @@ Also X11 color names are supported.

.TP
\fBTektronix mode colours\fP
For Tektronix 4014 emulation, colours can be overridden:
For Tektronix 4014 emulation, colours can be overridden;
\fBTekWriteThruColour\fP is used to visualize Write-Thru mode.
.br
\(en \fBTekForegroundColour\fP=\fI\fP
.br
\(en \fBTekBackgroundColour\fP=\fI\fP
.br
\(en \fBTekCursorColour\fP=\fI\fP
.br
\(en \fBTekWriteThruColour\fP=\fI\fP

.TP
\fBTektronix mode font\fP (TekFont=)
Expand Down
2 changes: 2 additions & 0 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const config default_cfg = {
.tek_fg_colour = (colour)-1,
.tek_bg_colour = (colour)-1,
.tek_cursor_colour = (colour)-1,
.tek_write_thru_colour = (colour)-1,
.tek_glow = 1,
.underl_colour = (colour)-1,
.disp_space = 0,
Expand Down Expand Up @@ -274,6 +275,7 @@ options[] = {
{"TekForegroundColour", OPT_COLOUR, offcfg(tek_fg_colour)},
{"TekBackgroundColour", OPT_COLOUR, offcfg(tek_bg_colour)},
{"TekCursorColour", OPT_COLOUR, offcfg(tek_cursor_colour)},
{"TekWriteThruColour", OPT_COLOUR, offcfg(tek_write_thru_colour)},
{"TekGlow", OPT_INT, offcfg(tek_glow)},
{"UnderlineColour", OPT_COLOUR, offcfg(underl_colour)},
{"DispSpace", OPT_INT, offcfg(disp_space)},
Expand Down
1 change: 1 addition & 0 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ typedef struct {
// Looks
colour fg_colour, bold_colour, bg_colour, cursor_colour;
colour tek_fg_colour, tek_bg_colour, tek_cursor_colour;
colour tek_write_thru_colour;
int tek_glow;
colour underl_colour, hover_colour;
int disp_space, disp_clear, disp_tab;
Expand Down
55 changes: 43 additions & 12 deletions src/tek.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,16 @@ static uchar style = 0; // for vector modes
static uchar font = 0;
static short margin = 0;
static bool beam_defocused = false;
static bool beam_writethru = false;
static bool plotpen = false;
static bool apl_mode = false;

static short tek_y, tek_x;
static uchar lastfont = 0;
static int lastwidth = -1;

static int beam_glow = 0;
static int beam_glow = 1;
static int thru_glow = 5;

static wchar * APL = W(" ¨)<≤=>]∨∧≠÷,+./0123456789([;×:\\¯⍺⊥∩⌊∊_∇∆⍳∘'⎕∣⊤○⋆?⍴⌈∼↓∪ω⊃↑⊂←⊢→≥-⋄ABCDEFGHIJKLMNOPQRSTUVWXYZ{⊣}$ ");

Expand All @@ -33,6 +35,7 @@ struct tekchar {
char type;
uchar recent;
bool defocused;
bool writethru;
#if CYGWIN_VERSION_API_MINOR >= 74
union {
struct {
Expand Down Expand Up @@ -123,6 +126,7 @@ tek_reset(void)
// line type
style = 0;
beam_defocused = false;
beam_writethru = false;
// font
font = 0;
apl_mode = false;
Expand Down Expand Up @@ -150,8 +154,9 @@ tek_write(wchar c, int width)
}

tek_buf_append(&(struct tekchar)
{.type = 0, .recent = beam_glow,
.defocused = beam_defocused,
{.type = 0,
.recent = beam_writethru ? thru_glow : beam_glow,
.defocused = beam_defocused, .writethru = beam_writethru,
.c = c, .w = width, .font = font});
if (width > 0) {
tek_x += width * tekfonts[font].wid;
Expand Down Expand Up @@ -181,8 +186,8 @@ tek_copy(void)
void
tek_beam(bool defocused, bool write_through, char vector_style)
{
(void)write_through;
beam_defocused = defocused;
beam_writethru = write_through;
if (vector_style > 4)
style = 0;
else
Expand Down Expand Up @@ -306,8 +311,9 @@ tek_address(char * code)
printf(" -> (%d) -> %d:%d\n", tek_mode, tek_y, tek_x);
#endif
tek_buf_append(&(struct tekchar)
{.type = tek_mode, .recent = beam_glow,
.defocused = beam_defocused,
{.type = tek_mode,
.recent = beam_writethru ? thru_glow : beam_glow,
.defocused = beam_defocused, .writethru = beam_writethru,
.y = tek_y, .x = tek_x,
.style = style, .intensity = intensity});
}
Expand All @@ -332,14 +338,16 @@ tek_step(char c)

if (plotpen) {
tek_buf_append(&(struct tekchar)
{.type = TEKMODE_POINT_PLOT, .recent = beam_glow,
.defocused = beam_defocused,
{.type = TEKMODE_POINT_PLOT,
.recent = beam_writethru ? thru_glow : beam_glow,
.defocused = beam_defocused, .writethru = beam_writethru,
.y = tek_y, .x = tek_x, .intensity = intensity});
}
else {
tek_buf_append(&(struct tekchar)
{.type = TEKMODE_GRAPH0, .recent = beam_glow,
.defocused = beam_defocused,
{.type = TEKMODE_GRAPH0,
.recent = beam_writethru ? thru_glow : beam_glow,
.defocused = beam_defocused, .writethru = beam_writethru,
.y = tek_y, .x = tek_x, .intensity = 0});
}
}
Expand Down Expand Up @@ -672,8 +680,31 @@ tek_paint(void)
for (int i = 0; i < tek_buf_len; i++) {
struct tekchar * tc = &tek_buf[i];

// beam glow effect (bright drawing spot)
if (tc->recent) {
// write-thru mode and beam glow effect (bright drawing spot)
if (tc->writethru) {
fg = fg0;
if (tc->recent) {
// simulate Write-Thru by distinct colour?
//fg = RGB(200, 100, 0);
// fade out?
if (tc->recent <= (thru_glow + 1) / 2)
fg = ((fg0 & 0xFEFEFEFE) >> 1) + ((bg & 0xFEFEFEFE) >> 1);

tc->recent--;
}
else {
// simulate faded Write-Thru by distinct colour?
//fg = RGB(200, 100, 0);
fg = cfg.tek_write_thru_colour;
if (fg == (colour)-1) {
fg = ((fg0 & 0xFEFEFEFE) >> 1) + ((bg & 0xFEFEFEFE) >> 1);
fg = RGB(green(fg), blue(fg), red(fg));
}
// fade away?
//fg = bg;
}
}
else if (tc->recent) {
fg = glowfg;
tc->recent --;
}
Expand Down

0 comments on commit 5c8cefd

Please sign in to comment.