Add option to change terminal alpha through key-bindings

This commit is contained in:
Utkarsh Verma 2022-06-02 08:12:31 +05:30
parent 377997be9d
commit 4e2347da12
No known key found for this signature in database
GPG key ID: 817656CF818EFCCC
7 changed files with 177 additions and 123 deletions

View file

@ -104,6 +104,9 @@ 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_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",

View file

@ -714,6 +714,15 @@ 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%. Default: _not_bound_.
*alpha-decrease*
Decreases alpha by 5%. Default: _not_bound_.
*alpha-reset*
Resets alpha to 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

View file

@ -133,6 +133,9 @@
# 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
# spawn-terminal=Control+Shift+n # spawn-terminal=Control+Shift+n
# minimize=none # minimize=none
# maximize=none # maximize=none

12
input.c
View file

@ -178,6 +178,18 @@ 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_increase(term);
return true;
case BIND_ACTION_ALPHA_DOWN:
term_alpha_decrease(term);
return true;
case BIND_ACTION_ALPHA_RESET:
term_alpha_reset(term);
return true;
case BIND_ACTION_SPAWN_TERMINAL: case BIND_ACTION_SPAWN_TERMINAL:
term_spawn_new(term); term_spawn_new(term);
return true; return true;

View file

@ -25,6 +25,9 @@ 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_SPAWN_TERMINAL, BIND_ACTION_SPAWN_TERMINAL,
BIND_ACTION_MINIMIZE, BIND_ACTION_MINIMIZE,
BIND_ACTION_MAXIMIZE, BIND_ACTION_MAXIMIZE,

View file

@ -2005,6 +2005,27 @@ term_font_size_reset(struct terminal *term)
return load_fonts_from_conf(term); return load_fonts_from_conf(term);
} }
bool
term_alpha_increase(struct terminal *term)
{
term->colors.alpha += 0.05;
return true;
}
bool
term_alpha_decrease(struct terminal *term)
{
term->colors.alpha -= 0.05;
return true;
}
bool
term_alpha_reset(struct terminal *term)
{
term->colors.alpha = term->conf->colors.alpha;
return true;
}
bool bool
term_font_dpi_changed(struct terminal *term, int old_scale) term_font_dpi_changed(struct terminal *term, int old_scale)
{ {

View file

@ -692,6 +692,9 @@ bool term_paste_data_to_slave(
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);
bool term_alpha_increase(struct terminal *term);
bool term_alpha_decrease(struct terminal *term);
bool term_alpha_reset(struct terminal *term);
bool term_font_dpi_changed(struct terminal *term, int old_scale); bool term_font_dpi_changed(struct terminal *term, int old_scale);
void term_font_subpixel_changed(struct terminal *term); void term_font_subpixel_changed(struct terminal *term);