Losing curses decorations.

Discussion in 'Python' started by Joe Keen, Oct 8, 2008.

  1. Joe Keen

    Joe Keen Guest

    I'm working on a small curses application that opens an external
    editor occasionally; in the current case I'm testing its running vi.
    Once I exit vi and return to the curses application I lose the
    background color, window frames, and any text I had on the screen
    before I opened vi. I can still see the program functioning though as
    it is still responding to key strokes and still updating small
    portions of the screen. I'm obviously doing something wrong but so
    far I haven't been able to figure out what from the documentation.

    I've boiled the problem I'm seeing down to a relatively small program:

    import curses
    import os

    def vitest():
    os.system('vi /tmp/foo_bar_baz');
    return 1

    def quit():
    return 0

    def nocommand():
    return 1

    command_table = { 'a' : vitest,
    'q' : quit}

    def refresh():
    screen.refresh()

    def keyhandler():
    key = screen.getkey()
    result = command_table.get(key,nocommand)()
    screen.addstr(1,1,"Got: "+key)
    return result

    def main(stdscr):
    global navigation, text, screen
    screen = stdscr
    screen.border()
    screen.addstr(0,1," Test Window ")

    refresh()

    while keyhandler():
    refresh()

    curses.wrapper(main)
    Joe Keen, Oct 8, 2008
    #1
    1. Advertising

  2. Joe Keen

    Joe Keen Guest

    On Oct 8, 1:16 am, Peter Otten <> wrote:
    > Joe Keen wrote:
    > > I'm working on a small curses application that opens an external
    > > editor occasionally; in the current case I'm testing its running vi.
    > > Once I exit vi and return to the curses application I lose the
    > > background color, window frames, and any text I had on the screen
    > > before I opened vi. I can still see the program functioning though as
    > > it is still responding to key strokes and still updating small
    > > portions of the screen. I'm obviously doing something wrong but so
    > > far I haven't been able to figure out what from the documentation.

    >
    > > I've boiled the problem I'm seeing down to a relatively small program:

    >
    > Does redrawing
    >
    > > def vitest():
    > > os.system('vi /tmp/foo_bar_baz');

    >
    > screen.redrawwin()
    > screen.refresh()
    >
    > > return 1

    >
    > help?
    >
    > Peter


    It helps a little bit. Using that the line I modified with
    screen.addstr(1,1,"Got: "+key) now has the proper background color and
    the window decorations on the far ends. Only that line does though.
    My understanding is that curses is going to try and redraw as little
    as possible. Is there a function to force a full redraw? Or is that
    redrawwin function supposed to be doing that?
    Joe Keen, Oct 8, 2008
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Skeleton Man

    curses and color

    Skeleton Man, May 25, 2004, in forum: Perl
    Replies:
    0
    Views:
    611
    Skeleton Man
    May 25, 2004
  2. Michael J. Barillier

    Curses chgat

    Michael J. Barillier, Sep 12, 2004, in forum: Perl
    Replies:
    0
    Views:
    671
    Michael J. Barillier
    Sep 12, 2004
  3. M.Senthil Kumar

    Boxline in curses ( Linux )

    M.Senthil Kumar, Feb 21, 2004, in forum: C Programming
    Replies:
    7
    Views:
    770
    Richard Bos
    Feb 23, 2004
  4. Jean-Paul Calderone
    Replies:
    2
    Views:
    423
    Joel Hedlund
    Feb 9, 2006
  5. Jason C
    Replies:
    4
    Views:
    673
    Morty Abzug
    Jun 26, 2012
Loading...

Share This Page