Hi

I think it would be better if this only uses sitm if it exists and uses smso if
it does not.

Cheers


On Fri, Apr 08, 2011 at 03:19:06PM -0300, Tiago Resende wrote:
> Hey, guys.
> 
> I'm trying to get italics working under tmux (cvs), especially for
> editing html files in vim. I use rxvt-unicode as my main terminal and it
> supports italics through its [ANSI escape code][1] (scroll down to SGR
> parameters):
> 
> ] Code        Effect
> ] ----------------
> ] 3   Italic: on
> 
> [1]: http://en.wikipedia.org/wiki/ANSI_escape_code
> 
> When italics are requested, tmux, like screen, uses standout mode
> instead. Here's a [very informative discussion][2] on this same issue on
> screen.
> 
> [2]: 
> http://old.nabble.com/Italic-text-with-screen-inside-urxvt-and-some-termcap-questions-td19616085.html
> 
> ]] In the screen manual 'Standout' have a '(ANSI: Italicized)' what is
> ]] that is supposed to mean?
> 
> ] It means that what Screen uses for standout mode, ANSI (and rxvt) uses
> ] for italics mode. I don't know why this is the case, but the fact that
> ] it is means that making screen support italics would be a PITA.
> 
> ] If we make screen use \033[3m for italics (instead of its current use
> ] for standout), and \033[7m for standout (ANSI's "negative image"), then
> ] all pre-existing termcap/terminfo definitions for screen will be wrong,
> ] and users will have to be especially careful not to use newer versions
> ] of screen with older termcap/terminfo definitions for screen. 
> 
> This means tmux and screen will escape things as standout when asked for
> italics, which will prompt terminals (urxvt included) to render the text
> in reverse video.
> 
> To correct this behavior, I added italics to the list of modes supported
> by tmux, and redirected the italics attribute to it, instead of
> standout (see attached patch; codes can be found in terminfo(5)). With
> this change, I can already output actual italics in the status line. On
> terminals that do not support italics, the text just shows up as regular
> text (which I guess is the expected behavior, from trying lots of other
> unsupported modes).
> 
> Programs (like vim) requesting italics still get standout, though,
> because of screen's terminfo, which lists :so=\E[3m:ZH=\E[7m:, so I
> added to vimrc, as a workaround (note I use default-terminal =
> screen-256color instead of screen):
> 
>       if $TERM =~ 'screen-256color'
>               " WARNING: ^[ must be entered as <c-v><c-[>
>               set t_so=^[[7m
>               set t_ZH=^[[3m
>       endif
> 
> A permanent fix would require me to build my own terminfo file for tmux,
> but first I wanted to know what you guys think of this kind of solution.
> Are there side-effects I didn't think of? How can I improve it? Should I
> go ahead and submit a feature request?

> diff -Ndur tmux-orig/tmux.h tmux/tmux.h
> --- tmux-orig/tmux.h  2011-04-06 19:29:26.000000000 -0300
> +++ tmux/tmux.h       2011-04-08 13:36:30.012264728 -0300
> @@ -319,6 +319,7 @@
>       TTYC_SMKX,      /* keypad_xmit, ks */
>       TTYC_SMSO,      /* enter_standout_mode, so */
>       TTYC_SMUL,      /* enter_underline_mode, us */
> +     TTYC_SITM,      /* enter_italics_mode, ZH */
>       TTYC_VPA,       /* row_address, cv */
>       TTYC_XENL,      /* eat_newline_glitch, xn */
>  };
> diff -Ndur tmux-orig/tty.c tmux/tty.c
> --- tmux-orig/tty.c   2011-04-06 19:18:05.000000000 -0300
> +++ tmux/tty.c        2011-04-08 13:31:16.453699919 -0300
> @@ -1218,7 +1218,7 @@
>       if (changed & GRID_ATTR_DIM)
>               tty_putcode(tty, TTYC_DIM);
>       if (changed & GRID_ATTR_ITALICS)
> -             tty_putcode(tty, TTYC_SMSO);
> +             tty_putcode(tty, TTYC_SITM);
>       if (changed & GRID_ATTR_UNDERSCORE)
>               tty_putcode(tty, TTYC_SMUL);
>       if (changed & GRID_ATTR_BLINK)
> diff -Ndur tmux-orig/tty-term.c tmux/tty-term.c
> --- tmux-orig/tty-term.c      2011-02-15 13:12:28.000000000 -0200
> +++ tmux/tty-term.c   2011-04-08 13:30:59.460904566 -0300
> @@ -181,6 +181,7 @@
>       { TTYC_SMKX, TTYCODE_STRING, "smkx" },
>       { TTYC_SMSO, TTYCODE_STRING, "smso" },
>       { TTYC_SMUL, TTYCODE_STRING, "smul" },
> +     { TTYC_SITM, TTYCODE_STRING, "sitm" },
>       { TTYC_VPA, TTYCODE_STRING, "vpa" },
>       { TTYC_XENL, TTYCODE_FLAG, "xenl" },
>  };

> ------------------------------------------------------------------------------
> Xperia(TM) PLAY
> It's a major breakthrough. An authentic gaming
> smartphone on the nation's most reliable network.
> And it wants your games.
> http://p.sf.net/sfu/verizon-sfdev

> _______________________________________________
> tmux-users mailing list
> tmux-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/tmux-users


------------------------------------------------------------------------------
Xperia(TM) PLAY
It's a major breakthrough. An authentic gaming
smartphone on the nation's most reliable network.
And it wants your games.
http://p.sf.net/sfu/verizon-sfdev
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to