client: Remove offset support of draw_select and use win.subwin instead

master
Felix Stupp 4 years ago
parent d8a91749a2
commit 1b19053d6f
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -58,16 +58,14 @@ def search_pictures(out, path):
out(text_closed_pictures) out(text_closed_pictures)
return ret return ret
def draw_select(win, dirs, sel, y_offset = 0): def draw_select(win, dirs, sel):
y_size, x_size = win.getmaxyx() y_size, x_size = win.getmaxyx()
y_size -= y_offset
# centered scroll # centered scroll
y_center = y_size // 2 y_center = y_size // 2
for y in range(y_size): for y in range(y_size):
y_real = y + y_offset
i = sel + y - y_center i = sel + y - y_center
if i < 0 or len(dirs) <= i: if i < 0 or len(dirs) <= i:
win.addstr(y_real, 1, " " * (x_size - 2), curses.A_NORMAL) win.addstr(y, 1, " " * (x_size - 2), curses.A_NORMAL)
else: else:
text = " " text = " "
text += indicator if i == sel else (" " * len(indicator)) text += indicator if i == sel else (" " * len(indicator))
@ -75,7 +73,7 @@ def draw_select(win, dirs, sel, y_offset = 0):
text += dirs[i].name text += dirs[i].name
text = stretch(text, x_size - 2) text = stretch(text, x_size - 2)
text_format = curses.A_STANDOUT if i == sel else curses.A_NORMAL text_format = curses.A_STANDOUT if i == sel else curses.A_NORMAL
win.addstr(y_real, 1, text, text_format) win.addstr(y, 1, text, text_format)
return True return True
def draw_header(win, base_dir, path): def draw_header(win, base_dir, path):
@ -100,7 +98,7 @@ def show_select(win, base_dir, path):
sel = 0 sel = 0
while True: while True:
draw_header(win, base_dir, path) draw_header(win, base_dir, path)
draw_select(win, dirs, sel, y_offset=3) draw_select(win.subwin(3, 0), dirs, sel)
c = win.getch() c = win.getch()
if c in binding_up: if c in binding_up:
sel = max(0, sel - 1) sel = max(0, sel - 1)

Loading…
Cancel
Save