jsmdcui 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/CHANGELOG.md +76 -0
  2. package/LICENSE +22 -0
  3. package/README.md +285 -0
  4. package/package.json +17 -0
  5. package/project_structure.txt +35 -0
  6. package/runmd.mjs +240 -0
  7. package/runtime/colorschemes/atom-dark.micro +33 -0
  8. package/runtime/colorschemes/bubblegum.micro +31 -0
  9. package/runtime/colorschemes/cmc-16.micro +47 -0
  10. package/runtime/colorschemes/cmc-tc.micro +43 -0
  11. package/runtime/colorschemes/darcula.micro +34 -0
  12. package/runtime/colorschemes/default.micro +1 -0
  13. package/runtime/colorschemes/dracula-tc.micro +49 -0
  14. package/runtime/colorschemes/dukedark-tc.micro +38 -0
  15. package/runtime/colorschemes/dukelight-tc.micro +38 -0
  16. package/runtime/colorschemes/dukeubuntu-tc.micro +38 -0
  17. package/runtime/colorschemes/geany.micro +29 -0
  18. package/runtime/colorschemes/gotham.micro +29 -0
  19. package/runtime/colorschemes/gruvbox-tc.micro +29 -0
  20. package/runtime/colorschemes/gruvbox.micro +26 -0
  21. package/runtime/colorschemes/material-tc.micro +36 -0
  22. package/runtime/colorschemes/monokai-dark.micro +28 -0
  23. package/runtime/colorschemes/monokai.micro +34 -0
  24. package/runtime/colorschemes/one-dark.micro +39 -0
  25. package/runtime/colorschemes/railscast.micro +37 -0
  26. package/runtime/colorschemes/simple.micro +33 -0
  27. package/runtime/colorschemes/solarized-tc.micro +31 -0
  28. package/runtime/colorschemes/solarized.micro +30 -0
  29. package/runtime/colorschemes/sunny-day.micro +29 -0
  30. package/runtime/colorschemes/twilight.micro +40 -0
  31. package/runtime/colorschemes/zenburn.micro +30 -0
  32. package/runtime/help/actions.md +161 -0
  33. package/runtime/help/cdp.md +119 -0
  34. package/runtime/help/colors.md +421 -0
  35. package/runtime/help/commands.md +161 -0
  36. package/runtime/help/copypaste.md +149 -0
  37. package/runtime/help/defaultkeys.md +148 -0
  38. package/runtime/help/help.md +285 -0
  39. package/runtime/help/keybindings.md +355 -0
  40. package/runtime/help/linter.md +90 -0
  41. package/runtime/help/options.md +709 -0
  42. package/runtime/help/plugins.md +544 -0
  43. package/runtime/help/tutorial.md +112 -0
  44. package/runtime/jsplugins/cdp/cdp-server.js +1161 -0
  45. package/runtime/jsplugins/cdp/cdp.js +192 -0
  46. package/runtime/jsplugins/chapter/chapter.js +108 -0
  47. package/runtime/jsplugins/diff/diff.js +46 -0
  48. package/runtime/jsplugins/example/example.js +110 -0
  49. package/runtime/jsplugins/linter/linter.js +281 -0
  50. package/runtime/plugins/autoclose/autoclose.lua +75 -0
  51. package/runtime/plugins/ftoptions/ftoptions.lua +17 -0
  52. package/runtime/plugins/literate/README.md +5 -0
  53. package/runtime/plugins/literate/literate.lua +55 -0
  54. package/runtime/plugins/status/help/status.md +21 -0
  55. package/runtime/plugins/status/status.lua +62 -0
  56. package/runtime/syntax/LICENSE +22 -0
  57. package/runtime/syntax/PowerShell.yaml +128 -0
  58. package/runtime/syntax/README.md +63 -0
  59. package/runtime/syntax/ada.yaml +43 -0
  60. package/runtime/syntax/apacheconf.yaml +59 -0
  61. package/runtime/syntax/arduino.yaml +101 -0
  62. package/runtime/syntax/asciidoc.yaml +51 -0
  63. package/runtime/syntax/asm.yaml +123 -0
  64. package/runtime/syntax/ats.yaml +99 -0
  65. package/runtime/syntax/awk.yaml +44 -0
  66. package/runtime/syntax/b.yaml +87 -0
  67. package/runtime/syntax/bat.yaml +57 -0
  68. package/runtime/syntax/c.yaml +60 -0
  69. package/runtime/syntax/caddyfile.yaml +23 -0
  70. package/runtime/syntax/cake.yaml +7 -0
  71. package/runtime/syntax/clojure.yaml +38 -0
  72. package/runtime/syntax/cmake.yaml +42 -0
  73. package/runtime/syntax/coffeescript.yaml +56 -0
  74. package/runtime/syntax/colortest.yaml +19 -0
  75. package/runtime/syntax/conky.yaml +17 -0
  76. package/runtime/syntax/cpp.yaml +91 -0
  77. package/runtime/syntax/crontab.yaml +36 -0
  78. package/runtime/syntax/crystal.yaml +72 -0
  79. package/runtime/syntax/csharp.yaml +52 -0
  80. package/runtime/syntax/css.yaml +44 -0
  81. package/runtime/syntax/csx.yaml +8 -0
  82. package/runtime/syntax/cuda.yaml +68 -0
  83. package/runtime/syntax/cython.yaml +52 -0
  84. package/runtime/syntax/d.yaml +121 -0
  85. package/runtime/syntax/dart.yaml +46 -0
  86. package/runtime/syntax/default.yaml +10 -0
  87. package/runtime/syntax/dockerfile.yaml +36 -0
  88. package/runtime/syntax/dot.yaml +29 -0
  89. package/runtime/syntax/elixir.yaml +30 -0
  90. package/runtime/syntax/elm.yaml +38 -0
  91. package/runtime/syntax/erb.yaml +42 -0
  92. package/runtime/syntax/erlang.yaml +45 -0
  93. package/runtime/syntax/fish.yaml +48 -0
  94. package/runtime/syntax/forth.yaml +34 -0
  95. package/runtime/syntax/fortran.yaml +64 -0
  96. package/runtime/syntax/freebsd-kernel.yaml +14 -0
  97. package/runtime/syntax/fsharp.yaml +48 -0
  98. package/runtime/syntax/gdscript.yaml +61 -0
  99. package/runtime/syntax/gemini.yaml +19 -0
  100. package/runtime/syntax/gentoo-ebuild.yaml +48 -0
  101. package/runtime/syntax/gentoo-etc-portage.yaml +23 -0
  102. package/runtime/syntax/git-commit.yaml +35 -0
  103. package/runtime/syntax/git-config.yaml +14 -0
  104. package/runtime/syntax/git-rebase-todo.yaml +19 -0
  105. package/runtime/syntax/gleam.yaml +69 -0
  106. package/runtime/syntax/glsl.yaml +26 -0
  107. package/runtime/syntax/gnuplot.yaml +15 -0
  108. package/runtime/syntax/go.yaml +62 -0
  109. package/runtime/syntax/godoc.yaml +17 -0
  110. package/runtime/syntax/golo.yaml +73 -0
  111. package/runtime/syntax/gomod.yaml +31 -0
  112. package/runtime/syntax/graphql.yaml +47 -0
  113. package/runtime/syntax/groff.yaml +30 -0
  114. package/runtime/syntax/groovy.yaml +111 -0
  115. package/runtime/syntax/haml.yaml +16 -0
  116. package/runtime/syntax/hare.yaml +52 -0
  117. package/runtime/syntax/haskell.yaml +52 -0
  118. package/runtime/syntax/hc.yaml +52 -0
  119. package/runtime/syntax/html.yaml +70 -0
  120. package/runtime/syntax/html4.yaml +25 -0
  121. package/runtime/syntax/html5.yaml +25 -0
  122. package/runtime/syntax/ini.yaml +23 -0
  123. package/runtime/syntax/inputrc.yaml +14 -0
  124. package/runtime/syntax/java.yaml +37 -0
  125. package/runtime/syntax/javascript.yaml +124 -0
  126. package/runtime/syntax/jinja2.yaml +19 -0
  127. package/runtime/syntax/json.yaml +39 -0
  128. package/runtime/syntax/jsonnet.yaml +92 -0
  129. package/runtime/syntax/julia.yaml +57 -0
  130. package/runtime/syntax/justfile.yaml +40 -0
  131. package/runtime/syntax/keymap.yaml +27 -0
  132. package/runtime/syntax/kickstart.yaml +16 -0
  133. package/runtime/syntax/kotlin.yaml +66 -0
  134. package/runtime/syntax/kvlang.yaml +67 -0
  135. package/runtime/syntax/ledger.yaml +14 -0
  136. package/runtime/syntax/lfe.yaml +17 -0
  137. package/runtime/syntax/lilypond.yaml +26 -0
  138. package/runtime/syntax/lisp.yaml +17 -0
  139. package/runtime/syntax/log.yaml +92 -0
  140. package/runtime/syntax/lua.yaml +111 -0
  141. package/runtime/syntax/mail.yaml +25 -0
  142. package/runtime/syntax/makefile.yaml +38 -0
  143. package/runtime/syntax/man.yaml +12 -0
  144. package/runtime/syntax/markdown.yaml +49 -0
  145. package/runtime/syntax/mc.yaml +23 -0
  146. package/runtime/syntax/meson.yaml +51 -0
  147. package/runtime/syntax/micro.yaml +34 -0
  148. package/runtime/syntax/mpdconf.yaml +13 -0
  149. package/runtime/syntax/msbuild.yaml +6 -0
  150. package/runtime/syntax/nanorc.yaml +16 -0
  151. package/runtime/syntax/nftables.yaml +30 -0
  152. package/runtime/syntax/nginx.yaml +22 -0
  153. package/runtime/syntax/nim.yaml +27 -0
  154. package/runtime/syntax/nix.yaml +32 -0
  155. package/runtime/syntax/nu.yaml +114 -0
  156. package/runtime/syntax/objc.yaml +60 -0
  157. package/runtime/syntax/ocaml.yaml +43 -0
  158. package/runtime/syntax/octave.yaml +83 -0
  159. package/runtime/syntax/odin.yaml +64 -0
  160. package/runtime/syntax/pascal.yaml +45 -0
  161. package/runtime/syntax/patch.yaml +14 -0
  162. package/runtime/syntax/peg.yaml +16 -0
  163. package/runtime/syntax/perl.yaml +58 -0
  164. package/runtime/syntax/php.yaml +60 -0
  165. package/runtime/syntax/pkg-config.yaml +12 -0
  166. package/runtime/syntax/po.yaml +12 -0
  167. package/runtime/syntax/pony.yaml +37 -0
  168. package/runtime/syntax/pov.yaml +21 -0
  169. package/runtime/syntax/privoxy-action.yaml +14 -0
  170. package/runtime/syntax/privoxy-config.yaml +10 -0
  171. package/runtime/syntax/privoxy-filter.yaml +12 -0
  172. package/runtime/syntax/proto.yaml +40 -0
  173. package/runtime/syntax/prql.yaml +84 -0
  174. package/runtime/syntax/puppet.yaml +22 -0
  175. package/runtime/syntax/python2.yaml +60 -0
  176. package/runtime/syntax/python3.yaml +80 -0
  177. package/runtime/syntax/r.yaml +32 -0
  178. package/runtime/syntax/raku.yaml +42 -0
  179. package/runtime/syntax/reST.yaml +18 -0
  180. package/runtime/syntax/renpy.yaml +15 -0
  181. package/runtime/syntax/rpmspec.yaml +43 -0
  182. package/runtime/syntax/ruby.yaml +73 -0
  183. package/runtime/syntax/rust.yaml +78 -0
  184. package/runtime/syntax/sage.yaml +60 -0
  185. package/runtime/syntax/scad.yaml +53 -0
  186. package/runtime/syntax/scala.yaml +33 -0
  187. package/runtime/syntax/sed.yaml +13 -0
  188. package/runtime/syntax/sh.yaml +69 -0
  189. package/runtime/syntax/sls.yaml +15 -0
  190. package/runtime/syntax/smalltalk.yaml +55 -0
  191. package/runtime/syntax/solidity.yaml +41 -0
  192. package/runtime/syntax/sql.yaml +35 -0
  193. package/runtime/syntax/stata.yaml +67 -0
  194. package/runtime/syntax/svelte.yaml +27 -0
  195. package/runtime/syntax/swift.yaml +103 -0
  196. package/runtime/syntax/systemd.yaml +16 -0
  197. package/runtime/syntax/tcl.yaml +18 -0
  198. package/runtime/syntax/terraform.yaml +87 -0
  199. package/runtime/syntax/tex.yaml +32 -0
  200. package/runtime/syntax/toml.yaml +56 -0
  201. package/runtime/syntax/twig.yaml +55 -0
  202. package/runtime/syntax/typescript.yaml +49 -0
  203. package/runtime/syntax/v.yaml +80 -0
  204. package/runtime/syntax/vala.yaml +26 -0
  205. package/runtime/syntax/verilog.yaml +60 -0
  206. package/runtime/syntax/vhdl.yaml +37 -0
  207. package/runtime/syntax/vi.yaml +31 -0
  208. package/runtime/syntax/vue.yaml +64 -0
  209. package/runtime/syntax/xml.yaml +37 -0
  210. package/runtime/syntax/xresources.yaml +14 -0
  211. package/runtime/syntax/yaml.yaml +34 -0
  212. package/runtime/syntax/yum.yaml +12 -0
  213. package/runtime/syntax/zig.yaml +52 -0
  214. package/runtime/syntax/zscript.yaml +72 -0
  215. package/runtime/syntax/zsh.yaml +52 -0
  216. package/single-exe/README.md +80 -0
  217. package/single-exe/assetsHelper.js +90 -0
  218. package/single-exe/assetsLoader.mjs +85 -0
  219. package/single-exe/compiled.js +149 -0
  220. package/single-exe/entry.mjs +9 -0
  221. package/single-exe/packAssets.sh +7 -0
  222. package/src/buffer/backup.js +160 -0
  223. package/src/buffer/buffer.js +126 -0
  224. package/src/buffer/fixed3-codec.js +140 -0
  225. package/src/buffer/loc.js +38 -0
  226. package/src/buffer/message.js +29 -0
  227. package/src/config/clean.js +172 -0
  228. package/src/config/colorscheme.js +99 -0
  229. package/src/config/config.js +122 -0
  230. package/src/config/defaults.js +109 -0
  231. package/src/cui/rpc.mjs +259 -0
  232. package/src/cui/server.mjs +116 -0
  233. package/src/display/ansi-style.js +60 -0
  234. package/src/highlight/highlighter.js +243 -0
  235. package/src/highlight/parser.js +225 -0
  236. package/src/index.js +8009 -0
  237. package/src/lua/engine.js +71 -0
  238. package/src/platform/archive.js +50 -0
  239. package/src/platform/clipboard.js +278 -0
  240. package/src/platform/commands.js +137 -0
  241. package/src/plugins/js-bridge.js +983 -0
  242. package/src/plugins/manager.js +674 -0
  243. package/src/runtime/assets.js +90 -0
  244. package/src/runtime/compiled.js +25 -0
  245. package/src/runtime/encodings.js +10 -0
  246. package/src/runtime/registry.js +134 -0
  247. package/src/screen/cell-buffer.js +81 -0
  248. package/src/screen/events.js +263 -0
  249. package/src/screen/screen.js +142 -0
  250. package/src/screen/vt100.js +571 -0
  251. package/src/shell/shell.js +70 -0
  252. package/testapp.md +55 -0
  253. package/tests/backup.test.js +133 -0
  254. package/tests/cmphex3b64.js +95 -0
  255. package/tests/pty-demo.js +492 -0
  256. package/tests/wv-client.js +96 -0
  257. package/tui +5 -0
  258. package/wui +5 -0
