Make magic coordinates more readable

This commit is contained in:
Andrew M. Kuchling 2004-10-19 19:21:20 +00:00
parent 5fcc003566
commit a13ea5572a
1 changed files with 7 additions and 3 deletions

View File

@ -3,7 +3,9 @@
import curses, ascii import curses, ascii
def rectangle(win, uly, ulx, lry, lrx): 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.vline(uly+1, ulx, curses.ACS_VLINE, lry - uly - 1)
win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1) win.hline(uly, ulx+1, curses.ACS_HLINE, lrx - ulx - 1)
win.hline(lry, 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__': if __name__ == '__main__':
def test_editbox(stdscr): def test_editbox(stdscr):
win = curses.newwin(4, 9, 15, 20) ncols, nlines = 9, 4
rectangle(stdscr, 14, 19, 19, 29) uly, ulx = 15, 20
win = curses.newwin(nlines, ncols, uly, ulx)
rectangle(stdscr, uly-1, ulx-1, uly + nlines, ulx + ncols)
stdscr.refresh() stdscr.refresh()
return Textbox(win).edit() return Textbox(win).edit()