4 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
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>
20 #include <sys/ioctl.h>
38 * Each window is attached to a number of panes, each of which is a pty. This
39 * file contains code to handle them.
41 * A pane has two buffers attached, these are filled and emptied by the main
42 * server poll loop. Output data is received from pty's in screen format,
43 * translated and returned as a series of escape sequences and strings via
44 * input_parse (in input.c). Input data is received as key codes and written
45 * directly via input_key.
47 * Each pane also has a "virtual" screen (screen.c) which contains the current
48 * state and is redisplayed when the window is reattached to a client.
50 * Windows are stored directly on a global array and wrapped in any number of
51 * winlink structs to be linked onto local session RB trees. A reference count
52 * is maintained and a window removed from the global list and destroyed when
56 /* Global window list. */
57 struct windows windows
;
59 /* Global panes tree. */
60 struct window_pane_tree all_window_panes
;
61 u_int next_window_pane_id
;
64 void window_pane_read_callback(struct bufferevent
*, void *);
65 void window_pane_error_callback(struct bufferevent
*, short, void *);
67 RB_GENERATE(winlinks
, winlink
, entry
, winlink_cmp
);
70 winlink_cmp(struct winlink
*wl1
, struct winlink
*wl2
)
72 return (wl1
->idx
- wl2
->idx
);
75 RB_GENERATE(window_pane_tree
, window_pane
, tree_entry
, window_pane_cmp
);
78 window_pane_cmp(struct window_pane
*wp1
, struct window_pane
*wp2
)
80 return (wp1
->id
- wp2
->id
);
84 winlink_find_by_window(struct winlinks
*wwl
, struct window
*w
)
88 RB_FOREACH(wl
, winlinks
, wwl
) {
97 winlink_find_by_index(struct winlinks
*wwl
, int idx
)
105 return (RB_FIND(winlinks
, wwl
, &wl
));
109 winlink_find_by_window_id(struct winlinks
*wwl
, u_int id
)
113 RB_FOREACH(wl
, winlinks
, wwl
) {
114 if (wl
->window
->id
== id
)
121 winlink_next_index(struct winlinks
*wwl
, int idx
)
127 if (winlink_find_by_index(wwl
, i
) == NULL
)
138 winlink_count(struct winlinks
*wwl
)
144 RB_FOREACH(wl
, winlinks
, wwl
)
151 winlink_add(struct winlinks
*wwl
, int idx
)
156 if ((idx
= winlink_next_index(wwl
, -idx
- 1)) == -1)
158 } else if (winlink_find_by_index(wwl
, idx
) != NULL
)
161 wl
= xcalloc(1, sizeof *wl
);
163 RB_INSERT(winlinks
, wwl
, wl
);
169 winlink_set_window(struct winlink
*wl
, struct window
*w
)
176 winlink_remove(struct winlinks
*wwl
, struct winlink
*wl
)
178 struct window
*w
= wl
->window
;
180 RB_REMOVE(winlinks
, wwl
, wl
);
181 if (wl
->status_text
!= NULL
)
182 xfree(wl
->status_text
);
186 if (w
->references
== 0)
187 fatal("bad reference count");
189 if (w
->references
== 0)
195 winlink_next(struct winlink
*wl
)
197 return (RB_NEXT(winlinks
, wwl
, wl
));
201 winlink_previous(struct winlink
*wl
)
203 return (RB_PREV(winlinks
, wwl
, wl
));
207 winlink_next_by_number(struct winlink
*wl
, struct session
*s
, int n
)
210 if ((wl
= RB_NEXT(winlinks
, wwl
, wl
)) == NULL
)
211 wl
= RB_MIN(winlinks
, &s
->windows
);
218 winlink_previous_by_number(struct winlink
*wl
, struct session
*s
, int n
)
221 if ((wl
= RB_PREV(winlinks
, wwl
, wl
)) == NULL
)
222 wl
= RB_MAX(winlinks
, &s
->windows
);
229 winlink_stack_push(struct winlink_stack
*stack
, struct winlink
*wl
)
234 winlink_stack_remove(stack
, wl
);
235 TAILQ_INSERT_HEAD(stack
, wl
, sentry
);
239 winlink_stack_remove(struct winlink_stack
*stack
, struct winlink
*wl
)
246 TAILQ_FOREACH(wl2
, stack
, sentry
) {
248 TAILQ_REMOVE(stack
, wl
, sentry
);
255 window_index(struct window
*s
, u_int
*i
)
257 for (*i
= 0; *i
< ARRAY_LENGTH(&windows
); (*i
)++) {
258 if (s
== ARRAY_ITEM(&windows
, *i
))
265 window_find_by_id(u_int id
)
270 for (i
= 0; i
< ARRAY_LENGTH(&windows
); i
++) {
271 w
= ARRAY_ITEM(&windows
, i
);
279 window_create1(u_int sx
, u_int sy
)
284 w
= xcalloc(1, sizeof *w
);
285 w
->id
= next_window_id
++;
289 TAILQ_INIT(&w
->panes
);
293 w
->layout_root
= NULL
;
298 queue_window_name(w
);
300 options_init(&w
->options
, &global_w_options
);
302 for (i
= 0; i
< ARRAY_LENGTH(&windows
); i
++) {
303 if (ARRAY_ITEM(&windows
, i
) == NULL
) {
304 ARRAY_SET(&windows
, i
, w
);
308 if (i
== ARRAY_LENGTH(&windows
))
309 ARRAY_ADD(&windows
, w
);
316 window_create(const char *name
, const char *cmd
, const char *shell
,
317 const char *cwd
, struct environ
*env
, struct termios
*tio
,
318 u_int sx
, u_int sy
, u_int hlimit
,char **cause
)
321 struct window_pane
*wp
;
323 w
= window_create1(sx
, sy
);
324 wp
= window_add_pane(w
, hlimit
);
326 if (window_pane_spawn(wp
, cmd
, shell
, cwd
, env
, tio
, cause
) != 0) {
330 w
->active
= TAILQ_FIRST(&w
->panes
);
332 w
->name
= xstrdup(name
);
333 options_set_number(&w
->options
, "automatic-rename", 0);
335 w
->name
= default_window_name(w
);
340 window_destroy(struct window
*w
)
344 if (window_index(w
, &i
) != 0)
345 fatalx("index not found");
346 ARRAY_SET(&windows
, i
, NULL
);
347 while (!ARRAY_EMPTY(&windows
) && ARRAY_LAST(&windows
) == NULL
)
348 ARRAY_TRUNC(&windows
, 1);
350 if (w
->layout_root
!= NULL
)
353 evtimer_del(&w
->name_timer
);
355 options_free(&w
->options
);
357 window_destroy_panes(w
);
365 window_set_name(struct window
*w
, const char *new_name
)
369 w
->name
= xstrdup(new_name
);
373 window_resize(struct window
*w
, u_int sx
, u_int sy
)
380 window_set_active_pane(struct window
*w
, struct window_pane
*wp
)
386 while (!window_pane_visible(w
->active
)) {
387 w
->active
= TAILQ_PREV(w
->active
, window_panes
, entry
);
388 if (w
->active
== NULL
)
389 w
->active
= TAILQ_LAST(&w
->panes
, window_panes
);
396 window_get_active_at(struct window
*w
, u_int x
, u_int y
)
398 struct window_pane
*wp
;
400 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
401 if (!window_pane_visible(wp
))
403 if (x
< wp
->xoff
|| x
> wp
->xoff
+ wp
->sx
)
405 if (y
< wp
->yoff
|| y
> wp
->yoff
+ wp
->sy
)
413 window_set_active_at(struct window
*w
, u_int x
, u_int y
)
415 struct window_pane
*wp
;
417 wp
= window_get_active_at(w
, x
, y
);
418 if (wp
!= NULL
&& wp
!= w
->active
)
419 window_set_active_pane(w
, wp
);
423 window_find_string(struct window
*w
, const char *s
)
430 if (strcasecmp(s
, "top") == 0)
432 else if (strcasecmp(s
, "bottom") == 0)
434 else if (strcasecmp(s
, "left") == 0)
436 else if (strcasecmp(s
, "right") == 0)
438 else if (strcasecmp(s
, "top-left") == 0) {
441 } else if (strcasecmp(s
, "top-right") == 0) {
444 } else if (strcasecmp(s
, "bottom-left") == 0) {
447 } else if (strcasecmp(s
, "bottom-right") == 0) {
453 return (window_get_active_at(w
, x
, y
));
457 window_add_pane(struct window
*w
, u_int hlimit
)
459 struct window_pane
*wp
;
461 wp
= window_pane_create(w
, w
->sx
, w
->sy
, hlimit
);
462 if (TAILQ_EMPTY(&w
->panes
))
463 TAILQ_INSERT_HEAD(&w
->panes
, wp
, entry
);
465 TAILQ_INSERT_AFTER(&w
->panes
, w
->active
, wp
, entry
);
470 window_remove_pane(struct window
*w
, struct window_pane
*wp
)
472 if (wp
== w
->active
) {
475 if (w
->active
== NULL
) {
476 w
->active
= TAILQ_PREV(wp
, window_panes
, entry
);
477 if (w
->active
== NULL
)
478 w
->active
= TAILQ_NEXT(wp
, entry
);
480 } else if (wp
== w
->last
)
483 TAILQ_REMOVE(&w
->panes
, wp
, entry
);
484 window_pane_destroy(wp
);
488 window_pane_at_index(struct window
*w
, u_int idx
)
490 struct window_pane
*wp
;
493 n
= options_get_number(&w
->options
, "pane-base-index");
494 TAILQ_FOREACH(wp
, &w
->panes
, entry
) {
503 window_pane_next_by_number(struct window
*w
, struct window_pane
*wp
, u_int n
)
506 if ((wp
= TAILQ_NEXT(wp
, entry
)) == NULL
)
507 wp
= TAILQ_FIRST(&w
->panes
);
514 window_pane_previous_by_number(struct window
*w
, struct window_pane
*wp
,
518 if ((wp
= TAILQ_PREV(wp
, window_panes
, entry
)) == NULL
)
519 wp
= TAILQ_LAST(&w
->panes
, window_panes
);
526 window_pane_index(struct window_pane
*wp
, u_int
*i
)
528 struct window_pane
*wq
;
529 struct window
*w
= wp
->window
;
531 *i
= options_get_number(&w
->options
, "pane-base-index");
532 TAILQ_FOREACH(wq
, &w
->panes
, entry
) {
543 window_count_panes(struct window
*w
)
545 struct window_pane
*wp
;
549 TAILQ_FOREACH(wp
, &w
->panes
, entry
)
555 window_destroy_panes(struct window
*w
)
557 struct window_pane
*wp
;
559 while (!TAILQ_EMPTY(&w
->panes
)) {
560 wp
= TAILQ_FIRST(&w
->panes
);
561 TAILQ_REMOVE(&w
->panes
, wp
, entry
);
562 window_pane_destroy(wp
);
566 /* Return list of printable window flag symbols. No flags is just a space. */
568 window_printable_flags(struct session
*s
, struct winlink
*wl
)
574 if (wl
->flags
& WINLINK_ACTIVITY
)
576 if (wl
->flags
& WINLINK_BELL
)
578 if (wl
->flags
& WINLINK_CONTENT
)
580 if (wl
->flags
& WINLINK_SILENCE
)
584 if (wl
== TAILQ_FIRST(&s
->lastw
))
589 return (xstrdup(flags
));
592 /* Find pane in global tree by id. */
594 window_pane_find_by_id(u_int id
)
596 struct window_pane wp
;
599 return (RB_FIND(window_pane_tree
, &all_window_panes
, &wp
));
603 window_pane_create(struct window
*w
, u_int sx
, u_int sy
, u_int hlimit
)
605 struct window_pane
*wp
;
607 wp
= xcalloc(1, sizeof *wp
);
610 wp
->id
= next_window_pane_id
++;
611 RB_INSERT(window_pane_tree
, &all_window_panes
, wp
);
622 wp
->layout_cell
= NULL
;
632 wp
->pipe_event
= NULL
;
634 wp
->saved_grid
= NULL
;
636 screen_init(&wp
->base
, sx
, sy
, hlimit
);
637 wp
->screen
= &wp
->base
;
645 window_pane_destroy(struct window_pane
*wp
)
647 window_pane_reset_mode(wp
);
650 bufferevent_free(wp
->event
);
656 screen_free(&wp
->base
);
657 if (wp
->saved_grid
!= NULL
)
658 grid_destroy(wp
->saved_grid
);
660 if (wp
->pipe_fd
!= -1) {
661 bufferevent_free(wp
->pipe_event
);
665 RB_REMOVE(window_pane_tree
, &all_window_panes
, wp
);
669 if (wp
->shell
!= NULL
)
677 window_pane_spawn(struct window_pane
*wp
, const char *cmd
, const char *shell
,
678 const char *cwd
, struct environ
*env
, struct termios
*tio
, char **cause
)
681 char *argv0
, paneid
[16];
686 bufferevent_free(wp
->event
);
692 wp
->cmd
= xstrdup(cmd
);
695 if (wp
->shell
!= NULL
)
697 wp
->shell
= xstrdup(shell
);
702 wp
->cwd
= xstrdup(cwd
);
705 memset(&ws
, 0, sizeof ws
);
706 ws
.ws_col
= screen_size_x(&wp
->base
);
707 ws
.ws_row
= screen_size_y(&wp
->base
);
709 switch (wp
->pid
= forkpty(&wp
->fd
, wp
->tty
, NULL
, &ws
)) {
712 xasprintf(cause
, "%s: %s", cmd
, strerror(errno
));
715 if (chdir(wp
->cwd
) != 0)
718 if (tcgetattr(STDIN_FILENO
, &tio2
) != 0)
719 fatal("tcgetattr failed");
721 memcpy(tio2
.c_cc
, tio
->c_cc
, sizeof tio2
.c_cc
);
722 tio2
.c_cc
[VERASE
] = '\177';
723 if (tcsetattr(STDIN_FILENO
, TCSANOW
, &tio2
) != 0)
724 fatal("tcgetattr failed");
726 closefrom(STDERR_FILENO
+ 1);
728 xsnprintf(paneid
, sizeof paneid
, "%%%u", wp
->id
);
729 environ_set(env
, "TMUX_PANE", paneid
);
735 if (*wp
->cmd
!= '\0') {
736 /* Set SHELL but only if it is currently not useful. */
737 shell
= getenv("SHELL");
738 if (checkshell(shell
))
739 setenv("SHELL", wp
->shell
, 1);
741 execl(_PATH_BSHELL
, "sh", "-c", wp
->cmd
, (char *) NULL
);
742 fatal("execl failed");
745 /* No command; fork a login shell. */
746 ptr
= strrchr(wp
->shell
, '/');
747 if (ptr
!= NULL
&& *(ptr
+ 1) != '\0')
748 xasprintf(&argv0
, "-%s", ptr
+ 1);
750 xasprintf(&argv0
, "-%s", wp
->shell
);
751 setenv("SHELL", wp
->shell
, 1);
752 execl(wp
->shell
, argv0
, (char *) NULL
);
753 fatal("execl failed");
756 setblocking(wp
->fd
, 0);
758 wp
->event
= bufferevent_new(wp
->fd
,
759 window_pane_read_callback
, NULL
, window_pane_error_callback
, wp
);
760 bufferevent_enable(wp
->event
, EV_READ
|EV_WRITE
);
767 window_pane_read_callback(unused
struct bufferevent
*bufev
, void *data
)
769 struct window_pane
*wp
= data
;
773 new_size
= EVBUFFER_LENGTH(wp
->event
->input
) - wp
->pipe_off
;
774 if (wp
->pipe_fd
!= -1 && new_size
> 0) {
775 new_data
= EVBUFFER_DATA(wp
->event
->input
);
776 bufferevent_write(wp
->pipe_event
, new_data
, new_size
);
781 wp
->pipe_off
= EVBUFFER_LENGTH(wp
->event
->input
);
784 * If we get here, we're not outputting anymore, so set the silence
785 * flag on the window.
787 wp
->window
->flags
|= WINDOW_SILENCE
;
788 if (gettimeofday(&wp
->window
->silence_timer
, NULL
) != 0)
789 fatal("gettimeofday failed.");
794 window_pane_error_callback(
795 unused
struct bufferevent
*bufev
, unused
short what
, void *data
)
797 struct window_pane
*wp
= data
;
799 server_destroy_pane(wp
);
803 window_pane_resize(struct window_pane
*wp
, u_int sx
, u_int sy
)
807 if (sx
== wp
->sx
&& sy
== wp
->sy
)
812 memset(&ws
, 0, sizeof ws
);
816 screen_resize(&wp
->base
, sx
, sy
);
817 if (wp
->mode
!= NULL
)
818 wp
->mode
->resize(wp
, sx
, sy
);
820 if (wp
->fd
!= -1 && ioctl(wp
->fd
, TIOCSWINSZ
, &ws
) == -1)
821 fatal("ioctl failed");
825 * Enter alternative screen mode. A copy of the visible screen is saved and the
826 * history is not updated
829 window_pane_alternate_on(struct window_pane
*wp
, struct grid_cell
*gc
)
831 struct screen
*s
= &wp
->base
;
834 if (wp
->saved_grid
!= NULL
)
836 if (!options_get_number(&wp
->window
->options
, "alternate-screen"))
838 sx
= screen_size_x(s
);
839 sy
= screen_size_y(s
);
841 wp
->saved_grid
= grid_create(sx
, sy
, 0);
842 grid_duplicate_lines(wp
->saved_grid
, 0, s
->grid
, screen_hsize(s
), sy
);
843 wp
->saved_cx
= s
->cx
;
844 wp
->saved_cy
= s
->cy
;
845 memcpy(&wp
->saved_cell
, gc
, sizeof wp
->saved_cell
);
847 grid_view_clear(s
->grid
, 0, 0, sx
, sy
);
849 wp
->base
.grid
->flags
&= ~GRID_HISTORY
;
851 wp
->flags
|= PANE_REDRAW
;
854 /* Exit alternate screen mode and restore the copied grid. */
856 window_pane_alternate_off(struct window_pane
*wp
, struct grid_cell
*gc
)
858 struct screen
*s
= &wp
->base
;
861 if (wp
->saved_grid
== NULL
)
863 if (!options_get_number(&wp
->window
->options
, "alternate-screen"))
865 sx
= screen_size_x(s
);
866 sy
= screen_size_y(s
);
869 * If the current size is bigger, temporarily resize to the old size
870 * before copying back.
872 if (sy
> wp
->saved_grid
->sy
)
873 screen_resize(s
, sx
, wp
->saved_grid
->sy
);
875 /* Restore the grid, cursor position and cell. */
876 grid_duplicate_lines(s
->grid
, screen_hsize(s
), wp
->saved_grid
, 0, sy
);
877 s
->cx
= wp
->saved_cx
;
878 if (s
->cx
> screen_size_x(s
) - 1)
879 s
->cx
= screen_size_x(s
) - 1;
880 s
->cy
= wp
->saved_cy
;
881 if (s
->cy
> screen_size_y(s
) - 1)
882 s
->cy
= screen_size_y(s
) - 1;
883 memcpy(gc
, &wp
->saved_cell
, sizeof *gc
);
886 * Turn history back on (so resize can use it) and then resize back to
889 wp
->base
.grid
->flags
|= GRID_HISTORY
;
890 if (sy
> wp
->saved_grid
->sy
)
891 screen_resize(s
, sx
, sy
);
893 grid_destroy(wp
->saved_grid
);
894 wp
->saved_grid
= NULL
;
896 wp
->flags
|= PANE_REDRAW
;
900 window_pane_set_mode(struct window_pane
*wp
, const struct window_mode
*mode
)
904 if (wp
->mode
!= NULL
)
908 if ((s
= wp
->mode
->init(wp
)) != NULL
)
910 wp
->flags
|= PANE_REDRAW
;
915 window_pane_reset_mode(struct window_pane
*wp
)
917 if (wp
->mode
== NULL
)
923 wp
->screen
= &wp
->base
;
924 wp
->flags
|= PANE_REDRAW
;
928 window_pane_key(struct window_pane
*wp
, struct session
*sess
, int key
)
930 struct window_pane
*wp2
;
932 if (!window_pane_visible(wp
))
935 if (wp
->mode
!= NULL
) {
936 if (wp
->mode
->key
!= NULL
)
937 wp
->mode
->key(wp
, sess
, key
);
944 if (options_get_number(&wp
->window
->options
, "synchronize-panes")) {
945 TAILQ_FOREACH(wp2
, &wp
->window
->panes
, entry
) {
946 if (wp2
== wp
|| wp2
->mode
!= NULL
)
948 if (wp2
->fd
!= -1 && window_pane_visible(wp2
))
956 struct window_pane
*wp
, struct session
*sess
, struct mouse_event
*m
)
958 if (!window_pane_visible(wp
))
961 if (m
->x
< wp
->xoff
|| m
->x
>= wp
->xoff
+ wp
->sx
)
963 if (m
->y
< wp
->yoff
|| m
->y
>= wp
->yoff
+ wp
->sy
)
968 if (wp
->mode
!= NULL
) {
969 if (wp
->mode
->mouse
!= NULL
&&
970 options_get_number(&wp
->window
->options
, "mode-mouse"))
971 wp
->mode
->mouse(wp
, sess
, m
);
972 } else if (wp
->fd
!= -1)
977 window_pane_visible(struct window_pane
*wp
)
979 struct window
*w
= wp
->window
;
981 if (wp
->xoff
>= w
->sx
|| wp
->yoff
>= w
->sy
)
983 if (wp
->xoff
+ wp
->sx
> w
->sx
|| wp
->yoff
+ wp
->sy
> w
->sy
)
989 window_pane_search(struct window_pane
*wp
, const char *searchstr
, u_int
*lineno
)
991 struct screen
*s
= &wp
->base
;
992 char *newsearchstr
, *line
, *msg
;
996 xasprintf(&newsearchstr
, "*%s*", searchstr
);
998 for (i
= 0; i
< screen_size_y(s
); i
++) {
999 line
= grid_view_string_cells(s
->grid
, 0, i
, screen_size_x(s
));
1000 if (fnmatch(newsearchstr
, line
, 0) == 0) {
1009 xfree(newsearchstr
);
1013 /* Find the pane directly above another. */
1014 struct window_pane
*
1015 window_pane_find_up(struct window_pane
*wp
)
1017 struct window_pane
*wp2
;
1020 if (wp
== NULL
|| !window_pane_visible(wp
))
1025 top
= wp
->window
->sy
+ 1;
1028 TAILQ_FOREACH(wp2
, &wp
->window
->panes
, entry
) {
1029 if (!window_pane_visible(wp2
))
1031 if (wp2
->yoff
+ wp2
->sy
+ 1 != top
)
1033 if (left
>= wp2
->xoff
&& left
<= wp2
->xoff
+ wp2
->sx
)
1039 /* Find the pane directly below another. */
1040 struct window_pane
*
1041 window_pane_find_down(struct window_pane
*wp
)
1043 struct window_pane
*wp2
;
1046 if (wp
== NULL
|| !window_pane_visible(wp
))
1049 bottom
= wp
->yoff
+ wp
->sy
+ 1;
1050 if (bottom
>= wp
->window
->sy
)
1054 TAILQ_FOREACH(wp2
, &wp
->window
->panes
, entry
) {
1055 if (!window_pane_visible(wp2
))
1057 if (wp2
->yoff
!= bottom
)
1059 if (left
>= wp2
->xoff
&& left
<= wp2
->xoff
+ wp2
->sx
)
1066 * Find the pane directly to the left of another, adjacent to the left side and
1067 * containing the top edge.
1069 struct window_pane
*
1070 window_pane_find_left(struct window_pane
*wp
)
1072 struct window_pane
*wp2
;
1075 if (wp
== NULL
|| !window_pane_visible(wp
))
1080 left
= wp
->window
->sx
+ 1;
1083 TAILQ_FOREACH(wp2
, &wp
->window
->panes
, entry
) {
1084 if (!window_pane_visible(wp2
))
1086 if (wp2
->xoff
+ wp2
->sx
+ 1 != left
)
1088 if (top
>= wp2
->yoff
&& top
<= wp2
->yoff
+ wp2
->sy
)
1095 * Find the pane directly to the right of another, that is adjacent to the
1096 * right edge and including the top edge.
1098 struct window_pane
*
1099 window_pane_find_right(struct window_pane
*wp
)
1101 struct window_pane
*wp2
;
1104 if (wp
== NULL
|| !window_pane_visible(wp
))
1107 right
= wp
->xoff
+ wp
->sx
+ 1;
1108 if (right
>= wp
->window
->sx
)
1112 TAILQ_FOREACH(wp2
, &wp
->window
->panes
, entry
) {
1113 if (!window_pane_visible(wp2
))
1115 if (wp2
->xoff
!= right
)
1117 if (top
>= wp2
->yoff
&& top
<= wp2
->yoff
+ wp2
->sy
)