@@ -0,0 +1,149 @@
1
+ Copy and paste are essential features in micro but can be
2
+ confusing to get right especially when running micro over SSH
3
+ because there are multiple methods. This help document will explain
4
+ the various methods for copying and pasting, how they work,
5
+ and the best methods for doing so over SSH.
6
+
7
+ # OSC 52 (terminal clipboard)
8
+
9
+ If possible, setting the `clipboard` option to `terminal` will give
10
+ best results because it will work over SSH and locally. However, there
11
+ is limited support among terminal emulators for the terminal clipboard
12
+ (which uses the OSC 52 protocol to communicate clipboard contents).
13
+ Here is a list of terminal emulators and their status:
14
+
15
+ * `Kitty`: supported, but only writing is enabled by default. To enable
16
+ reading, add `read-primary` and `read-clipboard` to the
17
+ `clipboard_control` option.
18
+
19
+ * `iTerm2`: only copying (writing to clipboard) is supported. Must be enabled in
20
+ `Preferences->General-> Selection->Applications in terminal may access clipboard`.
21
+ You can use `Command-v` to paste.
22
+
23
+ * `st`: supported.
24
+
25
+ * `rxvt-unicode`: not natively supported, but there is a Perl extension
26
+ [here](https://anti.teamidiot.de/static/nei/*/Code/urxvt/).
27
+
28
+ * `xterm`: supported, but disabled by default. It can be enabled by putting
29
+ the following in `.Xresources` or `.Xdefaults`:
30
+ `XTerm*disallowedWindowOps: 20,21,SetXprop`.
31
+
32
+ * `gnome-terminal`: does not support OSC 52.
33
+
34
+ * `alacritty`: supported. Since 0.13.0, reading has been disabled by default.
35
+ To reenable it, set the `terminal.osc52` option to `CopyPaste`.
36
+
37
+ * `foot`: supported.
38
+
39
+ * `wezterm`: only copying (writing to clipboard) is supported.
40
+
41
+
42
+ **Summary:** If you want copy and paste to work over SSH, then you
43
+ should set `clipboard` to `terminal`, and make sure your terminal
44
+ supports OSC 52.
45
+
46
+ # Pasting
47
+
48
+ ## Recommendations (TL;DR)
49
+
50
+ The recommended method of pasting is the following:
51
+
52
+ * If you are not working over SSH, use the micro keybinding (`Ctrl-v`
53
+ by default) to perform pastes. If on Linux, install `xclip` or
54
+ `xsel` beforehand.
55
+
56
+ * If you are working over SSH, use the terminal keybinding
57
+ (`Ctrl-Shift-v` or `Command-v`) to perform pastes. If your terminal
58
+ does not support bracketed paste, when performing a paste first
59
+ enable the `paste` option, and when finished disable the option.
60
+
61
+ ## Micro paste events
62
+
63
+ Micro is an application that runs within the terminal. This means
64
+ that the terminal sends micro events, such as key events, mouse
65
+ events, resize events, and paste events. Micro's default keybinding
66
+ for paste is `Ctrl-v`. This means that when micro receives the key
67
+ event saying `Ctrl-v` has been pressed from the terminal, it will
68
+ attempt to access the system clipboard and effect a paste. The
69
+ system clipboard will be accessed through `pbpaste` on MacOS
70
+ (installed by default), `xclip` or `xsel` on Linux (these
71
+ applications must be installed by the user) or a system call on
72
+ Windows.
73
+
74
+ ## Terminal paste events
75
+
76
+ For certain keypresses, the terminal will not send an event to
77
+ micro and will instead do something itself. In this document,
78
+ such keypresses will be called "terminal keybindings." Often
79
+ there will be a terminal keybinding for pasting and copying. On
80
+ MacOS these are Command-v and Command-c and on Linux `Ctrl-Shift-v`
81
+ and `Ctrl-Shift-c`. When the terminal keybinding for paste is
82
+ executed, your terminal will access the system clipboard, and send
83
+ micro either a paste event or a list of key events (one key for each
84
+ character in the paste), depending on whether or not your terminal
85
+ supports sending paste events (called bracketed paste).
86
+
87
+ If your terminal supports bracketed paste, then it will send a paste
88
+ event and everything will work well. However, if your terminal
89
+ sends a list of key events, this can cause issues because micro
90
+ will think you manually entered each character and may add closing
91
+ brackets or automatic indentation, which will mess up the pasted
92
+ text. To avoid this, you can temporarily enable the `paste` option
93
+ while you perform the paste. When paste option is on, micro will
94
+ aggregate lists of multiple key events into larger paste events.
95
+ It is a good idea to disable the `paste` option during normal use
96
+ as occasionally if you are typing quickly, the terminal will send
97
+ the key events as lists of characters that were in fact manually
98
+ entered.
99
+
100
+ ## Pasting over SSH
101
+
102
+ When working over SSH, micro is running on the remote machine and
103
+ your terminal is running on your local machine. Therefore if you
104
+ would like to paste, using `Ctrl-v` (micro's keybinding) will not
105
+ work because when micro attempts to access the system clipboard,
106
+ it will access the remote machine's clipboard rather than the local
107
+ machine's clipboard. On the other hand, the terminal keybinding
108
+ for paste will access your local clipboard and send the text over
109
+ the network as a paste event, which is what you want.
110
+
111
+ # Copying
112
+
113
+ # Recommendations (TL;DR)
114
+
115
+ The recommended method of copying is the following:
116
+
117
+ * If you are not working over SSH, use the micro keybinding (`Ctrl-c` by
118
+ default) to perform copies. If on Linux, install `xclip` or `xsel`
119
+ beforehand.
120
+
121
+ * If you are working over SSH, use the terminal keybinding
122
+ (`Ctrl-Shift-c` or `Command-c`) to perform copies. You must first disable
123
+ the `mouse` option to perform a terminal selection, and you may wish
124
+ to disable line numbers and diff indicators (`ruler` and `diffgutter`
125
+ options) and close other splits. This method will only be able to copy
126
+ characters that are displayed on the screen (you will not be able to
127
+ copy more than one page's worth of characters).
128
+
129
+ Copying follows a similar discussion to the one above about pasting.
130
+ The primary difference is before performing a copy, the application
131
+ doing the copy must be told what text needs to be copied.
132
+
133
+ Micro has a keybinding (`Ctrl-c`) for copying and will access the system
134
+ clipboard to perform the copy. The text that micro will copy into is
135
+ the text that is currently selected in micro (usually such text is
136
+ displayed with a white background). When the `mouse` option is enabled,
137
+ the mouse can be used to select text, as well as other keybindings,
138
+ such as ShiftLeft, etc...
139
+
140
+ The terminal also has a keybinding (`Ctrl-Shift-c` or `Command-c`) to perform
141
+ a copy, and the text that it copies is the text selected by the terminal's
142
+ selection (*not* micro's selection). To select text with the terminal
143
+ selection, micro's mouse support must first be disabled by turning the
144
+ `mouse` option off. The terminal, unlike micro, has no sense of different
145
+ buffers/splits and what the different characters being displayed are. This
146
+ means that for copying multiple lines using the terminal selection, you
147
+ should first disable line numbers and diff indicators (turn off the `ruler`
148
+ and `diffgutter` options), otherwise they might be part of your selection
149
+ and copied.
@@ -0,0 +1,148 @@
1
+ # Default Keys
2
+
3
+ Below are simple charts of the default hotkeys and their functions. For more
4
+ information about binding custom hotkeys or changing default bindings, please
5
+ run `> help keybindings`
6
+
7
+ Please remember that *all* keys here are rebindable! If you don't like it, you
8
+ can change it!
9
+
10
+ ### Power user
11
+
12
+ | Key | Description of function |
13
+ |---------- |-------------------------------------------------------------------------------------------------- |
14
+ | Ctrl-e | Open a command prompt for running commands (see `> help commands` for a list of valid commands). |
15
+ | Tab | In command prompt, it will autocomplete if possible. |
16
+ | Ctrl-b | Run a shell command (this will close micro while your command executes). |
17
+
18
+ ### Navigation
19
+
20
+ | Key | Description of function |
21
+ |---------------------------- |------------------------------------------------------------------------------------------ |
22
+ | Arrows | Move the cursor around |
23
+ | Shift-arrows | Move and select text |
24
+ | Alt(Ctrl on Mac)-LeftArrow | Move to the beginning of the current line |
25
+ | Alt(Ctrl on Mac)-RightArrow | Move to the end of the current line |
26
+ | Home | Move to the beginning of text on the current line |
27
+ | End | Move to the end of the current line |
28
+ | Ctrl(Alt on Mac)-LeftArrow | Move cursor one word left |
29
+ | Ctrl(Alt on Mac)-RightArrow | Move cursor one word right |
30
+ | Alt-{ | Move cursor to previous empty line, or beginning of document |
31
+ | Alt-} | Move cursor to next empty line, or end of document |
32
+ | PageUp | Move cursor up one page |
33
+ | PageDown | Move cursor down one page |
34
+ | Ctrl-Home or Ctrl-UpArrow | Move cursor to start of document |
35
+ | Ctrl-End or Ctrl-DownArrow | Move cursor to end of document |
36
+ | Ctrl-l | Jump to a line in the file (prompts with #) |
37
+ | Ctrl-w | Cycle between splits in the current tab (use `> vsplit` or `> hsplit` to create a split) |
38
+
39
+ ### Tabs
40
+
41
+ | Key | Description of function |
42
+ |------------- |-------------------------- |
43
+ | Ctrl-t | Open a new tab |
44
+ | Alt-, Alt-p | Previous tab |
45
+ | Alt-. Alt-t | Next tab |
46
+
47
+ ### Find Operations
48
+
49
+ | Key | Description of function |
50
+ |---------- |------------------------------------------ |
51
+ | Ctrl-f | Find (opens prompt) |
52
+ | Ctrl-n | Find next instance of current search |
53
+ | Ctrl-p | Find previous instance of current search |
54
+
55
+ | Alt-h | Open command prompt to replace keywords |
56
+
57
+ Note: `Ctrl-n` and `Ctrl-p` should be used from the main buffer, not from inside
58
+ the search prompt. After `Ctrl-f`, press enter to complete the search and then
59
+ you can use `Ctrl-n` and `Ctrl-p` to cycle through matches.
60
+
61
+ ### File Operations
62
+
63
+ | Key | Description of function |
64
+ |-------------- |------------------------------------------------------------------ |
65
+ | Ctrl-q Alt-q | Close current file (quits micro if this is the last file open) |
66
+ | Ctrl-o | Open a file (prompts for filename) |
67
+ | Ctrl-s | Save current file |
68
+
69
+ ### Text operations
70
+
71
+ | Key | Description of function |
72
+ |------------------------------------ |------------------------------------------ |
73
+ | Ctrl(Alt on Mac)-Shift-RightArrow | Select word right |
74
+ | Ctrl(Alt on Mac)-Shift-LeftArrow | Select word left |
75
+ | Alt(Ctrl on Mac)-Shift-LeftArrow | Select to start of current line |
76
+ | Alt(Ctrl on Mac)-Shift-RightArrow | Select to end of current line |
77
+ | Shift-Home | Select to start of current line |
78
+ | Shift-End | Select to end of current line |
79
+ | Ctrl-Shift-UpArrow | Select to start of file |
80
+ | Ctrl-Shift-DownArrow | Select to end of file |
81
+ | Ctrl-x | Cut selected text |
82
+ | Ctrl-c | Copy selected text |
83
+ | Ctrl-v | Paste |
84
+ | Ctrl-k | Cut current line |
85
+ | Ctrl-d | Duplicate current line |
86
+ | Ctrl-z | Undo |
87
+ | Ctrl-y | Redo |
88
+ | Alt-UpArrow Alt-k | Move current line or selected lines up |
89
+ | Alt-DownArrow Alt-j | Move current line or selected lines down |
90
+ | Alt-Backspace or Alt-Ctrl-h | Delete word left |
91
+ | Ctrl-a | Select all |
92
+ | Alt-s | Enter Selection mode |
93
+ | Alt-c | Toggle comment for lines |
94
+ | Tab | Indent selected text |
95
+ | Alt-d | Dedent selected text |
96
+ | Shift-Tab | Unindent selected text |
97
+
98
+ ### Macros(not implemented yet)
99
+
100
+ | Key | Description of function |
101
+ |---------- |---------------------------------------------------------------------------------- |
102
+ | Ctrl-u | Toggle macro recording (press Ctrl-u to start recording and press again to stop) |
103
+ | Ctrl-j | Run latest recorded macro |
104
+
105
+ ### Multiple cursors(not implemented yet)
106
+
107
+ | Key | Description of function |
108
+ |------------------ |---------------------------------------------------------------------------------------------- |
109
+ | Alt-n | Create new multiple cursor from selection (will select current word if no current selection) |
110
+ | Alt-Shift-Up | Spawn a new cursor on the line above the current one |
111
+ | Alt-Shift-Down | Spawn a new cursor on the line below the current one |
112
+ | Alt-p | Remove latest multiple cursor |
113
+ | Alt-c | Remove all multiple cursors (cancel) |
114
+ | Alt-x | Skip multiple cursor selection |
115
+ | Alt-m | Spawn a new cursor at the beginning of every line in the current selection |
116
+ | Ctrl-MouseLeft | Place a multiple cursor at any location |
117
+
118
+ ### Other
119
+
120
+ | Key | Description of function |
121
+ |---------- |-------------------------------------------------------------------------------------- |
122
+ | Ctrl-g | Open help file |
123
+ | Ctrl-h | Backspace (old terminals do not support the backspace key and use Ctrl+H instead) |
124
+ | Ctrl-r | Toggle the line number ruler |
125
+
126
+ ### Emacs style actions
127
+ - not implemented yet
128
+
129
+ | Key | Description of function |
130
+ |---------- |-------------------------- |
131
+ | Alt-f | Next word |
132
+ | Alt-b | Previous word |
133
+ | Alt-a | Move to start of line |
134
+ | Alt-e | Move to end of line |
135
+
136
+ ### Function keys.
137
+ - not implemented yet
138
+
139
+ Warning! The function keys may not work in all terminals!
140
+
141
+ | Key | Description of function |
142
+ |------ |-------------------------- |
143
+ | F1 | Open help |
144
+ | F2 | Save |
145
+ | F3 | Find |
146
+ | F4 | Quit |
147
+ | F7 | Find |
148
+ | F10 | Quit |
@@ -0,0 +1,285 @@
1
+ # Introduction
2
+ - jsmdcui stands for:
3
+ - JavaScript Markdown Cross-environment User Interface
4
+ - The goal is to use Markdown as a Common UI for Terminals and Web Browsers
5
+ * TUI = Terminal User Interface
6
+ * WUI = Web User Interface
7
+ - .
8
+ - It's based on bunmicro, a terminal text editor derived from the Micro text editor
9
+
10
+ - Original projects:
11
+ - https://github.com/jjtseng93/bunmicro
12
+ - https://github.com/micro-editor/micro
13
+
14
+ ## Quick start
15
+
16
+ jsmdcui requires [Bun](https://bun.com). On Android, install it in Termux:
17
+
18
+ ```sh
19
+ npm install -g bun
20
+ ```
21
+
22
+ On other platforms, follow the [official Bun installation guide](https://bun.com/docs/installation).
23
+
24
+ Choose either of these two ways to run jsmdcui.
25
+
26
+ > **Important:** Opening or rendering a local `.md` file writes or overwrites
27
+ > five generated files beside it. Starting `--wui` without a file writes the
28
+ > five files generated from `testapp.md` in the current directory. The source
29
+ > Markdown is not changed, but you should run the demo in a directory where
30
+ > overwriting generated files is safe.
31
+
32
+ ### Route 1: Run with npx
33
+
34
+ This route requires both `npx` and `bun` on your `PATH`; no source checkout is
35
+ required. Open the normal terminal editor:
36
+
37
+ ```sh
38
+ npx jsmdcui
39
+ ```
40
+
41
+ Or start the default browser demo:
42
+
43
+ ```sh
44
+ npx jsmdcui --wui
45
+ ```
46
+
47
+ If the current directory already contains `testapp.md`, that local file is used
48
+ instead of the bundled demo. To open your own Markdown UI, pass its path:
49
+
50
+ ```sh
51
+ npx jsmdcui app.md
52
+ npx jsmdcui --wui app.md
53
+ ```
54
+
55
+ ### Route 2: Clone the source
56
+
57
+ ```sh
58
+ git clone https://github.com/jjtseng93/jsmdcui.git
59
+ cd jsmdcui
60
+ bun src/index.js testapp.md
61
+ ```
62
+
63
+ The last command opens the included demo in the terminal. Use the arrow keys to
64
+ move, `Enter` or `Space` to activate an item, and `Ctrl-Q` to quit. To open the
65
+ same demo in a browser instead:
66
+
67
+ ```sh
68
+ bun src/index.js --wui testapp.md
69
+ ```
70
+
71
+ After starting `--wui`, open the last printed `http://...` URL in a browser.
72
+ Keep the command running while using the page, and press `Ctrl-C` in that
73
+ terminal to stop the server.
74
+
75
+ The command table below uses the cloned-source form. If you use npx, replace
76
+ `bun src/index.js` with `npx jsmdcui`.
77
+
78
+ | Command | Result |
79
+ | --- | --- |
80
+ | `bun src/index.js app.md` | Render `app.md` as a read-only terminal UI and write five generated files beside it. |
81
+ | `bun src/index.js --cat app.md` | Render the terminal version to stdout, write five generated files beside it, and exit. |
82
+ | `bun src/index.js --testapp.md` | Write the bundled `testapp.md` source to stdout and exit. |
83
+ | `bun src/index.js --wui` | Use local `testapp.md` when present, otherwise use the bundled demo; write five generated files in the current directory, then print and serve a random URL. |
84
+ | `bun src/index.js --wui app.md` | Write five generated files beside `app.md`, then print and serve a random URL. |
85
+ | `PORT=8080 bun src/index.js --wui app.md` | Start the browser UI on another port. |
86
+ | `bun src/index.js` | Open the normal terminal editor with an empty buffer. |
87
+
88
+ Run `npx jsmdcui --help` or `bun src/index.js --help` for all command-line
89
+ options.
90
+
91
+ ## Write a Markdown UI
92
+
93
+ Create `app.md`:
94
+
95
+ ````md
96
+ # My app
97
+
98
+ - [Say hello](javascript:sayHello())
99
+ - [Get server time](javascript:showServerTime())
100
+
101
+ ```js front
102
+ export function sayHello() {
103
+ const name = prompt("Your name:", "World");
104
+ if (name) alert(`Hello, ${name}!`);
105
+ }
106
+
107
+ export async function showServerTime() {
108
+ const time = await rpc.getServerTime();
109
+ alert(time);
110
+ }
111
+ ```
112
+
113
+ ```js back
114
+ export function getServerTime() {
115
+ return new Date().toISOString();
116
+ }
117
+ ```
118
+ ````
119
+
120
+ Open it in either UI:
121
+
122
+ ```sh
123
+ bun src/index.js app.md
124
+ bun src/index.js --wui app.md
125
+ ```
126
+
127
+ The three UI building blocks are:
128
+
129
+ - Regular Markdown provides headings, text, lists, task checkboxes, code, and
130
+ links.
131
+ - A `js front` block contains UI code. Exported functions can use
132
+ `alert`, `confirm`, `prompt`, and the generated `rpc` client.
133
+ - A `js back` block exports trusted backend functions. In the browser WUI,
134
+ `rpc` publishes only exported functions whose exported names do not start
135
+ with `_`. Call a published function from the front end with
136
+ `await rpc.functionName(arg1, arg2)`.
137
+
138
+ > An `_` prefix only hides a function from the browser WUI RPC interface. The
139
+ > local terminal UI imports the backend module directly, so `_` is a naming
140
+ > convention, not authentication or a security boundary. Use a name without
141
+ > `_` for a function that must work through RPC in both UIs.
142
+
143
+ Use a `javascript:` Markdown link to run front-end code:
144
+
145
+ ```md
146
+ [Button label](javascript:exportedFunction())
147
+ ```
148
+
149
+ The front and back code blocks are extracted and are not shown in the rendered
150
+ UI. In the terminal, `rpc` calls the generated backend module directly. In the
151
+ browser, it sends the call to the relative `rpc` endpoint under the printed
152
+ UUID URL (`/<uuid>/rpc`).
153
+
154
+ ## Terminal interaction
155
+
156
+ Markdown files automatically use `mdcui` mode. The rendered buffer is
157
+ read-only, but navigation, selection, search, and copy remain available.
158
+
159
+ | Input | Result |
160
+ | --- | --- |
161
+ | Arrow keys, `Home`, `End`, `PageUp`, `PageDown` | Move through the rendered UI. |
162
+ | `Enter` or `Space` | Activate the cell under the cursor. Put the cursor on a `javascript:` link to run it. |
163
+ | Left click | Move to and activate the clicked cell. A `javascript:` link runs immediately. |
164
+ | Mouse wheel | Scroll three rows at a time. |
165
+ | `Shift` + arrow keys | Select rendered text. |
166
+ | `Ctrl-C` | Copy the selection, or the current line when nothing is selected. |
167
+ | `Ctrl-A` | Select all rendered text. |
168
+ | `Ctrl-F` | Search; use `Ctrl-N` and `Ctrl-P` for the next and previous match. |
169
+ | `Ctrl-G` | Open the editor help. |
170
+ | `Alt-G` | Show or hide the shortcut bar. |
171
+ | `Ctrl-Q` or `Alt-Q` | Close the current UI. |
172
+
173
+ The terminal automatically reflows the Markdown when its width changes.
174
+ Only `javascript:` links execute in the TUI; ordinary web links behave as
175
+ normal links in the browser.
176
+
177
+ ## Browser interaction
178
+
179
+ The WUI uses normal browser mouse and keyboard behavior. Clicking a
180
+ `javascript:` link calls its front-end function, regular links navigate
181
+ normally, and task checkboxes can be toggled. `alert`, `confirm`, and `prompt`
182
+ use the browser's built-in dialogs. Checkbox changes exist only in the current
183
+ page: refreshing does not preserve them and does not update the Markdown file.
184
+
185
+ The WUI uses port `3000` by default and accepts connections through the
186
+ machine's available network interfaces. The printed `localhost` URL is for the
187
+ same machine. From another device on the same network, replace `localhost` with
188
+ the server machine's IP address and keep the same port and full path.
189
+
190
+ Each server start prints a new random path. The old URL stops working after the
191
+ server is stopped or restarted. Keep the process running while using the page,
192
+ and press `Ctrl-C` in its terminal to stop it.
193
+
194
+ ## Generated files
195
+
196
+ Opening a local Markdown UI generates these files beside the source file:
197
+
198
+ ```text
199
+ app.md.front.js
200
+ app.md.back.js
201
+ app.md.html
202
+ app.md-rpc.js
203
+ app.md-server.js
204
+ ```
205
+
206
+ They are regenerated from `app.md`, so edit the Markdown source rather than the
207
+ generated files. The source directory must be writable.
208
+
209
+ ## Security
210
+
211
+ A Markdown UI is an executable application, not a passive document. Starting a
212
+ WUI loads its backend module, loading the page runs its frontend module, and
213
+ activating a local terminal `javascript:` link runs frontend code. Backend and
214
+ terminal code can read or change files, start programs, access the network, and
215
+ read environment data with the permissions of the jsmdcui process. Only open
216
+ or serve Markdown UI files that you trust.
217
+
218
+ ### WUI network exposure
219
+
220
+ > **Warning:** The WUI is intended for local or trusted-network use. It is not
221
+ > a production web server.
222
+
223
+ - There is no login, per-user authorization, or HTTPS. Traffic and results are
224
+ sent over plain HTTP.
225
+ - The server may be reachable from other devices through the machine's network
226
+ interfaces, even though the printed URL says `localhost`.
227
+ - The random path makes the URL harder to guess, but it is not a password.
228
+ Anyone who can reach the server and obtains the complete URL can load the
229
+ page and call every backend function published through WUI RPC, using
230
+ arguments they choose.
231
+ - A backend RPC function runs with the same operating-system permissions as
232
+ jsmdcui. Its code determines what files, commands, network services, or
233
+ secrets a visitor may be able to reach.
234
+ - Do not share the complete URL, forward the port to the public internet, or
235
+ run the WUI on an untrusted network. Use a firewall when needed and stop the
236
+ server with `Ctrl-C` as soon as you finish.
237
+ - Prefixing a backend export with `_` keeps it out of WUI RPC discovery and
238
+ calls, but it does not protect the backend module from trusted local code and
239
+ is not a substitute for authentication.
240
+
241
+ ## Development
242
+
243
+ ```sh
244
+ npm run tui
245
+ npm run wui
246
+ npm run check
247
+ ```
248
+
249
+ `testapp.md` is the main working example.
250
+
251
+ testapp.md
252
+
253
+ ┌──────────────┴──────────────┐
254
+ │ │
255
+ ▼ ▼
256
+ Browser HTML TUI ANSI
257
+ │ │
258
+ javascript:foo() extract javascript:
259
+ │ │
260
+ ▼ ▼
261
+ window.frontFunc() evalFront(frontMod, text)
262
+ │ │
263
+ └──────────────┬──────────────┘
264
+
265
+ testapp.md.front.js
266
+
267
+ rpc.someFunc()
268
+ ┌───────────┴───────────┐
269
+ │ │
270
+ Browser TUI
271
+ │ │
272
+ RPC Proxy client import * as rpc
273
+ │ from back module
274
+ ▼ │
275
+ fetch rpc │
276
+ │ │
277
+ ▼ │
278
+ server.mjs │
279
+ │ │
280
+ ▼ │
281
+ evalBack(backMod, reqjson) │
282
+ │ │
283
+ └───────────┬───────────┘
284
+
285
+ testapp.md.back.js