···
ctx->control_sequence = false;
+
ctx->osc_escape = false;
ctx->discard_next = false;
ctx->reverse_video = false;
ctx->dec_private = false;
ctx->insert_mode = false;
···
ctx->current_primary = (size_t)-1;
+
ctx->current_bg = (size_t)-1;
ctx->scroll_top_margin = 0;
ctx->scroll_bottom_margin = ctx->rows;
···
ctx->current_primary = (size_t)-1;
+
ctx->current_bg = (size_t)-1;
ctx->set_text_bg_default(ctx);
ctx->set_text_fg_default(ctx);
···
+
else if (ctx->esc_values[i] == 5) {
+
if (ctx->current_bg != (size_t)-1) {
+
if (!ctx->reverse_video) {
+
ctx->set_text_bg_bright(ctx, ctx->current_bg);
+
ctx->set_text_fg_bright(ctx, ctx->current_bg);
else if (ctx->esc_values[i] == 22) {
if (ctx->current_primary != (size_t)-1) {
···
+
else if (ctx->esc_values[i] == 25) {
+
if (ctx->current_bg != (size_t)-1) {
+
if (!ctx->reverse_video) {
+
ctx->set_text_bg(ctx, ctx->current_bg);
+
ctx->set_text_fg(ctx, ctx->current_bg);
else if (ctx->esc_values[i] >= 30 && ctx->esc_values[i] <= 37) {
ctx->current_primary = ctx->esc_values[i] - offset;
···
+
if ((ctx->bold && !ctx->reverse_video)
+
|| (ctx->bg_bold && ctx->reverse_video)) {
ctx->set_text_fg_bright(ctx, ctx->esc_values[i] - offset);
ctx->set_text_fg(ctx, ctx->esc_values[i] - offset);
···
else if (ctx->esc_values[i] >= 40 && ctx->esc_values[i] <= 47) {
+
ctx->current_bg = ctx->esc_values[i] - offset;
if (ctx->reverse_video) {
+
if ((ctx->bold && ctx->reverse_video)
+
|| (ctx->bg_bold && !ctx->reverse_video)) {
ctx->set_text_bg_bright(ctx, ctx->esc_values[i] - offset);
ctx->set_text_bg(ctx, ctx->esc_values[i] - offset);
···
else if (ctx->esc_values[i] >= 100 && ctx->esc_values[i] <= 107) {
+
ctx->current_bg = ctx->esc_values[i] - offset;
if (ctx->reverse_video) {
···
else if (ctx->esc_values[i] == 49) {
+
ctx->current_bg = (size_t)-1;
if (ctx->reverse_video) {
···
+
static void osc_parse(struct term_context *ctx, uint8_t c) {
+
if (ctx->osc_escape && c == '\\') {
+
ctx->osc_escape = false;
+
ctx->osc_escape = true;
+
ctx->osc_escape = false;
static void control_sequence_parse(struct term_context *ctx, uint8_t c) {
if (ctx->escape_offset == 2) {
···
ctx->esc_values[0] = ctx->rows - 1;
ctx->set_cursor_pos(ctx, ctx->esc_values[1], ctx->esc_values[0]);
+
for (size_t i = 0; i < ctx->esc_values[0]; i++) {
+
size_t old_scroll_top_margin = ctx->scroll_top_margin;
+
ctx->scroll_top_margin = y + 1;
+
for (size_t i = 0; i < ctx->esc_values[0]; i++) {
+
ctx->scroll_top_margin = old_scroll_top_margin;
switch (ctx->esc_values[0]) {
···
size_t rows_remaining = ctx->rows - (y + 1);
size_t cols_diff = ctx->cols - (x + 1);
+
size_t to_clear = rows_remaining * ctx->cols + cols_diff + 1;
for (size_t i = 0; i < to_clear; i++) {
ctx->raw_putchar(ctx, ' ');
···
static void restore_state(struct term_context *ctx) {
ctx->bold = ctx->saved_state_bold;
+
ctx->bg_bold = ctx->saved_state_bg_bold;
ctx->reverse_video = ctx->saved_state_reverse_video;
ctx->current_charset = ctx->saved_state_current_charset;
ctx->current_primary = ctx->saved_state_current_primary;
+
ctx->current_bg = ctx->saved_state_current_bg;
···
ctx->saved_state_bold = ctx->bold;
+
ctx->saved_state_bg_bold = ctx->bg_bold;
ctx->saved_state_reverse_video = ctx->reverse_video;
ctx->saved_state_current_charset = ctx->current_charset;
ctx->saved_state_current_primary = ctx->current_primary;
+
ctx->saved_state_current_bg = ctx->current_bg;
static void escape_parse(struct term_context *ctx, uint8_t c) {
+
if (ctx->osc == true) {
if (ctx->control_sequence == true) {
control_sequence_parse(ctx, c);
···
ctx->get_cursor_pos(ctx, &x, &y);
+
ctx->osc_escape = false;
for (size_t i = 0; i < TERM_MAX_ESC_VALUES; i++)
···
ctx->control_sequence = false;
+
ctx->osc_escape = false;