]> git.armaanb.net Git - lightcards.git/commitdiff
Add keybinding to open file in editor
authorArmaan Bhojwani <me@armaanb.net>
Sun, 31 Jan 2021 19:14:38 +0000 (14:14 -0500)
committerArmaan Bhojwani <me@armaanb.net>
Sun, 31 Jan 2021 19:14:38 +0000 (14:14 -0500)
lightcards/display.py
lightcards/lightcards.py
man/lightcards.1
man/lightcards.1.md

index 8e7bba405a4ed3b404bdbd2be88b472529276f51..fd11158b789eccac7c0902aca69811e915b68af4 100755 (executable)
@@ -6,6 +6,8 @@ from random import shuffle
 import sys
 import textwrap
 
+from . import lightcards
+
 
 def disp_bar(stdscr, stack, headers, obj):
     """
@@ -156,7 +158,8 @@ def disp_help(stdscr, stack, headers, idx):
                   "i, /               star card\n" +
                   "0, ^, home         go to the start of the deck\n" +
                   "$, end             go to the end of the deck\n" +
-                  "H, ?               open this screen\n\n" +
+                  "H, ?               open this screen\n" +
+                  "e                  open the input file in $EDITOR\n\n" +
                   "More information can be found in the man page, or by\n" +
                   "running `lightcards --help`.\n\n" +
                   "Press [q], [H], or [?] to go back.")
@@ -210,3 +213,6 @@ def get_key(stdscr, stack, headers, idx):
             disp_card(stdscr, stack, headers, idx)
         elif key in ["H", "?"]:
             disp_help(stdscr, stack, headers, idx)
+        elif key == "e":
+            (headers, stack) = lightcards.reparse()
+            get_key(stdscr, stack, headers, idx)
index 66d123189628ce426ba3e69707a0635cb8941338..41b0db738a5d5520fdd2ee6e0e3b15ec2fd8a025 100755 (executable)
@@ -4,6 +4,7 @@
 
 import argparse
 from curses import wrapper
+import os
 from random import shuffle
 import sys
 
@@ -49,6 +50,12 @@ def show(args, stack, headers):
     wrapper(display.init_disp, stack, headers, idx)
 
 
+def reparse():
+    args = parse_args()
+    os.system(f"$EDITOR {args.inp[0]}"),
+    return parse.parse_html(parse.md2html(args.inp[0]))
+
+
 def main(args=sys.argv):
     args = parse_args()
     (headers, stack) = parse.parse_html(parse.md2html(args.inp[0]))
index a31e8bcaf836e40d1c410733dae7d3bf507baa4b..c8264e4c34fab5b4c07d2afb22286d2c919419d2 100644 (file)
@@ -53,6 +53,12 @@ Go to start of deck
 .TP
 \f[B]$\f[R], \f[B]end\f[R]
 Go to end of deck
+.TP
+\f[B]H\f[R], \f[B]?\f[R]
+Open help screen
+.TP
+\f[B]e\f[R]
+Open input file in $EDITOR
 .SH EXIT VALUES
 .TP
 \f[B]0\f[R]
index 2871c12d638bf4328b14bd8dca06d04ff6407b27..6c3a385b63fbd6106a2c054fd766146eb60c3843 100644 (file)
@@ -50,6 +50,12 @@ lightcards [[options]] [input file]
 **$**, **end**
 : Go to end of deck
 
+**H**, **?**
+: Open help screen
+
+**e**
+: Open input file in $EDITOR
+
 # EXIT VALUES
 **0**
 : Success