This commit is contained in:
CatChow0 2025-06-04 02:10:05 +02:00
parent 77f8e433b2
commit 4e2171fcda

View File

@ -89,10 +89,10 @@ def choisir_source(stdscr, sources_infos):
line = f"{idx+1}. {info['url']} ({info['qualite']}, {info['taille']})" line = f"{idx+1}. {info['url']} ({info['qualite']}, {info['taille']})"
if idx == sel: if idx == sel:
stdscr.attron(curses.color_pair(1)) stdscr.attron(curses.color_pair(1))
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.attroff(curses.color_pair(1)) stdscr.attroff(curses.color_pair(1))
else: else:
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.refresh() stdscr.refresh()
k = stdscr.getch() k = stdscr.getch()
if k == curses.KEY_UP and sel > 0: if k == curses.KEY_UP and sel > 0:
@ -167,10 +167,10 @@ def handle_multi_download(stdscr, conn):
line = f"{titre} (Saison {saison}, dernier: {format_dernier(dernier, saison)})" line = f"{titre} (Saison {saison}, dernier: {format_dernier(dernier, saison)})"
if idx == sel: if idx == sel:
stdscr.attron(curses.color_pair(1)) stdscr.attron(curses.color_pair(1))
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.attroff(curses.color_pair(1)) stdscr.attroff(curses.color_pair(1))
else: else:
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.refresh() stdscr.refresh()
k = stdscr.getch() k = stdscr.getch()
if k == curses.KEY_UP and sel > 0: if k == curses.KEY_UP and sel > 0:
@ -204,10 +204,10 @@ def handle_multi_download(stdscr, conn):
line = f"{mark} Épisode {idx+1}" line = f"{mark} Épisode {idx+1}"
if idx == cursor: if idx == cursor:
stdscr.attron(curses.color_pair(1)) stdscr.attron(curses.color_pair(1))
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.attroff(curses.color_pair(1)) stdscr.attroff(curses.color_pair(1))
else: else:
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.refresh() stdscr.refresh()
k = stdscr.getch() k = stdscr.getch()
if k == curses.KEY_UP and cursor > 0: if k == curses.KEY_UP and cursor > 0:
@ -427,10 +427,10 @@ def handle_delete(stdscr, conn):
line = f"{titre} (Saison {saison}, dernier: {format_dernier(dernier, saison)})" line = f"{titre} (Saison {saison}, dernier: {format_dernier(dernier, saison)})"
if idx == sel: if idx == sel:
stdscr.attron(curses.color_pair(1)) stdscr.attron(curses.color_pair(1))
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.attroff(curses.color_pair(1)) stdscr.attroff(curses.color_pair(1))
else: else:
stdscr.addstr(2 + idx, 2, line) safe_addstr(stdscr, 2 + idx, 2, line)
stdscr.refresh() stdscr.refresh()
k = stdscr.getch() k = stdscr.getch()
if k == curses.KEY_UP and sel > 0: if k == curses.KEY_UP and sel > 0:
@ -446,6 +446,11 @@ def handle_delete(stdscr, conn):
stdscr.addstr(2, 0, "Appuyez sur une touche pour revenir au menu.") stdscr.addstr(2, 0, "Appuyez sur une touche pour revenir au menu.")
stdscr.getch() stdscr.getch()
def safe_addstr(stdscr, y, x, text):
max_y, max_x = stdscr.getmaxyx()
if 0 <= y < max_y:
stdscr.addstr(y, x, text[:max_x - x - 1])
def main(): def main():
conn = init_db() conn = init_db()
curses.wrapper(setup_and_run, conn) curses.wrapper(setup_and_run, conn)