aboutsummaryrefslogtreecommitdiff
path: root/lib/help_screen.ml
diff options
context:
space:
mode:
Diffstat (limited to 'lib/help_screen.ml')
-rw-r--r--lib/help_screen.ml62
1 files changed, 48 insertions, 14 deletions
diff --git a/lib/help_screen.ml b/lib/help_screen.ml
index 223a863..0726be3 100644
--- a/lib/help_screen.ml
+++ b/lib/help_screen.ml
@@ -3,25 +3,29 @@ open Notty
type state = { go_back : unit -> unit }
-let info = [ "STITCH"; "Note composing tool" ]
-
let render_info =
- let title = I.strf ~attr:A.(st bold) "%s" "STITCH" |> I.pad ~l:2 ~t:0 in
+ let title = I.strf ~attr:A.(st bold ++ st underline) "%s" "Stitch" |> I.pad ~l:2 ~t:0 in
let description =
- I.strf ~attr:A.(st bold) "%s" "Small Note Composer" |> I.pad ~l:2 ~t:1
+ I.strf
+ ~attr:A.(st bold)
+ "%s"
+ "Minimal Note Composer. Run with stitch --help for more info."
+ |> I.pad ~l:2 ~t:1
in
- let keybindings = I.strf ~attr:A.(st bold) "%s" "Keybindings" |> I.pad ~l:2 ~t:4 in
+ let license = I.strf "%s" "Licensed under BSD-3" |> I.pad ~l:2 ~t:3 in
let open I in
- title </> description </> keybindings
+ 5, title </> description </> license
-let help_menu =
+let general_help_menu =
[ "Toggle this menu", "?"
; "Exit", "Ctrl-c, q, Esc"
- ; "Toggle collapsed view", "@"
; "Down", "Ctrl-n, j"
; "Up", "Ctrl-p, k"
- ; "Grep", "s"
+ ; "Regexp", "r"
+ ; "Note view", "1"
+ ; "Todo view", "2"
+ ; "Done view", "3"
; "Edit", "Enter, e"
]
@@ -31,22 +35,52 @@ let pad str n =
String.concat "" [ str; String.make padding ' ' ]
-let render_help_menu start_y =
+let render_menu ~menu ~title ~start_y =
+ let keybindings = I.strf ~attr:A.(st bold) "%s" title |> I.pad ~l:2 ~t:start_y in
let elements =
List.mapi
(fun i (explanation, keybinding) ->
let padding = pad explanation 27 in
- I.strf "%s%s" padding keybinding |> I.pad ~l:2 ~t:(i + start_y))
- help_menu
+ I.strf "%s%s" padding keybinding |> I.pad ~l:2 ~t:(i + start_y + 1))
+ menu
in
let open I in
- List.fold_left (fun sum el -> el </> sum) I.empty elements
+ 1 + List.length elements, List.fold_left (fun sum el -> el </> sum) keybindings elements
+
+let note_view_menu = [ "Toggle Stitch", "s" ]
+let todo_view_menu = [ "Toggle Done", "t" ]
+let done_view_menu = [ "Toggle Todo", "t" ]
let rec render t ({ go_back } as state) =
let img =
let open I in
- render_info </> render_help_menu 5
+ let info_length, info_img = render_info in
+ let general_length, general_img =
+ render_menu
+ ~menu:general_help_menu
+ ~title:"Keybindings (General)"
+ ~start_y:(info_length + 1)
+ in
+ let note_length, note_img =
+ render_menu
+ ~menu:note_view_menu
+ ~title:"Note View"
+ ~start_y:(general_length + info_length + 2)
+ in
+ let todo_length, todo_img =
+ render_menu
+ ~menu:todo_view_menu
+ ~title:"Todo View"
+ ~start_y:(note_length + general_length + info_length + 3)
+ in
+ let _, done_img =
+ render_menu
+ ~menu:done_view_menu
+ ~title:"Done View"
+ ~start_y:(todo_length + note_length + general_length + info_length + 4)
+ in
+ info_img </> general_img </> note_img </> todo_img </> done_img
in
Common.Term.image t img;
match Common.Term.event t with