8 def wrap_loop(self, loop):
9 curses.wrapper(self.start_loop, loop)
11 def safe_addstr(self, y, x, line, attr=0):
12 if y < self.size.y - 1 or x + len(line) < self.size.x:
13 self.stdscr.addstr(y, x, line, attr)
14 else: # workaround to <https://stackoverflow.com/q/7063128>
15 cut_i = self.size.x - x - 1
17 last_char = line[cut_i]
18 self.stdscr.addstr(y, self.size.x - 2, last_char, attr)
19 self.stdscr.insstr(y, self.size.x - 2, ' ')
20 self.stdscr.addstr(y, x, cut, attr)
23 from plomrogue.mapping import YX
24 self.size = YX(*self.stdscr.getmaxyx())
25 self.size = self.size - YX(self.size.y % 4, 0)
26 self.size = self.size - YX(0, self.size.x % 4)
28 def start_loop(self, stdscr, loop):
30 curses.curs_set(0) # hide cursor
36 def msg_into_lines_of_width(msg, width):
40 for i in range(len(msg)):
41 if x >= width or msg[i] == "\n":