mirror of
				https://github.com/tmux/tmux.git
				synced 2025-11-04 01:34:18 +00:00 
			
		
		
		
	Check for required term capabilities on start.
This commit is contained in:
		
							
								
								
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								CHANGES
									
									
									
									
									
								
							@@ -1,3 +1,7 @@
 | 
				
			|||||||
 | 
					08 November 2007
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					* (nicm) Check for required terminal capabilities on start.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
31 October 2007
 | 
					31 October 2007
 | 
				
			||||||
 | 
					
 | 
				
			||||||
* (nicm) Linux port.
 | 
					* (nicm) Linux port.
 | 
				
			||||||
@@ -186,4 +190,4 @@
 | 
				
			|||||||
  (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.58 2007-11-07 19:41:17 nicm Exp $
 | 
					$Id: CHANGES,v 1.59 2007-11-08 10:39:52 nicm Exp $
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										1
									
								
								TODO
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								TODO
									
									
									
									
									
								
							@@ -56,7 +56,6 @@
 | 
				
			|||||||
	kill session (not bound by default)
 | 
						kill session (not bound by default)
 | 
				
			||||||
- fix most(1) problems after scrolling
 | 
					- fix most(1) problems after scrolling
 | 
				
			||||||
- fix mutt problems with redraw (mutt's) status line when reading mail
 | 
					- fix mutt problems with redraw (mutt's) status line when reading mail
 | 
				
			||||||
- check for some reqd terminfo caps on startup
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
-- For 0.2 --------------------------------------------------------------------
 | 
					-- For 0.2 --------------------------------------------------------------------
 | 
				
			||||||
- copy and paste
 | 
					- copy and paste
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										10
									
								
								client.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								client.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: client.c,v 1.19 2007-10-31 14:26:26 nicm Exp $ */
 | 
					/* $Id: client.c,v 1.20 2007-11-08 10:39:52 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -136,15 +136,15 @@ client_main(struct client_ctx *cctx)
 | 
				
			|||||||
	char		*error;
 | 
						char		*error;
 | 
				
			||||||
	int		 timeout;
 | 
						int		 timeout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						siginit();
 | 
				
			||||||
 | 
						if ((cctx->loc_fd = local_init(&cctx->loc_in, &cctx->loc_out)) == -1)
 | 
				
			||||||
 | 
							return (1);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	logfile("client");
 | 
						logfile("client");
 | 
				
			||||||
#ifndef NO_SETPROCTITLE
 | 
					#ifndef NO_SETPROCTITLE
 | 
				
			||||||
	setproctitle("client");
 | 
						setproctitle("client");
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	siginit();
 | 
					 | 
				
			||||||
	if ((cctx->loc_fd = local_init(&cctx->loc_in, &cctx->loc_out)) == -1)
 | 
					 | 
				
			||||||
		return (1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	error = NULL;
 | 
						error = NULL;
 | 
				
			||||||
	timeout = INFTIM;
 | 
						timeout = INFTIM;
 | 
				
			||||||
	while (!sigterm) {
 | 
						while (!sigterm) {
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										82
									
								
								local.c
									
									
									
									
									
								
							
							
						
						
									
										82
									
								
								local.c
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
/* $Id: local.c,v 1.17 2007-10-31 14:26:26 nicm Exp $ */
 | 
					/* $Id: local.c,v 1.18 2007-11-08 10:39:52 nicm Exp $ */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/*
 | 
					/*
 | 
				
			||||||
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
					 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 | 
				
			||||||
@@ -213,10 +213,32 @@ u_char		 local_colr;
 | 
				
			|||||||
int
 | 
					int
 | 
				
			||||||
local_init(struct buffer **in, struct buffer **out)
 | 
					local_init(struct buffer **in, struct buffer **out)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	char		 *tty;
 | 
						char		       *tty;
 | 
				
			||||||
	int		  mode;
 | 
						int		  	mode, error;
 | 
				
			||||||
	struct termios	  tio;
 | 
						struct termios	  	tio;
 | 
				
			||||||
	struct local_key *lk;
 | 
						struct local_key       *lk;
 | 
				
			||||||
 | 
						u_int			i, j;
 | 
				
			||||||
 | 
						static const char *const reqd[] = {
 | 
				
			||||||
 | 
							"carriage_return",
 | 
				
			||||||
 | 
							"change_scroll_region",
 | 
				
			||||||
 | 
							"clear_screen",
 | 
				
			||||||
 | 
							"clr_bol",
 | 
				
			||||||
 | 
							"clr_eol",
 | 
				
			||||||
 | 
							"cursor_address",
 | 
				
			||||||
 | 
							"cursor_down",
 | 
				
			||||||
 | 
							"enter_ca_mode",
 | 
				
			||||||
 | 
							"exit_ca_mode",
 | 
				
			||||||
 | 
							"parm_dch",
 | 
				
			||||||
 | 
							"parm_delete_line",
 | 
				
			||||||
 | 
							"parm_down_cursor",
 | 
				
			||||||
 | 
							"parm_ich",
 | 
				
			||||||
 | 
							"parm_insert_line",
 | 
				
			||||||
 | 
							"parm_left_cursor",
 | 
				
			||||||
 | 
							"parm_right_cursor",
 | 
				
			||||||
 | 
							"parm_up_cursor",
 | 
				
			||||||
 | 
							"scroll_reverse",
 | 
				
			||||||
 | 
							NULL
 | 
				
			||||||
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ((tty = ttyname(STDOUT_FILENO)) == NULL)
 | 
						if ((tty = ttyname(STDOUT_FILENO)) == NULL)
 | 
				
			||||||
		fatal("ttyname failed");
 | 
							fatal("ttyname failed");
 | 
				
			||||||
@@ -227,11 +249,57 @@ local_init(struct buffer **in, struct buffer **out)
 | 
				
			|||||||
	if (fcntl(local_fd, F_SETFL, mode|O_NONBLOCK) == -1)
 | 
						if (fcntl(local_fd, F_SETFL, mode|O_NONBLOCK) == -1)
 | 
				
			||||||
		fatal("fcntl failed");
 | 
							fatal("fcntl failed");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (setupterm(NULL, STDOUT_FILENO, &error) != OK) {
 | 
				
			||||||
 | 
							switch (error) {
 | 
				
			||||||
 | 
							case 1:
 | 
				
			||||||
 | 
								log_warnx("hardcopy terminal cannot be used");
 | 
				
			||||||
 | 
								return (-1);
 | 
				
			||||||
 | 
							case 0:
 | 
				
			||||||
 | 
								log_warnx("terminal type not found or unsuitable");
 | 
				
			||||||
 | 
								return (-1);
 | 
				
			||||||
 | 
							case -1:
 | 
				
			||||||
 | 
								log_warnx("couldn't find terminfo database");
 | 
				
			||||||
 | 
								return (-1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						for (i = 0; reqd[i] != NULL; i++) {
 | 
				
			||||||
 | 
							error = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							for (j = 0; strfnames[j] != NULL; j++) {
 | 
				
			||||||
 | 
								if (strcmp(strfnames[j], reqd[i]) == 0) {
 | 
				
			||||||
 | 
									if (strcodes[j] == NULL)
 | 
				
			||||||
 | 
										error = -1;
 | 
				
			||||||
 | 
									break;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (error != -1) {
 | 
				
			||||||
 | 
								for (j = 0; numfnames[j] != NULL; j++) {
 | 
				
			||||||
 | 
									if (strcmp(numfnames[j], reqd[i]) == 0) {
 | 
				
			||||||
 | 
										if (numcodes[j] == NULL)
 | 
				
			||||||
 | 
											error = -1;
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							if (error != -1) {
 | 
				
			||||||
 | 
								for (j = 0; boolfnames[j] != NULL; j++) {
 | 
				
			||||||
 | 
									if (strcmp(boolfnames[j], reqd[i]) == 0) {
 | 
				
			||||||
 | 
										if (boolcodes[j] == NULL)
 | 
				
			||||||
 | 
											error = -1;
 | 
				
			||||||
 | 
										break;
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							if (error == -1) {
 | 
				
			||||||
 | 
								log_warnx("required capability missing: %s", reqd[i]);
 | 
				
			||||||
 | 
								return (-1);
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						
 | 
				
			||||||
	*in = local_in = buffer_create(BUFSIZ);
 | 
						*in = local_in = buffer_create(BUFSIZ);
 | 
				
			||||||
	*out = local_out = buffer_create(BUFSIZ);
 | 
						*out = local_out = buffer_create(BUFSIZ);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	setupterm(NULL, STDOUT_FILENO, NULL);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	if (tcgetattr(local_fd, &local_tio) != 0)
 | 
						if (tcgetattr(local_fd, &local_tio) != 0)
 | 
				
			||||||
		fatal("tcgetattr failed");
 | 
							fatal("tcgetattr failed");
 | 
				
			||||||
	memset(&tio, 0, sizeof tio);
 | 
						memset(&tio, 0, sizeof tio);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user