Question about terminfo - Unix

This is a discussion on Question about terminfo - Unix ; The terminfo man page has entries for "end italic" or "end standout" but it doesn't have entries for "end reverse" or "end bold" although it has entries for "start reverse" or "start bold". Does anyone know why this is ? ...

+ Reply to Thread
Results 1 to 14 of 14

Thread: Question about terminfo

  1. Question about terminfo

    The terminfo man page has entries for "end italic" or
    "end standout" but it doesn't have entries for "end reverse"
    or "end bold" although it has entries for "start reverse"
    or "start bold". Does anyone know why this is ?

    If you have a programme which needs to start reverse,
    print some things and then return the terminal to its
    previous state without affecting any other attributes
    apart from reverse , is there a way to do it ? I'm interested
    for an answer both with shell and with C.


  2. Re: Question about terminfo

    Spiros Bousbouras wrote:
    > The terminfo man page has entries for "end italic" or
    > "end standout" but it doesn't have entries for "end reverse"
    > or "end bold" although it has entries for "start reverse"
    > or "start bold". Does anyone know why this is ?
    >
    > If you have a programme which needs to start reverse,
    > print some things and then return the terminal to its
    > previous state without affecting any other attributes
    > apart from reverse , is there a way to do it ? I'm interested
    > for an answer both with shell and with C.


    Check your terminal description. You may find that "reverse" is
    the same as "standout" (though the terminfo man page says standout
    is reverse + bold). If that's the case, then using "rmso" may work
    for "reverse".

    If you don't want to assume standout and reverse are the same, it
    looks like you'll have to use "sgr". For instance, if you do:

    tput rev
    tput bold

    you can then do:

    tput sgr 0 0 0 0 0 1 0 0

    to turn off reverse and leave bold, or:

    tput sgr 0 0 1 0 0 0 0 0

    to turn off bold and leave reverse. Check the terminfo man page
    where it discusses "sgr" for the details.

  3. Re: Question about terminfo

    On 14 Sep, 16:36, Brian Bebeau wrote:
    > Spiros Bousbouras wrote:
    > > The terminfo man page has entries for "end italic" or
    > > "end standout" but it doesn't have entries for "end reverse"
    > > or "end bold" although it has entries for "start reverse"
    > > or "start bold". Does anyone know why this is ?

    >
    > > If you have a programme which needs to start reverse,
    > > print some things and then return the terminal to its
    > > previous state without affecting any other attributes
    > > apart from reverse , is there a way to do it ? I'm interested
    > > for an answer both with shell and with C.

    >
    > Check your terminal description. You may find that "reverse" is
    > the same as "standout" (though the terminfo man page says standout
    > is reverse + bold). If that's the case, then using "rmso" may work
    > for "reverse".


    The idea is to make it portable between different terminals (or
    emulators).

    >
    > If you don't want to assume standout and reverse are the same, it
    > looks like you'll have to use "sgr". For instance, if you do:
    >
    > tput rev
    > tput bold
    >
    > you can then do:
    >
    > tput sgr 0 0 0 0 0 1 0 0
    >
    > to turn off reverse and leave bold, or:
    >
    > tput sgr 0 0 1 0 0 0 0 0
    >
    > to turn off bold and leave reverse. Check the terminfo man page
    > where it discusses "sgr" for the details.


    The problem is that I don't know whether, before my programme/script
    starts, bold was on. The point is that if it was on I want to leave it
    on and
    if it was off I want to leave it off. Same for the other attributes
    apart from
    reverse. So is there a way to get that information ?



  4. Re: Question about terminfo

    2007-09-14, 08:53(-07), Spiros Bousbouras:
    [...]
    > The problem is that I don't know whether, before my programme/script
    > starts, bold was on. The point is that if it was on I want to leave it
    > on and
    > if it was off I want to leave it off. Same for the other attributes
    > apart from
    > reverse. So is there a way to get that information ?

    [...]

    There is no guarantee that for instance smso or rmso will start
    or stop bold mode, as you can read in ncurses' terminfo man
    page.

    Try for instance:
    tput bold; tput smso; tput rmso; echo "in bold?"
    on a variety of terminals. You'll see that many will not display
    it in bold.

    So even if there were a rmrev, there wouldn't be such guarantee
    either.

    In other words, the safest you can do is use sgr/sgr0 as
    that way you are in control of what is currently enabled.

    --
    Stéphane

  5. Re: Question about terminfo

    On 14 Sep, 16:59, Stephane CHAZELAS wrote:
    > 2007-09-14, 08:53(-07), Spiros Bousbouras:
    > [...]> The problem is that I don't know whether, before my programme/script
    > > starts, bold was on. The point is that if it was on I want to leave it
    > > on and
    > > if it was off I want to leave it off. Same for the other attributes
    > > apart from
    > > reverse. So is there a way to get that information ?

    >
    > [...]
    >
    > There is no guarantee that for instance smso or rmso will start
    > or stop bold mode, as you can read in ncurses' terminfo man
    > page.
    >
    > Try for instance:
    > tput bold; tput smso; tput rmso; echo "in bold?"
    > on a variety of terminals. You'll see that many will not display
    > it in bold.


    If standout is the same as bold you wouldn't expect it to display it
    in bold. But I don't understand your point or how it is related to my
    question.

    > So even if there were a rmrev, there wouldn't be such guarantee
    > either.


    What guarantee ?

    > In other words, the safest you can do is use sgr/sgr0 as
    > that way you are in control of what is currently enabled.


    So you're saying that I can't get the information I want in a standard
    manner. Out of curiosity are there any terminals/emulators which
    can be made to return such information ?




  6. Re: Question about terminfo

    On Sep 14, 11:18 am, Spiros Bousbouras wrote:
    > On 14 Sep, 16:59, Stephane CHAZELAS wrote:
    >
    >
    >
    > > 2007-09-14, 08:53(-07), Spiros Bousbouras:
    > > [...]> The problem is that I don't know whether, before my programme/script
    > > > starts, bold was on. The point is that if it was on I want to leave it
    > > > on and
    > > > if it was off I want to leave it off. Same for the other attributes
    > > > apart from
    > > > reverse. So is there a way to get that information ?

    >
    > > [...]

    >
    > > There is no guarantee that for instance smso or rmso will start
    > > or stop bold mode, as you can read in ncurses' terminfo man
    > > page.

    >
    > > Try for instance:
    > > tput bold; tput smso; tput rmso; echo "in bold?"
    > > on a variety of terminals. You'll see that many will not display
    > > it in bold.

    >
    > If standout is the same as bold you wouldn't expect it to display it
    > in bold. But I don't understand your point or how it is related to my
    > question.
    >
    > > So even if there were a rmrev, there wouldn't be such guarantee
    > > either.

    >
    > What guarantee ?
    >
    > > In other words, the safest you can do is use sgr/sgr0 as
    > > that way you are in control of what is currently enabled.

    >
    > So you're saying that I can't get the information I want in a standard
    > manner. Out of curiosity are there any terminals/emulators which
    > can be made to return such information ?


    I'm not sure if this is what you want. I tried to test it, but ran out
    of time...

    Will the Ansi Terminal Control sequences help you?

    These two operations sounded like they may help you:
    Save Cursor & Attrs 7

    * Save current cursor position.

    Restore Cursor & Attrs 8

    * Restores cursor position after a Save Cursor.

    Copied from:
    http://www.termsys.demon.co.uk/vtansi.htm

    Miles


  7. Re: Question about terminfo


    "Spiros Bousbouras" wrote in message
    news:1189786729.711553.68730@d55g2000hsg.googlegro ups.com...
    > On 14 Sep, 16:59, Stephane CHAZELAS wrote:
    > > 2007-09-14, 08:53(-07), Spiros Bousbouras:
    > > [...]> The problem is that I don't know whether, before my

    programme/script
    > > > starts, bold was on. The point is that if it was on I want to leave it
    > > > on and
    > > > if it was off I want to leave it off. Same for the other attributes
    > > > apart from
    > > > reverse. So is there a way to get that information ?

    > >
    > > [...]
    > >
    > > There is no guarantee that for instance smso or rmso will start
    > > or stop bold mode, as you can read in ncurses' terminfo man
    > > page.
    > >
    > > Try for instance:
    > > tput bold; tput smso; tput rmso; echo "in bold?"
    > > on a variety of terminals. You'll see that many will not display
    > > it in bold.

    >
    > If standout is the same as bold you wouldn't expect it to display it
    > in bold. But I don't understand your point or how it is related to my
    > question.
    >
    > > So even if there were a rmrev, there wouldn't be such guarantee
    > > either.

    >
    > What guarantee ?
    >
    > > In other words, the safest you can do is use sgr/sgr0 as
    > > that way you are in control of what is currently enabled.

    >
    > So you're saying that I can't get the information I want in a standard
    > manner. Out of curiosity are there any terminals/emulators which
    > can be made to return such information ?
    >
    >
    >


    Mr. Spiros:

    Time for thinking instead of the easy way out.

    First, terminal programming, terminfo, termcaps, every UNIX
    OS, and every terminal is a big area of "learning". The means
    if you want to find gold and diamonds, then you have to do
    whatever it takes to dig your way to them. Ask me where my
    gold mine is and see if I tell you ! Ask me how to find gold
    and I will tell you to dig for it.

    When I read your question, I saw that you are looking for the
    easy way out, wanting someone to give you answers without
    you doing much if anything. So, next, I suppose that you will
    want someone to give you the program to make this work on
    every terminal without you lifting a finger.

    In the folks of today, that is what I see as in your words, the
    "standard manner" of learning.

    Doesn't work that way. You will need to test for each OS and
    each terminal type, then do terminfo setup for each. If you
    want your program to be portable, you, not us, must make it
    portable. If you want it to work with BubbaJohn's little
    terminal, then you need to read BubbaJohn's documentation.
    By the way, that documentation won't just fall into your lap.

    Of the thousands of terminals, some have no graphic character
    sets; others have 4 or 5. Read the manual on the terminal that
    you are using, then you can program it. Don't tell it to do
    bold when there is no graphic set that supports it. The same
    with blink, bells, and whistles. Hold fast to the idea that
    everyone does it their own way, including BubbaJohn.

    Remember these points:

    1. Terminal programming is a big area that requires knowing.
    2. The data displayed in bold in only that small portion of
    the display memory. Not the way it was; just a small area.

    Then try these for the rest of your life:

    1. There is no substitute for knowledge.
    2. It is all easy if you know how.
    3. Don't bite the hand that feeds you.
    4. Then there is that honey and vinegar thing.

    Old Man



  8. Re: Question about terminfo

    2007-09-14, 09:18(-07), Spiros Bousbouras:
    > On 14 Sep, 16:59, Stephane CHAZELAS wrote:
    >> 2007-09-14, 08:53(-07), Spiros Bousbouras:
    >> [...]> The problem is that I don't know whether, before my programme/script
    >> > starts, bold was on. The point is that if it was on I want to leave it
    >> > on and
    >> > if it was off I want to leave it off. Same for the other attributes
    >> > apart from
    >> > reverse. So is there a way to get that information ?

    >>
    >> [...]
    >>
    >> There is no guarantee that for instance smso or rmso will start
    >> or stop bold mode, as you can read in ncurses' terminfo man
    >> page.
    >>
    >> Try for instance:
    >> tput bold; tput smso; tput rmso; echo "in bold?"
    >> on a variety of terminals. You'll see that many will not display
    >> it in bold.

    >
    > If standout is the same as bold you wouldn't expect it to display it
    > in bold. But I don't understand your point or how it is related to my
    > question.


    What I'm saying is that setting or resetting one attribute may
    very well reset another attribute. I picked stand-out and bold
    as an example of two such attributes above.

    --
    Stéphane

  9. Re: Question about terminfo

    On 14 Sep, 17:25, Miles wrote:
    > > > 2007-09-14, 08:53(-07), Spiros Bousbouras:
    > > > [...]> The problem is that I don't know whether, before my programme/script
    > > > > starts, bold was on. The point is that if it was on I want to leave it
    > > > > on and
    > > > > if it was off I want to leave it off. Same for the other attributes
    > > > > apart from
    > > > > reverse. So is there a way to get that information ?

    > Will the Ansi Terminal Control sequences help you?
    >
    > These two operations sounded like they may help you:
    > Save Cursor & Attrs 7
    >
    > * Save current cursor position.
    >
    > Restore Cursor & Attrs 8
    >
    > * Restores cursor position after a Save Cursor.
    >
    > Copied from:http://www.termsys.demon.co.uk/vtansi.htm


    This is the kind of thing I'm looking for but does anyone
    know how portable they are ? I would imagine they're less
    portable than terminfo.

    They are mentioned in the Linux console_codes man page
    in the section "ESC- but not CSI- sequences". On xterm
    and Linux console they restore cursor position and attributes,
    on gnome-terminal just cursor position.


  10. Re: Question about terminfo

    2007-09-15, 07:44(-07), Spiros Bousbouras:
    [...]
    >> These two operations sounded like they may help you:
    >> Save Cursor & Attrs 7
    >>
    >> * Save current cursor position.
    >>
    >> Restore Cursor & Attrs 8
    >>
    >> * Restores cursor position after a Save Cursor.
    >>
    >> Copied from:http://www.termsys.demon.co.uk/vtansi.htm

    >
    > This is the kind of thing I'm looking for but does anyone
    > know how portable they are ? I would imagine they're less
    > portable than terminfo.

    [...]

    They've got a terminfo capability associated with them: sc and
    rc. As you found out, restoring the attributes looks more like a
    side effect.

    If you want to restore the screen to what it was before, you can
    use the alternate screen if available.

    What if you explained what you really want to do?

    My view is that managing terminal attributes is a portability
    nightmare, so I would tend to use existing libraries to do
    anything fancy like ncurses, slang, cdk... and go for the
    simplest possible.

    --
    Stéphane

  11. Re: Question about terminfo

    >> * Restores cursor position after a Save Cursor.
    >>
    >> Copied from:http://www.termsys.demon.co.uk/vtansi.htm


    hmm (that page intermixes ANSI and VT100 without noting that they're
    not synonymous).

    better:

    http://vt100.net/

    e.g.,

    http://vt100.net/docs/vt102-ug/chapter5.html#S5.5.2

    "Saves cursor position, character attribute (graphic rendition),
    character set, and origin mode selection. (See restore cursor)"

    > This is the kind of thing I'm looking for but does anyone
    > know how portable they are ? I would imagine they're less
    > portable than terminfo.


    > They are mentioned in the Linux console_codes man page
    > in the section "ESC- but not CSI- sequences". On xterm
    > and Linux console they restore cursor position and attributes,
    > on gnome-terminal just cursor position.


    On any terminal that emulates vt100, they should restore the video attributes
    as well (but many terminal emulators claim to emulate vt100... ;-)

    --
    Thomas E. Dickey
    http://invisible-island.net
    ftp://invisible-island.net

  12. Re: Question about terminfo

    Thomas Dickey writes:

    > >> * Restores cursor position after a Save Cursor.
    > >>
    > >> Copied from:http://www.termsys.demon.co.uk/vtansi.htm

    >
    > hmm (that page intermixes ANSI and VT100 without noting that they're
    > not synonymous).
    >
    > better:
    >
    > http://vt100.net/
    >
    > e.g.,
    >
    > http://vt100.net/docs/vt102-ug/chapter5.html#S5.5.2
    >
    > "Saves cursor position, character attribute (graphic rendition),
    > character set, and origin mode selection. (See restore cursor)"
    >
    > > This is the kind of thing I'm looking for but does anyone
    > > know how portable they are ? I would imagine they're less
    > > portable than terminfo.


    As someone who remembers ADM and VT52 terminals (and ASR-33, TI Silent
    700, etc.), termcap/terminfo was AFAIK designed to support ANY
    terminal. It's the entry for the terminal that matters most. And if it
    didn't, we used to extract the part that described the terminal, and
    put it in a file, and set the environment variable to point to the
    file (because we didn't have permission to exit the database directly).

    Then we'd edit it until things worked properly.

    Many terminal emulators tried to emulate VT100's. There's a program
    called vttest that determines how accutrately your terminal did the
    emulation.

    So it there's a problem, you can either change the terminfo database
    to match the terminal you had, or you changed your terminal.

    If you wanted to make your applicaiton as portable as possiible, use
    the terminfo database. But test it with different types of terminals.
    I also remember a program called vtem, which used termcap/terminfo to
    emulate the actions of a vt102 terminals.



  13. Re: Question about terminfo

    On Sep 15, 4:34 pm, Stephane CHAZELAS wrote:
    > 2007-09-15, 07:44(-07), Spiros Bousbouras:
    > [...]>> These two operations sounded like they may help you:
    > >> Save Cursor & Attrs 7

    >
    > >> * Save current cursor position.

    >
    > >> Restore Cursor & Attrs 8

    >
    > >> * Restores cursor position after a Save Cursor.

    >
    > >> Copied from:http://www.termsys.demon.co.uk/vtansi.htm

    >
    > > This is the kind of thing I'm looking for but does anyone
    > > know how portable they are ? I would imagine they're less
    > > portable than terminfo.

    >
    > [...]
    >
    > They've got a terminfo capability associated with them: sc and
    > rc. As you found out, restoring the attributes looks more like a
    > side effect.


    The terminfo man page says that sc and rc save and restore
    respectively
    cursor position ; it doesn't say anything about attributes. On the
    other hand
    the console_codes man page when discussing 7 and 8 says
    that they also deal with attributes. So they don't look analogous to
    me.
    >
    > If you want to restore the screen to what it was before, you can
    > use the alternate screen if available.
    >
    > What if you explained what you really want to do?


    I thought that I did that in my first post but here goes again. I have
    a
    script which is supposed to print some things in normal and some
    things in reverse for emphasis. But ideally I would like for my script
    to
    leave after it finishes the terminal attributes as they were before my
    script
    started. If for example the user who uses my script likes to have bold
    on
    all the time and runs my script , then I want bold to remain on after
    my
    script finishes rather than force the user to turn it back on
    manually. So
    doing for example ``tput sgr0" at the end of my script won't do.

    > My view is that managing terminal attributes is a portability
    > nightmare, so I would tend to use existing libraries to do
    > anything fancy like ncurses, slang, cdk... and go for the
    > simplest possible.


    I wouldn't consider what I'm trying to do fancy. (n)curses won't do
    because it doesn't tell you what the terminal attributes were before
    you call the initialisation function for curses (can't remember what
    it's called).


  14. Re: Question about terminfo

    2007-09-18, 13:13(-00), Spiros Bousbouras:
    [...]
    > I thought that I did that in my first post but here goes
    > again. I have a script which is supposed to print some things
    > in normal and some things in reverse for emphasis. But ideally
    > I would like for my script to leave after it finishes the
    > terminal attributes as they were before my script started. If
    > for example the user who uses my script likes to have bold on
    > all the time and runs my script , then I want bold to remain
    > on after my script finishes rather than force the user to turn
    > it back on manually. So doing for example ``tput sgr0" at the
    > end of my script won't do.

    [...]

    I wouldn't bother. No visual application does that as far as I
    can see.

    So, if such basic applications as vi or less don't do it, users
    should expect that any command they run, especially visual ones
    may reset the attributes.

    shells like zsh or fish even reset the attributes (sgr0) before
    each prompt.

    --
    Stéphane

+ Reply to Thread