1 /* ----------------------------------------------------------------------------
2 Copyright (c) 2021, Daan Leijen
3 This is free software; you can redistribute it and/or modify it
4 under the terms of the MIT License. A copy of the license can be
5 found in the "LICENSE" file at the root of this distribution.
6 -----------------------------------------------------------------------------*/
8 //-------------------------------------------------------------
9 // Help: this is included into editline.c
10 //-------------------------------------------------------------
12 static const char* help
[] = {
15 "^b", "go one character to the left",
17 "^f", "go one character to the right",
18 "up", "go one row up, or back in the history",
19 "down", "go one row down, or forward in the history",
25 "go to the start of the previous word",
31 "go to the end the current word",
33 "^a", "go to the start of the current line",
35 "^e", "go to the end of the current line",
37 "^home", "go to the start of the current input",
39 "^end", "go to the end of the current input",
40 "alt-m", "jump to matching brace",
41 "^p", "go back in the history",
42 "^n", "go forward in the history",
43 "^r,^s", "search the history starting with the current word",
47 "del,^d", "delete the current character",
48 "backsp,^h", "delete the previous character",
49 "^w", "delete to preceding white space",
50 "alt-backsp", "delete to the start of the current word",
51 "alt-d", "delete to the end of the current word",
52 "^u", "delete to the start of the current line",
53 "^k", "delete to the end of the current line",
54 "esc", "delete the current input, or done with empty input",
58 "enter", "accept current input",
65 "create a new line for multi-line input",
66 //" ", "(or type '\\' followed by enter)",
68 "^t", "swap with previous character (move character backward)",
71 //"^C", "done with empty input",
72 //"F1", "show this help",
73 "tab", "try to complete the current input",
75 "","In the completion menu:",
76 "enter,left", "use the currently selected completion",
77 "1 - 9", "use completion N from the menu",
78 "tab,down", "select the next completion",
79 "shift-tab,up","select the previous completion",
80 "esc", "exit menu without completing",
81 "pgdn,^j", "show all further possible completions",
83 "","In incremental history search:",
84 "enter", "use the currently found history entry",
86 "^z", "go back to the previous match (undo)",
88 "^r", "find the next match",
90 "^s", "find an earlier match",
96 static const char* help_initial
=
98 "Isocline v1.0, copyright (c) 2021 Daan Leijen.\n"
99 "This is free software; you can redistribute it and/or\n"
100 "modify it under the terms of the MIT License.\n"
101 "See <[url]https://github.com/daanx/isocline[/url]> for further information.\n"
102 "We use ^<key> as a shorthand for ctrl-<key>.\n"
106 " home,ctrl-a cursor end,ctrl-e\n"
107 " ┌────────────────┼───────────────┐ (navigate)\n"
110 " │ ctrl-left │ ctrl-right │\n"
112 " │ alt-left │ alt-right │\n"
114 " │ ┌───────┼──────┐ │ ctrl-r : search history\n"
115 " ▼ ▼ ▼ ▼ ▼ tab : complete word\n"
116 " prompt> [ansi-darkgray]it's the quintessential language[/] shift-tab: insert new line\n"
117 " ▲ ▲ ▲ ▲ esc : delete input, done\n"
118 " │ └──────────────┘ │ ctrl-z : undo\n"
119 " │ alt-backsp alt-d │\n"
121 " └────────────────────────────────┘ (delete)\n"
123 "[/ansi-lightgray][/ic-info]\n";
125 static void edit_show_help(ic_env_t
* env
, editor_t
* eb
) {
127 bbcode_println(env
->bbcode
, help_initial
);
128 for (ssize_t i
= 0; help
[i
] != NULL
&& help
[i
+1] != NULL
; i
+= 2) {
129 if (help
[i
][0] == 0) {
130 bbcode_printf(env
->bbcode
, "[ic-info]%s[/]\n", help
[i
+1]);
133 bbcode_printf(env
->bbcode
, " [ic-emphasis]%-13s[/][ansi-lightgray]%s%s[/]\n", help
[i
], (help
[i
+1][0] == 0 ? "" : ": "), help
[i
+1]);
139 edit_refresh(env
, eb
);