1 # Copyright 2000-2004 Michael Hudson mwh@python.net
6 # Permission to use, copy, modify, and distribute this software and
7 # its documentation for any purpose is hereby granted without fee,
8 # provided that the above copyright notice appear in all copies and
9 # that both that copyright notice and this permission notice appear in
10 # supporting documentation.
12 # THE AUTHOR MICHAEL HUDSON DISCLAIMS ALL WARRANTIES WITH REGARD TO
13 # THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
14 # AND FITNESS, IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL,
15 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
16 # RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
17 # CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
18 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 def __init__(self
, tuples
):
24 self
.iflag
, self
.oflag
, self
.cflag
, self
.lflag
, \
25 self
.ispeed
, self
.ospeed
, self
.cc
= tuples
27 return [self
.iflag
, self
.oflag
, self
.cflag
, self
.lflag
,
28 self
.ispeed
, self
.ospeed
, self
.cc
]
31 return self
.__class
__(self
.as_list())
34 return TermState(termios
.tcgetattr(fd
))
36 def tcsetattr(fd
, when
, attrs
):
37 termios
.tcsetattr(fd
, when
, attrs
.as_list())
39 class Term(TermState
):
40 TS__init__
= TermState
.__init
__
41 def __init__(self
, fd
=0):
42 self
.TS__init__(termios
.tcgetattr(fd
))
46 self
.stack
.append( self
.as_list() )
47 def set(self
, when
=termios
.TCSANOW
):
48 termios
.tcsetattr(self
.fd
, when
, self
.as_list())
50 self
.TS__init__(self
.stack
.pop())