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 window_pane
*wp
, u_int px
, u_int py
,
115 struct options
*oo
= wp
->window
->options
;
117 u_int ex
= wp
->xoff
+ wp
->sx
, ey
= wp
->yoff
+ wp
->sy
;
120 if (px
>= wp
->xoff
&& px
< ex
&& py
>= wp
->yoff
&& py
< ey
)
121 return (SCREEN_REDRAW_INSIDE
);
123 /* Get pane indicator. */
124 switch (options_get_number(oo
, "pane-border-indicators")) {
125 case PANE_BORDER_COLOUR
:
126 case PANE_BORDER_BOTH
:
131 /* Left/right borders. */
132 if (pane_status
== PANE_STATUS_OFF
) {
133 if (screen_redraw_two_panes(wp
->window
, 0) && split
) {
134 if (wp
->xoff
== 0 && px
== wp
->sx
&& py
<= wp
->sy
/ 2)
135 return (SCREEN_REDRAW_BORDER_RIGHT
);
137 px
== wp
->xoff
- 1 &&
139 return (SCREEN_REDRAW_BORDER_LEFT
);
141 if ((wp
->yoff
== 0 || py
>= wp
->yoff
- 1) && py
<= ey
) {
142 if (wp
->xoff
!= 0 && px
== wp
->xoff
- 1)
143 return (SCREEN_REDRAW_BORDER_LEFT
);
145 return (SCREEN_REDRAW_BORDER_RIGHT
);
149 if ((wp
->yoff
== 0 || py
>= wp
->yoff
- 1) && py
<= ey
) {
150 if (wp
->xoff
!= 0 && px
== wp
->xoff
- 1)
151 return (SCREEN_REDRAW_BORDER_LEFT
);
153 return (SCREEN_REDRAW_BORDER_RIGHT
);
157 /* Top/bottom borders. */
158 if (pane_status
== PANE_STATUS_OFF
) {
159 if (screen_redraw_two_panes(wp
->window
, 1) && split
) {
160 if (wp
->yoff
== 0 && py
== wp
->sy
&& px
<= wp
->sx
/ 2)
161 return (SCREEN_REDRAW_BORDER_BOTTOM
);
163 py
== wp
->yoff
- 1 &&
165 return (SCREEN_REDRAW_BORDER_TOP
);
167 if ((wp
->xoff
== 0 || px
>= wp
->xoff
- 1) && px
<= ex
) {
168 if (wp
->yoff
!= 0 && py
== wp
->yoff
- 1)
169 return (SCREEN_REDRAW_BORDER_TOP
);
171 return (SCREEN_REDRAW_BORDER_BOTTOM
);
174 } else if (pane_status
== PANE_STATUS_TOP
) {
175 if ((wp
->xoff
== 0 || px
>= wp
->xoff
- 1) && px
<= ex
) {
176 if (wp
->yoff
!= 0 && py
== wp
->yoff
- 1)
177 return (SCREEN_REDRAW_BORDER_TOP
);
180 if ((wp
->xoff
== 0 || px
>= wp
->xoff
- 1) && px
<= ex
) {
182 return (SCREEN_REDRAW_BORDER_BOTTOM
);
187 return (SCREEN_REDRAW_OUTSIDE
);
190 /* Check if a cell is on a border. */
192 screen_redraw_cell_border(struct client
*c
, u_int px
, u_int py
, int pane_status
)
194 struct window
*w
= c
->session
->curw
->window
;
195 struct window_pane
*wp
;
197 /* Outside the window? */
198 if (px
> w
->sx
|| py
> w
->sy
)
201 /* On the window border? */
202 if (px
== w
->sx
|| py
== w
->sy
)
205 /* Check all the panes. */
206 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
207 if (!window_pane_visible(wp
))
209 switch (screen_redraw_pane_border(wp
, px
, py
, pane_status
)) {
210 case SCREEN_REDRAW_INSIDE
:
212 case SCREEN_REDRAW_OUTSIDE
:
222 /* Work out type of border cell from surrounding cells. */
224 screen_redraw_type_of_cell(struct client
*c
, u_int px
, u_int py
,
227 struct window
*w
= c
->session
->curw
->window
;
228 u_int sx
= w
->sx
, sy
= w
->sy
;
231 /* Is this outside the window? */
232 if (px
> sx
|| py
> sy
)
233 return (CELL_OUTSIDE
);
236 * Construct a bitmask of whether the cells to the left (bit 4), right,
237 * top, and bottom (bit 1) of this cell are borders.
239 if (px
== 0 || screen_redraw_cell_border(c
, px
- 1, py
, pane_status
))
241 if (px
<= sx
&& screen_redraw_cell_border(c
, px
+ 1, py
, pane_status
))
243 if (pane_status
== PANE_STATUS_TOP
) {
245 screen_redraw_cell_border(c
, px
, py
- 1, pane_status
))
247 if (screen_redraw_cell_border(c
, px
, py
+ 1, pane_status
))
249 } else if (pane_status
== PANE_STATUS_BOTTOM
) {
251 screen_redraw_cell_border(c
, px
, py
- 1, pane_status
))
254 screen_redraw_cell_border(c
, px
, py
+ 1, pane_status
))
258 screen_redraw_cell_border(c
, px
, py
- 1, pane_status
))
260 if (screen_redraw_cell_border(c
, px
, py
+ 1, pane_status
))
265 * Figure out what kind of border this cell is. Only one bit set
266 * doesn't make sense (can't have a border cell with no others
270 case 15: /* 1111, left right top bottom */
272 case 14: /* 1110, left right top */
273 return (CELL_BOTTOMJOIN
);
274 case 13: /* 1101, left right bottom */
275 return (CELL_TOPJOIN
);
276 case 12: /* 1100, left right */
277 return (CELL_LEFTRIGHT
);
278 case 11: /* 1011, left top bottom */
279 return (CELL_RIGHTJOIN
);
280 case 10: /* 1010, left top */
281 return (CELL_BOTTOMRIGHT
);
282 case 9: /* 1001, left bottom */
283 return (CELL_TOPRIGHT
);
284 case 7: /* 0111, right top bottom */
285 return (CELL_LEFTJOIN
);
286 case 6: /* 0110, right top */
287 return (CELL_BOTTOMLEFT
);
288 case 5: /* 0101, right bottom */
289 return (CELL_TOPLEFT
);
290 case 3: /* 0011, top bottom */
291 return (CELL_TOPBOTTOM
);
293 return (CELL_OUTSIDE
);
296 /* Check if cell inside a pane. */
298 screen_redraw_check_cell(struct client
*c
, u_int px
, u_int py
, int pane_status
,
299 struct window_pane
**wpp
)
301 struct window
*w
= c
->session
->curw
->window
;
302 struct window_pane
*wp
, *active
;
308 if (px
> w
->sx
|| py
> w
->sy
)
309 return (CELL_OUTSIDE
);
310 if (px
== w
->sx
|| py
== w
->sy
) /* window border */
311 return (screen_redraw_type_of_cell(c
, px
, py
, pane_status
));
313 if (pane_status
!= PANE_STATUS_OFF
) {
314 active
= wp
= server_client_get_pane(c
);
316 if (!window_pane_visible(wp
))
319 if (pane_status
== PANE_STATUS_TOP
)
322 line
= wp
->yoff
+ wp
->sy
;
323 right
= wp
->xoff
+ 2 + wp
->status_size
- 1;
325 if (py
== line
&& px
>= wp
->xoff
+ 2 && px
<= right
)
326 return (CELL_INSIDE
);
329 wp
= TAILQ_NEXT(wp
, entry
);
331 wp
= TAILQ_FIRST(&w
->panes
);
332 } while (wp
!= active
);
335 active
= wp
= server_client_get_pane(c
);
337 if (!window_pane_visible(wp
))
342 * If definitely inside, return. If not on border, skip.
343 * Otherwise work out the cell.
345 border
= screen_redraw_pane_border(wp
, px
, py
, pane_status
);
346 if (border
== SCREEN_REDRAW_INSIDE
)
347 return (CELL_INSIDE
);
348 if (border
== SCREEN_REDRAW_OUTSIDE
)
350 return (screen_redraw_type_of_cell(c
, px
, py
, pane_status
));
353 wp
= TAILQ_NEXT(wp
, entry
);
355 wp
= TAILQ_FIRST(&w
->panes
);
356 } while (wp
!= active
);
358 return (CELL_OUTSIDE
);
361 /* Check if the border of a particular pane. */
363 screen_redraw_check_is(u_int px
, u_int py
, int pane_status
,
364 struct window_pane
*wp
)
366 enum screen_redraw_border_type border
;
368 border
= screen_redraw_pane_border(wp
, px
, py
, pane_status
);
369 if (border
!= SCREEN_REDRAW_INSIDE
&& border
!= SCREEN_REDRAW_OUTSIDE
)
374 /* Update pane status. */
376 screen_redraw_make_pane_status(struct client
*c
, struct window_pane
*wp
,
377 struct screen_redraw_ctx
*rctx
, enum pane_lines pane_lines
)
379 struct window
*w
= wp
->window
;
382 struct format_tree
*ft
;
384 int pane_status
= rctx
->pane_status
;
385 u_int width
, i
, cell_type
, px
, py
;
386 struct screen_write_ctx ctx
;
389 ft
= format_create(c
, NULL
, FORMAT_PANE
|wp
->id
, FORMAT_STATUS
);
390 format_defaults(ft
, c
, c
->session
, c
->session
->curw
, wp
);
392 if (wp
== server_client_get_pane(c
))
393 style_apply(&gc
, w
->options
, "pane-active-border-style", ft
);
395 style_apply(&gc
, w
->options
, "pane-border-style", ft
);
396 fmt
= options_get_string(wp
->options
, "pane-border-format");
398 expanded
= format_expand_time(ft
, fmt
);
400 wp
->status_size
= width
= 0;
402 wp
->status_size
= width
= wp
->sx
- 4;
404 memcpy(&old
, &wp
->status_screen
, sizeof old
);
405 screen_init(&wp
->status_screen
, width
, 1, 0);
406 wp
->status_screen
.mode
= 0;
408 screen_write_start(&ctx
, &wp
->status_screen
);
410 for (i
= 0; i
< width
; i
++) {
411 px
= wp
->xoff
+ 2 + i
;
412 if (rctx
->pane_status
== PANE_STATUS_TOP
)
415 py
= wp
->yoff
+ wp
->sy
;
416 cell_type
= screen_redraw_type_of_cell(c
, px
, py
, pane_status
);
417 screen_redraw_border_set(w
, wp
, pane_lines
, cell_type
, &gc
);
418 screen_write_cell(&ctx
, &gc
);
420 gc
.attr
&= ~GRID_ATTR_CHARSET
;
422 screen_write_cursormove(&ctx
, 0, 0, 0);
423 format_draw(&ctx
, &gc
, width
, expanded
, NULL
, 0);
424 screen_write_stop(&ctx
);
429 if (grid_compare(wp
->status_screen
.grid
, old
.grid
) == 0) {
437 /* Draw pane status. */
439 screen_redraw_draw_pane_status(struct screen_redraw_ctx
*ctx
)
441 struct client
*c
= ctx
->c
;
442 struct window
*w
= c
->session
->curw
->window
;
443 struct tty
*tty
= &c
->tty
;
444 struct window_pane
*wp
;
446 u_int i
, x
, width
, xoff
, yoff
, size
;
448 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
450 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
451 if (!window_pane_visible(wp
))
453 s
= &wp
->status_screen
;
455 size
= wp
->status_size
;
456 if (ctx
->pane_status
== PANE_STATUS_TOP
)
459 yoff
= wp
->yoff
+ wp
->sy
;
462 if (xoff
+ size
<= ctx
->ox
||
463 xoff
>= ctx
->ox
+ ctx
->sx
||
465 yoff
>= ctx
->oy
+ ctx
->sy
)
468 if (xoff
>= ctx
->ox
&& xoff
+ size
<= ctx
->ox
+ ctx
->sx
) {
473 } else if (xoff
< ctx
->ox
&& xoff
+ size
> ctx
->ox
+ ctx
->sx
) {
474 /* Both left and right not visible. */
478 } else if (xoff
< ctx
->ox
) {
479 /* Left not visible. */
484 /* Right not visible. */
491 yoff
+= ctx
->statuslines
;
492 tty_draw_line(tty
, s
, i
, 0, width
, x
, yoff
- ctx
->oy
,
493 &grid_default_cell
, NULL
);
495 tty_cursor(tty
, 0, 0);
498 /* Update status line and change flags if unchanged. */
500 screen_redraw_update(struct client
*c
, int flags
)
502 struct window
*w
= c
->session
->curw
->window
;
503 struct window_pane
*wp
;
504 struct options
*wo
= w
->options
;
506 enum pane_lines lines
;
507 struct screen_redraw_ctx ctx
;
509 if (c
->message_string
!= NULL
)
510 redraw
= status_message_redraw(c
);
511 else if (c
->prompt_string
!= NULL
)
512 redraw
= status_prompt_redraw(c
);
514 redraw
= status_redraw(c
);
515 if (!redraw
&& (~flags
& CLIENT_REDRAWSTATUSALWAYS
))
516 flags
&= ~CLIENT_REDRAWSTATUS
;
518 if (c
->overlay_draw
!= NULL
)
519 flags
|= CLIENT_REDRAWOVERLAY
;
521 if (options_get_number(wo
, "pane-border-status") != PANE_STATUS_OFF
) {
522 screen_redraw_set_context(c
, &ctx
);
523 lines
= options_get_number(wo
, "pane-border-lines");
525 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
526 if (screen_redraw_make_pane_status(c
, wp
, &ctx
, lines
))
530 flags
|= CLIENT_REDRAWBORDERS
;
535 /* Set up redraw context. */
537 screen_redraw_set_context(struct client
*c
, struct screen_redraw_ctx
*ctx
)
539 struct session
*s
= c
->session
;
540 struct options
*oo
= s
->options
;
541 struct window
*w
= s
->curw
->window
;
542 struct options
*wo
= w
->options
;
545 memset(ctx
, 0, sizeof *ctx
);
548 lines
= status_line_size(c
);
549 if (c
->message_string
!= NULL
|| c
->prompt_string
!= NULL
)
550 lines
= (lines
== 0) ? 1 : lines
;
551 if (lines
!= 0 && options_get_number(oo
, "status-position") == 0)
553 ctx
->statuslines
= lines
;
555 ctx
->pane_status
= options_get_number(wo
, "pane-border-status");
556 ctx
->pane_lines
= options_get_number(wo
, "pane-border-lines");
558 tty_window_offset(&c
->tty
, &ctx
->ox
, &ctx
->oy
, &ctx
->sx
, &ctx
->sy
);
560 log_debug("%s: %s @%u ox=%u oy=%u sx=%u sy=%u %u/%d", __func__
, c
->name
,
561 w
->id
, ctx
->ox
, ctx
->oy
, ctx
->sx
, ctx
->sy
, ctx
->statuslines
,
565 /* Redraw entire screen. */
567 screen_redraw_screen(struct client
*c
)
569 struct screen_redraw_ctx ctx
;
572 if (c
->flags
& CLIENT_SUSPENDED
)
575 flags
= screen_redraw_update(c
, c
->flags
);
576 if ((flags
& CLIENT_ALLREDRAWFLAGS
) == 0)
579 screen_redraw_set_context(c
, &ctx
);
580 tty_sync_start(&c
->tty
);
581 tty_update_mode(&c
->tty
, c
->tty
.mode
, NULL
);
583 if (flags
& (CLIENT_REDRAWWINDOW
|CLIENT_REDRAWBORDERS
)) {
584 log_debug("%s: redrawing borders", c
->name
);
585 if (ctx
.pane_status
!= PANE_STATUS_OFF
)
586 screen_redraw_draw_pane_status(&ctx
);
587 screen_redraw_draw_borders(&ctx
);
589 if (flags
& CLIENT_REDRAWWINDOW
) {
590 log_debug("%s: redrawing panes", c
->name
);
591 screen_redraw_draw_panes(&ctx
);
593 if (ctx
.statuslines
!= 0 &&
594 (flags
& (CLIENT_REDRAWSTATUS
|CLIENT_REDRAWSTATUSALWAYS
))) {
595 log_debug("%s: redrawing status", c
->name
);
596 screen_redraw_draw_status(&ctx
);
598 if (c
->overlay_draw
!= NULL
&& (flags
& CLIENT_REDRAWOVERLAY
)) {
599 log_debug("%s: redrawing overlay", c
->name
);
600 c
->overlay_draw(c
, c
->overlay_data
, &ctx
);
606 /* Redraw a single pane. */
608 screen_redraw_pane(struct client
*c
, struct window_pane
*wp
)
610 struct screen_redraw_ctx ctx
;
612 if (!window_pane_visible(wp
))
615 screen_redraw_set_context(c
, &ctx
);
616 tty_sync_start(&c
->tty
);
617 tty_update_mode(&c
->tty
, c
->tty
.mode
, NULL
);
619 screen_redraw_draw_pane(&ctx
, wp
);
624 /* Get border cell style. */
625 static const struct grid_cell
*
626 screen_redraw_draw_borders_style(struct screen_redraw_ctx
*ctx
, u_int x
,
627 u_int y
, struct window_pane
*wp
)
629 struct client
*c
= ctx
->c
;
630 struct session
*s
= c
->session
;
631 struct window
*w
= s
->curw
->window
;
632 struct window_pane
*active
= server_client_get_pane(c
);
633 struct options
*oo
= w
->options
;
634 struct format_tree
*ft
;
636 if (wp
->border_gc_set
)
637 return (&wp
->border_gc
);
638 wp
->border_gc_set
= 1;
640 ft
= format_create_defaults(NULL
, c
, s
, s
->curw
, wp
);
641 if (screen_redraw_check_is(x
, y
, ctx
->pane_status
, active
))
642 style_apply(&wp
->border_gc
, oo
, "pane-active-border-style", ft
);
644 style_apply(&wp
->border_gc
, oo
, "pane-border-style", ft
);
647 return (&wp
->border_gc
);
650 /* Draw a border cell. */
652 screen_redraw_draw_borders_cell(struct screen_redraw_ctx
*ctx
, u_int i
, u_int j
)
654 struct client
*c
= ctx
->c
;
655 struct session
*s
= c
->session
;
656 struct window
*w
= s
->curw
->window
;
657 struct options
*oo
= w
->options
;
658 struct tty
*tty
= &c
->tty
;
659 struct format_tree
*ft
;
660 struct window_pane
*wp
, *active
= server_client_get_pane(c
);
662 const struct grid_cell
*tmp
;
663 struct overlay_ranges r
;
664 u_int cell_type
, x
= ctx
->ox
+ i
, y
= ctx
->oy
+ j
;
665 int arrows
= 0, border
;
666 int pane_status
= ctx
->pane_status
, isolates
;
668 if (c
->overlay_check
!= NULL
) {
669 c
->overlay_check(c
, c
->overlay_data
, x
, y
, 1, &r
);
670 if (r
.nx
[0] + r
.nx
[1] == 0)
674 cell_type
= screen_redraw_check_cell(c
, x
, y
, pane_status
, &wp
);
675 if (cell_type
== CELL_INSIDE
)
679 if (!ctx
->no_pane_gc_set
) {
680 ft
= format_create_defaults(NULL
, c
, s
, s
->curw
, NULL
);
681 memcpy(&ctx
->no_pane_gc
, &grid_default_cell
, sizeof gc
);
682 style_add(&ctx
->no_pane_gc
, oo
, "pane-border-style",
685 ctx
->no_pane_gc_set
= 1;
687 memcpy(&gc
, &ctx
->no_pane_gc
, sizeof gc
);
689 tmp
= screen_redraw_draw_borders_style(ctx
, x
, y
, wp
);
692 memcpy(&gc
, tmp
, sizeof gc
);
694 if (server_is_marked(s
, s
->curw
, marked_pane
.wp
) &&
695 screen_redraw_check_is(x
, y
, pane_status
, marked_pane
.wp
))
696 gc
.attr
^= GRID_ATTR_REVERSE
;
698 screen_redraw_border_set(w
, wp
, ctx
->pane_lines
, cell_type
, &gc
);
700 if (cell_type
== CELL_TOPBOTTOM
&&
701 (c
->flags
& CLIENT_UTF8
) &&
702 tty_term_has(tty
->term
, TTYC_BIDI
))
708 tty_cursor(tty
, i
, ctx
->statuslines
+ j
);
710 tty_cursor(tty
, i
, j
);
712 tty_puts(tty
, END_ISOLATE
);
714 switch (options_get_number(oo
, "pane-border-indicators")) {
715 case PANE_BORDER_ARROWS
:
716 case PANE_BORDER_BOTH
:
721 if (wp
!= NULL
&& arrows
) {
722 border
= screen_redraw_pane_border(active
, x
, y
, pane_status
);
723 if (((i
== wp
->xoff
+ 1 &&
724 (cell_type
== CELL_LEFTRIGHT
||
725 (cell_type
== CELL_TOPJOIN
&&
726 border
== SCREEN_REDRAW_BORDER_BOTTOM
) ||
727 (cell_type
== CELL_BOTTOMJOIN
&&
728 border
== SCREEN_REDRAW_BORDER_TOP
))) ||
729 (j
== wp
->yoff
+ 1 &&
730 (cell_type
== CELL_TOPBOTTOM
||
731 (cell_type
== CELL_LEFTJOIN
&&
732 border
== SCREEN_REDRAW_BORDER_RIGHT
) ||
733 (cell_type
== CELL_RIGHTJOIN
&&
734 border
== SCREEN_REDRAW_BORDER_LEFT
)))) &&
735 screen_redraw_check_is(x
, y
, pane_status
, active
)) {
736 gc
.attr
|= GRID_ATTR_CHARSET
;
737 utf8_set(&gc
.data
, BORDER_MARKERS
[border
]);
741 tty_cell(tty
, &gc
, &grid_default_cell
, NULL
);
743 tty_puts(tty
, START_ISOLATE
);
746 /* Draw the borders. */
748 screen_redraw_draw_borders(struct screen_redraw_ctx
*ctx
)
750 struct client
*c
= ctx
->c
;
751 struct session
*s
= c
->session
;
752 struct window
*w
= s
->curw
->window
;
753 struct window_pane
*wp
;
756 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
758 TAILQ_FOREACH(wp
, &w
->panes
, entry
)
759 wp
->border_gc_set
= 0;
761 for (j
= 0; j
< c
->tty
.sy
- ctx
->statuslines
; j
++) {
762 for (i
= 0; i
< c
->tty
.sx
; i
++)
763 screen_redraw_draw_borders_cell(ctx
, i
, j
);
767 /* Draw the panes. */
769 screen_redraw_draw_panes(struct screen_redraw_ctx
*ctx
)
771 struct client
*c
= ctx
->c
;
772 struct window
*w
= c
->session
->curw
->window
;
773 struct window_pane
*wp
;
775 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
777 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
778 if (window_pane_visible(wp
))
779 screen_redraw_draw_pane(ctx
, wp
);
783 /* Draw the status line. */
785 screen_redraw_draw_status(struct screen_redraw_ctx
*ctx
)
787 struct client
*c
= ctx
->c
;
788 struct window
*w
= c
->session
->curw
->window
;
789 struct tty
*tty
= &c
->tty
;
790 struct screen
*s
= c
->status
.active
;
793 log_debug("%s: %s @%u", __func__
, c
->name
, w
->id
);
798 y
= c
->tty
.sy
- ctx
->statuslines
;
799 for (i
= 0; i
< ctx
->statuslines
; i
++) {
800 tty_draw_line(tty
, s
, 0, i
, UINT_MAX
, 0, y
+ i
,
801 &grid_default_cell
, NULL
);
807 screen_redraw_draw_pane(struct screen_redraw_ctx
*ctx
, struct window_pane
*wp
)
809 struct client
*c
= ctx
->c
;
810 struct window
*w
= c
->session
->curw
->window
;
811 struct tty
*tty
= &c
->tty
;
812 struct screen
*s
= wp
->screen
;
813 struct colour_palette
*palette
= &wp
->palette
;
814 struct grid_cell defaults
;
815 u_int i
, j
, top
, x
, y
, width
;
817 log_debug("%s: %s @%u %%%u", __func__
, c
->name
, w
->id
, wp
->id
);
819 if (wp
->xoff
+ wp
->sx
<= ctx
->ox
|| wp
->xoff
>= ctx
->ox
+ ctx
->sx
)
822 top
= ctx
->statuslines
;
825 for (j
= 0; j
< wp
->sy
; j
++) {
826 if (wp
->yoff
+ j
< ctx
->oy
|| wp
->yoff
+ j
>= ctx
->oy
+ ctx
->sy
)
828 y
= top
+ wp
->yoff
+ j
- ctx
->oy
;
830 if (wp
->xoff
>= ctx
->ox
&&
831 wp
->xoff
+ wp
->sx
<= ctx
->ox
+ ctx
->sx
) {
834 x
= wp
->xoff
- ctx
->ox
;
836 } else if (wp
->xoff
< ctx
->ox
&&
837 wp
->xoff
+ wp
->sx
> ctx
->ox
+ ctx
->sx
) {
838 /* Both left and right not visible. */
842 } else if (wp
->xoff
< ctx
->ox
) {
843 /* Left not visible. */
844 i
= ctx
->ox
- wp
->xoff
;
848 /* Right not visible. */
850 x
= wp
->xoff
- ctx
->ox
;
853 log_debug("%s: %s %%%u line %u,%u at %u,%u, width %u",
854 __func__
, c
->name
, wp
->id
, i
, j
, x
, y
, width
);
856 tty_default_colours(&defaults
, wp
);
857 tty_draw_line(tty
, s
, i
, j
, width
, x
, y
, &defaults
, palette
);