mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-03 07:15:29 -04:00
term: implement reset
This commit is contained in:
parent
57564c2b59
commit
ab92abbd21
4 changed files with 86 additions and 2 deletions
2
csi.c
2
csi.c
|
|
@ -969,7 +969,7 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
case '!': {
|
case '!': {
|
||||||
switch (final) {
|
switch (final) {
|
||||||
case 'p':
|
case 'p':
|
||||||
LOG_WARN("unimplemented: soft reset");
|
term_reset(term, false);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
82
terminal.c
82
terminal.c
|
|
@ -13,10 +13,92 @@
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "vt.h"
|
#include "vt.h"
|
||||||
|
#include "selection.h"
|
||||||
|
|
||||||
#define min(x, y) ((x) < (y) ? (x) : (y))
|
#define min(x, y) ((x) < (y) ? (x) : (y))
|
||||||
#define max(x, y) ((x) > (y) ? (x) : (y))
|
#define max(x, y) ((x) > (y) ? (x) : (y))
|
||||||
|
|
||||||
|
void
|
||||||
|
term_reset(struct terminal *term, bool hard)
|
||||||
|
{
|
||||||
|
term->cursor_keys_mode = CURSOR_KEYS_NORMAL;
|
||||||
|
term->keypad_keys_mode = KEYPAD_NUMERICAL;
|
||||||
|
term->reverse = false;
|
||||||
|
term->hide_cursor = false;
|
||||||
|
term->auto_margin = true;
|
||||||
|
term->insert_mode = false;
|
||||||
|
term->bracketed_paste = false;
|
||||||
|
term->focus_events = false;
|
||||||
|
term->mouse_tracking = MOUSE_NONE;
|
||||||
|
term->mouse_reporting = MOUSE_NORMAL;
|
||||||
|
term->selected_charset = 0;
|
||||||
|
term->charset[0] = CHARSET_ASCII;
|
||||||
|
term->charset[1] = CHARSET_ASCII;
|
||||||
|
term->charset[2] = CHARSET_ASCII;
|
||||||
|
term->charset[3] = CHARSET_ASCII;
|
||||||
|
tll_free_and_free(term->window_title_stack, free);
|
||||||
|
free(term->window_title);
|
||||||
|
term->window_title = strdup("foot");
|
||||||
|
|
||||||
|
term->scroll_region.start = 0;
|
||||||
|
term->scroll_region.end = term->rows;
|
||||||
|
|
||||||
|
free(term->vt.osc.data);
|
||||||
|
memset(&term->vt, 0, sizeof(term->vt));
|
||||||
|
term->vt.state = 1; /* GROUND */
|
||||||
|
|
||||||
|
if (term->grid == &term->alt) {
|
||||||
|
term->grid = &term->normal;
|
||||||
|
term_restore_cursor(term);
|
||||||
|
selection_cancel(term);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hard)
|
||||||
|
return;
|
||||||
|
|
||||||
|
term->flash.active = false;
|
||||||
|
term->blink.active = false;
|
||||||
|
term->blink.state = BLINK_ON;
|
||||||
|
term->colors.fg = term->colors.default_fg;
|
||||||
|
term->colors.bg = term->colors.default_bg;
|
||||||
|
for (size_t i = 0; i < 8; i++) {
|
||||||
|
term->colors.regular[i] = term->colors.default_regular[i];
|
||||||
|
term->colors.bright[i] = term->colors.default_bright[i];
|
||||||
|
}
|
||||||
|
term->print_needs_wrap = false;
|
||||||
|
term->cursor = (struct coord){0, 0};
|
||||||
|
term->saved_cursor = (struct coord){0, 0};
|
||||||
|
term->alt_saved_cursor = (struct coord){0, 0};
|
||||||
|
term->cursor_style = term->default_cursor_style;
|
||||||
|
term->cursor_blinking = false;
|
||||||
|
term->cursor_color.text = term->default_cursor_color.text;
|
||||||
|
term->cursor_color.cursor = term->default_cursor_color.cursor;
|
||||||
|
selection_cancel(term);
|
||||||
|
term->normal.offset = term->normal.view = 0;
|
||||||
|
term->alt.offset = term->alt.view = 0;
|
||||||
|
for (size_t i = 0; i < term->rows; i++) {
|
||||||
|
memset(term->normal.rows[i]->cells, 0, term->cols * sizeof(struct cell));
|
||||||
|
memset(term->alt.rows[i]->cells, 0, term->cols * sizeof(struct cell));
|
||||||
|
}
|
||||||
|
for (size_t i = term->rows; i < term->normal.num_rows; i++) {
|
||||||
|
grid_row_free(term->normal.rows[i]);
|
||||||
|
term->normal.rows[i] = NULL;
|
||||||
|
}
|
||||||
|
for (size_t i = term->rows; i < term->alt.num_rows; i++) {
|
||||||
|
grid_row_free(term->alt.rows[i]);
|
||||||
|
term->alt.rows[i] = NULL;
|
||||||
|
}
|
||||||
|
term->normal.cur_row = term->normal.rows[0];
|
||||||
|
term->alt.cur_row = term->alt.rows[0];
|
||||||
|
tll_free(term->normal.damage);
|
||||||
|
tll_free(term->normal.scroll_damage);
|
||||||
|
tll_free(term->alt.damage);
|
||||||
|
tll_free(term->alt.scroll_damage);
|
||||||
|
term->render.last_cursor.cell = NULL;
|
||||||
|
term->render.was_flashing = false;
|
||||||
|
term_damage_all(term);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
term_damage_rows(struct terminal *term, int start, int end)
|
term_damage_rows(struct terminal *term, int start, int end)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -341,6 +341,8 @@ struct terminal {
|
||||||
} render;
|
} render;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void term_reset(struct terminal *term, bool hard);
|
||||||
|
|
||||||
void term_damage_rows(struct terminal *term, int start, int end);
|
void term_damage_rows(struct terminal *term, int start, int end);
|
||||||
void term_damage_rows_in_view(struct terminal *term, int start, int end);
|
void term_damage_rows_in_view(struct terminal *term, int start, int end);
|
||||||
|
|
||||||
|
|
|
||||||
2
vt.c
2
vt.c
|
|
@ -601,7 +601,7 @@ esc_dispatch(struct terminal *term, uint8_t final)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
LOG_WARN("unimplemented: reset to initial state");
|
term_reset(term, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'B': {
|
case 'B': {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue