On Dec 20, 2003, at 19:51, Dave Thomas wrote: > Folks: > > It's always bugged me that 'ri'' throws away a fair amount of > font-related stuff when it outputs to a terminal. In the new ri, I'd > like to be able to keep it. However, that leaves me with a couple of > (apparent) problems: > > 1. I'd like to use the terminfo low-level methods in curses to get the > strings to use to (for example) embolden strings, but the standard > Ruby curses library doesn't seem to implement these. > > 2. Even if I assume ANSI-style escape sequences, getting these to pass > transparently through a pager program seems to be system-dependent. > > Ideally, I'd like to be able to have a nicely configurable output that > used colors and/or bold/underlining to add information to the ri > output. I'd like it to be paged too. > > Anyone got any ideas? > > > Cheers > > Dave > > > You can use the same approach as man does: it relies on a pager's ability to do highlighting and underlining when a backspace character is used. If you do, for example, "man man > man.txt" and then "vi man.txt", you would notice a bunch of backspace characters. If man wants to highlight "NAME", it outputs it as "N^HNA^HAM^HME^HE". The same approach is used for underlining (I am not sure whether other font styles are also supported). Pagers can use this information to do actual highlighting/underlining depending on a terminal currently in use. A benefit of such approach, among others, is that even if you redirect the output to a file, it is easy to get rid of "font styles" with a simple search-and-replace" command in vi. With using escape sequences it will not be that trivial. Sincerely, Gennady Bystritsky