From 9bb753cb13d6f89441e2655f1bdcfbac3306e2db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Fri, 31 Mar 2023 16:48:49 +0200 Subject: [PATCH] Curses --- README.md | 4 ++-- index.html | 8 ++++---- parse.js | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 37c7113..4998e2f 100644 --- a/README.md +++ b/README.md @@ -2429,7 +2429,7 @@ from curses import A_REVERSE, KEY_DOWN, KEY_UP, KEY_LEFT, KEY_RIGHT, KEY_ENTER def main(screen): ch, first, selected, paths = 0, 0, 0, os.listdir() - while ch not in [ord('q'), curses.ascii.ESC]: + while ch != curses.ascii.ESC: height, width = screen.getmaxyx() screen.erase() for y, filename in enumerate(paths[first : first+height]): @@ -2439,7 +2439,7 @@ def main(screen): selected += (ch == KEY_DOWN) - (ch == KEY_UP) selected = max(0, min(len(paths)-1, selected)) first += (selected >= first + height) - (selected < first) - if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, 10, 13]: + if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, ord('\n'), ord('\r')]: new_dir = '..' if ch == KEY_LEFT else paths[selected] if os.path.isdir(new_dir): os.chdir(new_dir) diff --git a/index.html b/index.html index fbfc3fb..8b5ba0f 100644 --- a/index.html +++ b/index.html @@ -54,7 +54,7 @@
- +
@@ -1991,7 +1991,7 @@ print(table) def main(screen): ch, first, selected, paths = 0, 0, 0, os.listdir() - while ch not in [ord('q'), curses.ascii.ESC]: + while ch != curses.ascii.ESC: height, width = screen.getmaxyx() screen.erase() for y, filename in enumerate(paths[first : first+height]): @@ -2001,7 +2001,7 @@ print(table) selected += (ch == KEY_DOWN) - (ch == KEY_UP) selected = max(0, min(len(paths)-1, selected)) first += (selected >= first + height) - (selected < first) - if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, 10, 13]: + if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, ord('\n'), ord('\r')]: new_dir = '..' if ch == KEY_LEFT else paths[selected] if os.path.isdir(new_dir): os.chdir(new_dir) @@ -2935,7 +2935,7 @@ $ pyinstaller script.py --add-data '<path>:.' diff --git a/parse.js b/parse.js index 0c34300..7fd7c61 100755 --- a/parse.js +++ b/parse.js @@ -167,7 +167,7 @@ const CURSES = '\n' + 'def main(screen):\n' + ' ch, first, selected, paths = 0, 0, 0, os.listdir()\n' + - ' while ch not in [ord(\'q\'), curses.ascii.ESC]:\n' + + ' while ch != curses.ascii.ESC:\n' + ' height, width = screen.getmaxyx()\n' + ' screen.erase()\n' + ' for y, filename in enumerate(paths[first : first+height]):\n' + @@ -177,7 +177,7 @@ const CURSES = ' selected += (ch == KEY_DOWN) - (ch == KEY_UP)\n' + ' selected = max(0, min(len(paths)-1, selected))\n' + ' first += (selected >= first + height) - (selected < first)\n' + - ' if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, 10, 13]:\n' + + ' if ch in [KEY_LEFT, KEY_RIGHT, KEY_ENTER, ord(\'\\n\'), ord(\'\\r\')]:\n' + ' new_dir = \'..\' if ch == KEY_LEFT else paths[selected]\n' + ' if os.path.isdir(new_dir):\n' + ' os.chdir(new_dir)\n' +