Merge branch 'master' of ssh://git.code.sf.net/p/tmux/tmux-code

This commit is contained in:
Nicholas Marriott 2013-05-31 13:00:11 +01:00
commit 2ee9c4df12
33 changed files with 555 additions and 147 deletions

1
.gitignore vendored
View File

@ -15,3 +15,4 @@ tmux
Makefile
Makefile.in
configure
tmux.1

View File

@ -2,18 +2,18 @@
# Obvious program stuff.
bin_PROGRAMS = tmux
dist_man1_MANS = tmux.1
CLEANFILES = tmux.1.mdoc tmux.1.man
# Distribution tarball options.
EXTRA_DIST = \
CHANGES FAQ README TODO examples compat \
array.h compat.h tmux.h osdep-*.c
array.h compat.h tmux.h osdep-*.c mdoc2man.awk tmux.1
dist-hook:
grep "^#found_debug=" configure
find $(distdir) -name .svn -type d|xargs rm -Rf
# Preprocessor flags.
CPPFLAGS += @XOPEN_DEFINES@
CPPFLAGS += @XOPEN_DEFINES@ -DTMUX_CONF="\"$(sysconfdir)/tmux.conf\""
# glibc as usual does things ass-backwards and hides useful things by default,
# so everyone has to add this.
@ -231,6 +231,22 @@ endif
if NO_B64_NTOP
nodist_tmux_SOURCES += compat/b64_ntop.c
endif
if NO_CFMAKERAW
nodist_tmux_SOURCES += compat/cfmakeraw.c
endif
# Install tmux.1 in the right format.
install-exec-hook:
if test x@MANFORMAT@ = xmdoc; then \
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1 \
>$(srcdir)/tmux.1.mdoc; \
else \
sed -e "s|@SYSCONFDIR@|$(sysconfdir)|g" $(srcdir)/tmux.1| \
$(AWK) -fmdoc2man.awk >$(srcdir)/tmux.1.man; \
fi
$(MKDIR_P) $(DESTDIR)$(mandir)/man1
$(INSTALL_DATA) $(srcdir)/tmux.1.@MANFORMAT@ \
$(DESTDIR)$(mandir)/man1/tmux.1
# Update SF web site.
upload-index.html: update-index.html

3
TODO
View File

@ -47,7 +47,7 @@
- hooks!
- warts on current naming:
* display-time but message-fg/bg/attr
* display-time but message-fg/bg/attr
* list-* vs show-*
* server-info
* split-window -> split-pane??
@ -55,6 +55,7 @@
- way to keep a job running just read its last line of output for #()
- better UTF-8 support:
* #22T can split in the middle of UTF-8 characters!
* window names and titles
* message display
* prompt input

View File

@ -78,8 +78,8 @@ client_get_lock(char *lockfile)
if ((lockfd = open(lockfile, O_WRONLY|O_CREAT, 0600)) == -1)
fatal("open failed");
if (flock(lockfd, LOCK_EX|LOCK_NB) == -1 && errno == EWOULDBLOCK) {
while (flock(lockfd, LOCK_EX) == -1 && errno == EINTR)
if (lockf(lockfd, F_TLOCK, 0) == -1 && errno == EAGAIN) {
while (lockf(lockfd, F_LOCK, 0) == -1 && errno == EINTR)
/* nothing */;
close(lockfd);
return (-1);

15
clock.c
View File

@ -103,13 +103,20 @@ clock_draw(struct screen_write_ctx *ctx, int colour, int style)
struct grid_cell gc;
char tim[64], *ptr;
time_t t;
struct tm *tm;
u_int i, j, x, y, idx;
t = time(NULL);
if (style == 0)
strftime(tim, sizeof tim, "%l:%M %p", localtime(&t));
else
strftime(tim, sizeof tim, "%H:%M", localtime(&t));
tm = localtime(&t);
if (style == 0) {
strftime(tim, sizeof tim, "%l:%M ", localtime(&t));
if (tm->tm_hour >= 12)
strlcat(tim, "PM", sizeof tim);
else
strlcat(tim, "AM", sizeof tim);
} else
strftime(tim, sizeof tim, "%H:%M", tm);
screen_write_clearscreen(ctx);

View File

@ -89,10 +89,7 @@ cmd_choose_tree_exec(struct cmd *self, struct cmd_q *cmdq)
return (CMD_RETURN_ERROR);
}
if ((s = c->session) == NULL)
return (CMD_RETURN_ERROR);
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), NULL)) == NULL)
if ((wl = cmd_find_window(cmdq, args_get(args, 't'), &s)) == NULL)
return (CMD_RETURN_ERROR);
if (window_pane_set_mode(wl->window->active, &window_choose_mode) != 0)
@ -231,9 +228,12 @@ windows_only:
free(final_win_template_last);
window_choose_ready(wl->window->active, cur_win, NULL);
window_choose_collapse_all(wl->window->active);
if (args_has(args, 'u'))
if (args_has(args, 'u')) {
window_choose_expand_all(wl->window->active);
window_choose_set_current(wl->window->active, cur_win);
}
return (CMD_RETURN_NORMAL);
}

View File

@ -54,9 +54,11 @@ cmd_copy_mode_exec(struct cmd *self, struct cmd_q *cmdq)
if (cmd_find_pane(cmdq, args_get(args, 't'), NULL, &wp) == NULL)
return (CMD_RETURN_ERROR);
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
return (CMD_RETURN_NORMAL);
window_copy_init_from_pane(wp);
if (wp->mode != &window_copy_mode) {
if (window_pane_set_mode(wp, &window_copy_mode) != 0)
return (CMD_RETURN_NORMAL);
window_copy_init_from_pane(wp);
}
if (wp->mode == &window_copy_mode && args_has(self->args, 'u'))
window_copy_pageup(wp);

View File

@ -158,7 +158,7 @@ cmdq_guard(struct cmd_q *cmdq, const char *guard)
{
struct client *c = cmdq->client;
if (c == NULL || c->session == NULL)
if (c == NULL)
return 0;
if (!(c->flags & CLIENT_CONTROL))
return 0;

View File

@ -49,6 +49,7 @@ cmd_source_file_exec(struct cmd *self, struct cmd_q *cmdq)
char *cause;
cmdq1 = cmdq_new(NULL);
cmdq1->client = cmdq->client;
cmdq1->emptyfn = cmd_source_file_done;
cmdq1->data = cmdq;

View File

@ -75,8 +75,12 @@ cmd_swap_pane_exec(struct cmd *self, struct cmd_q *cmdq)
src_wp = TAILQ_PREV(dst_wp, window_panes, entry);
if (src_wp == NULL)
src_wp = TAILQ_LAST(&dst_w->panes, window_panes);
} else
return (CMD_RETURN_NORMAL);
} else {
src_wl = cmd_find_pane(cmdq, NULL, NULL, &src_wp);
if (src_wl == NULL)
return (CMD_RETURN_ERROR);
src_w = src_wl->window;
}
} else {
src_wl = cmd_find_pane(cmdq, args_get(args, 's'), NULL, &src_wp);
if (src_wl == NULL)

4
cmd.c
View File

@ -294,8 +294,8 @@ cmd_print(struct cmd *cmd, char *buf, size_t len)
size_t off, used;
off = xsnprintf(buf, len, "%s ", cmd->entry->name);
if (off < len) {
used = args_print(cmd->args, buf + off, len - off);
if (off + 1 < len) {
used = args_print(cmd->args, buf + off, len - off - 1);
if (used == 0)
off--;
else

View File

@ -287,29 +287,3 @@ colour_256to16(u_char c)
return (table[c]);
}
/* Convert 256 colour palette to 88. */
u_char
colour_256to88(u_char c)
{
static const u_char table[256] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
16, 17, 17, 18, 18, 19, 20, 21, 21, 22, 22, 23, 20, 21, 21, 22,
22, 23, 24, 25, 25, 26, 26, 27, 24, 25, 25, 26, 26, 27, 28, 29,
29, 30, 30, 31, 32, 33, 33, 34, 34, 35, 36, 37, 37, 38, 38, 39,
36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43, 40, 41, 41, 42,
42, 43, 44, 45, 45, 46, 46, 47, 32, 33, 33, 34, 34, 35, 36, 37,
37, 38, 38, 39, 36, 37, 37, 38, 38, 39, 40, 41, 41, 42, 42, 43,
40, 41, 41, 42, 42, 43, 44, 45, 45, 46, 46, 47, 48, 49, 49, 50,
50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54, 54, 55, 56, 57,
57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61, 61, 62, 62, 63,
48, 49, 49, 50, 50, 51, 52, 53, 53, 54, 54, 55, 52, 53, 53, 54,
54, 55, 56, 57, 57, 58, 58, 59, 56, 57, 57, 58, 58, 59, 60, 61,
61, 62, 62, 63, 64, 65, 65, 66, 66, 67, 68, 69, 69, 70, 70, 71,
68, 69, 69, 70, 70, 71, 72, 73, 73, 74, 74, 75, 72, 73, 73, 74,
74, 75, 76, 77, 77, 78, 78, 79, 0, 0, 80, 80, 80, 81, 81, 81,
82, 82, 82, 83, 83, 83, 84, 84, 84, 85, 85, 85, 86, 86, 86, 87
};
return (table[c]);
}

View File

@ -236,6 +236,11 @@ int setenv(const char *, const char *, int);
int unsetenv(const char *);
#endif
#ifndef HAVE_CFMAKERAW
/* cfmakeraw.c */
void cfmakeraw(struct termios *tio);
#endif
#ifdef HAVE_GETOPT
#include <getopt.h>
#else

32
compat/cfmakeraw.c Normal file
View File

@ -0,0 +1,32 @@
/* $Id$ */
/*
* Copyright (c) 2013 Dagobert Michelsen
* Copyright (c) 2013 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 <string.h>
#include "tmux.h"
void
cfmakeraw(struct termios *tio)
{
tio->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
tio->c_oflag &= ~OPOST;
tio->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
tio->c_cflag &= ~(CSIZE|PARENB);
tio->c_cflag |= CS8;
}

View File

@ -18,6 +18,9 @@ AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
# Default tmux.conf goes in /etc not ${prefix}/etc.
test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
# Check for various headers. Alternatives included from compat.h.
AC_CHECK_HEADERS(
[ \
@ -313,6 +316,13 @@ if test "x$found_strnvis" = xyes; then
fi
AM_CONDITIONAL(NO_VIS, [test "x$found_strnvis" = xno])
# Look for cfmakeraw, compat/cfmakeraw.c used if missing.
AC_CHECK_FUNC(cfmakeraw, found_cfmakeraw=yes, found_cfmakeraw=no)
if test "x$found_cfmakeraw" = xyes; then
AC_DEFINE(HAVE_CFMAKERAW)
fi
AM_CONDITIONAL(NO_CFMAKERAW, [test "x$found_cfmakeraw" = xno])
# Look for getopt. glibc's getopt does not enforce argument order and the ways
# of making it do so are stupid, so just use our own instead.
AC_CHECK_FUNC(getopt, found_getopt=yes, found_getopt=no)
@ -345,6 +355,7 @@ AC_CHECK_FUNCS(
dirfd \
setproctitle \
sysconf \
cfmakeraw \
]
)
@ -416,6 +427,10 @@ else
AC_MSG_RESULT(no)
fi
# Man page defaults to mdoc.
MANFORMAT=mdoc
AC_SUBST(MANFORMAT)
# Figure out the platform for osdep-*.c and forkpty-*.c.
AC_MSG_CHECKING(platform)
case "$host_os" in
@ -455,6 +470,7 @@ case "$host_os" in
*solaris*)
AC_MSG_RESULT(sunos)
PLATFORM=sunos
MANFORMAT=man
;;
*hpux*)
AC_MSG_RESULT(hpux)

View File

@ -56,7 +56,7 @@ syn keyword tmuxCmds
\ list-buffers loadb load-buffer pasteb paste-buffer saveb save-buffer
\ setb set-buffer showb show-buffer
\ clock-mode if[-shell] lock[-server] run[-shell] server-info info
\ choose-list
\ choose-list wait-for
syn keyword tmuxOptsSet
\ buffer-limit escape-time exit-unattached exit-unattached quiet

View File

@ -288,7 +288,7 @@ format_session(struct format_tree *ft, struct session *s)
format_add(ft, "session_group", "%u", session_group_index(sg));
t = s->creation_time.tv_sec;
format_add(ft, "session_created", "%ld", (long) t);
format_add(ft, "session_created", "%lld", (long long) t);
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
format_add(ft, "session_created_string", "%s", tim);
@ -314,13 +314,13 @@ format_client(struct format_tree *ft, struct client *c)
format_add(ft, "client_termname", "%s", c->tty.termname);
t = c->creation_time.tv_sec;
format_add(ft, "client_created", "%ld", (long) t);
format_add(ft, "client_created", "%lld", (long long) t);
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
format_add(ft, "client_created_string", "%s", tim);
t = c->activity_time.tv_sec;
format_add(ft, "client_activity", "%ld", (long) t);
format_add(ft, "client_activity", "%lld", (long long) t);
tim = ctime(&t);
*strchr(tim, '\n') = '\0';
format_add(ft, "client_activity_string", "%s", tim);

View File

@ -226,7 +226,7 @@ input_mouse(struct window_pane *wp, struct session *s, struct mouse_event *m)
len += utf8_split2(m->x + 33, &buf[len]);
len += utf8_split2(m->y + 33, &buf[len]);
} else {
if (m->xb > 223 || m->x >= 222 || m->y > 222)
if (m->xb > 223)
return;
len = xsnprintf(buf, sizeof buf, "\033[M");
buf[len++] = m->xb + 32;

6
job.c
View File

@ -108,7 +108,7 @@ job_run(const char *cmd, struct session *s,
job->event = bufferevent_new(job->fd, NULL, job_write_callback,
job_callback, job);
bufferevent_enable(job->event, EV_READ);
bufferevent_enable(job->event, EV_READ|EV_WRITE);
log_debug("run job %p: %s, pid %ld", job, job->cmd, (long) job->pid);
return (job);
@ -143,8 +143,8 @@ job_write_callback(unused struct bufferevent *bufev, void *data)
struct job *job = data;
size_t len = EVBUFFER_LENGTH(EVBUFFER_OUTPUT(job->event));
log_debug("job write %p: %s, pid %ld, output left %lu", job, job->cmd,
(long) job->pid, (unsigned long) len);
log_debug("job write %p: %s, pid %ld, output left %zu", job, job->cmd,
(long) job->pid, len);
if (len == 0) {
shutdown(job->fd, SHUT_WR);

370
mdoc2man.awk Normal file
View File

@ -0,0 +1,370 @@
#!/usr/bin/awk
#
# $Id: mdoc2man.awk,v 1.9 2009/10/24 00:52:42 dtucker Exp $
#
# Version history:
# v4+ Adapted for OpenSSH Portable (see cvs Id and history)
# v3, I put the program under a proper license
# Dan Nelson <dnelson@allantgroup.com> added .An, .Aq and fixed a typo
# v2, fixed to work on GNU awk --posix and MacOS X
# v1, first attempt, didn't work on MacOS X
#
# Copyright (c) 2003 Peter Stuge <stuge-mdoc2man@cdy.org>
#
# 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 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.
BEGIN {
optlist=0
oldoptlist=0
nospace=0
synopsis=0
reference=0
block=0
ext=0
extopt=0
literal=0
prenl=0
breakw=0
line=""
}
function wtail() {
retval=""
while(w<nwords) {
if(length(retval))
retval=retval OFS
retval=retval words[++w]
}
return retval
}
function add(str) {
for(;prenl;prenl--)
line=line "\n"
line=line str
}
! /^\./ {
for(;prenl;prenl--)
print ""
print
if(literal)
print ".br"
next
}
/^\.\\"/ { next }
{
option=0
parens=0
angles=0
sub("^\\.","")
nwords=split($0,words)
for(w=1;w<=nwords;w++) {
skip=0
if(match(words[w],"^Li|Pf$")) {
skip=1
} else if(match(words[w],"^Xo$")) {
skip=1
ext=1
if(length(line)&&!(match(line," $")||prenl))
add(OFS)
} else if(match(words[w],"^Xc$")) {
skip=1
ext=0
if(!extopt)
prenl++
w=nwords
} else if(match(words[w],"^Bd$")) {
skip=1
if(match(words[w+1],"-literal")) {
literal=1
prenl++
w=nwords
}
} else if(match(words[w],"^Ed$")) {
skip=1
literal=0
} else if(match(words[w],"^Ns$")) {
skip=1
if(!nospace)
nospace=1
sub(" $","",line)
} else if(match(words[w],"^No$")) {
skip=1
sub(" $","",line)
add(words[++w])
} else if(match(words[w],"^Dq$")) {
skip=1
add("``")
add(words[++w])
while(w<nwords&&!match(words[w+1],"^[\\.,]"))
add(OFS words[++w])
add("''")
if(!nospace&&match(words[w+1],"^[\\.,]"))
nospace=1
} else if(match(words[w],"^Sq|Ql$")) {
skip=1
add("`" words[++w] "'")
if(!nospace&&match(words[w+1],"^[\\.,]"))
nospace=1
} else if(match(words[w],"^Oo$")) {
skip=1
extopt=1
if(!nospace)
nospace=1
add("[")
} else if(match(words[w],"^Oc$")) {
skip=1
extopt=0
add("]")
}
if(!skip) {
if(!nospace&&length(line)&&!(match(line," $")||prenl))
add(OFS)
if(nospace==1)
nospace=0
}
if(match(words[w],"^Dd$")) {
if(match(words[w+1],"^\\$Mdocdate:")) {
w++;
if(match(words[w+4],"^\\$$")) {
words[w+4] = ""
}
}
date=wtail()
next
} else if(match(words[w],"^Dt$")) {
id=wtail()
next
} else if(match(words[w],"^Ux$")) {
add("UNIX")
skip=1
} else if(match(words[w],"^Ox$")) {
add("OpenBSD")
skip=1
} else if(match(words[w],"^Os$")) {
add(".TH " id " \"" date "\" \"" wtail() "\"")
} else if(match(words[w],"^Sh$")) {
add(".SH")
synopsis=match(words[w+1],"SYNOPSIS")
} else if(match(words[w],"^Xr$")) {
add("\\fB" words[++w] "\\fP(" words[++w] ")" words[++w])
} else if(match(words[w],"^Rs$")) {
split("",refauthors)
nrefauthors=0
reftitle=""
refissue=""
refdate=""
refopt=""
refreport=""
reference=1
next
} else if(match(words[w],"^Re$")) {
prenl++
for(i=nrefauthors-1;i>0;i--) {
add(refauthors[i])
if(i>1)
add(", ")
}
if(nrefauthors>1)
add(" and ")
if(nrefauthors>0)
add(refauthors[0] ", ")
add("\\fI" reftitle "\\fP")
if(length(refissue))
add(", " refissue)
if(length(refreport)) {
add(", " refreport)
}
if(length(refdate))
add(", " refdate)
if(length(refopt))
add(", " refopt)
add(".")
reference=0
} else if(reference) {
if(match(words[w],"^%A$")) { refauthors[nrefauthors++]=wtail() }
if(match(words[w],"^%T$")) {
reftitle=wtail()
sub("^\"","",reftitle)
sub("\"$","",reftitle)
}
if(match(words[w],"^%N$")) { refissue=wtail() }
if(match(words[w],"^%D$")) { refdate=wtail() }
if(match(words[w],"^%O$")) { refopt=wtail() }
if(match(words[w],"^%R$")) { refreport=wtail() }
} else if(match(words[w],"^Nm$")) {
if(synopsis) {
add(".br")
prenl++
}
n=words[++w]
if(!length(name))
name=n
if(!length(n))
n=name
add("\\fB" n "\\fP")
if(!nospace&&match(words[w+1],"^[\\.,]"))
nospace=1
} else if(match(words[w],"^Nd$")) {
add("\\- " wtail())
} else if(match(words[w],"^Fl$")) {
add("\\fB\\-" words[++w] "\\fP")
if(!nospace&&match(words[w+1],"^[\\.,]"))
nospace=1
} else if(match(words[w],"^Ar$")) {
add("\\fI")
if(w==nwords)
add("file ...\\fP")
else {
add(words[++w] "\\fP")
while(match(words[w+1],"^\\|$"))
add(OFS words[++w] " \\fI" words[++w] "\\fP")
}
if(!nospace&&match(words[w+1],"^[\\.,]"))
nospace=1
} else if(match(words[w],"^Cm$")) {
add("\\fB" words[++w] "\\fP")
while(w<nwords&&match(words[w+1],"^[\\.,:;)]"))
add(words[++w])
} else if(match(words[w],"^Op$")) {
option=1
if(!nospace)
nospace=1
add("[")
} else if(match(words[w],"^Pp$")) {
prenl++
} else if(match(words[w],"^An$")) {
prenl++
} else if(match(words[w],"^Ss$")) {
add(".SS")
} else if(match(words[w],"^Pa$")&&!option) {
add("\\fI")
w++
if(match(words[w],"^\\."))
add("\\&")
add(words[w] "\\fP")
while(w<nwords&&match(words[w+1],"^[\\.,:;)]"))
add(words[++w])
} else if(match(words[w],"^Dv$")) {
add(".BR")
} else if(match(words[w],"^Em|Ev$")) {
add(".IR")
} else if(match(words[w],"^Pq$")) {
add("(")
nospace=1
parens=1
} else if(match(words[w],"^Aq$")) {
add("<")
nospace=1
angles=1
} else if(match(words[w],"^S[xy]$")) {
add(".B " wtail())
} else if(match(words[w],"^Ic$")) {
plain=1
add("\\fB")
while(w<nwords) {
w++
if(match(words[w],"^Op$")) {
w++
add("[")
words[nwords]=words[nwords] "]"
}
if(match(words[w],"^Ar$")) {
add("\\fI" words[++w] "\\fP")
} else if(match(words[w],"^[\\.,]")) {
sub(" $","",line)
if(plain) {
add("\\fP")
plain=0
}
add(words[w])
} else {
if(!plain) {
add("\\fB")
plain=1
}
add(words[w])
}
if(!nospace)
add(OFS)
}
sub(" $","",line)
if(plain)
add("\\fP")
} else if(match(words[w],"^Bl$")) {
oldoptlist=optlist
if(match(words[w+1],"-bullet"))
optlist=1
else if(match(words[w+1],"-enum")) {
optlist=2
enum=0
} else if(match(words[w+1],"-tag"))
optlist=3
else if(match(words[w+1],"-item"))
optlist=4
else if(match(words[w+1],"-bullet"))
optlist=1
w=nwords
} else if(match(words[w],"^El$")) {
optlist=oldoptlist
} else if(match(words[w],"^Bk$")) {
if(match(words[w+1],"-words")) {
w++
breakw=1
}
} else if(match(words[w],"^Ek$")) {
breakw=0
} else if(match(words[w],"^It$")&&optlist) {
if(optlist==1)
add(".IP \\(bu")
else if(optlist==2)
add(".IP " ++enum ".")
else if(optlist==3) {
add(".TP")
prenl++
if(match(words[w+1],"^Pa$|^Ev$")) {
add(".B")
w++
}
} else if(optlist==4)
add(".IP")
} else if(match(words[w],"^Sm$")) {
if(match(words[w+1],"off"))
nospace=2
else if(match(words[w+1],"on"))
nospace=0
w++
} else if(!skip) {
add(words[w])
}
}
if(match(line,"^\\.[^a-zA-Z]"))
sub("^\\.","",line)
if(parens)
add(")")
if(angles)
add(">")
if(option)
add("]")
if(ext&&!extopt&&!match(line," $"))
add(OFS)
if(!ext&&!extopt&&length(line)) {
print line
prenl=0
line=""
}
}

View File

@ -413,7 +413,7 @@ const struct options_table_entry session_options_table[] = {
{ .name = "terminal-overrides",
.type = OPTIONS_TABLE_STRING,
.default_str = "*88col*:colors=88,*256col*:colors=256"
.default_str = "*256col*:colors=256"
",xterm*:XT:Ms=\\E]52;%p1%s;%p2%s\\007"
":Cc=\\E]12;%p1%s\\007:Cr=\\E]112\\007"
":Cs=\\E[%p1%d q:Csr=\\E[2 q,screen*:XT"

View File

@ -56,7 +56,7 @@ screen_write_reset(struct screen_write_ctx *ctx)
screen_reset_tabs(s);
screen_write_scrollregion(ctx, 0, screen_size_y(s) - 1);
s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD);
s->mode &= ~(MODE_INSERT|MODE_KCURSOR|MODE_KKEYPAD|MODE_FOCUSON);
s->mode &= ~(ALL_MOUSE_MODES|MODE_MOUSE_UTF8|MODE_MOUSE_SGR);
screen_write_clearscreen(ctx);
@ -488,6 +488,8 @@ screen_write_cursorup(struct screen_write_ctx *ctx, u_int ny)
if (ny > s->cy - s->rupper)
ny = s->cy - s->rupper;
}
if (s->cx == screen_size_x(s))
s->cx--;
if (ny == 0)
return;
@ -512,6 +514,8 @@ screen_write_cursordown(struct screen_write_ctx *ctx, u_int ny)
if (ny > s->rlower - s->cy)
ny = s->rlower - s->cy;
}
if (s->cx == screen_size_x(s))
s->cx--;
if (ny == 0)
return;

View File

@ -366,7 +366,13 @@ void
screen_reflow(struct screen *s, u_int new_x)
{
struct grid *old = s->grid;
u_int change;
s->grid = grid_create(old->sx, old->sy, old->hlimit);
s->cy -= grid_reflow(s->grid, old, new_x);
change = grid_reflow(s->grid, old, new_x);
if (change < s->cy)
s->cy -= change;
else
s->cy = 0;
}

View File

@ -514,8 +514,10 @@ server_client_loop(void)
w->flags &= ~WINDOW_REDRAW;
TAILQ_FOREACH(wp, &w->panes, entry) {
server_client_check_focus(wp);
server_client_check_resize(wp);
if (wp->fd != -1) {
server_client_check_focus(wp);
server_client_check_resize(wp);
}
wp->flags &= ~PANE_REDRAW;
}
}
@ -527,25 +529,15 @@ server_client_check_resize(struct window_pane *wp)
{
struct winsize ws;
if (wp->fd == -1 || !(wp->flags & PANE_RESIZE))
if (!(wp->flags & PANE_RESIZE))
return;
memset(&ws, 0, sizeof ws);
ws.ws_col = wp->sx;
ws.ws_row = wp->sy;
if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1) {
#ifdef __sun
/*
* Some versions of Solaris apparently can return an error when
* resizing; don't know why this happens, can't reproduce on
* other platforms and ignoring it doesn't seem to cause any
* issues.
*/
if (errno != EINVAL)
#endif
if (ioctl(wp->fd, TIOCSWINSZ, &ws) == -1)
fatal("ioctl failed");
}
wp->flags &= ~PANE_RESIZE;
}
@ -981,8 +973,6 @@ server_client_msg_identify(
c->tty.flags |= TTY_UTF8;
if (data->flags & IDENTIFY_256COLOURS)
c->tty.term_flags |= TERM_256COLOURS;
else if (data->flags & IDENTIFY_88COLOURS)
c->tty.term_flags |= TERM_88COLOURS;
tty_resize(&c->tty);

View File

@ -283,6 +283,7 @@ server_kill_window(struct window *w)
if (options_get_number(&s->options, "renumber-windows"))
session_renumber_windows(s);
}
recalculate_sizes();
}
int

View File

@ -170,13 +170,13 @@ server_start(int lockfd, char *lockfile)
cfg_references = 1;
ARRAY_INIT(&cfg_causes);
if (access(SYSTEM_CFG, R_OK) == 0) {
if (load_cfg(SYSTEM_CFG, cfg_cmd_q, &cause) == -1) {
xasprintf(&cause, "%s: %s", SYSTEM_CFG, cause);
if (access(TMUX_CONF, R_OK) == 0) {
if (load_cfg(TMUX_CONF, cfg_cmd_q, &cause) == -1) {
xasprintf(&cause, "%s: %s", TMUX_CONF, cause);
ARRAY_ADD(&cfg_causes, cause);
}
} else if (errno != ENOENT) {
xasprintf(&cause, "%s: %s", SYSTEM_CFG, strerror(errno));
xasprintf(&cause, "%s: %s", TMUX_CONF, strerror(errno));
ARRAY_ADD(&cfg_causes, cause);
}
if (cfg_file != NULL) {

24
tmux.1
View File

@ -98,10 +98,6 @@ The options are as follows:
Force
.Nm
to assume the terminal supports 256 colours.
.It Fl 8
Like
.Fl 2 ,
but indicates that the terminal supports 88 colours.
.It Fl C
Start in control mode.
Given twice
@ -126,7 +122,7 @@ Specify an alternative configuration file.
By default,
.Nm
loads the system configuration file from
.Pa /etc/tmux.conf ,
.Pa @SYSCONFDIR@/tmux.conf ,
if present, then looks for a user configuration file at
.Pa ~/.tmux.conf .
.Pp
@ -145,11 +141,12 @@ session created, and continues to process the rest of the configuration file.
.It Fl L Ar socket-name
.Nm
stores the server socket in a directory under
.Pa /tmp
(or
.Ev TMUX_TMPDIR ,
.Ev TMPDIR
if set);
the default socket is named
if it is unset, or
.Pa /tmp
if both are unset.
The default socket is named
.Em default .
This option allows a different socket name to be specified, allowing several
independent
@ -2652,7 +2649,7 @@ The default is
.Ql \ -_@ .
.El
.It Xo Ic set-window-option
.Op Fl agqu
.Op Fl agoqu
.Op Fl t Ar target-window
.Ar option Ar value
.Xc
@ -2661,6 +2658,7 @@ Set a window option.
The
.Fl a ,
.Fl g ,
.Fl o ,
.Fl q
and
.Fl u
@ -3542,7 +3540,7 @@ Lock each client individually by running the command specified by the
.Ic lock-command
option.
.It Xo Ic run-shell
.Fl b
.Op Fl b
.Op Fl t Ar target-pane
.Ar shell-command
.Xc
@ -3707,12 +3705,12 @@ was renamed to
.Ar name .
.El
.Sh FILES
.Bl -tag -width "/etc/tmux.confXXX" -compact
.Bl -tag -width "@SYSCONFDIR@/tmux.confXXX" -compact
.It Pa ~/.tmux.conf
Default
.Nm
configuration file.
.It Pa /etc/tmux.conf
.It Pa @SYSCONFDIR@/tmux.conf
System-wide configuration file.
.El
.Sh EXAMPLES

20
tmux.c
View File

@ -22,6 +22,7 @@
#include <errno.h>
#include <event.h>
#include <fcntl.h>
#include <locale.h>
#include <pwd.h>
#include <stdlib.h>
#include <string.h>
@ -167,10 +168,12 @@ makesocketpath(const char *label)
u_int uid;
uid = getuid();
if ((s = getenv("TMPDIR")) == NULL || *s == '\0')
xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid);
else
if ((s = getenv("TMUX_TMPDIR")) != NULL && *s != '\0')
xsnprintf(base, sizeof base, "%s/", s);
else if ((s = getenv("TMPDIR")) != NULL && *s != '\0')
xsnprintf(base, sizeof base, "%s/tmux-%u", s, uid);
else
xsnprintf(base, sizeof base, "%s/tmux-%u", _PATH_TMP, uid);
if (mkdir(base, S_IRWXU) != 0 && errno != EEXIST)
return (NULL);
@ -244,18 +247,15 @@ main(int argc, char **argv)
malloc_options = (char *) "AFGJPX";
#endif
setlocale(LC_TIME, "");
quiet = flags = 0;
label = path = NULL;
login_shell = (**argv == '-');
while ((opt = getopt(argc, argv, "28c:Cdf:lL:qS:uUvV")) != -1) {
while ((opt = getopt(argc, argv, "2c:Cdf:lL:qS:uUVv")) != -1) {
switch (opt) {
case '2':
flags |= IDENTIFY_256COLOURS;
flags &= ~IDENTIFY_88COLOURS;
break;
case '8':
flags |= IDENTIFY_88COLOURS;
flags &= ~IDENTIFY_256COLOURS;
break;
case 'c':
free(shell_cmd);
@ -363,7 +363,7 @@ main(int argc, char **argv)
if (pw != NULL)
home = pw->pw_dir;
}
xasprintf(&cfg_file, "%s/%s", home, DEFAULT_CFG);
xasprintf(&cfg_file, "%s/.tmux.conf", home);
if (access(cfg_file, R_OK) != 0 && errno == ENOENT) {
free(cfg_file);
cfg_file = NULL;

13
tmux.h
View File

@ -39,9 +39,8 @@
extern char *__progname;
extern char **environ;
/* Default configuration files. */
#define DEFAULT_CFG ".tmux.conf"
#define SYSTEM_CFG "/etc/tmux.conf"
/* Default global configuration file. */
#define TMUX_CONF "/etc/tmux.conf"
/* Default prompt history length. */
#define PROMPT_HISTORY 100
@ -477,7 +476,7 @@ struct msg_identify_data {
#define IDENTIFY_UTF8 0x1
#define IDENTIFY_256COLOURS 0x2
#define IDENTIFY_88COLOURS 0x4
/* 0x4 unused */
#define IDENTIFY_CONTROL 0x8
#define IDENTIFY_TERMIOS 0x10
int flags;
@ -1137,8 +1136,7 @@ struct tty_term {
struct tty_code codes[NTTYCODE];
#define TERM_256COLOURS 0x1
#define TERM_88COLOURS 0x2
#define TERM_EARLYWRAP 0x4
#define TERM_EARLYWRAP 0x2
int flags;
LIST_ENTRY(tty_term) entry;
@ -1982,7 +1980,6 @@ void colour_set_bg(struct grid_cell *, int);
const char *colour_tostring(int);
int colour_fromstring(const char *);
u_char colour_256to16(u_char);
u_char colour_256to88(u_char);
/* attributes.c */
const char *attributes_tostring(u_char);
@ -2255,6 +2252,8 @@ struct window_choose_data *window_choose_add_item(struct window_pane *,
struct client *, struct winlink *, const char *,
const char *, u_int);
void window_choose_expand_all(struct window_pane *);
void window_choose_collapse_all(struct window_pane *);
void window_choose_set_current(struct window_pane *, u_int);
/* names.c */
void queue_window_name(struct window *);

View File

@ -410,11 +410,9 @@ tty_term_find(char *name, int fd, const char *overrides, char **cause)
goto error;
}
/* Figure out if we have 256 or 88 colours. */
/* Figure out if we have 256. */
if (tty_term_number(term, TTYC_COLORS) == 256)
term->flags |= TERM_256COLOURS;
if (tty_term_number(term, TTYC_COLORS) == 88)
term->flags |= TERM_88COLOURS;
/*
* Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1

36
tty.c
View File

@ -35,7 +35,6 @@ void tty_read_callback(struct bufferevent *, void *);
void tty_error_callback(struct bufferevent *, short, void *);
int tty_try_256(struct tty *, u_char, const char *);
int tty_try_88(struct tty *, u_char, const char *);
void tty_colours(struct tty *, const struct grid_cell *);
void tty_check_fg(struct tty *, struct grid_cell *);
@ -221,7 +220,7 @@ tty_start_tty(struct tty *tty)
tty_puts(tty, "\033[?1000l\033[?1006l\033[?1005l");
if (tty_term_has(tty->term, TTYC_XT))
tty_puts(tty, "\033[c\033[>4;1m\033[?1004h");
tty_puts(tty, "\033[c\033[>4;1m\033[?1004h\033[m");
tty->cx = UINT_MAX;
tty->cy = UINT_MAX;
@ -284,7 +283,7 @@ tty_stop_tty(struct tty *tty)
tty_raw(tty, "\033[?1000l\033[?1006l\033[?1005l");
if (tty_term_has(tty->term, TTYC_XT))
tty_raw(tty, "\033[>4m\033[?1004l");
tty_raw(tty, "\033[>4m\033[?1004l\033[m");
tty_raw(tty, tty_term_string(tty->term, TTYC_RMCUP));
@ -1446,9 +1445,7 @@ tty_check_fg(struct tty *tty, struct grid_cell *gc)
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_FG256) {
/* And not a 256 colour mode? */
if (!(tty->term->flags & TERM_88COLOURS) &&
!(tty->term_flags & TERM_88COLOURS) &&
!(tty->term->flags & TERM_256COLOURS) &&
if (!(tty->term->flags & TERM_256COLOURS) &&
!(tty->term_flags & TERM_256COLOURS)) {
gc->fg = colour_256to16(gc->fg);
if (gc->fg & 8) {
@ -1481,9 +1478,7 @@ tty_check_bg(struct tty *tty, struct grid_cell *gc)
* palette. Bold background doesn't exist portably, so just
* discard the bold bit if set.
*/
if (!(tty->term->flags & TERM_88COLOURS) &&
!(tty->term_flags & TERM_88COLOURS) &&
!(tty->term->flags & TERM_256COLOURS) &&
if (!(tty->term->flags & TERM_256COLOURS) &&
!(tty->term_flags & TERM_256COLOURS)) {
gc->bg = colour_256to16(gc->bg);
if (gc->bg & 8)
@ -1511,11 +1506,9 @@ tty_colours_fg(struct tty *tty, const struct grid_cell *gc)
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_FG256) {
/* Try as 256 colours or translating to 88. */
/* Try as 256 colours. */
if (tty_try_256(tty, fg, "38") == 0)
goto save_fg;
if (tty_try_88(tty, fg, "38") == 0)
goto save_fg;
/* Else already handled by tty_check_fg. */
return;
}
@ -1546,11 +1539,9 @@ tty_colours_bg(struct tty *tty, const struct grid_cell *gc)
/* Is this a 256-colour colour? */
if (gc->flags & GRID_FLAG_BG256) {
/* Try as 256 colours or translating to 88. */
/* Try as 256 colours. */
if (tty_try_256(tty, bg, "48") == 0)
goto save_bg;
if (tty_try_88(tty, bg, "48") == 0)
goto save_bg;
/* Else already handled by tty_check_bg. */
return;
}
@ -1591,21 +1582,6 @@ tty_try_256(struct tty *tty, u_char colour, const char *type)
return (0);
}
int
tty_try_88(struct tty *tty, u_char colour, const char *type)
{
char s[32];
if (!(tty->term->flags & TERM_88COLOURS) &&
!(tty->term_flags & TERM_88COLOURS))
return (-1);
colour = colour_256to88(colour);
xsnprintf(s, sizeof s, "\033[%s;5;%hhum", type, colour);
tty_puts(tty, s);
return (0);
}
void
tty_bell(struct tty *tty)
{

1
utf8.c
View File

@ -173,7 +173,6 @@ struct utf8_width_entry utf8_width_table[] = {
{ 0x30000, 0x3fffd, 2, NULL, NULL },
{ 0x00711, 0x00711, 0, NULL, NULL },
{ 0x0fe00, 0x0fe0f, 0, NULL, NULL },
{ 0x01160, 0x011ff, 0, NULL, NULL },
{ 0x0180b, 0x0180d, 0, NULL, NULL },
{ 0x10a3f, 0x10a3f, 0, NULL, NULL },
{ 0x00981, 0x00981, 0, NULL, NULL },

View File

@ -44,7 +44,6 @@ void window_choose_scroll_down(struct window_pane *);
void window_choose_collapse(struct window_pane *, struct session *);
void window_choose_expand(struct window_pane *, struct session *, u_int);
void window_choose_collapse_all(struct window_pane *);
enum window_choose_input_type {
WINDOW_CHOOSE_NORMAL = -1,
@ -102,8 +101,7 @@ window_choose_add(struct window_pane *wp, struct window_choose_data *wcd)
}
void
window_choose_ready(struct window_pane *wp, u_int cur,
void (*callbackfn)(struct window_choose_data *))
window_choose_set_current(struct window_pane *wp, u_int cur)
{
struct window_choose_mode_data *data = wp->modedata;
struct screen *s = &data->screen;
@ -112,12 +110,22 @@ window_choose_ready(struct window_pane *wp, u_int cur,
if (data->selected > screen_size_y(s) - 1)
data->top = ARRAY_LENGTH(&data->list) - screen_size_y(s);
window_choose_redraw_screen(wp);
}
void
window_choose_ready(struct window_pane *wp, u_int cur,
void (*callbackfn)(struct window_choose_data *))
{
struct window_choose_mode_data *data = wp->modedata;
data->callbackfn = callbackfn;
if (data->callbackfn == NULL)
data->callbackfn = window_choose_default_callback;
ARRAY_CONCAT(&data->old_list, &data->list);
window_choose_set_current(wp, cur);
window_choose_collapse_all(wp);
}