mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 00:56:10 +00:00 
			
		
		
		
	Incomplete resize support.
This commit is contained in:
		
							
								
								
									
										10
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								CHANGES
									
									
									
									
									
								
							@@ -1,8 +1,10 @@
 | 
				
			|||||||
04 October 2007
 | 
					04 October 2007
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* (mxey) Added my tmux start script as an example (examples/start-tmux.sh)
 | 
					* (nicm) Partial resizing support. Still buggy. A C-b S and back sometimes fixes
 | 
				
			||||||
* (mxey) New sessions can now be given a command for their first window
 | 
					  it when it goes wonky.
 | 
				
			||||||
* (mxey) Fixed usage statemnt for new-window
 | 
					* (mxey) Added my tmux start script as an example (examples/start-tmux.sh).
 | 
				
			||||||
 | 
					* (mxey) New sessions can now be given a command for their first window.
 | 
				
			||||||
 | 
					* (mxey) Fixed usage statement for new-window.
 | 
				
			||||||
* (nicm) attach-session (can't believe I forgot it until now!) and list-windows
 | 
					* (nicm) attach-session (can't believe I forgot it until now!) and list-windows
 | 
				
			||||||
  commands.
 | 
					  commands.
 | 
				
			||||||
* (nicm) rename-window and select-window commands.
 | 
					* (nicm) rename-window and select-window commands.
 | 
				
			||||||
@@ -115,5 +117,5 @@
 | 
				
			|||||||
  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
					  (including mutt, emacs). No status bar yet and no key remapping or other
 | 
				
			||||||
  customisation.
 | 
					  customisation.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
$Id: CHANGES,v 1.34 2007-10-04 14:14:12 mxey Exp $
 | 
					$Id: CHANGES,v 1.35 2007-10-04 19:03:51 nicm Exp $
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								Makefile
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
# $Id: Makefile,v 1.22 2007-10-04 11:52:02 nicm Exp $
 | 
					# $Id: Makefile,v 1.23 2007-10-04 19:03:51 nicm Exp $
 | 
				
			||||||
 | 
					
 | 
				
			||||||
.SUFFIXES: .c .o .y .h
 | 
					.SUFFIXES: .c .o .y .h
 | 
				
			||||||
.PHONY: clean
 | 
					.PHONY: clean
 | 
				
			||||||
@@ -18,7 +18,7 @@ META?= \002 # C-b
 | 
				
			|||||||
SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
 | 
					SRCS= tmux.c server.c server-msg.c server-fn.c buffer.c buffer-poll.c status.c \
 | 
				
			||||||
      xmalloc.c xmalloc-debug.c input.c input-keys.c screen.c window.c \
 | 
					      xmalloc.c xmalloc-debug.c input.c input-keys.c screen.c window.c \
 | 
				
			||||||
      session.c local.c log.c client.c client-msg.c client-fn.c key-string.c \
 | 
					      session.c local.c log.c client.c client-msg.c client-fn.c key-string.c \
 | 
				
			||||||
      key-bindings.c cmd.c cmd-new-session.c cmd-detach-session.c \
 | 
					      key-bindings.c resize.c cmd.c cmd-new-session.c cmd-detach-session.c \
 | 
				
			||||||
      cmd-list-sessions.c cmd-new-window.c cmd-next-window.c cmd-bind-key.c \
 | 
					      cmd-list-sessions.c cmd-new-window.c cmd-next-window.c cmd-bind-key.c \
 | 
				
			||||||
      cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
 | 
					      cmd-unbind-key.c cmd-previous-window.c cmd-last-window.c cmd-list-keys.c \
 | 
				
			||||||
      cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
 | 
					      cmd-set-option.c cmd-rename-window.c cmd-select-window.c \
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								client.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: client.c,v 1.12 2007-10-04 11:52:02 nicm Exp $ */
 | 
					/* $Id: client.c,v 1.13 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -175,7 +175,7 @@ client_main(struct client_ctx *cctx)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	if (error != NULL) {
 | 
						if (error != NULL) {
 | 
				
			||||||
		if (*error == '\0') {
 | 
							if (*error == '\0') {
 | 
				
			||||||
			printf("[exited]\n", error);
 | 
								printf("[exited]\n");
 | 
				
			||||||
			return (0);
 | 
								return (0);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		printf("[error: %s]\n", error);
 | 
							printf("[error: %s]\n", error);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-attach-session.c,v 1.1 2007-10-04 11:52:03 nicm Exp $ */
 | 
					/* $Id: cmd-attach-session.c,v 1.2 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -55,5 +55,6 @@ cmd_attach_session_exec(unused void *ptr, struct cmd_ctx *ctx)
 | 
				
			|||||||
	c->session = s;
 | 
						c->session = s;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	server_write_client(c, MSG_READY, NULL, 0);
 | 
						server_write_client(c, MSG_READY, NULL, 0);
 | 
				
			||||||
 | 
						recalculate_sizes();
 | 
				
			||||||
	server_redraw_client(c);
 | 
						server_redraw_client(c);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: cmd-new-session.c,v 1.6 2007-10-04 13:43:14 mxey Exp $ */
 | 
					/* $Id: cmd-new-session.c,v 1.7 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -99,7 +99,7 @@ cmd_new_session_usage(void)
 | 
				
			|||||||
void
 | 
					void
 | 
				
			||||||
cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
 | 
					cmd_new_session_exec(void *ptr, struct cmd_ctx *ctx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct cmd_new_session_data	*data = ptr, std = { NULL, 0 };
 | 
						struct cmd_new_session_data	*data = ptr, std = { NULL, NULL, 0 };
 | 
				
			||||||
	struct client			*c = ctx->client;
 | 
						struct client			*c = ctx->client;
 | 
				
			||||||
	char				*cmd;
 | 
						char				*cmd;
 | 
				
			||||||
	u_int				 sy;
 | 
						u_int				 sy;
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								input.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								input.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: input.c,v 1.19 2007-10-03 10:18:32 nicm Exp $ */
 | 
					/* $Id: input.c,v 1.20 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -427,7 +427,9 @@ void
 | 
				
			|||||||
input_handle_character(u_char ch, struct input_ctx *ictx)
 | 
					input_handle_character(u_char ch, struct input_ctx *ictx)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	log_debug2("-- ch %zu: %hhu (%c)", ictx->off, ch, ch);
 | 
						log_debug2("-- ch %zu: %hhu (%c)", ictx->off, ch, ch);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						if (ictx->s->cx > ictx->s->sx - 1 || ictx->s->cy > ictx->s->sy - 1)
 | 
				
			||||||
 | 
							return;
 | 
				
			||||||
	screen_write_character(ictx->s, ch);
 | 
						screen_write_character(ictx->s, ch);
 | 
				
			||||||
	input_store8(ictx->b, ch);
 | 
						input_store8(ictx->b, ch);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										102
									
								
								resize.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										102
									
								
								resize.c
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,102 @@
 | 
				
			|||||||
 | 
					/* $Id: resize.c,v 1.1 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Permission to use, copy, modify, and distribute this software for any
 | 
				
			||||||
 | 
					 * purpose with or without fee is hereby granted, provided that the above
 | 
				
			||||||
 | 
					 * copyright notice and this permission notice appear in all copies.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 | 
				
			||||||
 | 
					 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 | 
				
			||||||
 | 
					 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 | 
				
			||||||
 | 
					 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 | 
				
			||||||
 | 
					 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
 | 
				
			||||||
 | 
					 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 | 
				
			||||||
 | 
					 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <sys/types.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <string.h>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include "tmux.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Recalculate window and session sizes.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * Every session has the size of the smallest client it is attached to and
 | 
				
			||||||
 | 
					 * every window the size of the smallest session it is attached to.
 | 
				
			||||||
 | 
					 *
 | 
				
			||||||
 | 
					 * So, when a client is resized or a session attached to or detached from a
 | 
				
			||||||
 | 
					 * client, the window sizes must be recalculated. For each session, find the
 | 
				
			||||||
 | 
					 * smallest client it is attached to, and resize it to that size. Then for
 | 
				
			||||||
 | 
					 * every window, find the smallest session it is attached to, resize it to that
 | 
				
			||||||
 | 
					 * size and clear and redraw every client with it as the current window.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This is quite inefficient - better/additional data structures are needed
 | 
				
			||||||
 | 
					 * to make it better.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					recalculate_sizes(void)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct session	*s;
 | 
				
			||||||
 | 
						struct client	*c;
 | 
				
			||||||
 | 
						struct window	*w;
 | 
				
			||||||
 | 
						u_int		 i, j, ssx, ssy;
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
 | 
				
			||||||
 | 
							s = ARRAY_ITEM(&sessions, i);
 | 
				
			||||||
 | 
							if (s == NULL)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ssx = ssy = UINT_MAX;
 | 
				
			||||||
 | 
							for (j = 0; j < ARRAY_LENGTH(&clients); j++) {
 | 
				
			||||||
 | 
								c = ARRAY_ITEM(&clients, j);
 | 
				
			||||||
 | 
								if (c == NULL || c->session != s)
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								if (c->sx < ssx)
 | 
				
			||||||
 | 
									ssx = c->sx;
 | 
				
			||||||
 | 
								if (c->sy < ssy)
 | 
				
			||||||
 | 
									ssy = c->sy;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (ssy < status_lines)
 | 
				
			||||||
 | 
								ssy = status_lines + 1;
 | 
				
			||||||
 | 
							ssy -= status_lines;
 | 
				
			||||||
 | 
							if (s->sx == ssx && s->sy == ssy)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							log_debug(
 | 
				
			||||||
 | 
							    "session size %u,%u (was %u,%u)", ssx, ssy, s->sx, s->sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							s->sx = ssx;
 | 
				
			||||||
 | 
							s->sy = ssy;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i = 0; i < ARRAY_LENGTH(&windows); i++) {
 | 
				
			||||||
 | 
							w = ARRAY_ITEM(&windows, i);
 | 
				
			||||||
 | 
							if (w == NULL)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							ssx = ssy = UINT_MAX;
 | 
				
			||||||
 | 
							for (j = 0; j < ARRAY_LENGTH(&sessions); j++) {
 | 
				
			||||||
 | 
								s = ARRAY_ITEM(&sessions, j);
 | 
				
			||||||
 | 
								if (s == NULL || !session_has(s, w))
 | 
				
			||||||
 | 
									continue;
 | 
				
			||||||
 | 
								if (s->sx < ssx)
 | 
				
			||||||
 | 
									ssx = s->sx;
 | 
				
			||||||
 | 
								if (s->sy < ssy)
 | 
				
			||||||
 | 
									ssy = s->sy;
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (w->screen.sx == ssx && w->screen.sy == ssy)
 | 
				
			||||||
 | 
								continue;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							log_debug("window size %u,%u (was %u,%u)", 
 | 
				
			||||||
 | 
							    ssx, ssy, w->screen.sx, w->screen.sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							server_clear_window(w);
 | 
				
			||||||
 | 
							window_resize(w, ssx, ssy);
 | 
				
			||||||
 | 
							server_redraw_window(w);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										5
									
								
								screen.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								screen.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: screen.c,v 1.19 2007-10-01 14:18:42 nicm Exp $ */
 | 
					/* $Id: screen.c,v 1.20 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -87,6 +87,9 @@ screen_resize(struct screen *s, u_int sx, u_int sy)
 | 
				
			|||||||
	s->sx = sx;
 | 
						s->sx = sx;
 | 
				
			||||||
	s->sy = sy;
 | 
						s->sy = sy;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						s->ry_upper = 0;
 | 
				
			||||||
 | 
						s->ry_lower = screen_last_y(s);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log_debug("resizing screen (%u, %u) -> (%u, %u)", ox, oy, sx, sy);
 | 
						log_debug("resizing screen (%u, %u) -> (%u, %u)", ox, oy, sx, sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (sy < oy) {
 | 
						if (sy < oy) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										43
									
								
								server-fn.c
									
									
									
									
									
								
							
							
						
						
									
										43
									
								
								server-fn.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server-fn.c,v 1.17 2007-10-04 10:39:07 nicm Exp $ */
 | 
					/* $Id: server-fn.c,v 1.18 2007-10-04 19:03:51 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -128,7 +128,7 @@ server_redraw_status(struct client *c)
 | 
				
			|||||||
	struct hdr	hdr;
 | 
						struct hdr	hdr;
 | 
				
			||||||
	size_t		size;
 | 
						size_t		size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (status_lines == 0)
 | 
						if (status_lines == 0 || c->sy <= status_lines)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer_ensure(c->out, sizeof hdr);
 | 
						buffer_ensure(c->out, sizeof hdr);
 | 
				
			||||||
@@ -144,11 +144,35 @@ server_redraw_status(struct client *c)
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
server_redraw_client(struct client *c)
 | 
					server_clear_client(struct client *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
						struct screen	*s = &c->session->window->screen;
 | 
				
			||||||
	struct hdr	 hdr;
 | 
						struct hdr	 hdr;
 | 
				
			||||||
	size_t		 size;
 | 
						size_t		 size;
 | 
				
			||||||
 | 
						u_int		 i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						buffer_ensure(c->out, sizeof hdr);
 | 
				
			||||||
 | 
						buffer_add(c->out, sizeof hdr);
 | 
				
			||||||
 | 
						size = BUFFER_USED(c->out);
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						input_store_zero(c->out, CODE_CURSOROFF);
 | 
				
			||||||
 | 
						for (i = 0; i < s->sy; i++) {
 | 
				
			||||||
 | 
							input_store_two(c->out, CODE_CURSORMOVE, i + 1, 1);
 | 
				
			||||||
 | 
							input_store_zero(c->out, CODE_CLEARLINE);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
 | 
						size = BUFFER_USED(c->out) - size;
 | 
				
			||||||
 | 
						hdr.type = MSG_DATA;
 | 
				
			||||||
 | 
						hdr.size = size;
 | 
				
			||||||
 | 
						memcpy(BUFFER_IN(c->out) - size - sizeof hdr,  &hdr, sizeof hdr);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					server_redraw_client(struct client *c)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
	struct screen	*s = &c->session->window->screen;
 | 
						struct screen	*s = &c->session->window->screen;
 | 
				
			||||||
 | 
						struct hdr	 hdr;
 | 
				
			||||||
 | 
						size_t		 size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer_ensure(c->out, sizeof hdr);
 | 
						buffer_ensure(c->out, sizeof hdr);
 | 
				
			||||||
	buffer_add(c->out, sizeof hdr);
 | 
						buffer_add(c->out, sizeof hdr);
 | 
				
			||||||
@@ -181,6 +205,19 @@ server_redraw_session(struct session *s)
 | 
				
			|||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					void
 | 
				
			||||||
 | 
					server_clear_window(struct window *w)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct client	*c;
 | 
				
			||||||
 | 
						u_int		 i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						for (i = 0; i < ARRAY_LENGTH(&clients); i++) {
 | 
				
			||||||
 | 
							c = ARRAY_ITEM(&clients, i);
 | 
				
			||||||
 | 
							if (c != NULL && c->session != NULL && c->session->window == w)
 | 
				
			||||||
 | 
								server_clear_client(c);
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void
 | 
					void
 | 
				
			||||||
server_redraw_window(struct window *w)
 | 
					server_redraw_window(struct window *w)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										29
									
								
								server-msg.c
									
									
									
									
									
								
							
							
						
						
									
										29
									
								
								server-msg.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server-msg.c,v 1.23 2007-10-04 11:52:03 nicm Exp $ */
 | 
					/* $Id: server-msg.c,v 1.24 2007-10-04 19:03:52 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -150,7 +150,7 @@ server_msg_fn_identify(struct hdr *hdr, struct client *c)
 | 
				
			|||||||
		fatalx("bad MSG_IDENTIFY size");
 | 
							fatalx("bad MSG_IDENTIFY size");
 | 
				
			||||||
	buffer_read(c->in, &data, sizeof data);
 | 
						buffer_read(c->in, &data, sizeof data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	log_debug("got identify msg from client: %u,%u", data.sx, data.sy);
 | 
						log_debug("identify msg from client: %u,%u", data.sx, data.sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c->sx = data.sx;
 | 
						c->sx = data.sx;
 | 
				
			||||||
	c->sy = data.sy;
 | 
						c->sy = data.sy;
 | 
				
			||||||
@@ -164,12 +164,13 @@ int
 | 
				
			|||||||
server_msg_fn_resize(struct hdr *hdr, struct client *c)
 | 
					server_msg_fn_resize(struct hdr *hdr, struct client *c)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct msg_resize_data	data;
 | 
						struct msg_resize_data	data;
 | 
				
			||||||
	u_int			sy;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (hdr->size != sizeof data)
 | 
						if (hdr->size != sizeof data)
 | 
				
			||||||
		fatalx("bad MSG_RESIZE size");
 | 
							fatalx("bad MSG_RESIZE size");
 | 
				
			||||||
	buffer_read(c->in, &data, sizeof data);
 | 
						buffer_read(c->in, &data, sizeof data);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						log_debug("resize msg from client: %u,%u", data.sx, data.sy);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	c->sx = data.sx;
 | 
						c->sx = data.sx;
 | 
				
			||||||
	if (c->sx == 0)
 | 
						if (c->sx == 0)
 | 
				
			||||||
		c->sx = 80;
 | 
							c->sx = 80;
 | 
				
			||||||
@@ -177,27 +178,7 @@ server_msg_fn_resize(struct hdr *hdr, struct client *c)
 | 
				
			|||||||
	if (c->sy == 0)
 | 
						if (c->sy == 0)
 | 
				
			||||||
		c->sy = 25;
 | 
							c->sy = 25;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sy = c->sy;
 | 
						recalculate_sizes();
 | 
				
			||||||
	if (sy < status_lines)
 | 
					 | 
				
			||||||
		sy = status_lines + 1;
 | 
					 | 
				
			||||||
	sy -= status_lines;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	/* XXX */
 | 
					 | 
				
			||||||
	/*
 | 
					 | 
				
			||||||
	 * Okay. Need to be able to recalculate sizes:
 | 
					 | 
				
			||||||
	 *	- every session has the size of the smallest client it is 
 | 
					 | 
				
			||||||
	 *	  attached to
 | 
					 | 
				
			||||||
	 *	- every window has the size of the smallest session it is
 | 
					 | 
				
			||||||
	 *	  attached to
 | 
					 | 
				
			||||||
	 *
 | 
					 | 
				
			||||||
	 * So, when a client is resized or a session added to a new client:
 | 
					 | 
				
			||||||
	 *	- find the smallest client it is attached to, and resize to
 | 
					 | 
				
			||||||
	 *	  that size
 | 
					 | 
				
			||||||
	 * And when a session's window changes or a window is added/removed
 | 
					 | 
				
			||||||
	 * from a session:
 | 
					 | 
				
			||||||
	 *	- find the smallest session the window is attached to
 | 
					 | 
				
			||||||
	 *	  and use that
 | 
					 | 
				
			||||||
	 */
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return (0);
 | 
						return (0);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										6
									
								
								server.c
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								server.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: server.c,v 1.23 2007-10-04 11:52:03 nicm Exp $ */
 | 
					/* $Id: server.c,v 1.24 2007-10-04 19:03:52 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -309,6 +309,8 @@ server_lost_client(struct client *c)
 | 
				
			|||||||
	buffer_destroy(c->in);
 | 
						buffer_destroy(c->in);
 | 
				
			||||||
	buffer_destroy(c->out);
 | 
						buffer_destroy(c->out);
 | 
				
			||||||
	xfree(c);
 | 
						xfree(c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						recalculate_sizes();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* Handle window data. */
 | 
					/* Handle window data. */
 | 
				
			||||||
@@ -376,5 +378,7 @@ server_lost_window(struct window *w)
 | 
				
			|||||||
				server_redraw_client(c);
 | 
									server_redraw_client(c);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						recalculate_sizes();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										4
									
								
								status.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								status.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: status.c,v 1.2 2007-10-03 23:32:26 nicm Exp $ */
 | 
					/* $Id: status.c,v 1.3 2007-10-04 19:03:52 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -37,7 +37,7 @@ status_write(struct client *c)
 | 
				
			|||||||
	input_store_two(b, CODE_CURSORMOVE, c->sy - status_lines + 1, 1);
 | 
						input_store_two(b, CODE_CURSORMOVE, c->sy - status_lines + 1, 1);
 | 
				
			||||||
	input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x20);
 | 
						input_store_two(b, CODE_ATTRIBUTES, ATTR_REVERSE, 0x20);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	size = s->sx;
 | 
						size = c->sx;
 | 
				
			||||||
	for (i = 0; i < ARRAY_LENGTH(&c->session->windows); i++) {
 | 
						for (i = 0; i < ARRAY_LENGTH(&c->session->windows); i++) {
 | 
				
			||||||
		w = ARRAY_ITEM(&c->session->windows, i);
 | 
							w = ARRAY_ITEM(&c->session->windows, i);
 | 
				
			||||||
		if (w == NULL)
 | 
							if (w == NULL)
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										7
									
								
								tmux.h
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								tmux.h
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: tmux.h,v 1.47 2007-10-04 11:52:03 nicm Exp $ */
 | 
					/* $Id: tmux.h,v 1.48 2007-10-04 19:03:52 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -593,14 +593,19 @@ void	 server_write_session(
 | 
				
			|||||||
void	 server_write_window(
 | 
					void	 server_write_window(
 | 
				
			||||||
             struct window *, enum hdrtype, const void *, size_t);
 | 
					             struct window *, enum hdrtype, const void *, size_t);
 | 
				
			||||||
void	 server_redraw_status(struct client *);
 | 
					void	 server_redraw_status(struct client *);
 | 
				
			||||||
 | 
					void	 server_clear_client(struct client *);
 | 
				
			||||||
void	 server_redraw_client(struct client *);
 | 
					void	 server_redraw_client(struct client *);
 | 
				
			||||||
void	 server_redraw_session(struct session *);
 | 
					void	 server_redraw_session(struct session *);
 | 
				
			||||||
 | 
					void	 server_clear_window(struct window *);
 | 
				
			||||||
void	 server_redraw_window(struct window *);
 | 
					void	 server_redraw_window(struct window *);
 | 
				
			||||||
void	 server_write_message(struct client *, const char *, ...);
 | 
					void	 server_write_message(struct client *, const char *, ...);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* status.c */
 | 
					/* status.c */
 | 
				
			||||||
void	 status_write(struct client *c);
 | 
					void	 status_write(struct client *c);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* resize.c */
 | 
				
			||||||
 | 
					void	 recalculate_sizes(void);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* input.c */
 | 
					/* input.c */
 | 
				
			||||||
void	 input_init(struct input_ctx *, struct screen *);
 | 
					void	 input_init(struct input_ctx *, struct screen *);
 | 
				
			||||||
void	 input_free(struct input_ctx *);
 | 
					void	 input_free(struct input_ctx *);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user