From 5fbdca890ab7dec63d96128d5b5ecd145b6e15f4 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Thu, 23 Apr 2009 21:09:17 +0000 Subject: [PATCH] Use the xenl terminfo flag to detect early-wrap terminals like the FreeBSD console. Many thanks for a very informative email from Christian Weisgerber. --- CHANGES | 7 ++++++- TODO | 2 -- tmux.h | 5 +++-- tty-term.c | 36 +++++++++++++++--------------------- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/CHANGES b/CHANGES index dbb9a1a3..d68be569 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,8 @@ +23 April 2009 + +* Use the xenl terminfo flag to detect early-wrap terminals like the FreeBSD + console. Many thanks for a very informative email from Christian Weisgerber. + 21 April 2009 * tmux 0.8 released. @@ -1208,7 +1213,7 @@ (including mutt, emacs). No status bar yet and no key remapping or other customisation. -$Id: CHANGES,v 1.273 2009-04-23 17:51:57 nicm Exp $ +$Id: CHANGES,v 1.274 2009-04-23 21:09:17 nicm Exp $ LocalWords: showw utf UTF fulvio ciriaco joshe OSC APC gettime abc DEF OA clr LocalWords: rivo nurges lscm Erdely eol smysession mysession ek dstname RB ms diff --git a/TODO b/TODO index 898a824a..2ccfae93 100644 --- a/TODO +++ b/TODO @@ -62,8 +62,6 @@ - a confirm-before command which asks "Are you sure? (y/n)" before executing command, eg bind-key "&" confirm-before "kill-window" - clear window title on exit -- better support for stupid margin terminals. strcmp for cons25 sucks, how can - these be autodetected? - refer to windows by name etc (duplicates? fnmatch?) - the output code (tty.c) could do with optimisation depending on term capibilities diff --git a/tmux.h b/tmux.h index 3440718a..a756ebb4 100644 --- a/tmux.h +++ b/tmux.h @@ -1,4 +1,4 @@ -/* $Id: tmux.h,v 1.299 2009-04-03 17:21:46 nicm Exp $ */ +/* $Id: tmux.h,v 1.300 2009-04-23 21:09:17 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -317,8 +317,9 @@ enum tty_code_code { TTYC_SMKX, /* keypad_xmit, ks */ TTYC_SMSO, /* enter_standout_mode, so */ TTYC_SMUL, /* enter_underline_mode, us */ + TTYC_XENL, /* eat_newline_glitch, xn */ }; -#define NTTYCODE (TTYC_SMUL + 1) +#define NTTYCODE (TTYC_XENL + 1) /* Termcap types. */ enum tty_code_type { diff --git a/tty-term.c b/tty-term.c index 61ebcacb..89a7e81a 100644 --- a/tty-term.c +++ b/tty-term.c @@ -1,4 +1,4 @@ -/* $Id: tty-term.c,v 1.17 2009-03-07 10:29:06 nicm Exp $ */ +/* $Id: tty-term.c,v 1.18 2009-04-23 21:09:17 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott @@ -107,6 +107,7 @@ struct tty_term_code_entry tty_term_codes[NTTYCODE] = { { TTYC_SMKX, TTYCODE_STRING, "smkx" }, { TTYC_SMSO, TTYCODE_STRING, "smso" }, { TTYC_SMUL, TTYCODE_STRING, "smul" }, + { TTYC_XENL, TTYCODE_FLAG, "xenl" }, }; char * @@ -156,26 +157,6 @@ tty_term_quirks(struct tty_term *term) term->codes[TTYC_ICH1].value.string = xstrdup("\033[@"); } } - -#ifdef __FreeBSD__ - if (strncmp(term->name, "cons", 4) == 0) { - /* - * FreeBSD's console wraps lines at $COLUMNS - 1 rather than - * $COLUMNS (the cursor can never be beyond $COLUMNS - 1) and - * does not appear to support changing this behaviour, or any - * of the obvious possibilities (turning off right margin - * wrapping, insert mode). - * - * This is irritating, most notably because it is impossible to - * write to the very bottom-right of the screen without - * scrolling. - * - * Flag the terminal here and apply some workarounds in other - * places to do the best possible. - */ - term->flags |= TERM_EARLYWRAP; - } -#endif } struct tty_term * @@ -323,6 +304,19 @@ tty_term_find(char *name, int fd, char **cause) if (strstr(name, "88col") != NULL) /* XXX HACK */ term->flags |= TERM_88COLOURS; + /* + * Terminals without xenl (eat newline glitch) wrap at at $COLUMNS - 1 + * rather than $COLUMNS (the cursor can never be beyond $COLUMNS - 1). + * + * This is irritating, most notably because it is impossible to write + * to the very bottom-right of the screen without scrolling. + * + * Flag the terminal here and apply some workarounds in other places to + * do the best possible. + */ + if (!tty_term_flag(term, TTYC_XENL)) + term->flags |= TERM_EARLYWRAP; + return (term); error: