home
·
contact
·
privacy
projects
/
plomrogue
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix buggy healthy_addch().
[plomrogue]
/
client
/
window_management.py
diff --git
a/client/window_management.py
b/client/window_management.py
index b1f68c24f44b5fa805bbeba32928f58f04850a96..a896b0207e39bb970db07572145dbf07ae69f6b0 100644
(file)
--- a/
client/window_management.py
+++ b/
client/window_management.py
@@
-1,3
+1,8
@@
+# This file is part of PlomRogue. PlomRogue is licensed under the GPL version 3
+# or any later version. For details on its copyright, license, and warranties,
+# see the file NOTICE in the root directory of the PlomRogue source package.
+
+
import curses
import types
import curses
import types
@@
-19,7
+24,7
@@
class Window:
self.size = size
self.size = size
-def set_window
_geometrie
s():
+def set_windows():
def size_window(config):
size = [0, 0]
def size_window(config):
size = [0, 0]
@@
-90,6
+95,8
@@
def set_window_geometries():
curses.endwin()
stdscr = curses.initscr()
screen_size = stdscr.getmaxyx()
curses.endwin()
stdscr = curses.initscr()
screen_size = stdscr.getmaxyx()
+ global windows
+ windows = []
for config in windows_config:
size = size_window(config["config"])
window = Window(config["title"], config["func"], size)
for config in windows_config:
size = size_window(config["config"])
window = Window(config["title"], config["func"], size)
@@
-101,14
+108,20
@@
def set_window_geometries():
def draw_screen():
def healthy_addch(y, x, char, attr=0):
def draw_screen():
def healthy_addch(y, x, char, attr=0):
- """Workaround for <http://stackoverflow.com/questions/7063128/>."""
+ """Wrap Python curses' addch() weirdnesses into sane interface.
+
+ Works around <http://stackoverflow.com/questions/7063128/> with
+ <https://stackoverflow.com/a/26797300> and enforces char to be a byte
+ instead of a single-char string.
+ """
if y == screen_size[0] - 1 and x == screen_size[1] - 1:
char_before = stdscr.inch(y, x - 1)
if y == screen_size[0] - 1 and x == screen_size[1] - 1:
char_before = stdscr.inch(y, x - 1)
- stdscr.addch(y, x - 1, char, attr)
+ stdscr.addch(y, x - 1, char
.encode()
, attr)
stdscr.insstr(y, x - 1, " ")
stdscr.insstr(y, x - 1, " ")
- stdscr.addch(y, x - 1, char_before)
+ stdscr.addch(y, x - 1,
+ char_before & 0xFF, char_before & curses.A_ATTRIBUTES)
else:
else:
- stdscr.addch(y, x, char, attr)
+ stdscr.addch(y, x, char
.encode()
, attr)
def draw_window_border_lines():
for win in windows:
def draw_window_border_lines():
for win in windows: