aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-27 15:23:28 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-27 15:23:28 +0000
commit61cabdac13986e6cb2ba69e81d5934f55d92a1a9 (patch)
tree5ad589c35e81ecb86270261514cf623739d99c35 /render.c
parentrender: center grid in window (diff)
search: wip: re-direct input while searching, and build a search buffer
This adds a new state, 'is_searching'. While active, input is re-directed, and stored in a search buffer. In the future, we'll use this buffer and search for its content in the scrollback buffer, and move the view and create a selection on matches. When rendering in 'is_searching', everything is dimmed. In the future, we'll render the current search buffer on-top of the dimmed "regular" terminal output.
Diffstat (limited to 'render.c')
-rw-r--r--render.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/render.c b/render.c
index 84c86232..990726d8 100644
--- a/render.c
+++ b/render.c
@@ -204,6 +204,11 @@ render_cell(struct terminal *term, pixman_image_t *pix,
bg = color_hex_to_pixman(term->cursor_color.cursor);
}
+ if (term->is_searching) {
+ pixman_color_dim(&fg);
+ pixman_color_dim(&bg);
+ }
+
struct font *font = attrs_to_font(term, &cell->attrs);
const struct glyph *glyph = font_glyph_for_wc(font, cell->wc);
@@ -216,9 +221,13 @@ render_cell(struct terminal *term, pixman_image_t *pix,
/* Non-block cursors */
if (has_cursor && !block_cursor) {
- pixman_color_t cursor_color = term->cursor_color.text >> 31
- ? color_hex_to_pixman(term->cursor_color.cursor)
- : fg;
+ pixman_color_t cursor_color;
+ if (term->cursor_color.text >> 31) {
+ cursor_color = color_hex_to_pixman(term->cursor_color.cursor);
+ if (term->is_searching)
+ pixman_color_dim(&cursor_color);
+ } else
+ cursor_color = fg;
if (term->cursor_style == CURSOR_BAR)
draw_bar(term, pix, &cursor_color, x, y);
@@ -435,9 +444,10 @@ grid_render(struct terminal *term)
term_damage_view(term);
/* If we resized the window, or is flashing, or just stopped flashing */
- if (term->render.last_buf != buf || term->flash.active || term->render.was_flashing) {
- LOG_DBG("new buffer");
-
+ if (term->render.last_buf != buf ||
+ term->flash.active || term->render.was_flashing ||
+ term->is_searching != term->render.was_searching)
+ {
/* Fill area outside the cell grid with the default background color */
int rmargin = term->x_margin + term->cols * term->cell_width;
int bmargin = term->y_margin + term->rows * term->cell_height;
@@ -445,8 +455,10 @@ grid_render(struct terminal *term)
int bmargin_height = term->height - bmargin;
uint32_t _bg = !term->reverse ? term->colors.bg : term->colors.fg;
-
pixman_color_t bg = color_hex_to_pixman_with_alpha(_bg, term->colors.alpha);
+ if (term->is_searching)
+ pixman_color_dim(&bg);
+
pixman_image_fill_rectangles(
PIXMAN_OP_SRC, pix, &bg, 4,
(pixman_rectangle16_t[]){
@@ -469,6 +481,7 @@ grid_render(struct terminal *term)
term->render.last_buf = buf;
term->render.was_flashing = term->flash.active;
+ term->render.was_searching = term->is_searching;
}
tll_foreach(term->grid->scroll_damage, it) {
@@ -626,6 +639,7 @@ grid_render(struct terminal *term)
if (term->flash.active) {
/* Note: alpha is pre-computed in each color component */
+ /* TODO: dim while searching */
pixman_image_fill_rectangles(
PIXMAN_OP_OVER, pix,
&(pixman_color_t){.red=0x7fff, .green=0x7fff, .blue=0, .alpha=0x7fff},