ocarina/src/core/cline/message.py

49 lines
921 B
Python

#! /usr/bin/python
# To change this template, choose Tools | Templates
# and open the template in the editor.
__author__="bjschuma"
__date__ ="$Dec 19, 2009 11:57:19 PM$"
import curses
import settings
import bt.message
def advance(y, maxy, stdscr):
if y < (maxy-1):
settings.replace("cliney", y+1)
return y+1
stdscr.move(0,0)
stdscr.deleteln()
return y
# Add string to line y
def insert(string):
stdscr = settings.get("stdscr")
maxyx = settings.get("maxyx")
y = settings.get("cliney")
if len(string) > maxyx[1]:
stdscr.addstr(y, 0, string[0:maxyx[1]])
advance(y, maxyx[0], stdscr)
insert(string[maxyx[1]:])
return
stdscr.addstr(y, 0, string)
advance(y, maxyx[0], stdscr)
# Replace the string on the current line
def disp(string):
stdscr = settings.get("stdscr")
try:
stdscr.addstr(settings.get("cliney"), 0, string)
except:
bt.message.error("Error displaying string: "+string)