Some Linux fixes; some code tidying. Don't redraw status bar so often.

This commit is contained in:
Nicholas Marriott 2008-06-06 17:20:30 +00:00
parent ac332b6e79
commit 6a187bb8d3
9 changed files with 52 additions and 25 deletions

View File

@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.16 2008-06-05 21:25:00 nicm Exp $
# $Id: GNUmakefile,v 1.17 2008-06-06 17:20:15 nicm Exp $
.PHONY: clean
@ -63,7 +63,7 @@ SRCS+= compat/strlcpy.c compat/strlcat.c compat/strtonum.c
CFLAGS+= $(shell getconf LFS_CFLAGS) -D_GNU_SOURCE \
-DNO_STRLCPY -DNO_STRLCAT -DNO_STRTONUM -DNO_SETPROCTITLE \
-DNO_QUEUE_H -DNO_TREE_H -DUSE_PTY_H
LDFLAGS+= -lresolv -lutil
LDFLAGS+= -lrt -lutil
# Required for LLONG_MAX and friends
CFLAGS+= -std=c99
endif

View File

@ -1,4 +1,4 @@
/* $Id: cmd-link-window.c,v 1.20 2008-06-05 22:59:38 nicm Exp $ */
/* $Id: cmd-link-window.c,v 1.21 2008-06-06 17:20:15 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -66,6 +66,7 @@ cmd_link_window_exec(struct cmd *self, struct cmd_ctx *ctx)
return;
}
wl_dst = NULL;
if (idx != -1)
wl_dst = winlink_find_by_index(&s->windows, idx);
if (wl_dst != NULL) {

View File

@ -1,4 +1,4 @@
/* $Id: input-keys.c,v 1.6 2008-01-03 21:32:11 nicm Exp $ */
/* $Id: input-keys.c,v 1.7 2008-06-06 17:20:29 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -28,6 +28,8 @@ struct {
int key;
const char *data;
} input_keys[] = {
/* { KEYC_BACKSPACE, "\010" }, */
{ KEYC_DC, "\e[3~" },
{ KEYC_F1, "\eOP" },
{ KEYC_F10, "\e[21~" },
@ -108,12 +110,14 @@ input_key(struct window *w, int key)
#endif
for (i = 0; i < NINPUTKEYS; i++) {
if (input_keys[i].key == key) {
log_debug2(
"found key %d: \"%s\"", key, input_keys[i].data);
buffer_write(w->out,
input_keys[i].data, strlen(input_keys[i].data));
return;
}
if (input_keys[i].key == key)
break;
}
if (i == NINPUTKEYS) {
log_debug2("key %d missing", key);
return;
}
log_debug2("found key %d: \"%s\"", key, input_keys[i].data);
buffer_write(w->out, input_keys[i].data, strlen(input_keys[i].data));
}

View File

@ -1,4 +1,4 @@
/* $Id: server.c,v 1.53 2008-06-04 17:54:26 nicm Exp $ */
/* $Id: server.c,v 1.54 2008-06-06 17:20:29 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -32,6 +32,7 @@
#include <string.h>
#include <syslog.h>
#include <termios.h>
#include <time.h>
#include <unistd.h>
#include "tmux.h"
@ -415,19 +416,21 @@ server_handle_window(struct window *w)
{
struct session *s;
u_int i;
int action;
int action, update;
window_parse(w);
if (!(w->flags & WINDOW_BELL) && !(w->flags & WINDOW_ACTIVITY))
return;
update = 0;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
if (s == NULL || !session_has(s, w))
continue;
if (w->flags & WINDOW_BELL) {
if (w->flags & WINDOW_BELL &&
!session_alert_has(s, w, WINDOW_BELL)) {
session_alert_add(s, w, WINDOW_BELL);
action = options_get_number(&s->options, "bell-action");
@ -441,12 +444,18 @@ server_handle_window(struct window *w)
tty_write_session(s, TTY_CHARACTER, '\007');
break;
}
update = 1;
}
if ((w->flags & WINDOW_MONITOR) && (w->flags & WINDOW_ACTIVITY))
if ((w->flags & WINDOW_MONITOR) &&
(w->flags & WINDOW_ACTIVITY) &&
!session_alert_has(s, w, WINDOW_ACTIVITY)) {
session_alert_add(s, w, WINDOW_ACTIVITY);
update = 1;
}
}
server_status_window(w);
if (update)
server_status_window(w);
w->flags &= ~(WINDOW_BELL|WINDOW_ACTIVITY);
}

View File

@ -1,4 +1,4 @@
/* $Id: session.c,v 1.34 2008-06-04 16:46:23 nicm Exp $ */
/* $Id: session.c,v 1.35 2008-06-06 17:20:29 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -17,10 +17,10 @@
*/
#include <sys/types.h>
#include <sys/time.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <unistd.h>
#include "tmux.h"

