Skip to content

Commit

Permalink
Modified the way the CSI and OSC (VT100) commands were expressed to m…
Browse files Browse the repository at this point in the history
…ake them a little clearer
  • Loading branch information
Bill-Gray committed Sep 23, 2023
1 parent f94027b commit 666bf7a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
8 changes: 4 additions & 4 deletions vt/pdckbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,18 +662,18 @@ int PDC_mouse_set( void)
if( curr_tracking_state > 0)
{
#ifdef HAVE_SNPRINTF
snprintf( tbuff, sizeof( tbuff), "\033[?%dl", curr_tracking_state);
snprintf( tbuff, sizeof( tbuff), CSI "?%dl", curr_tracking_state);
#else
sprintf( tbuff, "\033[?%dl", curr_tracking_state);
sprintf( tbuff, CSI "?%dl", curr_tracking_state);
#endif
PDC_puts_to_stdout( tbuff);
}
if( tracking_state)
{
#ifdef HAVE_SNPRINTF
snprintf( tbuff, sizeof( tbuff), "\033[?%dh", tracking_state);
snprintf( tbuff, sizeof( tbuff), CSI "?%dh", tracking_state);
#else
sprintf( tbuff, "\033[?%dh", tracking_state);
sprintf( tbuff, CSI "?%dh", tracking_state);
#endif
PDC_puts_to_stdout( tbuff);
}
Expand Down
14 changes: 7 additions & 7 deletions vt/pdcscrn.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ void PDC_reset_prog_mode( void)
#endif
#ifndef _WIN32
if( !PDC_is_ansi)
PDC_puts_to_stdout( "\033[?1006h"); /* Set SGR mouse tracking, if available */
PDC_puts_to_stdout( CSI "?1006h"); /* Set SGR mouse tracking, if available */
#endif
if( !SP->_preserve)
PDC_puts_to_stdout( "\033[?47h"); /* Save screen */
PDC_puts_to_stdout( CSI "?47h"); /* Save screen */
PDC_puts_to_stdout( "\033" "7"); /* save cursor & attribs (VT100) */

SP->_trap_mbe = _stored_trap_mbe;
Expand All @@ -165,9 +165,9 @@ int PDC_resize_screen(int nlines, int ncols)
char tbuff[50];

#ifdef HAVE_SNPRINTF
snprintf( tbuff, sizeof( tbuff), "\033[8;%d;%dt", nlines, ncols);
snprintf( tbuff, sizeof( tbuff), CSI "8;%d;%dt", nlines, ncols);
#else
sprintf( tbuff, "\033[8;%d;%dt", nlines, ncols);
sprintf( tbuff, CSI "8;%d;%dt", nlines, ncols);
#endif
PDC_puts_to_stdout( tbuff);
PDC_rows = nlines;
Expand All @@ -190,11 +190,11 @@ void PDC_scr_close( void)
{
#ifndef _WIN32
if( !PDC_is_ansi)
PDC_puts_to_stdout( "\033[?1006l"); /* Turn off SGR mouse tracking */
PDC_puts_to_stdout( CSI "?1006l"); /* Turn off SGR mouse tracking */
#endif
PDC_puts_to_stdout( "\033" "8"); /* restore cursor & attribs (VT100) */
PDC_puts_to_stdout( "\033[m"); /* set default screen attributes */
PDC_puts_to_stdout( "\033[?47l"); /* restore screen */
PDC_puts_to_stdout( CSI "m"); /* set default screen attributes */
PDC_puts_to_stdout( CSI "?47l"); /* restore screen */
PDC_curs_set( 2); /* blinking block cursor */
PDC_gotoyx( PDC_cols - 1, 0);
_stored_trap_mbe = SP->_trap_mbe;
Expand Down
3 changes: 3 additions & 0 deletions vt/pdcvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ extern int PDC_is_ansi;
# define _CRT_SECURE_NO_DEPRECATE 1 /* kill nonsense warnings */
#endif

#define CSI "\x1b["
#define OSC "\x1b]"

void PDC_puts_to_stdout( const char *buff); /* pdcdisp.c */

0 comments on commit 666bf7a

Please sign in to comment.