Solved

How to properly end curses-session in xterm.

Posted on 2006-11-27
3
357 Views
Last Modified: 2010-04-21
I run a console-app, written in curses, called trough Python from a terminal. This app. also calls some functions that show a Yes/No-dialog, DropDownbox, Edit-entry, all written in curses. All these functions run fine from within the app.

However, those functions also need to be called from a terminal. That's were things go wrong.

When calling either of these functions, for example  the YesNo-dialog, the entire screen gets blank, all text that is on the terminalscreen disappears, only my YesNo-dialog is present. When I leave the dialog, the screen with text reappears. But I would like to have the YesNo-dialog popup on top of the terminal-screen, so I can still see what's going on. Second thing that goes wrong is that, after that YesNo-dialog closes, the terminal doesn't recognize any linefeeds and tabs. When I want to print text  after calling the YesNo-dialog, all text gets wrapped up. I have to explicitly add a chr(13) to each item to have it nicely printed on the left side of the screen.
It looks like curses is initializing the total screen, taking over full controle, and, after ending, doesn't return correctly back to the terminal.

My Linux-version is Ubuntu Breezer.

These are my Init and InitOut-sections:
def Init():
    '''
    Initialize environment
    '''
    curses.initscr()
    curses.start_color()
    curses.init_pair(1, curses.COLOR_YELLOW, curses.COLOR_BLACK)
    curses.init_pair(2, curses.COLOR_WHITE, curses.COLOR_BLUE)
    curses.init_pair(3, curses.COLOR_WHITE, curses.COLOR_MAGENTA)
    curses.init_pair(4, curses.COLOR_RED, curses.COLOR_WHITE)
    curses.init_pair(5, curses.COLOR_BLACK, curses.COLOR_WHITE)

# Turn off echoing of keys, and enter cbreak mode,
# where no buffering is performed on keyboardinput
    curses.noecho() ; curses.cbreak() ; curses.curs_set(0) ;
    stdscr.keypad(False)

def InitOut():
    curses.nocbreak()
    curses.echo()
    curses.doupdate()
    curses.endwin()

Am I missing something ???

I can't use the Dialogs.py, because the whole app. has to be written in curses by ourselves.
0
Comment
Question by:vanmilp
3 Comments
 
LVL 34

Accepted Solution

by:
Duncan Roe earned 500 total points
ID: 18057787
This looks like the old problem of the init string for your terminal switching to the alternate screen and switching back on completion. Nowadays I use "less -X" to avoid the termcap init/deinit strings - you could do the same programmatically or do what I used to do: modify the xterm terminfo entry not to switch screens, but that was a long time ago and I've lost the details. You'll need to find out what is the command that does the switch (must be documented for an xterm somewhere but I could never find it) and become horribly familiar with:
  man terminfo
  man infocmp
  man tic
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to command 8 96
what does getent do 3 50
Error while installing rpm 1 83
bash file 10 37
Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question