curses for different terminals

H

harold fellermann

Hi all,

I want to use curses in a server application that provides a GUI for
telnet clients. Therefore, I need the functionality to open and handle
several
screens. Concerning
http://dickey.his.com/ncurses/ncurses-intro.html#init
this can be done using the function newterm(type,ofp,ifp). However, this
function seems not to be defined in the python library. Does anyone know
how this can be done in python?

cheers,

- harold -
 
C

Christos TZOTZIOY Georgiou

I want to use curses in a server application that provides a GUI for
telnet clients. Therefore, I need the functionality to open and handle
several
screens.

Just to make sure we understand what you want to do:

1. Are you doing an single process application that produces output on
many terminals? ie the program is kind of like a service?

2. Are you doing an application with one session per terminal? ie a
user starts your app in every terminal, no multi-term output from a
single process.

3. Are you doing an application that runs on one terminal but with many
"virtual" sessions (or screens), kind of like the `screen(1)` program or
the behaviour of the linux or Novell console?
Concerning
http://dickey.his.com/ncurses/ncurses-intro.html#init
this can be done using the function newterm(type,ofp,ifp). However, this
function seems not to be defined in the python library. Does anyone know
how this can be done in python?

Select one of the above, or describe more the desired situation if I
didn't cover your case, and we will try to help you more.
 
H

harold fellermann

Just to make sure we understand what you want to do:

1. Are you doing an single process application that produces output on
many terminals? ie the program is kind of like a service?

gotcha. I want to write a TCP server that handles incoming requests in
threads (one thread per request using SocketServer.ThreadingTCPServer).
Now, I want the server to use curses for client-server communication
(client will be telnet). Thus, my programm runs in a single process
(although several threads) and provides several curses screens (one for
each client.)
Select one of the above, or describe more the desired situation if I
didn't cover your case, and we will try to help you more.

great, thanks,

- harold -
 
C

Christos TZOTZIOY Georgiou

gotcha. I want to write a TCP server that handles incoming requests in
threads (one thread per request using SocketServer.ThreadingTCPServer).
Now, I want the server to use curses for client-server communication
(client will be telnet). Thus, my programm runs in a single process
(although several threads) and provides several curses screens (one for
each client.)

I see. At first, here is some relevant source from
Modules/_cursesmodule.c :

"""
A number of SysV or ncurses functions don't have wrappers yet; if you
need
a given function, add it and send a patch. Here's a list of currently
unsupported functions:

addchnstr addchstr chgat color_set define_key
del_curterm delscreen dupwin inchnstr inchstr innstr keyok
mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr
mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat
mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm
resizeterm restartterm ripoffline scr_dump
scr_init scr_restore scr_set scrl set_curterm set_term setterm
tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
vidattr vidputs waddchnstr waddchstr wchgat
wcolor_set winchnstr winchstr winnstr wmouse_trafo wscrl
"""

So the answer is that, no, you can't use newterm currently.

But even if you did, it's not certain that you could use multiterminal
ncurses in a multithreaded environment; AFAIK in ncurses you just change
the "current" term and then go on with normal curses calls; is there a
"current" term per thread, or is there one per process? I couldn't find
an answer in the short search I did.

I am afraid you will have to make it into a 3-tier arch; that is, your
server has the data model and absolutely no curses knowledge, and the
clients run a middle application, interfacing ncurses I/O and server
protocol.
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top