77 lines
1.4 KiB
Python
77 lines
1.4 KiB
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
|
|
from session import settings
|
|
import bt.message
|
|
import bt.signal
|
|
|
|
|
|
def advance(y, maxy, stdscr):
|
|
if y < (maxy-2):
|
|
settings["cliney"] = y+1
|
|
return y+1
|
|
stdscr.move(0,0)
|
|
stdscr.deleteln()
|
|
stdscr.move(y,0)
|
|
space = " " * settings["maxyx"][1]
|
|
stdscr.addstr(y,0,space)
|
|
return y
|
|
|
|
|
|
# Add string to line y
|
|
def insert(string):
|
|
if len(string) == 0:
|
|
return
|
|
|
|
stdscr = settings["stdscr"]
|
|
maxyx = settings["maxyx"]
|
|
y = settings["cliney"]
|
|
|
|
if len(string) >= maxyx[1]:
|
|
stdscr.addstr(y, 0, string[0:maxyx[1]])
|
|
y = advance(y, maxyx[0], stdscr)
|
|
insert(string[maxyx[1]:])
|
|
return
|
|
stdscr.addstr(y, 0, string)
|
|
advance(y, maxyx[0], stdscr)
|
|
|
|
bt.signal.stop("message-write")
|
|
|
|
|
|
|
|
# Replace the string on the current line
|
|
def disp(string, y=-1):
|
|
stdscr = settings["stdscr"]
|
|
if stdscr == None:
|
|
return
|
|
|
|
move = None
|
|
|
|
if y == -1:
|
|
y = settings["cliney"]
|
|
space = " " * settings["maxyx"][1]
|
|
stdscr.addstr(y, 0, space)
|
|
else:
|
|
stdscr.leaveok(True)
|
|
move = stdscr.getyx()
|
|
space = " " * settings["maxyx"][1]
|
|
#stdscr.addstr(y, 0, space)
|
|
|
|
|
|
try:
|
|
|
|
stdscr.addstr(y, 0, string)
|
|
except:
|
|
bt.message.error("Error displaying string: "+string)
|
|
|
|
stdscr.leaveok(False)
|
|
if move != None:
|
|
stdscr.move( move[0], move[1] )
|