##
## statline.py -- Status line upkeep.
##
## Copyleft 1997 Teemu Kalvas <chery@s2.org>
##

## +class StatLine  (screen)  parent screen object
##  -method redraw  ()
##  -method touch   ()

import curses

class StatLine:
    def __init__(self, screen):
	self.screen = screen
	self.redraw()

    def redraw(self):
	window = self.screen.stat_area
	width = window.getmaxyx()[1]
	win = self.screen.current.next
	detect = ''
	while win <> self.screen.current:
	    if not win.detect:
		detect = detect + ' '
	    elif win.detect < 10:
		detect = detect + repr(win.detect)
	    else:
		detect = detect + 'X'
	    win = win.next
	left = 'on ' + self.screen.current.name
	right = '[' + detect + ']'
	window.addstr(0, 0, left + ' ' + (width - len(left) - len(right) - 2) *
		      '-' + ' ' + right, curses.A_REVERSE)
	self.touch()

    def touch(self):
	screen = self.screen
	screen.touched = screen.touched | 2

## End. ##