View File

@ -1,4 +1,4 @@
/* $Id: status.c,v 1.21 2008-06-04 16:46:23 nicm Exp $ */
/* $Id: status.c,v 1.22 2008-06-06 17:20:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -17,10 +17,10 @@
*/
#include <sys/types.h>
#include <sys/time.h>
#include <stdarg.h>
#include <string.h>
#include <time.h>
#include "tmux.h"

4
tmux.c
View File

@ -1,4 +1,4 @@
/* $Id: tmux.c,v 1.53 2008-06-05 16:35:32 nicm Exp $ */
/* $Id: tmux.c,v 1.54 2008-06-06 17:20:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -174,7 +174,7 @@ main(int argc, char **argv)
int n, opt;
client = path = name = NULL;
while ((opt = getopt(argc, argv, "c:f:S:s:vV")) != EOF) {
while ((opt = getopt(argc, argv, "f:S:vV")) != EOF) {
switch (opt) {
case 'f':
cfg_file = xstrdup(optarg);

11
tmux.h
View File

@ -1,4 +1,4 @@
/* $Id: tmux.h,v 1.133 2008-06-05 21:25:00 nicm Exp $ */
/* $Id: tmux.h,v 1.134 2008-06-06 17:20:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -59,6 +59,13 @@ extern char *__progname;
#define __packed __attribute__ ((__packed__))
#endif
#ifndef timespeccmp
#define timespeccmp(tsp, usp, cmp) \
(((tsp)->tv_sec == (usp)->tv_sec) ? \
((tsp)->tv_nsec cmp (usp)->tv_nsec) : \
((tsp)->tv_sec cmp (usp)->tv_sec))
#endif
#ifndef TTY_NAME_MAX
#define TTY_NAME_MAX 32
#endif
@ -115,7 +122,7 @@ struct buffer {
#define KEYC_A1 -1
#define KEYC_A3 -2
#define KEYC_B2 -3
/* XXX #define KEYC_BACKSPACE -4 */
/* #define KEYC_BACKSPACE -4 */
#define KEYC_BEG -5
#define KEYC_BTAB -6
#define KEYC_C1 -7

View File

@ -1,4 +1,4 @@
/* $Id: tty-keys.c,v 1.2 2007-12-06 09:46:23 nicm Exp $ */
/* $Id: tty-keys.c,v 1.3 2008-06-06 17:20:30 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -26,6 +26,7 @@ struct {
const char *name;
int code;
} tty_keys[] = {
/* { "kb", KEYC_BACKSPACE }, */
{ "kBEG", KEYC_SBEG },
{ "kCAN", KEYC_SCANCEL },
{ "kCMD", KEYC_SCOMMAND },
@ -259,6 +260,11 @@ tty_keys_next(struct tty *tty, int *code)
}
xfree(s);
if (tk == NULL) {
size = tty->ksize;
if (size > BUFFER_USED(tty->in))
size = BUFFER_USED(tty->in);
log_debug(
"unmatched key: %.*s", (int) size, BUFFER_OUT(tty->in));
/*
* XXX Pass through unchanged.
*/