From 9147407f9fec4ac5578e10ca08f24f445e42abc6 Mon Sep 17 00:00:00 2001 From: Raimund Sacherer Date: Sat, 7 Oct 2023 19:37:04 +0200 Subject: [PATCH] Enable the use of flash as visual bell With this patch we can configure flash in the bell section. The colors section allow now to configure the color of the flash and the alpha to apply to. Default values are the values which where currently used for flash, altough I personally like a nice red (eb1313) better. --- CHANGELOG.md | 3 +++ config.c | 4 ++-- doc/foot.ini.5.scd | 10 ++++------ foot.ini | 6 +++--- render.c | 4 +++- terminal.c | 2 +- 6 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f55792d8..2c99f446 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,9 +60,12 @@ row ([#1364][1364]). * Support for DECSET/DECRST/DECRQM 2027 (_Grapheme cluster processing_). +* Support for visual bell which flashes the terminal window. + ([#1508][1508]). [1077]: https://codeberg.org/dnkl/foot/issues/1077 [1364]: https://codeberg.org/dnkl/foot/issues/1364 +[1508]: https://codeberg.org/dnkl/foot/issues/1508 ### Changed diff --git a/config.c b/config.c index 0f5cb009..4b6b43aa 100644 --- a/config.c +++ b/config.c @@ -1031,7 +1031,7 @@ parse_section_bell(struct context *ctx) return value_to_bool(ctx, &conf->bell.urgent); else if (strcmp(key, "notify") == 0) return value_to_bool(ctx, &conf->bell.notify); - else if (strcmp(key, "flash") == 0) + else if (strcmp(key, "visual") == 0) return value_to_bool(ctx, &conf->bell.flash); else if (strcmp(key, "command") == 0) return value_to_spawn_template(ctx, &conf->bell.command); @@ -1300,7 +1300,7 @@ parse_section_colors(struct context *ctx) return true; } - else if (strcmp(key, "flash_alpha") == 0) { + else if (strcmp(key, "flash-alpha") == 0) { float alpha; if (!value_to_float(ctx, &alpha)) return false; diff --git a/doc/foot.ini.5.scd b/doc/foot.ini.5.scd index 4c5fc7fb..bab71996 100644 --- a/doc/foot.ini.5.scd +++ b/doc/foot.ini.5.scd @@ -394,9 +394,8 @@ Note: do not set *TERM* here; use the *term* option in the main Default: _no_ -*flash* - When set to _yes_, foot will emit the bell signal flashing the - terminal window whenever *BEL* is received. +*visual* + When set to _yes_, foot will flash terminal window. Default: _no_ @@ -618,14 +617,13 @@ can configure the background transparency with the _alpha_ option. *flash* Color to use for the terminal window flash. - Default: _7f7fff_. - + Default: _7f7f00_. *flash_alpha* Flash translucency. A value in the range 0.0-1.0, where 0.0 means completely transparent, and 1.0 is opaque. - Default: _0.7_. + Default: _0.5_. *alpha* Background translucency. A value in the range 0.0-1.0, where 0.0 diff --git a/foot.ini b/foot.ini index 7fd1c607..97872061 100644 --- a/foot.ini +++ b/foot.ini @@ -43,7 +43,7 @@ [bell] # urgent=no # notify=no -# flash=no +# visual=no # command= # command-focused=no @@ -78,8 +78,8 @@ # alpha=1.0 # background=242424 # foreground=ffffff -# flash=7f7fff -# flash_alpha=0.7 +# flash=7f7f00 +# flash_alpha=0.5 ## Normal/regular colors (color palette 0-7) # regular0=242424 # black diff --git a/render.c b/render.c index 12ddbf13..a380381f 100644 --- a/render.c +++ b/render.c @@ -1582,7 +1582,9 @@ render_overlay(struct terminal *term) break; case OVERLAY_FLASH: - color = color_hex_to_pixman_with_alpha(term->colors.flash, term->colors.flash_alpha); + color = color_hex_to_pixman_with_alpha( + term->conf->colors.flash, + term->conf->colors.flash_alpha); break; } diff --git a/terminal.c b/terminal.c index 99093342..da64740e 100644 --- a/terminal.c +++ b/terminal.c @@ -3294,7 +3294,7 @@ term_bell(struct terminal *term) notify_notify(term, "Bell", "Bell in terminal"); if (term->conf->bell.flash) - term_flash(term, 100); + term_flash(term, 100); if ((term->conf->bell.command.argv.args != NULL) && (!term->kbd_focus || term->conf->bell.command_focused))