Wednesday, June 2, 2010

Re: Formatting help files

On Jun 2, 11:46 am, Pablo Giménez <pablog...@gmail.com> wrote:
...[snip]...

>
> > Hmmm... That's very strange. Are you sure that the `hi Ignore
> > ctermfg=black' command is never executed? I'm wondering whether it's
> > possible that something else is changing the Ignore ctermfg setting after
> > the `hi Ignore' command... There are several ways you could check this. The
> > simplest is probably to run `:hi Ignore' at the command line, both just
> > before and just after changing the colorscheme, to see what happens to
> > ctermfg. Note that you can also set 'verbose' just before running
> > `:colorscheme' to see the exact sequence of commands that are executed.
> > (`set verbose=0' gets you out of verbose mode.)
>
> I have changed the autocommand to:
> augroup colorStarted
>     if !has("gui_running")
>         autocmd ColorScheme * hi Ignore ctermfg=0
>     endif
>     "autocmd ColorScheme * :Refresh
>     augroup END
>
> And running:
> :verbose hi Ignore
> Ignore         xxx ctermfg=0
>         Last set from /usr/share/vim/vim71/syntax/syncolor.vim
>
> Which I am not sure if it good or not.
> Thing is that when I change to another colorcheme now the funny chracters
> dissapear. I amtrying now with the zenburn color scheme.
> But the background color for the words with formatting is white rather than
> grey, which is the ciolor it should have.

Pablo,
I believe the background color for the words with formatting is a
result of using italic in a terminal that doesn't support it. If you
want to use italic in a color terminal, you should probably install
urxvt and be sure TERM is set to rxvt-unicode. I've verified that
italic displays properly in this terminal. There may be others that
support it, but I don't believe gnome-terminal or xterm do...

> Attached screenshot.
> I have also checked if I am using a 256 terminal:
> :echo &t_Co
> I got 256, so it should be all right.
>


>
> >  And because the command works from the command line I suppose the terminal
> >> color palette has black.
>
> > Actually, you won't get an error for a standard color name such as "black",
> > even if the color palette doesn't contain it. You would get an error only
> > for an unknown color name such as "somesillycolor".
>
> >> I have attached a screenshot which shows the same text in gvim, gnome-
> >> terminal, and below xterm and gnome-termnial color settings.
>
> >  Another problem seems to be the lack of italics support in my terminals
> >> both, gnome-terminal and xterm don't shpw italics characters.
> >> I have been googling a little but there aren't too much help for this. In
> >> the gnome-terminal the only setting related to font style is
> >> enable/disable
> >> bold fonts. How do you enable italics in your terminals.
> >> I am using Deja Vu Sans Mono as the font for gnome-terminal.
>
> > I seem to remember urxvt supporting italic, but it doesn't seem to be
> > working for me now. I'll investigate and get back with you...
>
> >> Finally as a temp workaround One thing I can do is to disable text
> >> formatting when a txtfmt file is opened in a non-gui environment and also
> >> if
> >> it would be possible delete the funny characters, but just in the buffer
> >> not
> >> in the file itself, it is possible?
>
> > Yes. Removing the characters in the buffer is fairly simple. Note that you
> > can run...
> > :ShowTokenMap
> > ...in a Txtfmt buffer to see which character codes are used for the various
> > formatting regions. (You should be aware that the range of characters used
> > is configurable.)
>
> > :help txtfmtTokrange
>
> > For a utf-8 encoding, the default range is 0xE000-0xE019. Thus, to get rid
> > of all tokens in a buffer, I could do something like this:
>
> > %s/[\ue000-\ue019]//g
>
> > Of course, you probably would want to implement with autocommands in such a
> > way that the original file cannot be modified by the person viewing it in a
> > color terminal. I'm thinking of a solution that involves  reading a copy of
> > the file into a readonly, "no file" buffer and then deleting the tokens.
> > Since a "no file" buffer is not associated with a file, there would be no
> > risk of the person viewing the file overwriting the original file containing
> > the tokens. I'll try to come up with a possible implementation and get back
> > with you after testing it...
>
> Autocommands usually have a pattern to attach them to a filetype.
> In my case I am setting the filetype using in my modeline ft=help,txtfmt.
> So how I can make an autocommand in this situation that only affects help
> files with txtfmt enabled? I am asking becouse the extension of these files
> is txt, so I can't assign this  extension to the autocommand.
> cheers
>

This is crude, but it represents one possible approach using filetype
rather than file extension...

fu! StripTxtfmtTokens()
if has('gui_running')
" Don't strip tokens for GUI
return
endif
" Create an empty buffer not associated with any file
new
set buftype=nofile
" Read the help.txtfmt file into the empty buffer
:r #
" Delete all Txtfmt tokens
silent! %s/[\ue000-\ue019]//g
" Set filetype to Vim help only
set ft=help
" Discard the original buffer
:bd #
endfu

augroup txtfmt
autocmd!
autocmd FileType help.txtfmt call StripTxtfmtTokens()
augroup END

Sincerely,
Brett Stahlman

...[snip]...

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: