]> granicus.if.org Git - python/commitdiff
Make magic coordinates more readable
authorAndrew M. Kuchling <amk@amk.ca>
Tue, 19 Oct 2004 19:21:20 +0000 (19:21 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Tue, 19 Oct 2004 19:21:20 +0000 (19:21 +0000)
Lib/curses/textpad.py

index bfc270addb6e2982dd2584740881b3bd433549b4..cd4813bdfe0d91a81be63b8494133783fed46ee5 100644 (file)
@@ -3,7 +3,9 @@
 import curses, ascii
 
 def rectangle(win, uly, ulx, lry, lrx):
-    "Draw a rectangle."
+    """Draw a rectangle with corners at the provided upper-left
+    and lower-right coordinates.
+    """
     win.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1)
     win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1)
     win.hline(lry, ulx+1, curses.ACS_HLINE, lrx - ulx - 1)
@@ -157,8 +159,10 @@ class Textbox:
 
 if __name__ == '__main__':
     def test_editbox(stdscr):
-        win = curses.newwin(4, 9, 15, 20)
-        rectangle(stdscr, 14, 19, 19, 29)
+        ncols, nlines = 9, 4
+        uly, ulx = 15, 20
+        win = curses.newwin(nlines, ncols, uly, ulx)
+        rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
         stdscr.refresh()
         return Textbox(win).edit()