|
13 | 13 | #include "banner_private.h" |
14 | 14 | #include "shell.h" |
15 | 15 |
|
16 | | -/* A rotating-feel showcase of real things this shell can do that a plain sh |
17 | | - can't — a brag line plus two copy-pasteable tricks. Each is fronted by a |
18 | | - coloured badge (g_chip) and carries its own inline colours: the command in |
19 | | - warm code-yellow, the gloss in muted grey. All verified to work. */ |
20 | | -static const char *g_chip[] = { |
21 | | - "\033[1;48;5;209;38;5;236m HOT \033[0m", |
22 | | - "\033[1;48;5;141;38;5;236m PRO \033[0m", |
23 | | - "\033[1;48;5;73;38;5;236m TIP \033[0m" |
24 | | -}; |
25 | | - |
26 | | -static const char *g_news[] = { |
27 | | - "\033[38;5;245moutpaces \033[1;38;5;209mbash --posix\033[0m" |
28 | | - "\033[38;5;245m on compute-heavy scripts\033[0m", |
29 | | - "\033[38;5;223mdiff <(a) <(b)\033[0m" |
30 | | - "\033[38;5;245m compare two outputs, no temp files\033[0m", |
31 | | - "\033[38;5;223mcp report{,.bak}\033[0m" |
32 | | - "\033[38;5;245m duplicate a name in one word\033[0m", |
33 | | - NULL |
34 | | -}; |
35 | | - |
36 | | -/* The block heading — an invitation to learn a trick, in cool cyan. */ |
37 | | -static void news_head(char *dst) |
| 16 | +/* One row of "What's new in 3.2": the keys that reach a new feature, in |
| 17 | + code-yellow, then what it does, in muted grey -- the shape of "Getting |
| 18 | + started", so each can be tried before the prompt even appears. Every |
| 19 | + row fits the 32 columns the right column has on an 80-column terminal. |
| 20 | + Keys are padded to ten columns by hand (ft_snprintf pads bytes; an arrow |
| 21 | + is three bytes in one column); the ASCII keys are for terminals where |
| 22 | + header_use_unicode() says no. A NULL key ends a group: the always-on |
| 23 | + features, then the hint keys, which need HELLISH_AUTOSUGGEST. |
| 24 | + wiki/whats-new.md is the long form of this table and must stay in step |
| 25 | + with it; next release, replace both and bump HELLISH_HEADER_REV. |
| 26 | + Returns 0 at the end of a group. */ |
| 27 | +static int news_row(char *dst, int n) |
38 | 28 | { |
39 | | - ft_snprintf(dst, 160, "\033[1;38;5;81mDid you know?\033[0m"); |
40 | | -} |
| 29 | + static const char *utf8[] = {"\xe2\x86\x91 \xe2\x86\x93 ", |
| 30 | + "make <TAB>", "bind -x ", "bindkey ", "${var@P} ", "$SRANDOM ", |
| 31 | + NULL, "\xe2\x86\x92 ^F End ", "Alt-F ", "Alt-N/P ", NULL}; |
| 32 | + static const char *ascii[] = {"Up Down ", "make <TAB>", "bind -x ", |
| 33 | + "bindkey ", "${var@P} ", "$SRANDOM ", NULL, "Right ^F ", |
| 34 | + "Alt-F ", "Alt-N/P ", NULL}; |
| 35 | + static const char *what[] = {"history by prefix", "Makefile targets", |
| 36 | + "key runs a command", "zsh binds now work", "render as a prompt", |
| 37 | + "and $EPOCHREALTIME", NULL, "take the dim hint", "take one word", |
| 38 | + "older/newer hint"}; |
| 39 | + const char **keys; |
41 | 40 |
|
42 | | -/* One showcase line: an indented badge, then the self-coloured tip. */ |
43 | | -static void news_item(char *dst, const char *chip, const char *text) |
44 | | -{ |
45 | | - ft_snprintf(dst, 160, " %s %s\033[0m", chip, text); |
| 41 | + keys = ascii; |
| 42 | + if (header_use_unicode()) |
| 43 | + keys = utf8; |
| 44 | + if (!keys[n]) |
| 45 | + return (0); |
| 46 | + ft_snprintf(dst, 192, " \033[38;5;223m%s\033[0m " |
| 47 | + "\033[38;5;245m%s\033[0m", keys[n], what[n]); |
| 48 | + return (1); |
46 | 49 | } |
47 | 50 |
|
48 | | -/* The showcase block: the heading, one badged tip per feature, then a salmon |
49 | | - pointer onward to the docs. Backing strings are caller-owned. */ |
50 | | -static void news_block(const char **r, int *i, char nw[][160]) |
| 51 | +/* The news block: a salmon NEW badge on a cyan title, the always-on rows, |
| 52 | + then the switch for hints and the keys that take them. `k` walks the |
| 53 | + table across its group break; `m` the caller-owned backing rows. */ |
| 54 | +static void news_block(const char **r, int *i, char nw[][192]) |
51 | 55 | { |
52 | | - const char *arw; |
53 | | - int n; |
| 56 | + int k; |
| 57 | + int m; |
54 | 58 |
|
55 | | - news_head(nw[0]); |
56 | | - r[(*i)++] = nw[0]; |
| 59 | + r[(*i)++] = "\033[1;48;5;209;38;5;236m NEW \033[0m " |
| 60 | + "\033[1;38;5;81mWhat's new in 3.2\033[0m"; |
57 | 61 | r[(*i)++] = ""; |
58 | | - n = -1; |
59 | | - while (g_news[++n]) |
60 | | - { |
61 | | - news_item(nw[n + 1], g_chip[n], g_news[n]); |
62 | | - r[(*i)++] = nw[n + 1]; |
63 | | - } |
64 | | - arw = "->"; |
65 | | - if (header_use_unicode()) |
66 | | - arw = "\xe2\x86\x92"; |
67 | | - ft_snprintf(nw[4], 160, " \033[38;5;173m%s\033[0m " |
68 | | - "\033[38;5;245mmore in docs/, or run \033[0m\033[38;5;223mhelp\033[0m", |
69 | | - arw); |
| 62 | + k = 0; |
| 63 | + m = 0; |
| 64 | + while (news_row(nw[m], k++)) |
| 65 | + r[(*i)++] = nw[m++]; |
70 | 66 | r[(*i)++] = ""; |
71 | | - r[(*i)++] = nw[4]; |
| 67 | + r[(*i)++] = " \033[38;5;223mexport HELLISH_AUTOSUGGEST=1\033[0m"; |
| 68 | + while (news_row(nw[m], k++)) |
| 69 | + r[(*i)++] = nw[m++]; |
72 | 70 | } |
73 | 71 |
|
74 | | -/* The right column: getting-started tips, the "Did you know?" showcase, then a |
75 | | - live version/update status footer. Backing strings are static (shown once). |
76 | | -*/ |
| 72 | +/* The right column: getting-started tips, what is new in this release, |
| 73 | + then a live version/update status footer. Backing strings are static |
| 74 | + (shown once). */ |
77 | 75 | void build_right(const char **r) |
78 | 76 | { |
79 | | - static char nw[5][160]; |
| 77 | + static char nw[9][192]; |
80 | 78 | static char status[192]; |
81 | 79 | int i; |
82 | 80 |
|
83 | 81 | i = 0; |
84 | 82 | r[i++] = HP_HEAD "Getting started"; |
85 | 83 | r[i++] = ""; |
86 | 84 | r[i++] = " help commands & options"; |
87 | | - r[i++] = " update check for a newer release"; |
88 | | - r[i++] = " type NAME how any name resolves"; |
| 85 | + r[i++] = " update check for updates"; |
| 86 | + r[i++] = " type NAME what a name runs"; |
89 | 87 | r[i++] = HP_RULE; |
90 | 88 | news_block(r, &i, nw); |
91 | 89 | r[i++] = HP_RULE; |
|
0 commit comments