Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Curses, Terminal Settings

Reply
Thread Tools

Curses, Terminal Settings

 
 
J Turner
Guest
Posts: n/a
 
      08-28-2003
Hello,

I'm playing with a python-based shell, which uses (guess what?) python as
it's scripting language, for iterative invocation, environment
variables, etc.

Everything was going well, until I moved beyond sys.readline() into
curses territory to flesh out the line-editing capabilities. Curses
always seems to get me.

The problem I'm having is described here:

I call the following things to get the terminal into a the state I want,
and then back out of it:

def _pysh_cursesInmode():
curses.noecho()
curses.raw()
stdscr.keypad(1)
stdscr.idlok(1)
stdscr.scrollok(1)
curses.nonl()

def _pysh_cursesOutmode():
curses.echo()
curses.noraw()
stdscr.keypad(0)
stdscr.idlok(0)
stdscr.scrollok(0)
curses.nl()

Then, if a line, or an `inline command`, is determined to be a program
invocation, the shell piggybacks onto bash for forking/exec ing, piping,
and all that jazz, with a 'bash -noprofile -c "cmd"'.

When I call out to bash, I obviously want the terminal back in a
non-curses state. I want to undo *all* the changes so that when bash,
ls, ps, etc, starts up, the terminal is in a sane state when they write
to stdout.

Despite calling the Outmode() function listed above, the terminal is not
in this state. Newlines don't return the output to position 0, though
they do advance down a line.

like
this

Here's a real example.

zsh:
(10:06:3jamwt/ % ls
LICENSE Maildir bin doc lists scrib vault
Mail att devel etc public tmp web
(10:06:3jamwt/ % ls

bash through python curses:
$ ls
LICENSE Maildir bin doc lists scrib vault
Mail att
devel etc public tmp web
$

.... and something like 'top' looks just terrible.

I really don't know what else to do besides undo the changes I've made!
That seems to be what I'm doing with the mode functions above.. what am
I missing?

This is the end of the problem description. Thanks.

Here's a look at the pre-curses shell:

(10:09:41)jamwt/ % pysh
$ ls
LICENSE Maildir bin doc lists scrib vault
Mail att devel etc public tmp web
$ for item in `ls`.split("\n"): print item[:3]
>

LIC
Mai
Mai
att
bin
dev
doc
etc
lis
pub
scr
tmp
vau
web

$ FOO = "bar"
$ import sys
$ BAR = sys.version
$ export FOO
$ export BAR
$ env
FTP_PASSIVE_MODE=YES

.... etc ..

BAR=2.3 (#1, Jul 31 2003, 00:45:11)
[GCC 2.95.4 20020320 [FreeBSD]]

.... etc ..

FOO=bar


- Jamie

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
v = vte.Terminal() AttributeError: 'module' object has no attribute 'Terminal' Steve Python 2 12-07-2010 05:48 PM
Settings.settings file with settings for multiple regions donet programmer ASP .Net 3 11-20-2009 03:05 PM
open a new terminal window from another terminal window in linux/unixsystem gaurav kashyap Python 3 10-31-2008 12:10 PM



Advertisments