mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-15 08:21:03 -04:00
key-binding: add binds for changing alpha
This commit is contained in:
parent
d7b48d3924
commit
1ed7206222
9 changed files with 54 additions and 2 deletions
|
|
@ -15,8 +15,6 @@
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "xmalloc.h"
|
#include "xmalloc.h"
|
||||||
|
|
||||||
#define clamp(x, lower, upper) (min(upper, max(x, lower)))
|
|
||||||
|
|
||||||
enum thickness {
|
enum thickness {
|
||||||
LIGHT,
|
LIGHT,
|
||||||
HEAVY,
|
HEAVY,
|
||||||
|
|
|
||||||
4
config.c
4
config.c
|
|
@ -124,6 +124,10 @@ static const char *const binding_action_map[] = {
|
||||||
[BIND_ACTION_FONT_SIZE_UP] = "font-increase",
|
[BIND_ACTION_FONT_SIZE_UP] = "font-increase",
|
||||||
[BIND_ACTION_FONT_SIZE_DOWN] = "font-decrease",
|
[BIND_ACTION_FONT_SIZE_DOWN] = "font-decrease",
|
||||||
[BIND_ACTION_FONT_SIZE_RESET] = "font-reset",
|
[BIND_ACTION_FONT_SIZE_RESET] = "font-reset",
|
||||||
|
[BIND_ACTION_ALPHA_UP] = "alpha-increase",
|
||||||
|
[BIND_ACTION_ALPHA_DOWN] = "alpha-decrease",
|
||||||
|
[BIND_ACTION_ALPHA_RESET] = "alpha-reset",
|
||||||
|
[BIND_ACTION_ALPHA_TOGGLE] = "alpha-toggle",
|
||||||
[BIND_ACTION_SPAWN_TERMINAL] = "spawn-terminal",
|
[BIND_ACTION_SPAWN_TERMINAL] = "spawn-terminal",
|
||||||
[BIND_ACTION_MINIMIZE] = "minimize",
|
[BIND_ACTION_MINIMIZE] = "minimize",
|
||||||
[BIND_ACTION_MAXIMIZE] = "maximize",
|
[BIND_ACTION_MAXIMIZE] = "maximize",
|
||||||
|
|
|
||||||
|
|
@ -1307,6 +1307,18 @@ e.g. *search-start=none*.
|
||||||
*font-reset*
|
*font-reset*
|
||||||
Resets the font size to the default. Default: _Control+0 Control+KP\_0_.
|
Resets the font size to the default. Default: _Control+0 Control+KP\_0_.
|
||||||
|
|
||||||
|
*alpha-increase*
|
||||||
|
Increases alpha by 5 percentage points. Default: _not_bound_.
|
||||||
|
|
||||||
|
*alpha-decrease*
|
||||||
|
Decreases alpha by 5 percentage points. Default: _not_bound_.
|
||||||
|
|
||||||
|
*alpha-reset*
|
||||||
|
Resets alpha to the default. Default: _not_bound_.
|
||||||
|
|
||||||
|
*alpha-toggle*
|
||||||
|
Toggles alpha between 100% and the default. Default: _not_bound_.
|
||||||
|
|
||||||
*spawn-terminal*
|
*spawn-terminal*
|
||||||
Spawns a new terminal. If the shell has been configured to emit
|
Spawns a new terminal. If the shell has been configured to emit
|
||||||
the OSC 7 escape sequence, the new terminal will start in the
|
the OSC 7 escape sequence, the new terminal will start in the
|
||||||
|
|
|
||||||
4
foot.ini
4
foot.ini
|
|
@ -199,6 +199,10 @@
|
||||||
# font-increase=Control+plus Control+equal Control+KP_Add
|
# font-increase=Control+plus Control+equal Control+KP_Add
|
||||||
# font-decrease=Control+minus Control+KP_Subtract
|
# font-decrease=Control+minus Control+KP_Subtract
|
||||||
# font-reset=Control+0 Control+KP_0
|
# font-reset=Control+0 Control+KP_0
|
||||||
|
# alpha-increase=none
|
||||||
|
# alpha-decrease=none
|
||||||
|
# alpha-reset=none
|
||||||
|
# alpha-toggle=none
|
||||||
# spawn-terminal=Control+Shift+n
|
# spawn-terminal=Control+Shift+n
|
||||||
# minimize=none
|
# minimize=none
|
||||||
# maximize=none
|
# maximize=none
|
||||||
|
|
|
||||||
19
input.c
19
input.c
|
|
@ -198,6 +198,25 @@ execute_binding(struct seat *seat, struct terminal *term,
|
||||||
term_font_size_reset(term);
|
term_font_size_reset(term);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case BIND_ACTION_ALPHA_UP:
|
||||||
|
term_alpha_set(term,
|
||||||
|
clamp(term->colors.alpha + 0.05 * UINT16_MAX, 0, UINT16_MAX));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case BIND_ACTION_ALPHA_DOWN:
|
||||||
|
term_alpha_set(term,
|
||||||
|
clamp(term->colors.alpha - 0.05 * UINT16_MAX, 0, UINT16_MAX));
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case BIND_ACTION_ALPHA_RESET:
|
||||||
|
term_alpha_set(term, term->conf->colors.alpha);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case BIND_ACTION_ALPHA_TOGGLE:
|
||||||
|
term_alpha_set(term, term->colors.alpha == UINT16_MAX
|
||||||
|
? term->conf->colors.alpha : UINT16_MAX);
|
||||||
|
return true;
|
||||||
|
|
||||||
case BIND_ACTION_SPAWN_TERMINAL:
|
case BIND_ACTION_SPAWN_TERMINAL:
|
||||||
term_spawn_new(term);
|
term_spawn_new(term);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,10 @@ enum bind_action_normal {
|
||||||
BIND_ACTION_FONT_SIZE_UP,
|
BIND_ACTION_FONT_SIZE_UP,
|
||||||
BIND_ACTION_FONT_SIZE_DOWN,
|
BIND_ACTION_FONT_SIZE_DOWN,
|
||||||
BIND_ACTION_FONT_SIZE_RESET,
|
BIND_ACTION_FONT_SIZE_RESET,
|
||||||
|
BIND_ACTION_ALPHA_UP,
|
||||||
|
BIND_ACTION_ALPHA_DOWN,
|
||||||
|
BIND_ACTION_ALPHA_RESET,
|
||||||
|
BIND_ACTION_ALPHA_TOGGLE,
|
||||||
BIND_ACTION_SPAWN_TERMINAL,
|
BIND_ACTION_SPAWN_TERMINAL,
|
||||||
BIND_ACTION_MINIMIZE,
|
BIND_ACTION_MINIMIZE,
|
||||||
BIND_ACTION_MAXIMIZE,
|
BIND_ACTION_MAXIMIZE,
|
||||||
|
|
|
||||||
|
|
@ -2323,6 +2323,15 @@ term_font_size_reset(struct terminal *term)
|
||||||
return load_fonts_from_conf(term);
|
return load_fonts_from_conf(term);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
term_alpha_set(struct terminal *term, uint16_t alpha)
|
||||||
|
{
|
||||||
|
term->colors.alpha = alpha;
|
||||||
|
term_damage_margins(term);
|
||||||
|
wayl_win_alpha_changed(term->window);
|
||||||
|
term_font_subpixel_changed(term);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
term_fractional_scaling(const struct terminal *term)
|
term_fractional_scaling(const struct terminal *term)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -859,6 +859,7 @@ bool term_update_scale(struct terminal *term);
|
||||||
bool term_font_size_increase(struct terminal *term);
|
bool term_font_size_increase(struct terminal *term);
|
||||||
bool term_font_size_decrease(struct terminal *term);
|
bool term_font_size_decrease(struct terminal *term);
|
||||||
bool term_font_size_reset(struct terminal *term);
|
bool term_font_size_reset(struct terminal *term);
|
||||||
|
void term_alpha_set(struct terminal *term, uint16_t alpha);
|
||||||
bool term_font_dpi_changed(struct terminal *term, float old_scale);
|
bool term_font_dpi_changed(struct terminal *term, float old_scale);
|
||||||
void term_font_subpixel_changed(struct terminal *term);
|
void term_font_subpixel_changed(struct terminal *term);
|
||||||
int term_font_baseline(const struct terminal *term);
|
int term_font_baseline(const struct terminal *term);
|
||||||
|
|
|
||||||
1
util.h
1
util.h
|
|
@ -8,6 +8,7 @@
|
||||||
#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
|
#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
|
||||||
#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))
|
||||||
|
#define clamp(x, lower, upper) (min(upper, max(x, lower)))
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
streq(const char *a, const char *b)
|
streq(const char *a, const char *b)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue