remove gcc for MacOS in conan.yml
[liba.git] / lua / isocline / src / editline_help.c
blobb1616b2935d3543b28bee4349c5ab2b147db8586
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[] = {
13 "","Navigation:",
14 "left,"
15 "^b", "go one character to the left",
16 "right,"
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",
20 #ifdef __APPLE__
21 "shift-left",
22 #else
23 "^left",
24 #endif
25 "go to the start of the previous word",
26 #ifdef __APPLE__
27 "shift-right",
28 #else
29 "^right",
30 #endif
31 "go to the end the current word",
32 "home,"
33 "^a", "go to the start of the current line",
34 "end,"
35 "^e", "go to the end of the current line",
36 "pgup,"
37 "^home", "go to the start of the current input",
38 "pgdn,"
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",
44 "","",
46 "", "Deletion:",
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",
55 "","",
57 "", "Editing:",
58 "enter", "accept current input",
59 #ifndef __APPLE__
60 "^enter, ^j", "",
61 "shift-tab",
62 #else
63 "shift-tab,^j",
64 #endif
65 "create a new line for multi-line input",
66 //" ", "(or type '\\' followed by enter)",
67 "^l", "clear screen",
68 "^t", "swap with previous character (move character backward)",
69 "^z,^_", "undo",
70 "^y", "redo",
71 //"^C", "done with empty input",
72 //"F1", "show this help",
73 "tab", "try to complete the current input",
74 "","",
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",
82 "","",
83 "","In incremental history search:",
84 "enter", "use the currently found history entry",
85 "backsp,"
86 "^z", "go back to the previous match (undo)",
87 "tab,"
88 "^r", "find the next match",
89 "shift-tab,"
90 "^s", "find an earlier match",
91 "esc", "exit search",
92 " ","",
93 NULL, NULL
96 static const char* help_initial =
97 "[ic-info]"
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"
103 "\n"
104 "Overview:\n"
105 "\n[ansi-lightgray]"
106 " home,ctrl-a cursor end,ctrl-e\n"
107 " ┌────────────────┼───────────────┐ (navigate)\n"
108 //" │ │ │\n"
109 #ifndef __APPLE__
110 " │ ctrl-left │ ctrl-right │\n"
111 #else
112 " │ alt-left │ alt-right │\n"
113 #endif
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"
120 //" │ │ │\n"
121 " └────────────────────────────────┘ (delete)\n"
122 " ctrl-u ctrl-k\n"
123 "[/ansi-lightgray][/ic-info]\n";
125 static void edit_show_help(ic_env_t* env, editor_t* eb) {
126 edit_clear(env, 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]);
132 else {
133 bbcode_printf(env->bbcode, " [ic-emphasis]%-13s[/][ansi-lightgray]%s%s[/]\n", help[i], (help[i+1][0] == 0 ? "" : ": "), help[i+1]);
137 eb->cur_rows = 0;
138 eb->cur_row = 0;
139 edit_refresh(env, eb);