Line |
Branch |
Exec |
Source |
1 |
|
|
#ifndef TERMINAL_OUTPUT_H |
2 |
|
|
#define TERMINAL_OUTPUT_H |
3 |
|
|
|
4 |
|
|
#include <stdbool.h> |
5 |
|
|
#include <stddef.h> |
6 |
|
|
#include "style.h" |
7 |
|
|
#include "terminal.h" |
8 |
|
|
#include "util/macros.h" |
9 |
|
|
#include "util/unicode.h" |
10 |
|
|
|
11 |
|
|
enum { |
12 |
|
|
// Minimum repeat count for which ECMA-48 REP sequence makes sense. |
13 |
|
|
// STRLEN("_\033[5b") is 5 bytes and the sequence fills 6 columns. |
14 |
|
|
// Any repeat count lower than 6 can be done with memset(3) in equal |
15 |
|
|
// or fewer bytes. |
16 |
|
|
ECMA48_REP_MIN = 6, |
17 |
|
|
|
18 |
|
|
// Maximum repeat count for which ECMA-48 REP sequence should be used |
19 |
|
|
// (fits in 15 bits, to avoid issues in terminals using int16_t params). |
20 |
|
|
ECMA48_REP_MAX = 30000, |
21 |
|
|
}; |
22 |
|
|
|
23 |
|
|
typedef enum { |
24 |
|
|
// Indicates that term_set_bytes() wrote 1 byte followed by an ECMA-48 |
25 |
|
|
// (§8.3.103) REP sequence, in order to instruct the terminal to fill |
26 |
|
|
// a run of cells with the same character |
27 |
|
|
TERM_SET_BYTES_REP, |
28 |
|
|
|
29 |
|
|
// Indicates that term_set_bytes() simply called memset(3), in order |
30 |
|
|
// to fill the output buffer (and thus also the terminal) with a run |
31 |
|
|
// of the same character |
32 |
|
|
TERM_SET_BYTES_MEMSET, |
33 |
|
|
} TermSetBytesMethod; |
34 |
|
|
|
35 |
|
|
enum { |
36 |
|
|
// Returned by term_clear_eol() to indicate that an ECMA-48 (§8.3.41) |
37 |
|
|
// EL sequence was used to erase the remainder of the current line, |
38 |
|
|
// instead of REP or memset(3) |
39 |
|
|
TERM_CLEAR_EOL_USED_EL = -1, |
40 |
|
|
}; |
41 |
|
|
|
42 |
|
|
#define term_put_literal(buf, s) term_put_bytes(buf, s, STRLEN(s)) |
43 |
|
|
|
44 |
|
96 |
static inline size_t obuf_avail(TermOutputBuffer *obuf) |
45 |
|
|
{ |
46 |
|
96 |
return TERM_OUTBUF_SIZE - obuf->count; |
47 |
|
|
} |
48 |
|
|
|
49 |
|
|
void term_output_init(TermOutputBuffer *obuf); |
50 |
|
|
void term_output_free(TermOutputBuffer *obuf); |
51 |
|
|
char *term_output_reserve_space(TermOutputBuffer *obuf, size_t count) NONNULL_ARGS_AND_RETURN; |
52 |
|
|
void term_output_reset(Terminal *term, size_t start_x, size_t width, size_t scroll_x); |
53 |
|
|
void term_put_byte(TermOutputBuffer *obuf, char ch); |
54 |
|
|
void term_put_bytes(TermOutputBuffer *obuf, const char *str, size_t count); |
55 |
|
|
TermSetBytesMethod term_set_bytes(Terminal *term, char ch, size_t count); |
56 |
|
|
void term_put_str(TermOutputBuffer *obuf, const char *str); |
57 |
|
|
void term_put_initial_queries(Terminal *term, unsigned int level); |
58 |
|
|
void term_put_level_2_queries(Terminal *term, bool emit_all); |
59 |
|
|
void term_put_level_3_queries(Terminal *term, bool emit_all); |
60 |
|
|
void term_use_alt_screen_buffer(Terminal *term); |
61 |
|
|
void term_use_normal_screen_buffer(Terminal *term); |
62 |
|
|
void term_hide_cursor(Terminal *term); |
63 |
|
|
void term_show_cursor(Terminal *term); |
64 |
|
|
void term_begin_sync_update(Terminal *term); |
65 |
|
|
void term_end_sync_update(Terminal *term); |
66 |
|
|
void term_move_cursor(TermOutputBuffer *obuf, unsigned int x, unsigned int y); |
67 |
|
|
void term_save_title(Terminal *term); |
68 |
|
|
void term_restore_title(Terminal *term); |
69 |
|
|
bool term_can_clear_eol_with_el_sequence(const Terminal *term); |
70 |
|
|
int term_clear_eol(Terminal *term); |
71 |
|
|
void term_clear_screen(TermOutputBuffer *obuf); |
72 |
|
|
void term_output_flush(TermOutputBuffer *obuf) NOINLINE; |
73 |
|
|
bool term_put_char(TermOutputBuffer *obuf, CodePoint u); |
74 |
|
|
void term_set_style(Terminal *term, TermStyle style); |
75 |
|
|
void term_set_cursor_style(Terminal *term, TermCursorStyle style); |
76 |
|
|
|
77 |
|
|
#endif |
78 |
|
|
|