self.win.addch(ch)
except curses.error:
pass
- elif ch == ascii.SOH: # ^a
+ elif ch == ascii.SOH: # ^a
self.win.move(y, 0)
elif ch in (ascii.STX,curses.KEY_LEFT, ascii.BS,curses.KEY_BACKSPACE):
if x > 0:
self.win.move(y-1, self.maxx)
if ch in (ascii.BS, curses.KEY_BACKSPACE):
self.win.delch()
- elif ch == ascii.EOT: # ^d
+ elif ch == ascii.EOT: # ^d
self.win.delch()
- elif ch == ascii.ENQ: # ^e
+ elif ch == ascii.ENQ: # ^e
if self.stripspaces:
self.win.move(y, self._end_of_line(y))
else:
self.win.move(y, self.maxx)
- elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f
+ elif ch in (ascii.ACK, curses.KEY_RIGHT): # ^f
if x < self.maxx:
self.win.move(y, x+1)
elif y == self.maxy:
pass
else:
self.win.move(y+1, 0)
- elif ch == ascii.BEL: # ^g
+ elif ch == ascii.BEL: # ^g
return 0
- elif ch == ascii.NL: # ^j
+ elif ch == ascii.NL: # ^j
if self.maxy == 0:
return 0
elif y < self.maxy:
self.win.move(y+1, 0)
- elif ch == ascii.VT: # ^k
+ elif ch == ascii.VT: # ^k
if x == 0 and self._end_of_line(y) == 0:
self.win.deleteln()
else:
self.win.clrtoeol()
- elif ch == ascii.FF: # ^l
+ elif ch == ascii.FF: # ^l
self.win.refresh()
- elif ch in (ascii.SO, curses.KEY_DOWN): # ^n
+ elif ch in (ascii.SO, curses.KEY_DOWN): # ^n
if y < self.maxy:
self.win.move(y+1, x)
if x > self._end_of_line(y+1):
self.win.move(y+1, self._end_of_line(y+1))
- elif ch == ascii.SI: # ^o
+ elif ch == ascii.SI: # ^o
self.win.insertln()
- elif ch in (ascii.DLE, curses.KEY_UP): # ^p
+ elif ch in (ascii.DLE, curses.KEY_UP): # ^p
if y > 0:
self.win.move(y-1, x)
if x > self._end_of_line(y-1):
self.win.move(y-1, self._end_of_line(y-1))
return 1
-
+
def gather(self):
"Collect and return the contents of the window."
result = ""
as its first argument, followed by any other arguments passed to
wrapper().
"""
-
+
res = None
try:
- # Initialize curses
+ # Initialize curses
stdscr=curses.initscr()
-
- # Turn off echoing of keys, and enter cbreak mode,
- # where no buffering is performed on keyboard input
+
+ # Turn off echoing of keys, and enter cbreak mode,
+ # where no buffering is performed on keyboard input
curses.noecho()
curses.cbreak()
- # In keypad mode, escape sequences for special keys
- # (like the cursor keys) will be interpreted and
- # a special value like curses.KEY_LEFT will be returned
+ # In keypad mode, escape sequences for special keys
+ # (like the cursor keys) will be interpreted and
+ # a special value like curses.KEY_LEFT will be returned
stdscr.keypad(1)
# Start color, too. Harmless if the terminal doesn't have
res = apply(func, (stdscr,) + rest)
except:
- # In the event of an error, restore the terminal
- # to a sane state.
+ # In the event of an error, restore the terminal
+ # to a sane state.
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
curses.endwin()
-
+
# Pass the exception upwards
(exc_type, exc_value, exc_traceback) = sys.exc_info()
raise exc_type, exc_value, exc_traceback
else:
- # Set everything back to normal
+ # Set everything back to normal
stdscr.keypad(0)
curses.echo()
curses.nocbreak()
- curses.endwin() # Terminate curses
+ curses.endwin() # Terminate curses
return res
# of Python is only distributed with threads enabled.
#
# tested configurations:
-#
+#
# * EMX gcc 2.81/EMX 0.9d fix03
# created 2001/5/7, Andrew MacIntyre, from Rene Liebscher's cywinccompiler.py
shared_lib_format = "%s%s"
res_extension = ".res" # compiled resource file
exe_extension = ".exe"
-
+
def __init__ (self,
verbose=0,
dry_run=0,
"Python's pyconfig.h doesn't seem to support your compiler. " +
("Reason: %s." % details) +
"Compiling may fail because of undefined preprocessor macros.")
-
+
(self.gcc_version, self.ld_version) = \
get_versions()
self.debug_print(self.compiler_type + ": gcc %s, ld %s\n" %
- (self.gcc_version,
+ (self.gcc_version,
self.ld_version) )
# Hard-code GCC because that's what this is all about.
# want the gcc library statically linked (so that we don't have
# to distribute a version dependent on the compiler we have)
self.dll_libraries=["gcc"]
-
+
# __init__ ()
def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts):
self.spawn(["rc", "-r", src])
except DistutilsExecError, msg:
raise CompileError, msg
- else: # for other files use the C-compiler
+ else: # for other files use the C-compiler
try:
self.spawn(self.compiler_so + cc_args + [src, '-o', obj] +
extra_postargs)
extra_preargs=None,
extra_postargs=None,
build_temp=None):
-
+
# use separate copies, so we can modify the lists
extra_preargs = copy.copy(extra_preargs or [])
libraries = copy.copy(libraries or [])
objects = copy.copy(objects or [])
-
+
# Additional libraries
libraries.extend(self.dll_libraries)
(target_desc != self.EXECUTABLE)):
# (The linker doesn't do anything if output is up-to-date.
# So it would probably better to check if we really need this,
- # but for this we had to insert some unchanged parts of
- # UnixCCompiler, and this is not what we want.)
+ # but for this we had to insert some unchanged parts of
+ # UnixCCompiler, and this is not what we want.)
- # we want to put some files in the same directory as the
+ # we want to put some files in the same directory as the
# object files are, build_temp doesn't help much
# where are the object files
temp_dir = os.path.dirname(objects[0])
# generate the filenames for these files
def_file = os.path.join(temp_dir, dll_name + ".def")
-
+
# Generate .def file
contents = [
"LIBRARY %s INITINSTANCE TERMINSTANCE" % \
"writing %s" % def_file)
# next add options for def-file and to creating import libraries
- # for gcc/ld the def-file is specified as any other object files
+ # for gcc/ld the def-file is specified as any other object files
objects.append(def_file)
#end: if ((export_symbols is not None) and
# (target_desc != self.EXECUTABLE or self.linker_dll == "gcc")):
-
+
# who wants symbols and a many times larger output file
- # should explicitly switch the debug mode on
+ # should explicitly switch the debug mode on
# otherwise we let dllwrap/ld strip the output file
- # (On my machine: 10KB < stripped_file < ??100KB
+ # (On my machine: 10KB < stripped_file < ??100KB
# unstripped_file = stripped_file + XXX KB
- # ( XXX=254 for a typical python extension))
- if not debug:
- extra_preargs.append("-s")
-
+ # ( XXX=254 for a typical python extension))
+ if not debug:
+ extra_preargs.append("-s")
+
UnixCCompiler.link(self,
target_desc,
objects,
extra_preargs,
extra_postargs,
build_temp)
-
+
# link ()
# -- Miscellaneous methods -----------------------------------------
base = os.path.basename (base)
if ext == '.rc':
# these need to be compiled to object files
- obj_names.append (os.path.join (output_dir,
+ obj_names.append (os.path.join (output_dir,
base + self.res_extension))
else:
obj_names.append (os.path.join (output_dir,
emx_dirs = os.environ['LIBRARY_PATH'].split(';')
except KeyError:
emx_dirs = []
-
+
for dir in dirs + emx_dirs:
shortlibp = os.path.join(dir, shortlib)
longlibp = os.path.join(dir, longlib)
return shortlibp
elif os.path.exists(longlibp):
return longlibp
-
+
# Oops, didn't find it in *any* of 'dirs'
return None
# GCC, and the pyconfig.h file should be OK
if string.find(sys.version,"GCC") >= 0:
return (CONFIG_H_OK, "sys.version mentions 'GCC'")
-
+
fn = sysconfig.get_config_h_filename()
try:
# It would probably better to read single lines to search.
- # But we do this only once, and it is fast enough
+ # But we do this only once, and it is fast enough
f = open(fn)
s = f.read()
f.close()
-
+
except IOError, exc:
# if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing
from distutils.version import StrictVersion
from distutils.spawn import find_executable
import re
-
+
gcc_exe = find_executable('gcc')
if gcc_exe:
out = os.popen(gcc_exe + ' -dumpversion','r')
# anyway - so we can link OMF DLLs
ld_version = None
return (gcc_version, ld_version)
-