txtv

Swiss text tv in the terminal
git clone https://git.in0rdr.ch/txtv.git
Log | Files | Refs | Pull requests |Archive | README | LICENSE

commit 493757f5fc32ccf63f98b1f978f61fc1d6024cb1
parent 9e0cd0f83550fb548e9f95979054e9d7aaeba64d
Author: Isak Lindhé <isak.e.lindhe@gmail.com>
Date:   Thu, 31 Jan 2019 17:52:56 +0100

number commands and help text for interactive mode

Diffstat:
Msrc/txtv.py | 20+++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/src/txtv.py b/src/txtv.py @@ -122,25 +122,39 @@ def show_headers(): title, page_nbr = art print(title.ljust(38, '.'), Fore.BLUE + str(page_nbr) + Fore.RESET) +INTERACTIVE_HELP = """ +help -- show this text +quit, q, exit, EOF-character -- quit +next, n, j, > -- next available page +prev, p, k, < -- previous available page +<any 3 digit number> -- go to the page with that number + +commands are case insensitive +""" + def interactive(start_page: Page): start_page.show() page = start_page running = True while running: try: - cmd = input('> ') + cmd = input('> ').strip().lower() if cmd == '': pass elif cmd == 'help': print('here will be a helptext later') # TODO elif cmd in ['quit', 'q', 'exit']: running = False - elif cmd.lower() in ['next', 'n', 'j', '>']: + elif cmd in ['next', 'n', 'j', '>']: page = Page(page.next) page.show() - elif cmd.lower() in ['previous', 'prev', 'p', 'k', '<']: + elif cmd in ['previous', 'prev', 'p', 'k', '<']: page = Page(page.prev) page.show() + elif re.fullmatch('[1-9][0-9][0-9]',cmd): + nbr = int(cmd) + page = Page(int(cmd)) + page.show() else: print("That's not a command, type help for help, or quit to quit.") except EOFError: