mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-24 09:05:48 -04:00
term: remove read-only properties copied from the config
Use the config directly instead.
This commit is contained in:
parent
bb0b3ab122
commit
360cc8e6de
4 changed files with 37 additions and 56 deletions
3
csi.c
3
csi.c
|
|
@ -15,6 +15,7 @@
|
||||||
#define LOG_MODULE "csi"
|
#define LOG_MODULE "csi"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
#include "config.h"
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
#include "sixel.h"
|
#include "sixel.h"
|
||||||
|
|
@ -1513,11 +1514,11 @@ csi_dispatch(struct terminal *term, uint8_t final)
|
||||||
int param = vt_param_get(term, 0, 0);
|
int param = vt_param_get(term, 0, 0);
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 0: /* blinking block, but we use it to reset to configured default */
|
case 0: /* blinking block, but we use it to reset to configured default */
|
||||||
term->cursor_style = term->default_cursor_style;
|
|
||||||
if (term->default_cursor_blink)
|
if (term->default_cursor_blink)
|
||||||
term_cursor_blink_enable(term);
|
term_cursor_blink_enable(term);
|
||||||
else
|
else
|
||||||
term_cursor_blink_disable(term);
|
term_cursor_blink_disable(term);
|
||||||
|
term->cursor_style = term->conf->cursor.style;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1: /* blinking block */
|
case 1: /* blinking block */
|
||||||
|
|
|
||||||
5
osc.c
5
osc.c
|
|
@ -8,6 +8,7 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
|
#include "config.h"
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
#include "render.h"
|
#include "render.h"
|
||||||
#include "selection.h"
|
#include "selection.h"
|
||||||
|
|
@ -663,8 +664,8 @@ osc_dispatch(struct terminal *term)
|
||||||
|
|
||||||
case 112:
|
case 112:
|
||||||
LOG_DBG("resetting cursor color");
|
LOG_DBG("resetting cursor color");
|
||||||
term->cursor_color.text = term->default_cursor_color.text;
|
term->cursor_color.text = term->conf->cursor.color.text;
|
||||||
term->cursor_color.cursor = term->default_cursor_color.cursor;
|
term->cursor_color.cursor = term->conf->cursor.color.cursor;
|
||||||
term_damage_cursor(term);
|
term_damage_cursor(term);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
79
terminal.c
79
terminal.c
|
|
@ -198,6 +198,8 @@ fdm_ptmx_out(struct fdm *fdm, int fd, int events, void *data)
|
||||||
static struct timespec last = {0};
|
static struct timespec last = {0};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static bool cursor_blink_rearm_timer(struct terminal *term);
|
||||||
|
|
||||||
/* Externally visible, but not declared in terminal.h, to enable pgo
|
/* Externally visible, but not declared in terminal.h, to enable pgo
|
||||||
* to call this function directly */
|
* to call this function directly */
|
||||||
bool
|
bool
|
||||||
|
|
@ -215,7 +217,10 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prevent blinking while typing */
|
/* Prevent blinking while typing */
|
||||||
term_cursor_blink_restart(term);
|
if (term->cursor_blink.fd >= 0) {
|
||||||
|
term->cursor_blink.state = CURSOR_BLINK_ON;
|
||||||
|
cursor_blink_rearm_timer(term);
|
||||||
|
}
|
||||||
|
|
||||||
term->render.app_sync_updates.flipped = false;
|
term->render.app_sync_updates.flipped = false;
|
||||||
|
|
||||||
|
|
@ -311,7 +316,7 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hup) {
|
if (hup) {
|
||||||
if (term->hold_at_exit) {
|
if (term->conf->hold_at_exit) {
|
||||||
fdm_del(fdm, fd);
|
fdm_del(fdm, fd);
|
||||||
term->ptmx = -1;
|
term->ptmx = -1;
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -1056,18 +1061,13 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.alpha = conf->colors.alpha,
|
.alpha = conf->colors.alpha,
|
||||||
},
|
},
|
||||||
.origin = ORIGIN_ABSOLUTE,
|
.origin = ORIGIN_ABSOLUTE,
|
||||||
.default_cursor_blink = conf->cursor.blink,
|
|
||||||
.default_cursor_style = conf->cursor.style,
|
|
||||||
.cursor_style = conf->cursor.style,
|
.cursor_style = conf->cursor.style,
|
||||||
.cursor_blink = {
|
.cursor_blink = {
|
||||||
.active = conf->cursor.blink,
|
.decset = false,
|
||||||
|
.deccsusr = conf->cursor.blink,
|
||||||
.state = CURSOR_BLINK_ON,
|
.state = CURSOR_BLINK_ON,
|
||||||
.fd = -1,
|
.fd = -1,
|
||||||
},
|
},
|
||||||
.default_cursor_color = {
|
|
||||||
.text = conf->cursor.color.text,
|
|
||||||
.cursor = conf->cursor.color.cursor,
|
|
||||||
},
|
|
||||||
.cursor_color = {
|
.cursor_color = {
|
||||||
.text = conf->cursor.color.text,
|
.text = conf->cursor.color.text,
|
||||||
.cursor = conf->cursor.color.cursor,
|
.cursor = conf->cursor.color.cursor,
|
||||||
|
|
@ -1112,7 +1112,6 @@ term_init(const struct config *conf, struct fdm *fdm, struct reaper *reaper,
|
||||||
.max_width = SIXEL_MAX_WIDTH,
|
.max_width = SIXEL_MAX_WIDTH,
|
||||||
.max_height = SIXEL_MAX_HEIGHT,
|
.max_height = SIXEL_MAX_HEIGHT,
|
||||||
},
|
},
|
||||||
.hold_at_exit = conf->hold_at_exit,
|
|
||||||
.shutdown_cb = shutdown_cb,
|
.shutdown_cb = shutdown_cb,
|
||||||
.shutdown_data = shutdown_data,
|
.shutdown_data = shutdown_data,
|
||||||
.foot_exe = xstrdup(foot_exe),
|
.foot_exe = xstrdup(foot_exe),
|
||||||
|
|
@ -1256,13 +1255,13 @@ term_shutdown(struct terminal *term)
|
||||||
* iteration, by creating an event FD that we trigger immediately.
|
* iteration, by creating an event FD that we trigger immediately.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
term_cursor_blink_disable(term);
|
term_cursor_blink_update(term);
|
||||||
|
assert(term->cursor_blink.fd < 0);
|
||||||
|
|
||||||
fdm_del(term->fdm, term->selection.auto_scroll.fd);
|
fdm_del(term->fdm, term->selection.auto_scroll.fd);
|
||||||
fdm_del(term->fdm, term->render.app_sync_updates.timer_fd);
|
fdm_del(term->fdm, term->render.app_sync_updates.timer_fd);
|
||||||
fdm_del(term->fdm, term->delayed_render_timer.lower_fd);
|
fdm_del(term->fdm, term->delayed_render_timer.lower_fd);
|
||||||
fdm_del(term->fdm, term->delayed_render_timer.upper_fd);
|
fdm_del(term->fdm, term->delayed_render_timer.upper_fd);
|
||||||
fdm_del(term->fdm, term->cursor_blink.fd);
|
|
||||||
fdm_del(term->fdm, term->blink.fd);
|
fdm_del(term->fdm, term->blink.fd);
|
||||||
fdm_del(term->fdm, term->flash.fd);
|
fdm_del(term->fdm, term->flash.fd);
|
||||||
|
|
||||||
|
|
@ -1275,7 +1274,6 @@ term_shutdown(struct terminal *term)
|
||||||
term->render.app_sync_updates.timer_fd = -1;
|
term->render.app_sync_updates.timer_fd = -1;
|
||||||
term->delayed_render_timer.lower_fd = -1;
|
term->delayed_render_timer.lower_fd = -1;
|
||||||
term->delayed_render_timer.upper_fd = -1;
|
term->delayed_render_timer.upper_fd = -1;
|
||||||
term->cursor_blink.fd = -1;
|
|
||||||
term->blink.fd = -1;
|
term->blink.fd = -1;
|
||||||
term->flash.fd = -1;
|
term->flash.fd = -1;
|
||||||
term->ptmx = -1;
|
term->ptmx = -1;
|
||||||
|
|
@ -1575,13 +1573,12 @@ term_reset(struct terminal *term, bool hard)
|
||||||
term->normal.saved_cursor = (struct cursor){.point = {0, 0}};
|
term->normal.saved_cursor = (struct cursor){.point = {0, 0}};
|
||||||
term->alt.cursor = (struct cursor){.point = {0, 0}};
|
term->alt.cursor = (struct cursor){.point = {0, 0}};
|
||||||
term->alt.saved_cursor = (struct cursor){.point = {0, 0}};
|
term->alt.saved_cursor = (struct cursor){.point = {0, 0}};
|
||||||
term->cursor_style = term->default_cursor_style;
|
term->cursor_style = term->conf->cursor.style;
|
||||||
if (term->conf->cursor.blink)
|
term->cursor_blink.decset = false;
|
||||||
term_cursor_blink_enable(term);
|
term->cursor_blink.deccsusr = term->conf->cursor.blink;
|
||||||
else
|
term_cursor_blink_update(term);
|
||||||
term_cursor_blink_disable(term);
|
term->cursor_color.text = term->conf->cursor.color.text;
|
||||||
term->cursor_color.text = term->default_cursor_color.text;
|
term->cursor_color.cursor = term->conf->cursor.color.cursor;
|
||||||
term->cursor_color.cursor = term->default_cursor_color.cursor;
|
|
||||||
selection_cancel(term);
|
selection_cancel(term);
|
||||||
term->normal.offset = term->normal.view = 0;
|
term->normal.offset = term->normal.view = 0;
|
||||||
term->alt.offset = term->alt.view = 0;
|
term->alt.offset = term->alt.view = 0;
|
||||||
|
|
@ -1917,7 +1914,7 @@ term_cursor_down(struct terminal *term, int count)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cursor_blink_start_timer(struct terminal *term)
|
cursor_blink_rearm_timer(struct terminal *term)
|
||||||
{
|
{
|
||||||
if (term->cursor_blink.fd < 0) {
|
if (term->cursor_blink.fd < 0) {
|
||||||
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||||
|
|
@ -1950,7 +1947,7 @@ cursor_blink_start_timer(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
cursor_blink_stop_timer(struct terminal *term)
|
cursor_blink_disarm_timer(struct terminal *term)
|
||||||
{
|
{
|
||||||
fdm_del(term->fdm, term->cursor_blink.fd);
|
fdm_del(term->fdm, term->cursor_blink.fd);
|
||||||
term->cursor_blink.fd = -1;
|
term->cursor_blink.fd = -1;
|
||||||
|
|
@ -1958,29 +1955,21 @@ cursor_blink_stop_timer(struct terminal *term)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
term_cursor_blink_enable(struct terminal *term)
|
term_cursor_blink_update(struct terminal *term)
|
||||||
{
|
{
|
||||||
term->cursor_blink.state = CURSOR_BLINK_ON;
|
bool enable = term->cursor_blink.decset || term->cursor_blink.deccsusr;
|
||||||
term->cursor_blink.active = term->kbd_focus
|
bool activate = !term->is_shutting_down && enable && term->kbd_focus;
|
||||||
? cursor_blink_start_timer(term) : true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
LOG_DBG("decset=%d, deccsrusr=%d, focus=%d, shutting-down=%d, enable=%d, activate=%d",
|
||||||
term_cursor_blink_disable(struct terminal *term)
|
term->cursor_blink.decset, term->cursor_blink.deccsusr,
|
||||||
{
|
term->kbd_focus, term->is_shutting_down,
|
||||||
term->cursor_blink.active = false;
|
enable, activate);
|
||||||
term->cursor_blink.state = CURSOR_BLINK_ON;
|
|
||||||
cursor_blink_stop_timer(term);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
if (activate && term->cursor_blink.fd < 0) {
|
||||||
term_cursor_blink_restart(struct terminal *term)
|
|
||||||
{
|
|
||||||
if (term->cursor_blink.active) {
|
|
||||||
term->cursor_blink.state = CURSOR_BLINK_ON;
|
term->cursor_blink.state = CURSOR_BLINK_ON;
|
||||||
term->cursor_blink.active = term->kbd_focus
|
cursor_blink_rearm_timer(term);
|
||||||
? cursor_blink_start_timer(term) : true;
|
} else if (!activate && term->cursor_blink.fd >= 0)
|
||||||
}
|
cursor_blink_disarm_timer(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
|
@ -2182,9 +2171,7 @@ term_visual_focus_in(struct terminal *term)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
term->visual_focus = true;
|
term->visual_focus = true;
|
||||||
if (term->cursor_blink.active)
|
term_cursor_blink_update(term);
|
||||||
cursor_blink_start_timer(term);
|
|
||||||
|
|
||||||
render_refresh_csd(term);
|
render_refresh_csd(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2195,9 +2182,7 @@ term_visual_focus_out(struct terminal *term)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
term->visual_focus = false;
|
term->visual_focus = false;
|
||||||
if (term->cursor_blink.active)
|
term_cursor_blink_update(term);
|
||||||
cursor_blink_stop_timer(term);
|
|
||||||
|
|
||||||
render_refresh_csd(term);
|
render_refresh_csd(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -336,7 +336,6 @@ struct terminal {
|
||||||
uint32_t default_table[256];
|
uint32_t default_table[256];
|
||||||
} colors;
|
} colors;
|
||||||
|
|
||||||
enum cursor_style default_cursor_style;
|
|
||||||
enum cursor_style cursor_style;
|
enum cursor_style cursor_style;
|
||||||
struct {
|
struct {
|
||||||
bool active;
|
bool active;
|
||||||
|
|
@ -344,10 +343,6 @@ struct terminal {
|
||||||
int fd;
|
int fd;
|
||||||
} cursor_blink;
|
} cursor_blink;
|
||||||
bool default_cursor_blink;
|
bool default_cursor_blink;
|
||||||
struct {
|
|
||||||
uint32_t text;
|
|
||||||
uint32_t cursor;
|
|
||||||
} default_cursor_color;
|
|
||||||
struct {
|
struct {
|
||||||
uint32_t text;
|
uint32_t text;
|
||||||
uint32_t cursor;
|
uint32_t cursor;
|
||||||
|
|
@ -474,7 +469,6 @@ struct terminal {
|
||||||
} sixel;
|
} sixel;
|
||||||
|
|
||||||
bool quit;
|
bool quit;
|
||||||
bool hold_at_exit;
|
|
||||||
bool is_shutting_down;
|
bool is_shutting_down;
|
||||||
void (*shutdown_cb)(void *data, int exit_code);
|
void (*shutdown_cb)(void *data, int exit_code);
|
||||||
void *shutdown_data;
|
void *shutdown_data;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue