Skip to content

Commit

Permalink
seqs: Add seqs to enable/disable the alt screen
Browse files Browse the repository at this point in the history
  • Loading branch information
hpjansson committed Jun 17, 2023
1 parent 4bdffef commit 1a3f027
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions chafa/chafa-term-db.c
Expand Up @@ -86,6 +86,10 @@ static const SeqStr vt220_seqs [] =
{ CHAFA_TERM_SEQ_SAVE_CURSOR_POS, "\033[s" },
{ CHAFA_TERM_SEQ_RESTORE_CURSOR_POS, "\033[u" },

/* These are actually xterm seqs, but we'll allow it */
{ CHAFA_TERM_SEQ_ENABLE_ALT_SCREEN, "\033[1049h" },
{ CHAFA_TERM_SEQ_DISABLE_ALT_SCREEN, "\033[1049l" },

{ CHAFA_TERM_SEQ_MAX, NULL }
};

Expand Down
2 changes: 2 additions & 0 deletions chafa/chafa-term-info.c
Expand Up @@ -181,6 +181,8 @@
* @CHAFA_TERM_SEQ_RESTORE_CURSOR_POS: Move cursor to the last saved position.
* @CHAFA_TERM_SEQ_ENABLE_ADVANCE_DOWN_AFTER_SIXEL: After showing a sixel image, leave cursor below the first column.
* @CHAFA_TERM_SEQ_ENABLE_ADVANCE_RIGHT_AFTER_SIXEL: After showing a sixel image, leave cursor to the right of the last row.
* @CHAFA_TERM_SEQ_ENABLE_ALT_SCREEN: Switch to the alternate screen buffer.
* @CHAFA_TERM_SEQ_DISABLE_ALT_SCREEN: Switch back to the regular screen buffer.
* @CHAFA_TERM_SEQ_MAX: Last control sequence plus one.
*
* An enumeration of the control sequences supported by #ChafaTermInfo.
Expand Down
34 changes: 34 additions & 0 deletions chafa/chafa-term-seq-def.h
Expand Up @@ -2533,6 +2533,40 @@ CHAFA_TERM_SEQ_DEF(enable_advance_down_after_sixel, ENABLE_ADVANCE_DOWN_AFTER_SI
**/
CHAFA_TERM_SEQ_DEF(enable_advance_right_after_sixel, ENABLE_ADVANCE_RIGHT_AFTER_SIXEL, 0, none, char)

/**
* chafa_term_info_emit_enable_alt_screen:
* @term_info: A #ChafaTermInfo
* @dest: String destination
*
* Prints the control sequence for #CHAFA_TERM_SEQ_ENABLE_ALT_SCREEN.
*
* @dest must have enough space to hold
* #CHAFA_TERM_SEQ_LENGTH_MAX bytes, even if the emitted sequence is
* shorter. The output will not be zero-terminated.
*
* Returns: Pointer to first byte after emitted string
*
* Since: 1.14
**/
CHAFA_TERM_SEQ_DEF(enable_alt_screen, ENABLE_ALT_SCREEN, 0, none, char)

/**
* chafa_term_info_emit_disable_alt_screen:
* @term_info: A #ChafaTermInfo
* @dest: String destination
*
* Prints the control sequence for #CHAFA_TERM_SEQ_DISABLE_ALT_SCREEN.
*
* @dest must have enough space to hold
* #CHAFA_TERM_SEQ_LENGTH_MAX bytes, even if the emitted sequence is
* shorter. The output will not be zero-terminated.
*
* Returns: Pointer to first byte after emitted string
*
* Since: 1.14
**/
CHAFA_TERM_SEQ_DEF(disable_alt_screen, DISABLE_ALT_SCREEN, 0, none, char)

#undef CHAFA_TERM_SEQ_AVAILABILITY

#undef CHAFA_TERM_SEQ_ARGS

0 comments on commit 1a3f027

Please sign in to comment.