mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
term: add term_font_size_{increase,decrease}()
This commit is contained in:
parent
9e2ca2b1a3
commit
89cca2a5d1
2 changed files with 54 additions and 6 deletions
44
terminal.c
44
terminal.c
|
|
@ -603,6 +603,7 @@ term_init(const struct config *conf, struct fdm *fdm, struct wayland *wayl,
|
||||||
/* Initialize configure-based terminal attributes */
|
/* Initialize configure-based terminal attributes */
|
||||||
*term = (struct terminal) {
|
*term = (struct terminal) {
|
||||||
.fdm = fdm,
|
.fdm = fdm,
|
||||||
|
.conf = conf,
|
||||||
.quit = false,
|
.quit = false,
|
||||||
.ptmx = ptmx,
|
.ptmx = ptmx,
|
||||||
.ptmx_buffer = tll_init(),
|
.ptmx_buffer = tll_init(),
|
||||||
|
|
@ -1099,6 +1100,49 @@ term_reset(struct terminal *term, bool hard)
|
||||||
term_damage_all(term);
|
term_damage_all(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
term_font_size_adjust(struct terminal *term, double amount)
|
||||||
|
{
|
||||||
|
struct font *fonts[4] = {
|
||||||
|
font_size_adjust(term->fonts[0], amount),
|
||||||
|
font_size_adjust(term->fonts[1], amount),
|
||||||
|
font_size_adjust(term->fonts[2], amount),
|
||||||
|
font_size_adjust(term->fonts[3], amount),
|
||||||
|
};
|
||||||
|
|
||||||
|
if (fonts[0] == NULL || fonts[1] == NULL ||
|
||||||
|
fonts[2] == NULL || fonts[3] == NULL)
|
||||||
|
{
|
||||||
|
for (size_t i = 0; i < 4; i++)
|
||||||
|
font_destroy(fonts[i]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < 4; i++) {
|
||||||
|
font_destroy(term->fonts[i]);
|
||||||
|
term->fonts[i] = fonts[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
term->cell_width = term->fonts[0]->space_x_advance > 0
|
||||||
|
? term->fonts[0]->space_x_advance : term->fonts[0]->max_x_advance;
|
||||||
|
term->cell_height = term->fonts[0]->height;
|
||||||
|
LOG_INFO("cell width=%d, height=%d", term->cell_width, term->cell_height);
|
||||||
|
|
||||||
|
render_resize_force(term, term->width, term->height);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
term_font_size_increase(struct terminal *term)
|
||||||
|
{
|
||||||
|
term_font_size_adjust(term, 1.);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
term_font_size_decrease(struct terminal *term)
|
||||||
|
{
|
||||||
|
term_font_size_adjust(term, -1.);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
term_damage_rows(struct terminal *term, int start, int end)
|
term_damage_rows(struct terminal *term, int start, int end)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
16
terminal.h
16
terminal.h
|
|
@ -175,11 +175,18 @@ struct ptmx_buffer {
|
||||||
|
|
||||||
struct terminal {
|
struct terminal {
|
||||||
struct fdm *fdm;
|
struct fdm *fdm;
|
||||||
|
const struct config *conf;
|
||||||
|
|
||||||
pid_t slave;
|
pid_t slave;
|
||||||
int ptmx;
|
int ptmx;
|
||||||
bool quit;
|
bool quit;
|
||||||
|
|
||||||
|
struct grid normal;
|
||||||
|
struct grid alt;
|
||||||
|
struct grid *grid;
|
||||||
|
|
||||||
|
struct font *fonts[4];
|
||||||
|
|
||||||
tll(struct ptmx_buffer) ptmx_buffer;
|
tll(struct ptmx_buffer) ptmx_buffer;
|
||||||
|
|
||||||
enum cursor_keys cursor_keys_mode;
|
enum cursor_keys cursor_keys_mode;
|
||||||
|
|
@ -277,12 +284,6 @@ struct terminal {
|
||||||
size_t match_len;
|
size_t match_len;
|
||||||
} search;
|
} search;
|
||||||
|
|
||||||
struct grid normal;
|
|
||||||
struct grid alt;
|
|
||||||
struct grid *grid;
|
|
||||||
|
|
||||||
struct font *fonts[4];
|
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
bool esc_prefix;
|
bool esc_prefix;
|
||||||
bool eight_bit;
|
bool eight_bit;
|
||||||
|
|
@ -362,6 +363,9 @@ int term_destroy(struct terminal *term);
|
||||||
void term_reset(struct terminal *term, bool hard);
|
void term_reset(struct terminal *term, bool hard);
|
||||||
bool term_to_slave(struct terminal *term, const void *data, size_t len);
|
bool term_to_slave(struct terminal *term, const void *data, size_t len);
|
||||||
|
|
||||||
|
void term_font_size_increase(struct terminal *term);
|
||||||
|
void term_font_size_decrease(struct terminal *term);
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue