4 * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
15 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
16 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
26 static void screen_redraw_draw_borders(struct screen_redraw_ctx
*);
27 static void screen_redraw_draw_panes(struct screen_redraw_ctx
*);
28 static void screen_redraw_draw_status(struct screen_redraw_ctx
*);
29 static void screen_redraw_draw_pane(struct screen_redraw_ctx
*,
30 struct window_pane
*);
31 static void screen_redraw_set_context(struct client
*,
32 struct screen_redraw_ctx
*);
34 #define START_ISOLATE "\342\201\246"
35 #define END_ISOLATE "\342\201\251"
37 /* Border in relation to a pane. */
38 enum screen_redraw_border_type
{
39 SCREEN_REDRAW_OUTSIDE
,
41 SCREEN_REDRAW_BORDER_LEFT
,
42 SCREEN_REDRAW_BORDER_RIGHT
,
43 SCREEN_REDRAW_BORDER_TOP
,
44 SCREEN_REDRAW_BORDER_BOTTOM
46 #define BORDER_MARKERS " +,.-"
48 /* Get cell border character. */
50 screen_redraw_border_set(struct window
*w
, struct window_pane
*wp
,
51 enum pane_lines pane_lines
, int cell_type
, struct grid_cell
*gc
)
55 if (cell_type
== CELL_OUTSIDE
&& w
->fill_character
!= NULL
) {
56 utf8_copy(&gc
->data
, &w
->fill_character
[0]);
61 case PANE_LINES_NUMBER
:
62 if (cell_type
== CELL_OUTSIDE
) {
63 gc
->attr
|= GRID_ATTR_CHARSET
;
64 utf8_set(&gc
->data
, CELL_BORDERS
[CELL_OUTSIDE
]);
67 gc
->attr
&= ~GRID_ATTR_CHARSET
;
68 if (wp
!= NULL
&& window_pane_index(wp
, &idx
) == 0)
69 utf8_set(&gc
->data
, '0' + (idx
% 10));
71 utf8_set(&gc
->data
, '*');
73 case PANE_LINES_DOUBLE
:
74 gc
->attr
&= ~GRID_ATTR_CHARSET
;
75 utf8_copy(&gc
->data
, tty_acs_double_borders(cell_type
));
77 case PANE_LINES_HEAVY
:
78 gc
->attr
&= ~GRID_ATTR_CHARSET
;
79 utf8_copy(&gc
->data
, tty_acs_heavy_borders(cell_type
));
81 case PANE_LINES_SIMPLE
:
82 gc
->attr
&= ~GRID_ATTR_CHARSET
;
83 utf8_set(&gc
->data
, SIMPLE_BORDERS
[cell_type
]);
86 gc
->attr
|= GRID_ATTR_CHARSET
;
87 utf8_set(&gc
->data
, CELL_BORDERS
[cell_type
]);
92 /* Return if window has only two panes. */
94 screen_redraw_two_panes(struct window
*w
, int direction
)
96 struct window_pane
*wp
;
98 wp
= TAILQ_NEXT(TAILQ_FIRST(&w
->panes
), entry
);
100 return (0); /* one pane */
101 if (TAILQ_NEXT(wp
, entry
) != NULL
)
102 return (0); /* more than two panes */
103 if (direction
== 0 && wp
->xoff
== 0)
105 if (direction
== 1 && wp
->yoff
== 0)
110 /* Check if cell is on the border of a pane. */
111 static enum screen_redraw_border_type
112 screen_redraw_pane_border(struct screen_redraw_ctx
*ctx
, struct window_pane
*wp
,
115 struct options
*oo
= wp
->window
->options
;
117 u_int ex
= wp
->xoff
+ wp
->sx
, ey
= wp
->yoff
+ wp
->sy
;
118 int pane_status
= ctx
->pane_status
;
121 if (px
>= wp
->xoff
&& px
< ex
&& py
>= wp
->yoff
&& py
< ey
)
122 return (SCREEN_REDRAW_INSIDE
);
124 /* Get pane indicator. */
125 switch (options_get_number(oo
, "pane-border-indicators")) {
126 case PANE_BORDER_COLOUR
:
127 case PANE_BORDER_BOTH
:
132 /* Left/right borders. */
133 if (pane_status
== PANE_STATUS_OFF
) {
134 if (screen_redraw_two_panes(wp
->window
, 0) && split
) {
135 if (wp
->xoff
== 0 && px
== wp
->sx
&& py
<= wp
->sy
/ 2)
136 return (SCREEN_REDRAW_BORDER_RIGHT
);
138 px
== wp
->xoff
- 1 &&
140 return (SCREEN_REDRAW_BORDER_LEFT
);
142 if ((wp
->yoff
== 0 || py
>= wp
->yoff
- 1) && py
<= ey
) {
143 if (wp
->xoff
!= 0 && px
== wp
->xoff
- 1)
144 return (SCREEN_REDRAW_BORDER_LEFT
);
146 return (SCREEN_REDRAW_BORDER_RIGHT
);
150 if ((wp
->yoff
== 0 || py
>= wp
->yoff
- 1) && py
<= ey
) {
151 if (wp
->xoff
!= 0 && px
== wp
->xoff
- 1)
152 return (SCREEN_REDRAW_BORDER_LEFT
);
154 return (SCREEN_REDRAW_BORDER_RIGHT
);
158 /* Top/bottom borders. */
159 if (pane_status
== PANE_STATUS_OFF
) {
160 if (screen_redraw_two_panes(wp
->window
, 1) && split
) {
161 if (wp
->yoff
== 0 && py
== wp
->sy
&& px
<= wp
->sx
/ 2)
162 return (SCREEN_REDRAW_BORDER_BOTTOM
);
164 py
== wp
->yoff
- 1 &&
166 return (SCREEN_REDRAW_BORDER_TOP
);
168 if ((wp
->xoff
== 0 || px
>= wp
->xoff
- 1) && px
<= ex
) {
169 if (wp
->yoff
!= 0 && py
== wp
->yoff
- 1)
170 return (SCREEN_REDRAW_BORDER_TOP
);
172 return (SCREEN_REDRAW_BORDER_BOTTOM
);
175 } else if (pane_status
== PANE_STATUS_TOP
) {
176 if ((wp
->xoff
== 0 || px
>= wp
->xoff
- 1) && px
<= ex
) {
177 if (wp
->yoff
!= 0 && py
== wp
->yoff
- 1)
178 return (SCREEN_REDRAW_BORDER_TOP
);
181 if ((wp
->xoff
== 0 || px
>= wp
->xoff
- 1) && px
<= ex
) {
183 return (SCREEN_REDRAW_BORDER_BOTTOM
);
188 return (SCREEN_REDRAW_OUTSIDE
);
191 /* Check if a cell is on a border. */
193 screen_redraw_cell_border(struct screen_redraw_ctx
*ctx
, u_int px
, u_int py
)
195 struct client
*c
= ctx
->c
;
196 struct window
*w
= c
->session
->curw
->window
;
197 struct window_pane
*wp
;
199 /* Outside the window? */
200 if (px
> w
->sx
|| py
> w
->sy
)
203 /* On the window border? */
204 if (px
== w
->sx
|| py
== w
->sy
)
207 /* Check all the panes. */
208 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
209 if (!window_pane_visible(wp
))
211 switch (screen_redraw_pane_border(ctx
, wp
, px
, py
)) {
212 case SCREEN_REDRAW_INSIDE
:
214 case SCREEN_REDRAW_OUTSIDE
:
224 /* Work out type of border cell from surrounding cells. */
226 screen_redraw_type_of_cell(struct screen_redraw_ctx
*ctx
, u_int px
, u_int py
)
228 struct client
*c
= ctx
->c
;
229 int pane_status
= ctx
->pane_status
;
230 struct window
*w
= c
->session
->curw
->window
;
231 u_int sx
= w
->sx
, sy
= w
->sy
;
234 /* Is this outside the window? */
235 if (px
> sx
|| py
> sy
)
236 return (CELL_OUTSIDE
);
239 * Construct a bitmask of whether the cells to the left (bit 4), right,
240 * top, and bottom (bit 1) of this cell are borders.
242 if (px
== 0 || screen_redraw_cell_border(ctx
, px
- 1, py
))
244 if (px
<= sx
&& screen_redraw_cell_border(ctx
, px
+ 1, py
))
246 if (pane_status
== PANE_STATUS_TOP
) {
248 screen_redraw_cell_border(ctx
, px
, py
- 1))
250 if (screen_redraw_cell_border(ctx
, px
, py
+ 1))
252 } else if (pane_status
== PANE_STATUS_BOTTOM
) {
254 screen_redraw_cell_border(ctx
, px
, py
- 1))
257 screen_redraw_cell_border(ctx
, px
, py
+ 1))
261 screen_redraw_cell_border(ctx
, px
, py
- 1))
263 if (screen_redraw_cell_border(ctx
, px
, py
+ 1))
268 * Figure out what kind of border this cell is. Only one bit set
269 * doesn't make sense (can't have a border cell with no others
273 case 15: /* 1111, left right top bottom */
275 case 14: /* 1110, left right top */
276 return (CELL_BOTTOMJOIN
);
277 case 13: /* 1101, left right bottom */
278 return (CELL_TOPJOIN
);
279 case 12: /* 1100, left right */
280 return (CELL_LEFTRIGHT
);
281 case 11: /* 1011, left top bottom */
282 return (CELL_RIGHTJOIN
);
283 case 10: /* 1010, left top */
284 return (CELL_BOTTOMRIGHT
);
285 case 9: /* 1001, left bottom */
286 return (CELL_TOPRIGHT
);
287 case 7: /* 0111, right top bottom */
288 return (CELL_LEFTJOIN
);
289 case 6: /* 0110, right top */
290 return (CELL_BOTTOMLEFT
);
291 case 5: /* 0101, right bottom */
292 return (CELL_TOPLEFT
);
293 case 3: /* 0011, top bottom */
294 return (CELL_TOPBOTTOM
);
296 return (CELL_OUTSIDE
);
299 /* Check if cell inside a pane. */
301 screen_redraw_check_cell(struct screen_redraw_ctx
*ctx
, u_int px
, u_int py
,
302 struct window_pane
**wpp
)
304 struct client
*c
= ctx
->c
;
305 struct window
*w
= c
->session
->curw
->window
;
306 struct window_pane
*wp
, *active
;
307 int pane_status
= ctx
->pane_status
;
313 if (px
> w
->sx
|| py
> w
->sy
)
314 return (CELL_OUTSIDE
);
315 if (px
== w
->sx
|| py
== w
->sy
) /* window border */
316 return (screen_redraw_type_of_cell(ctx
, px
, py
));
318 if (pane_status
!= PANE_STATUS_OFF
) {
319 active
= wp
= server_client_get_pane(c
);
321 if (!window_pane_visible(wp
))
324 if (pane_status
== PANE_STATUS_TOP
)
327 line
= wp
->yoff
+ wp
->sy
;
328 right
= wp
->xoff
+ 2 + wp
->status_size
- 1;
330 if (py
== line
&& px
>= wp
->xoff
+ 2 && px
<= right
)
331 return (CELL_INSIDE
);
334 wp
= TAILQ_NEXT(wp
, entry
);
336 wp
= TAILQ_FIRST(&w
->panes
);
337 } while (wp
!= active
);
340 active
= wp
= server_client_get_pane(c
);
342 if (!window_pane_visible(wp
))
347 * If definitely inside, return. If not on border, skip.
348 * Otherwise work out the cell.
350 border
= screen_redraw_pane_border(ctx
, wp
, px
, py
);
351 if (border
== SCREEN_REDRAW_INSIDE
)
352 return (CELL_INSIDE
);
353 if (border
== SCREEN_REDRAW_OUTSIDE
)
355 return (screen_redraw_type_of_cell(ctx
, px
, py
));
358 wp
= TAILQ_NEXT(wp
, entry
);
360 wp
= TAILQ_FIRST(&w
->panes
);
361 } while (wp
!= active
);
363 return (CELL_OUTSIDE
);
366 /* Check if the border of a particular pane. */
368 screen_redraw_check_is(struct screen_redraw_ctx
*ctx
, u_int px
, u_int py
,
369 struct window_pane
*wp
)
371 enum screen_redraw_border_type border
;
373 border
= screen_redraw_pane_border(ctx
, wp
, px
, py
);
374 if (border
!= SCREEN_REDRAW_INSIDE
&& border
!= SCREEN_REDRAW_OUTSIDE
)
379 /* Update pane status. */
381 screen_redraw_make_pane_status(struct client
*c
, struct window_pane
*wp
,
382 struct screen_redraw_ctx
*rctx
, enum pane_lines pane_lines
)
384 struct window
*w
= wp
->window
;
387 struct format_tree
*ft
;
389 int pane_status
= rctx
->pane_status
;
390 u_int width
, i
, cell_type
, px
, py
;
391 struct screen_write_ctx ctx
;
394 ft
= format_create(c
, NULL
, FORMAT_PANE
|wp
->id
, FORMAT_STATUS
);
395 format_defaults(ft
, c
, c
->session
, c
->session
->curw
, wp
);
397 if (wp
== server_client_get_pane(c
))
398 style_apply(&gc
, w
->options
, "pane-active-border-style", ft
);
400 style_apply(&gc
, w
->options
, "pane-border-style", ft
);
401 fmt
= options_get_string(wp
->options
, "pane-border-format");
403 expanded
= format_expand_time(ft
, fmt
);
405 wp
->status_size
= width
= 0;
407 wp
->status_size
= width
= wp
->sx
- 4;
409 memcpy(&old
, &wp
->status_screen
, sizeof old
);
410 screen_init(&wp
->status_screen
, width
, 1, 0);
411 wp
->status_screen
.mode
= 0;
413 screen_write_start(&ctx
, &wp
->status_screen
);
415 for (i
= 0; i
< width
; i
++) {
416 px
= wp
->xoff
+ 2 + i
;
417 if (pane_status
== PANE_STATUS_TOP
)
420 py
= wp
->yoff
+ wp
->sy
;
421 cell_type
= screen_redraw_type_of_cell(rctx
, px
, py
);
422 screen_redraw_border_set(w
, wp
, pane_lines
, cell_type
, &gc
);
423 screen_write_cell(&ctx
, &gc
);
425 gc
.attr
&= ~GRID_ATTR_CHARSET
;
427 screen_write_cursormove(&ctx
, 0, 0, 0);
428 format_draw(&ctx
, &gc
, width
, expanded
, NULL
, 0);
429 screen_write_stop(&ctx
);
434 if (grid_compare(wp
->status_screen
.grid
, old
.grid
) == 0) {
442 /* Draw pane status. */
444 screen_redraw_draw_pane_status(struct screen_redraw_ctx
*ctx
)
446 struct client
*c
= ctx
->c
;
447 struct window
*w
= c
->session
->curw
->window
;
448 struct tty
*tty
= &c
->tty
;
449 struct window_pane
*wp
;
451 u_int i
, x
, width
, xoff
, yoff
, size
;
453 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
455 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
456 if (!window_pane_visible(wp
))
458 s
= &wp
->status_screen
;
460 size
= wp
->status_size
;
461 if (ctx
->pane_status
== PANE_STATUS_TOP
)
464 yoff
= wp
->yoff
+ wp
->sy
;
467 if (xoff
+ size
<= ctx
->ox
||
468 xoff
>= ctx
->ox
+ ctx
->sx
||
470 yoff
>= ctx
->oy
+ ctx
->sy
)
473 if (xoff
>= ctx
->ox
&& xoff
+ size
<= ctx
->ox
+ ctx
->sx
) {
478 } else if (xoff
< ctx
->ox
&& xoff
+ size
> ctx
->ox
+ ctx
->sx
) {
479 /* Both left and right not visible. */
483 } else if (xoff
< ctx
->ox
) {
484 /* Left not visible. */
489 /* Right not visible. */
496 yoff
+= ctx
->statuslines
;
497 tty_draw_line(tty
, s
, i
, 0, width
, x
, yoff
- ctx
->oy
,
498 &grid_default_cell
, NULL
);
500 tty_cursor(tty
, 0, 0);
503 /* Update status line and change flags if unchanged. */
505 screen_redraw_update(struct client
*c
, uint64_t flags
)
507 struct window
*w
= c
->session
->curw
->window
;
508 struct window_pane
*wp
;
509 struct options
*wo
= w
->options
;
511 enum pane_lines lines
;
512 struct screen_redraw_ctx ctx
;
514 if (c
->message_string
!= NULL
)
515 redraw
= status_message_redraw(c
);
516 else if (c
->prompt_string
!= NULL
)
517 redraw
= status_prompt_redraw(c
);
519 redraw
= status_redraw(c
);
520 if (!redraw
&& (~flags
& CLIENT_REDRAWSTATUSALWAYS
))
521 flags
&= ~CLIENT_REDRAWSTATUS
;
523 if (c
->overlay_draw
!= NULL
)
524 flags
|= CLIENT_REDRAWOVERLAY
;
526 if (options_get_number(wo
, "pane-border-status") != PANE_STATUS_OFF
) {
527 screen_redraw_set_context(c
, &ctx
);
528 lines
= options_get_number(wo
, "pane-border-lines");
530 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
531 if (screen_redraw_make_pane_status(c
, wp
, &ctx
, lines
))
535 flags
|= CLIENT_REDRAWBORDERS
;
540 /* Set up redraw context. */
542 screen_redraw_set_context(struct client
*c
, struct screen_redraw_ctx
*ctx
)
544 struct session
*s
= c
->session
;
545 struct options
*oo
= s
->options
;
546 struct window
*w
= s
->curw
->window
;
547 struct options
*wo
= w
->options
;
550 memset(ctx
, 0, sizeof *ctx
);
553 lines
= status_line_size(c
);
554 if (c
->message_string
!= NULL
|| c
->prompt_string
!= NULL
)
555 lines
= (lines
== 0) ? 1 : lines
;
556 if (lines
!= 0 && options_get_number(oo
, "status-position") == 0)
558 ctx
->statuslines
= lines
;
560 ctx
->pane_status
= options_get_number(wo
, "pane-border-status");
561 ctx
->pane_lines
= options_get_number(wo
, "pane-border-lines");
563 tty_window_offset(&c
->tty
, &ctx
->ox
, &ctx
->oy
, &ctx
->sx
, &ctx
->sy
);
565 log_debug("%s: %s @%u ox=%u oy=%u sx=%u sy=%u %u/%d", __func__
, c
->name
,
566 w
->id
, ctx
->ox
, ctx
->oy
, ctx
->sx
, ctx
->sy
, ctx
->statuslines
,
570 /* Redraw entire screen. */
572 screen_redraw_screen(struct client
*c
)
574 struct screen_redraw_ctx ctx
;
577 if (c
->flags
& CLIENT_SUSPENDED
)
580 flags
= screen_redraw_update(c
, c
->flags
);
581 if ((flags
& CLIENT_ALLREDRAWFLAGS
) == 0)
584 screen_redraw_set_context(c
, &ctx
);
585 tty_sync_start(&c
->tty
);
586 tty_update_mode(&c
->tty
, c
->tty
.mode
, NULL
);
588 if (flags
& (CLIENT_REDRAWWINDOW
|CLIENT_REDRAWBORDERS
)) {
589 log_debug("%s: redrawing borders", c
->name
);
590 if (ctx
.pane_status
!= PANE_STATUS_OFF
)
591 screen_redraw_draw_pane_status(&ctx
);
592 screen_redraw_draw_borders(&ctx
);
594 if (flags
& CLIENT_REDRAWWINDOW
) {
595 log_debug("%s: redrawing panes", c
->name
);
596 screen_redraw_draw_panes(&ctx
);
598 if (ctx
.statuslines
!= 0 &&
599 (flags
& (CLIENT_REDRAWSTATUS
|CLIENT_REDRAWSTATUSALWAYS
))) {
600 log_debug("%s: redrawing status", c
->name
);
601 screen_redraw_draw_status(&ctx
);
603 if (c
->overlay_draw
!= NULL
&& (flags
& CLIENT_REDRAWOVERLAY
)) {
604 log_debug("%s: redrawing overlay", c
->name
);
605 c
->overlay_draw(c
, c
->overlay_data
, &ctx
);
611 /* Redraw a single pane. */
613 screen_redraw_pane(struct client
*c
, struct window_pane
*wp
)
615 struct screen_redraw_ctx ctx
;
617 if (!window_pane_visible(wp
))
620 screen_redraw_set_context(c
, &ctx
);
621 tty_sync_start(&c
->tty
);
622 tty_update_mode(&c
->tty
, c
->tty
.mode
, NULL
);
624 screen_redraw_draw_pane(&ctx
, wp
);
629 /* Get border cell style. */
630 static const struct grid_cell
*
631 screen_redraw_draw_borders_style(struct screen_redraw_ctx
*ctx
, u_int x
,
632 u_int y
, struct window_pane
*wp
)
634 struct client
*c
= ctx
->c
;
635 struct session
*s
= c
->session
;
636 struct window
*w
= s
->curw
->window
;
637 struct window_pane
*active
= server_client_get_pane(c
);
638 struct options
*oo
= w
->options
;
639 struct format_tree
*ft
;
641 if (wp
->border_gc_set
)
642 return (&wp
->border_gc
);
643 wp
->border_gc_set
= 1;
645 ft
= format_create_defaults(NULL
, c
, s
, s
->curw
, wp
);
646 if (screen_redraw_check_is(ctx
, x
, y
, active
))
647 style_apply(&wp
->border_gc
, oo
, "pane-active-border-style", ft
);
649 style_apply(&wp
->border_gc
, oo
, "pane-border-style", ft
);
652 return (&wp
->border_gc
);
655 /* Draw a border cell. */
657 screen_redraw_draw_borders_cell(struct screen_redraw_ctx
*ctx
, u_int i
, u_int j
)
659 struct client
*c
= ctx
->c
;
660 struct session
*s
= c
->session
;
661 struct window
*w
= s
->curw
->window
;
662 struct options
*oo
= w
->options
;
663 struct tty
*tty
= &c
->tty
;
664 struct format_tree
*ft
;
665 struct window_pane
*wp
, *active
= server_client_get_pane(c
);
667 const struct grid_cell
*tmp
;
668 struct overlay_ranges r
;
669 u_int cell_type
, x
= ctx
->ox
+ i
, y
= ctx
->oy
+ j
;
670 int arrows
= 0, border
;
673 if (c
->overlay_check
!= NULL
) {
674 c
->overlay_check(c
, c
->overlay_data
, x
, y
, 1, &r
);
675 if (r
.nx
[0] + r
.nx
[1] == 0)
679 cell_type
= screen_redraw_check_cell(ctx
, x
, y
, &wp
);
680 if (cell_type
== CELL_INSIDE
)
684 if (!ctx
->no_pane_gc_set
) {
685 ft
= format_create_defaults(NULL
, c
, s
, s
->curw
, NULL
);
686 memcpy(&ctx
->no_pane_gc
, &grid_default_cell
, sizeof gc
);
687 style_add(&ctx
->no_pane_gc
, oo
, "pane-border-style",
690 ctx
->no_pane_gc_set
= 1;
692 memcpy(&gc
, &ctx
->no_pane_gc
, sizeof gc
);
694 tmp
= screen_redraw_draw_borders_style(ctx
, x
, y
, wp
);
697 memcpy(&gc
, tmp
, sizeof gc
);
699 if (server_is_marked(s
, s
->curw
, marked_pane
.wp
) &&
700 screen_redraw_check_is(ctx
, x
, y
, marked_pane
.wp
))
701 gc
.attr
^= GRID_ATTR_REVERSE
;
703 screen_redraw_border_set(w
, wp
, ctx
->pane_lines
, cell_type
, &gc
);
705 if (cell_type
== CELL_TOPBOTTOM
&&
706 (c
->flags
& CLIENT_UTF8
) &&
707 tty_term_has(tty
->term
, TTYC_BIDI
))
713 tty_cursor(tty
, i
, ctx
->statuslines
+ j
);
715 tty_cursor(tty
, i
, j
);
717 tty_puts(tty
, END_ISOLATE
);
719 switch (options_get_number(oo
, "pane-border-indicators")) {
720 case PANE_BORDER_ARROWS
:
721 case PANE_BORDER_BOTH
:
726 if (wp
!= NULL
&& arrows
) {
727 border
= screen_redraw_pane_border(ctx
, active
, x
, y
);
728 if (((i
== wp
->xoff
+ 1 &&
729 (cell_type
== CELL_LEFTRIGHT
||
730 (cell_type
== CELL_TOPJOIN
&&
731 border
== SCREEN_REDRAW_BORDER_BOTTOM
) ||
732 (cell_type
== CELL_BOTTOMJOIN
&&
733 border
== SCREEN_REDRAW_BORDER_TOP
))) ||
734 (j
== wp
->yoff
+ 1 &&
735 (cell_type
== CELL_TOPBOTTOM
||
736 (cell_type
== CELL_LEFTJOIN
&&
737 border
== SCREEN_REDRAW_BORDER_RIGHT
) ||
738 (cell_type
== CELL_RIGHTJOIN
&&
739 border
== SCREEN_REDRAW_BORDER_LEFT
)))) &&
740 screen_redraw_check_is(ctx
, x
, y
, active
)) {
741 gc
.attr
|= GRID_ATTR_CHARSET
;
742 utf8_set(&gc
.data
, BORDER_MARKERS
[border
]);
746 tty_cell(tty
, &gc
, &grid_default_cell
, NULL
, NULL
);
748 tty_puts(tty
, START_ISOLATE
);
751 /* Draw the borders. */
753 screen_redraw_draw_borders(struct screen_redraw_ctx
*ctx
)
755 struct client
*c
= ctx
->c
;
756 struct session
*s
= c
->session
;
757 struct window
*w
= s
->curw
->window
;
758 struct window_pane
*wp
;
761 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
763 TAILQ_FOREACH(wp
, &w
->panes
, entry
)
764 wp
->border_gc_set
= 0;
766 for (j
= 0; j
< c
->tty
.sy
- ctx
->statuslines
; j
++) {
767 for (i
= 0; i
< c
->tty
.sx
; i
++)
768 screen_redraw_draw_borders_cell(ctx
, i
, j
);
772 /* Draw the panes. */
774 screen_redraw_draw_panes(struct screen_redraw_ctx
*ctx
)
776 struct client
*c
= ctx
->c
;
777 struct window
*w
= c
->session
->curw
->window
;
778 struct window_pane
*wp
;
780 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
782 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
783 if (window_pane_visible(wp
))
784 screen_redraw_draw_pane(ctx
, wp
);
788 /* Draw the status line. */
790 screen_redraw_draw_status(struct screen_redraw_ctx
*ctx
)
792 struct client
*c
= ctx
->c
;
793 struct window
*w
= c
->session
->curw
->window
;
794 struct tty
*tty
= &c
->tty
;
795 struct screen
*s
= c
->status
.active
;
798 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
803 y
= c
->tty
.sy
- ctx
->statuslines
;
804 for (i
= 0; i
< ctx
->statuslines
; i
++) {
805 tty_draw_line(tty
, s
, 0, i
, UINT_MAX
, 0, y
+ i
,
806 &grid_default_cell
, NULL
);
812 screen_redraw_draw_pane(struct screen_redraw_ctx
*ctx
, struct window_pane
*wp
)
814 struct client
*c
= ctx
->c
;
815 struct window
*w
= c
->session
->curw
->window
;
816 struct tty
*tty
= &c
->tty
;
817 struct screen
*s
= wp
->screen
;
818 struct colour_palette
*palette
= &wp
->palette
;
819 struct grid_cell defaults
;
820 u_int i
, j
, top
, x
, y
, width
;
822 log_debug("%s: %s @%u %%%u", __func__
, c
->name
, w
->id
, wp
->id
);
824 if (wp
->xoff
+ wp
->sx
<= ctx
->ox
|| wp
->xoff
>= ctx
->ox
+ ctx
->sx
)
827 top
= ctx
->statuslines
;
830 for (j
= 0; j
< wp
->sy
; j
++) {
831 if (wp
->yoff
+ j
< ctx
->oy
|| wp
->yoff
+ j
>= ctx
->oy
+ ctx
->sy
)
833 y
= top
+ wp
->yoff
+ j
- ctx
->oy
;
835 if (wp
->xoff
>= ctx
->ox
&&
836 wp
->xoff
+ wp
->sx
<= ctx
->ox
+ ctx
->sx
) {
839 x
= wp
->xoff
- ctx
->ox
;
841 } else if (wp
->xoff
< ctx
->ox
&&
842 wp
->xoff
+ wp
->sx
> ctx
->ox
+ ctx
->sx
) {
843 /* Both left and right not visible. */
847 } else if (wp
->xoff
< ctx
->ox
) {
848 /* Left not visible. */
849 i
= ctx
->ox
- wp
->xoff
;
853 /* Right not visible. */
855 x
= wp
->xoff
- ctx
->ox
;
858 log_debug("%s: %s %%%u line %u,%u at %u,%u, width %u",
859 __func__
, c
->name
, wp
->id
, i
, j
, x
, y
, width
);
861 tty_default_colours(&defaults
, wp
);
862 tty_draw_line(tty
, s
, i
, j
, width
, x
, y
, &defaults
, palette
);
866 tty_draw_images(c
, wp
, s
);