10 curses.wrapper(self.run_loop)
12 def addstr(self, y, x, line, attr=0):
13 if y < self.size.y - 1 or x + len(line) < self.size.x:
14 self.stdscr.addstr(y, x, line, attr)
15 else: # workaround to <https://stackoverflow.com/q/7063128>
16 cut_i = self.size.x - x - 1
18 last_char = line[cut_i]
19 self.stdscr.addstr(y, self.size.x - 2, last_char, attr)
20 self.stdscr.insstr(y, self.size.x - 2, ' ')
21 self.stdscr.addstr(y, x, cut, attr)
24 from plomrogue.mapping import YX
25 self.size = YX(*self.stdscr.getmaxyx())
26 self.size = self.size - YX(self.size.y % 4, 0)
27 self.size = self.size - YX(0, self.size.x % 4)
30 curses.curs_set(0) # hide cursor
31 self.stdscr.timeout(10)
34 def run_loop(self, stdscr):
45 def msg_into_lines_of_width(msg, width):
49 for i in range(len(msg)):
50 if x >= width or msg[i] == "\n":