commit 9e0cd0f83550fb548e9f95979054e9d7aaeba64d
parent 80c1d7455156e80da6aa7ab4c394c55a9cc3e4b8
Author: Isak Lindhé <isak.e.lindhe@gmail.com>
Date: Thu, 31 Jan 2019 17:38:54 +0100
interactive mode
Diffstat:
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/src/txtv.py b/src/txtv.py
@@ -122,8 +122,33 @@ def show_headers():
title, page_nbr = art
print(title.ljust(38, '.'), Fore.BLUE + str(page_nbr) + Fore.RESET)
+def interactive(start_page: Page):
+ start_page.show()
+ page = start_page
+ running = True
+ while running:
+ try:
+ cmd = input('> ')
+ 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', '>']:
+ page = Page(page.next)
+ page.show()
+ elif cmd.lower() in ['previous', 'prev', 'p', 'k', '<']:
+ page = Page(page.prev)
+ page.show()
+ else:
+ print("That's not a command, type help for help, or quit to quit.")
+ except EOFError:
+ running = False
+
if __name__ == '__main__':
+ IFLAG = True
colorama.init()
cfg = get_or_gen_config()
raw_arg = '__DEFAULT__'
@@ -138,7 +163,10 @@ if __name__ == '__main__':
page_nbr = validate_page_nbr(real_arg)
try:
page = Page(page_nbr)
- page.show()
+ if IFLAG:
+ interactive(page)
+ else:
+ page.show()
except rq.exceptions.ConnectionError:
err('Could not connect to network :(')
colorama.deinit()