Bold/underlined/colors and ri

D

Dave Thomas

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
 
G

Gennady

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top