diff --git a/MANUAL.rst b/MANUAL.rst index 85d6bce..775d9cc 100644 --- a/MANUAL.rst +++ b/MANUAL.rst @@ -8,13 +8,21 @@ CLI Synopsis .. code-block:: - Usage: ghcitui [OPTIONS] [TARGET] + Usage: ghcitui [--version] [--debug-console] [-v] [--daemon-log LOGFILE] + [-c|--cmd CMD] [-C|--workdir DIR] [TARGET] ghcitui: A TUI interface for GHCi Available options: -h,--help Show this help text - -d,--debug-console Display the debug console + --version Print the version number and exit + --debug-console Display the debug console + -v Set verbosity for output logs. Pass multiple times + (e.g -vvv) to increase the logging. Use --daemon-log + to specify where the logs go. + --daemon-log LOGFILE File path for debugging daemon logs. Used with -v. + Setting this to 'stdout' or 'stderr' sends logs to + each, respectively. Defaults to /tmp/ghcitui.log. -c,--cmd CMD Command to start the internal interpreter -C,--workdir DIR Set working dir @@ -129,6 +137,7 @@ Live Interpreter (REPL) - ``Ctrl+x``: Toggle between the Source Viewer and the Live Interpreter panels. - ````: Switch to Source Viewer. +- ```` while in scrolling mode: Exit scrolling mode. - ````: Scroll back in time through the REPL command history. - ````: Scroll forward in time through the REPL command history. - ````: Scroll the Live Interpreter window one page up. diff --git a/app/BrickUI.hs b/app/BrickUI.hs index 6a24ad7..9d2d7c6 100644 --- a/app/BrickUI.hs +++ b/app/BrickUI.hs @@ -48,11 +48,11 @@ appDraw s = ] dialogMaxWidth :: (Integral a) => a -dialogMaxWidth = 90 +dialogMaxWidth = 94 {- | Draw the dialog layer. -If there's no dialog, returns an 'emptyWidget'. + If there's no dialog, returns an 'emptyWidget'. -} drawDialogLayer :: AppS -> B.Widget AppName -- Quit Dialog diff --git a/app/Events.hs b/app/Events.hs index d3b1bef..09c1cee 100644 --- a/app/Events.hs +++ b/app/Events.hs @@ -425,6 +425,8 @@ handleDialogHelp (B.VtyEvent (V.EvKey key _)) B.put $ appState{activeWindow = ActiveCodeViewport} | key == V.KPageDown = B.vScrollPage scroller B.Down | key == V.KPageUp = B.vScrollPage scroller B.Up + | key == V.KDown = B.vScrollBy scroller 1 + | key == V.KUp = B.vScrollBy scroller (-1) | otherwise = pure () where scroller = B.viewportScroll HelpViewport diff --git a/app/HelpText.hs b/app/HelpText.hs index 1b4b941..adec006 100644 --- a/app/HelpText.hs +++ b/app/HelpText.hs @@ -4,141 +4,7 @@ module HelpText where import Data.String (IsString) --- import Data.FileEmbed +import qualified Data.FileEmbed as FileEmbed helpText :: (IsString a) => a -helpText = - "\ - \GHCITUI MANUAL() GHCITUI MANUAL()\n\ - \\n\ - \NAME\n\ - \ GHCiTUI MANUAL -\n\ - \\n\ - \CLI SYNOPSIS\n\ - \ Usage: ghcitui [OPTIONS] [TARGET]\n\ - \\n\ - \ ghcitui: A TUI interface for GHCi\n\ - \\n\ - \ Available options:\n\ - \ -h,--help Show this help text\n\ - \ -d,--debug-console Display the debug console\n\ - \ -c,--cmd CMD Command to start the internal\n\ - \ interpreter\n\ - \ -C,--workdir DIR Set working dir\n\ - \\n\ - \STARTING AND STOPPING\n\ - \ Starting\n\ - \ GHCiTUI runs a REPL in the current directory by default. By default,\n\ - \ it launches cabal repl.\n\ - \\n\ - \ $ cd your/cabal/project/root/directory\n\ - \ $ ghcitui\n\ - \\n\ - \ You can specify another starting directory with the -C flag.\n\ - \\n\ - \ $ ghcitui -C some/other/directory\n\ - \\n\ - \ Stopping\n\ - \ To quit, press or q while in the code viewport panel to quit.\n\ - \ While not in the code viewport panel, you may press to get to\n\ - \ the viewport panel.\n\ - \\n\ - \LAYOUT\n\ - \ GHCiTUI is an in-terminal viewer for GHCi. The TUI is broken up into\n\ - \ three primary panels, with some additional auxiliary panels for spe‐\n\ - \ cial use cases:\n\ - \\n\ - \ ┌──────────────────┬──────┐\n\ - \ │ │ Info │\n\ - \ │ │ │\n\ - \ │ Source Viewer │ │\n\ - \ │ │ │\n\ - \ │ │ │\n\ - \ ├──────────────────┤ │\n\ - \ │ │ │\n\ - \ │ Live Interpreter │ │\n\ - \ │ │ │\n\ - \ └──────────────────┴──────┘\n\ - \\n\ - \ Source Viewer: This panel shows source code. You can step, continue,\n\ - \ and toggle breakpoints among other operations in this panel.\n\ - \\n\ - \ Live Interpreter: This panel shows the GHCi/REPL passthrough. You can\n\ - \ enter expressions and GHCi commands here like you would normally,\n\ - \ with some additional keybindings.\n\ - \\n\ - \ Info: This panel displays miscellaneous info about whatever is cur‐\n\ - \ rently running. For example, it can display the current bindings,\n\ - \ loaded modules, and the current program trace.\n\ - \\n\ - \NAVIGATION\n\ - \ At any point in time, you can revert back to the Source Viewer panel\n\ - \ with the key, and you can always quit by hitting in the\n\ - \ Source Viewer panel.\n\ - \\n\ - \KEYBINDINGS\n\ - \ At this time, keybindings are hardcoded. This will hopefully change\n\ - \ in the future with a keybinding configuration file.\n\ - \\n\ - \ Source Viewer\n\ - \ • Ctrl+x: Toggle between the Source Viewer and the Live Interpreter\n\ - \ panels.\n\ - \\n\ - \ • , q: Quit.\n\ - \\n\ - \ • , k: Move the cursor up. (j and k from Vim keybinds)\n\ - \\n\ - \ • , j: Move the cursor down. (j and k from Vim keybinds).\n\ - \\n\ - \ • : Move the source viewer one page up.\n\ - \\n\ - \ • : Move the source viewer one page down.\n\ - \\n\ - \ • +, -: Increase/decrease the Info panel size.\n\ - \\n\ - \ • b: Toggle breakpoint at current line. Not every line in a source\n\ - \ file can have a breakpoint placed on it.\n\ - \\n\ - \ • s: Advance execution by one step. Same as the :step in GHCi.\n\ - \\n\ - \ • c: Advance execution until next breakpoint. Same as :continue in\n\ - \ GHCi.\n\ - \\n\ - \ • t: Advance execution until next breakpoint under tracing. Same as\n\ - \ :trace in GHCi.\n\ - \\n\ - \ Live Interpreter (REPL)\n\ - \ • Ctrl+x: Toggle between the Source Viewer and the Live Interpreter\n\ - \ panels.\n\ - \\n\ - \ • : Switch to Source Viewer.\n\ - \\n\ - \ • : Scroll back in time through the REPL command history.\n\ - \\n\ - \ • : Scroll forward in time through the REPL command history.\n\ - \\n\ - \ • : Scroll the Live Interpreter window one page up.\n\ - \\n\ - \ • : Scroll the Live Interpreter window one page down.\n\ - \\n\ - \ • Ctrl+n: Toggle scrolling mode.\n\ - \\n\ - \ • +, - while in scrolling mode: Increase/decrease the live panel\n\ - \ size.\n\ - \\n\ - \ • : Enter a command to the REPL.\n\ - \\n\ - \ Modules\n\ - \ • Ctrl+x: Switch to the Live Interpreter.\n\ - \\n\ - \ • : Switch to Source Viewer.\n\ - \\n\ - \ • , k: Move the module selection up.\n\ - \\n\ - \ • , j: Move the module selection down.\n\ - \\n\ - \ • +, -: Increase/decrease the info panel size.\n\ - \\n\ - \ • , o: Open the selected module.\n\ - \\n\ - \ GHCITUI MANUAL()" +helpText = $(FileEmbed.makeRelativeToProject "gen/MANUAL.txt" >>= FileEmbed.embedStringFile) \ No newline at end of file diff --git a/gen/MANUAL.txt b/gen/MANUAL.txt new file mode 100644 index 0000000..9d49cca --- /dev/null +++ b/gen/MANUAL.txt @@ -0,0 +1,145 @@ +CLI SYNOPSIS + Usage: ghcitui [--version] [--debug-console] [-v] [--daemon-log LOGFILE] + [-c|--cmd CMD] [-C|--workdir DIR] [TARGET] + + ghcitui: A TUI interface for GHCi + + Available options: + -h,--help Show this help text + --version Print the version number and exit + --debug-console Display the debug console + -v Set verbosity for output logs. Pass multiple times + (e.g -vvv) to increase the logging. Use --daemon-log + to specify where the logs go. + --daemon-log LOGFILE File path for debugging daemon logs. Used with -v. + Setting this to 'stdout' or 'stderr' sends logs to + each, respectively. Defaults to /tmp/ghcitui.log. + -c,--cmd CMD Command to start the internal interpreter + -C,--workdir DIR Set working dir + +STARTING AND STOPPING + Starting + GHCiTUI runs a REPL in the current directory by default. By default, it + launches cabal repl. + + $ cd your/cabal/project/root/directory + $ ghcitui + + You can specify another starting directory with the -C flag. + + $ ghcitui -C some/other/directory + + Stopping + To quit, press or q while in the code viewport panel to quit. + While not in the code viewport panel, you may press to get to the + viewport panel. + +LAYOUT + GHCiTUI is an in-terminal viewer for GHCi. The TUI is broken up into + three primary panels, with some additional auxiliary panels for special + use cases: + + ┌──────────────────┬──────┐ + │ │ Info │ + │ │ │ + │ Source Viewer │ │ + │ │ │ + │ │ │ + ├──────────────────┤ │ + │ │ │ + │ Live Interpreter │ │ + │ │ │ + └──────────────────┴──────┘ + + Source Viewer: This panel shows source code. You can step, continue, + and toggle breakpoints among other operations in this panel. + + Live Interpreter: This panel shows the GHCi/REPL passthrough. You can + enter expressions and GHCi commands here like you would normally, with + some additional keybindings. + + Info: This panel displays miscellaneous info about whatever is cur‐ + rently running. For example, it can display the current bindings, + loaded modules, and the current program trace. + +NAVIGATION + At any point in time, you can revert back to the Source Viewer panel + with the key, and you can always quit by hitting in the + Source Viewer panel. + + On top of each panel is a label where the navigation key combination is + located. For example, the key combination above the Modules panel dis‐ + plays [M]. Pressing this key combination will move the focus to that + panel. + +KEYBINDINGS + At this time, keybindings are hardcoded. This will hopefully change in + the future with a keybinding configuration file. + + Source Viewer + • ?: Display help inside GHCiTUI. + + • Ctrl+x: Toggle between the Source Viewer and the Live Interpreter + panels. + + • , q: Quit. + + • , k: Move the cursor up. (j and k from Vim keybinds) + + • , j: Move the cursor down. (j and k from Vim keybinds). + + • : Move the source viewer one page up. + + • : Move the source viewer one page down. + + • +, -: Increase/decrease the left panel sizes. + + • b: Toggle breakpoint at current line. Not every line in a source file + can have a breakpoint placed on it. + + • s: Advance execution by one step. Same as the :step in GHCi. + + • c: Advance execution until next breakpoint. Same as :continue in + GHCi. + + • t: Advance execution until next breakpoint under tracing. Same as + :trace in GHCi. + + Live Interpreter (REPL) + • Ctrl+x: Toggle between the Source Viewer and the Live Interpreter + panels. + + • : Switch to Source Viewer. + + • while in scrolling mode: Exit scrolling mode. + + • : Scroll back in time through the REPL command history. + + • : Scroll forward in time through the REPL command history. + + • : Scroll the Live Interpreter window one page up. + + • : Scroll the Live Interpreter window one page down. + + • Ctrl+n: Toggle scrolling mode. + + • +, - while in scrolling mode: Increase/decrease the live panel size. + + • : Enter a command to the REPL. + + Modules + • ?: Display help inside GHCiTUI. + + • Ctrl+x: Switch to the Live Interpreter. + + • : Switch to Source Viewer. + + • , k: Move the module selection up. + + • , j: Move the module selection down. + + • +, -: Increase/decrease the info panel size. + + • , o: Open the selected module. + + GHCITUI MANUAL() diff --git a/gen/README.md b/gen/README.md new file mode 100644 index 0000000..f578e76 --- /dev/null +++ b/gen/README.md @@ -0,0 +1,3 @@ +# Generated Assets + +This dir contains files generated during the pre-build process. diff --git a/ghcitui.cabal b/ghcitui.cabal index fc0a8f6..54152dd 100644 --- a/ghcitui.cabal +++ b/ghcitui.cabal @@ -29,6 +29,7 @@ extra-source-files: CHANGELOG.md , LICENSE , MANUAL.rst , README.md + , gen/MANUAL.txt source-repository head type: git @@ -40,6 +41,7 @@ executable ghcitui , brick , containers >= 0.6.7 && < 0.8 , errors ^>= 2.3.0 + , file-embed ^>= 0.0.15 , ghcitui-core , ghcitui-brick , microlens ^>= 0.4.13.1 diff --git a/regenerate_help.sh b/regenerate_help.sh new file mode 100755 index 0000000..14c4712 --- /dev/null +++ b/regenerate_help.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +GENDIR="gen" +mkdir -p "${GENDIR}" +TMPFILE="$(mktemp)" +rst2man MANUAL.rst > "${TMPFILE}" +man "${TMPFILE}" | sed -e '1,5d' > ${GENDIR}/MANUAL.txt \ No newline at end of file