blob: cb0ed6146553e9d755491d184e7de3b1842e71ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
import curses
from .widimp import WidImp
class TextInput(WidImp):
def __init__(self):
self.text = ""
self.cursor = 0
def setText(self, text, cursor):
self.text = text
self.cursor = cursor
self.change()
def update(self, win):
width, height = win.getSize()
win.erase()
win.addLine((0, 0), self.text[:width])
if self.cursor >= 0 and self.cursor <= len(self.text):
win.setAttr((min(self.cursor, width-1), 0), curses.A_REVERSE)
win.noutrefresh()
|