• Home
  • Raw
  • Download

Lines Matching refs:curses

14    the :mod:`curses` extension module to control the display.
17 What is curses?
20 The curses library supplies a terminal-independent screen-painting and
35 The curses library hides all the details of different terminals, and provides
38 ways---adding text, erasing it, changing its appearance---and the curses library
42 The curses library was originally written for BSD Unix; the later System V
43 versions of Unix from AT&T added many enhancements and new functions. BSD curses
49 versions of curses carried by some proprietary Unixes may not support
52 No one has made a Windows port of the curses module. On a Windows platform, try
58 The Python curses module
62 curses; if you're already familiar with curses programming in C, it's really
68 This HOWTO is simply an introduction to writing text-mode programs with curses
69 and Python. It doesn't attempt to be a complete guide to the curses API; for
74 Starting and ending a curses application
77 Before doing anything, curses must be initialized. This is done by calling the
84 import curses
85 stdscr = curses.initscr()
87 Usually curses applications turn off automatic echoing of keys to the screen, in
91 curses.noecho()
97 curses.cbreak()
102 curses can do it for you, returning a special value such as
103 :const:`curses.KEY_LEFT`. To get curses to do the job, you'll have to enable
108 Terminating a curses application is much easier than starting one. You'll need
111 curses.nocbreak(); stdscr.keypad(0); curses.echo()
113 to reverse the curses-friendly terminal settings. Then call the :func:`endwin`
116 curses.endwin()
118 A common problem when debugging a curses application is to get your terminal
125 importing the :func:`curses.wrapper` function. It takes a callable and does
129 exceptions, performs curses deinitialization, and then passes the exception
136 Windows are the basic abstraction in curses. A window object represents a
148 win = curses.newwin(height, width, begin_y, begin_x)
150 A word about the coordinate system used in curses: coordinates are always passed
154 other computer applications, but it's been part of curses since it was first
158 show up on the display. This is because curses was originally written with slow
160 required to redraw the screen is very important. This lets curses accumulate
166 Accordingly, curses requires that you explicitly tell it to redraw windows,
168 really complicate programming with curses much. Most programs go into a flurry
181 pad = curses.newpad(100, 100)
188 except curses.error:
211 From a C programmer's point of view, curses may sometimes look like a twisty
247 displaying characters between 0 and 255. SVr4 curses provides constants for
262 older curses versions, there's a ``leaveok(bool)`` function. When *bool* is
263 true, the curses library will attempt to suppress the flashing cursor, and you
272 highlight certain words. curses supports this by allowing you to specify an
276 try to display text with multiple attribute bits set, but curses doesn't
301 curses.A_REVERSE)
304 The curses library also supports color on those terminals that provide it. The
310 :func:`curses.wrapper.wrapper` function does this automatically). Once that's
312 actually display color. (Note: curses uses the American spelling 'color',
317 The curses library maintains a finite number of color pairs, containing a
325 stdscr.addstr("Pretty text", curses.color_pair(1))
331 7:white. The curses module defines named constants for each of these colors:
332 :const:`curses.COLOR_BLACK`, :const:`curses.COLOR_RED`, and so forth.
341 curses.init_pair(1, curses.COLOR_RED, curses.COLOR_WHITE)
347 stdscr.addstr(0,0, "RED ALERT!", curses.color_pair(1))
361 The curses library itself offers only very simple input mechanisms. Python's
371 ``curses.ERR`` (a value of -1) when no input is ready. There's also a
374 delay (measured in tenths of a second), curses raises an exception.
379 value returned to constants such as :const:`curses.KEY_PPAGE`,
380 :const:`curses.KEY_HOME`, or :const:`curses.KEY_LEFT`. Usually the main loop of
389 elif c == curses.KEY_HOME:
392 The :mod:`curses.ascii` module supplies ASCII class membership functions that
396 and return the same type. For example, :func:`curses.ascii.ctrl` returns the
404 curses.echo() # Enable echoing of characters
409 The Python :mod:`curses.textpad` module supplies something better. With it, you
413 spaces. See the library documentation on :mod:`curses.textpad` for the
422 the curses modules is now pretty complete. You should browse it next.
425 points, consult the manual pages for your curses implementation, whether it's
430 Because the curses API is so large, some functions aren't supported in the