Skip to content
Snippets Groups Projects
Commit 0f097996 authored by deuce's avatar deuce
Browse files

Sixel updates.

1) The colour values are expressed as a percentage, not a 0-255 value.
2) Implement CSI ? 80 h/l to set/reset the sixel scrolling mode (defaults to
   set).
3) Document sixel commands.
4) Combine the extended set/reset mode commands in the documentation now
   that multiple modes can be set or reset with a single sequence.
parent aeaa5fca
No related branches found
No related tags found
No related merge requests found
......@@ -1373,7 +1373,7 @@ static void parse_sixel_string(struct cterminal *cterm, bool finish)
b = strtoul(p, &p, 10);
}
if (t == 2) // Only support RGB
setpalette(cterm->sx_fg, r<<8|r, g<<8|g, b<<8|b);
setpalette(cterm->sx_fg, UINT16_MAX*r/100, UINT16_MAX*g/100, UINT16_MAX*b/100);
}
break;
case '$': // Graphics Carriage Return
......@@ -1390,6 +1390,11 @@ static void parse_sixel_string(struct cterminal *cterm, bool finish)
if(cterm->origin_mode)
max_row = cterm->bottom_margin - cterm->top_margin + 1;
if ((!cterm->sx_scroll_mode) && (((cterm->sx_y + 6 * cterm->sx_iv) + 6*cterm->sx_iv - 1) >= (cterm->y + max_row - 1) * vparams[vmode].charheight)) {
p++;
break;
}
cterm->sx_x = cterm->sx_left;
cterm->sx_y += 6*cterm->sx_iv;
while ((cterm->sx_y + 6 * cterm->sx_iv - 1) >= (cterm->y + max_row - 1) * vparams[vmode].charheight) {
......@@ -1414,6 +1419,8 @@ all_done:
GETTEXTINFO(&ti);
vmode = find_vmode(ti.currmode);
*cterm->hold_update=cterm->sx_hold_update;
if (cterm->sx_scroll_mode) {
cterm->sx_x = cterm->sx_left;
cterm->sx_x = cterm->sx_x / vparams[vmode].charwidth + 1;
cterm->sx_x -= (cterm->x - 1);
......@@ -1421,8 +1428,11 @@ all_done:
cterm->sx_y = (cterm->sx_y+6*cterm->sx_iv-1) / vparams[vmode].charheight + 1;
cterm->sx_y -= (cterm->y - 1);
*cterm->hold_update=cterm->sx_hold_update;
GOTOXY(cterm->sx_x,cterm->sx_y);
}
else {
GOTOXY(cterm->sx_start_x, cterm->sx_start_y);
}
SETCURSORTYPE(cterm->cursor);
cterm->sixel = SIXEL_INACTIVE;
}
......@@ -1503,6 +1513,10 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i=GETVIDEOFLAGS();
i|=CIOLIB_VIDEO_NOBLINK;
SETVIDEOFLAGS(i);
break;
case 80:
cterm->sx_scroll_mode = 1;
break;
}
}
}
......@@ -1549,6 +1563,9 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i&=~CIOLIB_VIDEO_NOBLINK;
SETVIDEOFLAGS(i);
break;
case 80:
cterm->sx_scroll_mode = 0;
break;
}
}
}
......@@ -1595,6 +1612,8 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
strcat(tmp, ";34");
if(vidflags & CIOLIB_VIDEO_NOBLINK)
strcat(tmp, ";35");
if (cterm->sx_scroll_mode)
strcat(tmp, ";80");
if (strlen(tmp) == 4) { // Nothing set
strcat(tmp, ";");
}
......@@ -1611,8 +1630,8 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
i=GETVIDEOFLAGS();
if(seq->param_count == 0) {
/* All the save stuff... */
cterm->saved_mode_mask |= (CTERM_SAVEMODE_AUTOWRAP|CTERM_SAVEMODE_CURSOR|CTERM_SAVEMODE_ALTCHARS|CTERM_SAVEMODE_NOBRIGHT|CTERM_SAVEMODE_BGBRIGHT|CTERM_SAVEMODE_ORIGIN);
cterm->saved_mode &= ~(CTERM_SAVEMODE_AUTOWRAP|CTERM_SAVEMODE_CURSOR|CTERM_SAVEMODE_ALTCHARS|CTERM_SAVEMODE_NOBRIGHT|CTERM_SAVEMODE_BGBRIGHT|CTERM_SAVEMODE_ORIGIN);
cterm->saved_mode_mask |= (CTERM_SAVEMODE_AUTOWRAP|CTERM_SAVEMODE_CURSOR|CTERM_SAVEMODE_ALTCHARS|CTERM_SAVEMODE_NOBRIGHT|CTERM_SAVEMODE_BGBRIGHT|CTERM_SAVEMODE_ORIGIN|CTERM_SAVEMODE_SIXEL_SCROLL);
cterm->saved_mode &= ~(CTERM_SAVEMODE_AUTOWRAP|CTERM_SAVEMODE_CURSOR|CTERM_SAVEMODE_ALTCHARS|CTERM_SAVEMODE_NOBRIGHT|CTERM_SAVEMODE_BGBRIGHT|CTERM_SAVEMODE_ORIGIN|CTERM_SAVEMODE_SIXEL_SCROLL);
cterm->saved_mode |= (cterm->autowrap)?CTERM_SAVEMODE_AUTOWRAP:0;
cterm->saved_mode |= (cterm->cursor==_NORMALCURSOR)?CTERM_SAVEMODE_CURSOR:0;
cterm->saved_mode |= (i&CIOLIB_VIDEO_ALTCHARS)?CTERM_SAVEMODE_ALTCHARS:0;
......@@ -1621,6 +1640,7 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
cterm->saved_mode |= (i&CIOLIB_VIDEO_BLINKALTCHARS)?CTERM_SAVEMODE_BLINKALTCHARS:0;
cterm->saved_mode |= (i&CIOLIB_VIDEO_NOBLINK)?CTERM_SAVEMODE_NOBLINK:0;
cterm->saved_mode |= (cterm->origin_mode)?CTERM_SAVEMODE_ORIGIN:0;
cterm->saved_mode |= (cterm->sx_scroll_mode)?CTERM_SAVEMODE_SIXEL_SCROLL:0;
break;
}
else {
......@@ -1666,6 +1686,11 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
cterm->saved_mode &= ~(CTERM_SAVEMODE_NOBLINK);
cterm->saved_mode |= (i&CIOLIB_VIDEO_NOBLINK)?CTERM_SAVEMODE_NOBLINK:0;
break;
case 80:
cterm->saved_mode_mask |= CTERM_SAVEMODE_SIXEL_SCROLL;
cterm->saved_mode &= ~(CTERM_SAVEMODE_SIXEL_SCROLL);
cterm->saved_mode |= (cterm->sx_scroll_mode)?CTERM_SAVEMODE_SIXEL_SCROLL:0;
break;
}
}
}
......@@ -1681,6 +1706,8 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
cterm->origin_mode=(cterm->saved_mode & CTERM_SAVEMODE_ORIGIN) ? true : false;
if(cterm->saved_mode_mask & CTERM_SAVEMODE_AUTOWRAP)
cterm->autowrap=(cterm->saved_mode & CTERM_SAVEMODE_AUTOWRAP) ? true : false;
if(cterm->saved_mode_mask & CTERM_SAVEMODE_SIXEL_SCROLL)
cterm->sx_scroll_mode=(cterm->saved_mode & CTERM_SAVEMODE_SIXEL_SCROLL) ? true : false;
if(cterm->saved_mode_mask & CTERM_SAVEMODE_CURSOR) {
cterm->cursor = (cterm->saved_mode & CTERM_SAVEMODE_CURSOR) ? _NORMALCURSOR : _NOCURSOR;
SETCURSORTYPE(cterm->cursor);
......@@ -1780,6 +1807,10 @@ static void do_ansi(struct cterminal *cterm, char *retbuf, size_t retsize, int *
SETVIDEOFLAGS(i);
}
break;
case 80:
if(cterm->saved_mode_mask & CTERM_SAVEMODE_SIXEL_SCROLL)
cterm->sx_scroll_mode=(cterm->saved_mode & CTERM_SAVEMODE_SIXEL_SCROLL) ? true : false;
break;
}
}
}
......@@ -2594,6 +2625,7 @@ struct cterminal* CIOLIBCALL cterm_init(int height, int width, int xpos, int ypo
cterm->origin_mode=false;
cterm->fg_color = UINT32_MAX;
cterm->bg_color = UINT32_MAX;
cterm->sx_scroll_mode = true;
if(cterm->scrollback!=NULL)
memset(cterm->scrollback,0,cterm->width*2*cterm->backlines);
if(cterm->scrollbackf!=NULL)
......@@ -2805,8 +2837,15 @@ static void parse_sixel_intro(struct cterminal *cterm)
GETTEXTINFO(&ti);
vmode = find_vmode(ti.currmode);
attr2palette(ti.attribute, &cterm->sx_fg, &cterm->sx_bg);
if (cterm->sx_scroll_mode) {
cterm->sx_x = cterm->sx_left = (cterm->x + WHEREX() - 2) * vparams[vmode].charwidth;
cterm->sx_y = (cterm->y + WHEREY() - 2) * vparams[vmode].charheight;
}
else {
cterm->sx_x = cterm->sx_left = cterm->sx_y = 0;
cterm->sx_start_x = WHEREX();
cterm->sx_start_y = WHEREY();
}
SETCURSORTYPE(_NOCURSOR);
GOTOXY(ti.winright - ti.winleft + 1, ti.winbottom - ti.wintop + 1);
*cterm->hold_update = 1;
......
......@@ -100,7 +100,7 @@ struct cterminal {
#define CTERM_SAVEMODE_ALTCHARS 0x004
#define CTERM_SAVEMODE_NOBRIGHT 0x008
#define CTERM_SAVEMODE_BGBRIGHT 0x010
// 0x010 was CTERM_SAVEMODE_DOORWAY
#define CTERM_SAVEMODE_SIXEL_SCROLL 0x020
#define CTERM_SAVEMODE_ORIGIN 0x040
#define CTERM_SAVEMODE_BLINKALTCHARS 0x080
#define CTERM_SAVEMODE_NOBLINK 0x100
......@@ -167,6 +167,9 @@ struct cterminal {
Raster Attributes are ignore if this is true. */
int sx_first_pass; // First pass through a line
int sx_hold_update; // hold_update value to restore on completion
bool sx_scroll_mode; // Sixel scrolling mode
int sx_start_x; // Starting X position
int sx_start_y; // Starting Y position
/* conio function pointers */
#ifdef CTERM_WITHOUT_CONIO
......
......@@ -64,11 +64,83 @@ ESC M (Disabled in current code)
SOURCE: BANSI.TXT
ESC _ Application Program String
Begins a string consisting of the characters 0x08 - 0x0d and
0x20-0x7e, terminated by a String Terminator (ST)
The string is currently ignored.
ESC P Device Control String
Begins a string consisting of the characters 0x08 - 0x0d and
0x20-0x7e, terminated by a String Terminator (ST)
Supported OSC values:
[ p1 [ ; p2 ] ] q
Defaults: p1 = 0 p2 = 0
Indicates the string is a sixel sequence.
p1 selects the vertical height of a single pixel. This
may be overridden by the raster attributes command, and
is deprecated. Supported values
Value Vertical Size
----- -------------
0,1,5,6 2 pixels
2 5 pixels
3,4 3 pixels
7,8,9 1 pixel
p2 indicates if unset sixels should be set to the current
background colour. If p2 is 1, positions specified as 0
remain at their current colour.
Any additional parameters are ignored.
The rest of the string is made up of sixel data characters and
sixel control functions. Sixel data characters are in the
rage of '?' (0x3f) to '~' (0x7e). Each sixel data character
represents six vertical pixels. The data is extracted by
subtracting 0x3f from the ASCII value of the character.
The least significant bit is the topmost pixel.
Sixel Control Functions
! Pn X
Graphics Repeat Introducer
The character X is repeated Pn times.
" p1 ; p2 [ ; p3 [ ; p4 ] ]
Raster Attributes
p1 indicates the vertical size in pixels of each
sixel. p2 indicates the horizontal size in pixels.
p3 and p4 define the height and width (in sixels)
respectively of a block to fill with the background
colour. This block may not extend past the current
bottom of the screen. If any pixel data characters
proceed this command, it is ignored.
# p1
Colour Select
Selects the current foreground colour from the
sixel palette.
# p1 ; p2 ; p3 ; p4 ; p5
Palette map
Defines sixel palette entry p1 and sets it as the
current foreground colour. p2 specifies the colour
space to define the colour in, the only supported
value is 2. p3, p4, and p5 specify the red, green,
and blue content as a percentage (0-100).
$
Graphics Carriage Return
Returns the active position to the left border of
the same sixel row. Generally, one pass per colour
is used. In passes after the first one, sixels
with a value of zero are not overwritten with the
background colour.
-
Graphics New Line
Moves the active position to the left border of the
next sixel row.
ESC ^ Privacy Message
Begins a string consisting of the characters 0x08 - 0x0d and
0x20-0x7e, terminated by a String Terminator (ST)
The string is currently ignored.
ESC ] Operating System Command
Begins a string consisting of the characters 0x08 - 0x0d and
0x20-0x7e, terminated by a String Terminator (ST)
......@@ -190,67 +262,49 @@ CSI = 255 h
SOURCE: BANSI.TXT
CSI ? 6 h
CSI ? [ p1 [ ; pX ... ] ] h
NON-STANDARD EXTENSION
Enable origin mode.
In this mode, position parameters are relative to the top left of the
scrolling region, not the screen.
Set Mode
Sets one or more mode. The following modes are supported:
6 - Enable origin mode.
In this mode, position parameters are relative to the top left of
the scrolling region, not the screen. Defaults to reset.
SOURCE: Digital VT102 User Guide
CSI ? 7 h
NON-STANDARD EXTENSION
Enable auto wrap.
7 - Enable auto wrap
This is the normal mode in which a write to the last column of a
row will move the cursor to the start of the next line triggering a
scroll if required to create a new line.
row will move the cursor to the start of the next line triggering
a scroll if required to create a new line. Defaults to set.
SOURCE: Digital VT102 User Guide
CSI ? 25 h
NON-STANDARD EXTENSION
Display the cursor
25 - Display the cursor. Defaults to set.
SOURCE: "Installing and Using the VT320 Video Terminal"
CSI ? 31 h
NON-STANDARD EXTENSION
Enable bright alt character set
31 - Enable bright alt character set
With this mode set, the bright (1) graphic rendition selects
characters from an alternate character set.
CSI ? 32 h
NON-STANDARD EXTENSION
Bright Intensity Disable
characters from an alternate character set. Defaults to reset.
32 - Bright Intensity Disable
This makes the bright intensity bit not control the intensity.
Mostly for use with CSI ? 31 h to permit fonts in the same
colours.
CSI ? 33 h
NON-STANDARD EXTENSION
Blink to Bright Intensity Background
colours. Defaults to reset.
33 - Blink to Bright Intensity Background
With this mode set, the blink (5,6) graphic renditions cause the
background colour to be high intensity rather than causing blink
CSI ? 34 h
NON-STANDARD EXTENSION
Enable blink alt character set
background colour to be high intensity rather than causing blink.
Defaults to reset.
34 - Enable blink alt character set
With this mode set, the blink (5, 6) graphic renditions selects
characters from an alternate character set.
CSI ? 35 h
NON-STANDARD EXTENSION
Blink Disabled
This makes the blink bit not cause the character to blink.
Mostly for use with CSI ? 34 h to permit fonts to be used without
blinking.
characters from an alternate character set. Defaults to reset
35 - Blink Disabled
This makes the blink (5, 6) graphic renditions not cause the
character to blink. Mostly for use with CSI ? 34 h to permit
fonts to be used without blinking. Defaults to reset.
80 - Sixel Scrolling Enabled
When this is set, the sixel active position begins in the
upper-left corner of the currently active text position.
When the sixel active position reaches the bottom of the
page, the page is scrolled up. At the end of the sixel
string, a sixel newline is appended, and the current cursor
position is the one in which the bottom sixel is in.
Defaults to set.
SOURCE: VT330/VT340 Programmer Reference Manual
CSI = 255 l
NON-STANDARD EXTENSION
......@@ -258,30 +312,48 @@ CSI = 255 l
SOURCE: BANSI.TXT
CSI ? 6 h
CSI ? [ p1 [ ; pX ... ] ] l
NON-STANDARD EXTENSION
Disable origin mode.
In this mode, position parameters are relative to the top left of the
screen, not the scrolling region.
Reset Mode
Resets one or more mode. The following modes are supported:
6 - Origin Mode
With this mode reset, position parameters are relative to the
top left of the screen, not the scrolling region. Defaults
to reset.
SOURCE: Digital VT102 User Guide
CSI ? 7 l
NON-STANDARD EXTENSION
Disable auto wrap.
This mode causes a write to the last column of a to leave the
cursor where it was before the write occurred, overwriting anything
which was previously written to the same position.
7 - Disable auto wrap
Resetting this mode causes a write to the last column of a to
leave the cursor where it was before the write occurred,
overwriting anything which was previously written to the same
position.
SOURCE: Digital VT102 User Guide
CSI ? 25 l
NON-STANDARD EXTENSION
Hide the cursor
25 - Hide the cursor. Defaults to set.
SOURCE: "Installing and Using the VT320 Video Terminal"
31 - Disable bright alt character set
With this mode reset, the bright (1) graphic rendition does not
select an alternative font. Defaults to reset.
32 - Bright Intensity Enable
When reset, bright intensity graphics rendition behaves normally.
Defaults to reset.
33 - Disable Blink to Bright Intensity Background
With this mode set, the blink (5,6) graphic renditions do not
affect the background colour. Defaults to reset.
34 - Disable blink alt character set
With this mode reset, the blink (5, 6) graphic renditions do not
select characters from an alternate character set. Defaults to
reset.
35 - Blink Enable
With this mode reset, the blink (5,6) graphic renditions behave
normally (cause the characters to blink). Defaults to reset.
80 - Sixel Scrolling Disabled
When this is reset, the sixel active position begins in the
upper-left corner of the page. Any commands that attempt to
advance the sixel position past the bottom of the page are
ignored. At the end of the sixel string, the current cursor
position is unchanged from where it was when the sixel string
started. Defaults to set.
SOURCE: VT330/VT340 Programmer Reference Manual
CSI ? 31 l
NON-STANDARD EXTENSION
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment