|
9 | 9 |
|
10 | 10 | ## ZUI – CGI+DHTML-like User Interface Library for Zsh / ZCurses |
11 | 11 |
|
12 | | -This is a RAD (Rapid Application Development) textual user interface library for Zsh. It in many aspects resembles a typical CGI+(D)HTML setup. There are: |
| 12 | +This is a RAD (Rapid Application Development) textual user interface library for Zsh. |
13 | 13 |
|
14 | | -- generators ran on the "server" side (basic Zshell-code that is just generating text!), |
15 | | -- event loop that turns the generated text into a document with active elements (buttons, anchors, toggle buttons, text fields, list boxes), |
16 | | -- mechanism to regenerate document parts from the original generators. |
| 14 | +It in many aspects resembles a typical CGI+(D)HTML setup. There are: |
| 15 | + |
| 16 | +- generators ran on the "server" side (basic Zshell code that is just generating text!) |
| 17 | +- event loop that turns the generated text into a document with active elements (buttons, anchors, toggle buttons, text fields, list boxes) |
| 18 | +- mechanism to regenerate document parts from the original generators |
17 | 19 |
|
18 | 20 | So, a Zshell code generates text. It is then turned into a document with hyperlinks. DHTML-like calls are possible that will regenerate document parts on the fly. Page can be also reloaded with input data, just like an HTML page. |
19 | 21 |
|
20 | 22 | A voiced [video tutorial](https://youtu.be/TfZ8b_RS_Bg) shows how to create an application – Nmap network scanner frontend. |
21 | 23 |
|
22 | | -> See also [ZSTYLES](ZSTYLES.md) |
| 24 | +> More: [zstyles](ZSTYLES.md), [demos](https://github.com/z-shell/zui/blob/main/demos/zui-demo-list-boxes) |
| 25 | +
|
| 26 | +The API is described in the [wiki](https://wiki.zshell.dev/ecosystem/plugins/zui). |
23 | 27 |
|
24 | 28 | ## Hello World |
25 | 29 |
|
| 30 | +Enable demo functions before loading the plugin: |
| 31 | + |
26 | 32 | ```zsh |
27 | | -# Started from Zle or from command line |
| 33 | +typeset -A ZUI |
| 34 | +ZUI[DEMOS]=1 |
| 35 | +``` |
28 | 36 |
|
| 37 | +Started from Zle or the command line: |
| 38 | + |
| 39 | +```zsh |
29 | 40 | -zui_std_cleanup deserialize:"zui-demo-hello-world" |
30 | 41 | -zui_std_init app:"zui-demo-hello-world" app_name:"ZUI Hello World" |
31 | | -emulate -LR zsh -o extended_glob -o typeset_silent -o warn_create_global |
32 | | --zui_std_init2 # after emulate -LR |
33 | 42 |
|
| 43 | +emulate -LR zsh |
| 44 | +setopt extended_glob typeset_silent warn_create_global |
| 45 | + |
| 46 | +-zui_std_init2 # after emulate -LR |
34 | 47 | -zui_std_store_default_app_config b:border 1 |
35 | 48 |
|
36 | 49 | demo_generator_A() { |
37 | | - local mod="$1" ice="$2" |
38 | | - # Content, no hyper-links |
39 | | - reply=( "Hello World from ${ZUI[YELLOW]}ZUI${ZUI[FMT_END]}! Module $mod, instance $ice." ) |
40 | | - # Non-selectable lines Hops to jump with [ and ] Local anchors |
41 | | - reply2=( ) reply3=( 1 ) reply4=( ) |
| 50 | + local mod="$1" ice="$2" |
| 51 | + # Content, no hyper-links |
| 52 | + reply=( "Hello World from ${ZUI[YELLOW]}ZUI${ZUI[FMT_END]}! Module $mod, instance $ice." ) |
| 53 | + # Non-selectable lines Hops to jump with [ and ] Local anchors |
| 54 | + reply2=( ) reply3=( 1 ) reply4=( ) |
42 | 55 | } |
| 56 | +``` |
43 | 57 |
|
44 | | -## Start application ## |
| 58 | +Start application: |
| 59 | + |
| 60 | +```zsh |
45 | 61 | zui-event-loop 1:demo_generator_A |
46 | 62 |
|
47 | 63 | -zui_std_cleanup serialize |
48 | 64 | ``` |
49 | 65 |
|
50 | | -Other example which uses list-box: [zui-demo-list-box](https://github.com/z-shell/zui/blob/main/demos/zui-demo-list-boxes) |
51 | | - |
52 | | -The API is described in the [wiki](https://wiki.zshell.dev/ecosystem/plugins/zui). |
53 | | - |
54 | 66 | ## Installation |
55 | 67 |
|
56 | | -**The plugin is "standalone"**, which means that only sourcing it is needed. To install, unpack `zui` somewhere and add to `zshrc`: |
| 68 | +**The plugin is "standalone"**, which means that only sourcing it is needed. To install, unpack <samp>zui</samp> and load from <samp>.zshrc</samp>: |
57 | 69 |
|
58 | 70 | ```zsh |
59 | 71 | source {where-zui-is}/zui.plugin.zsh |
60 | 72 | ``` |
61 | 73 |
|
62 | | -If using a plugin manager, then `Zi` is recommended, but you can use any other too, and also install with `Oh My Zsh` (by copying the directory to `~`/.oh-my-zsh/custom/plugins`). |
63 | | - |
64 | 74 | ### [Zi](https://github.com/z-shell/zi) |
65 | 75 |
|
66 | | -Add `zi load z-shell/zui` to your `.zshrc` file. ZI will handle the rest automatically the next time you start zsh. To update (i.e. to pull from origin) issue `zi update z-shell/zui`. |
| 76 | +Add <samp>zi load z-shell/zui</samp> to your <samp>.zshrc</samp> file. ZI will handle the rest automatically the next time you start zsh. To update (i.e. to pull from origin) issue <samp>zi update z-shell/zui</samp>. |
67 | 77 |
|
68 | 78 | ### Antigen |
69 | 79 |
|
70 | | -Add `antigen bundle z-shell/zui` to your `.zshrc` file. Antigen will handle cloning the plugin for you automatically the next time you start zsh. |
| 80 | +Add <samp>antigen bundle z-shell/zui</samp> to your <samp>.zshrc</samp> file. Antigen will handle cloning the plugin for you automatically the next time you start zsh. |
71 | 81 |
|
72 | 82 | ### Oh-My-Zsh |
73 | 83 |
|
74 | | -1. `cd ~/.oh-my-zsh/custom/plugins` |
75 | | -2. `git clone git@github.com:z-shell/zui.git` |
76 | | -3. Add `zui` to your plugin list |
| 84 | +1. <samp>cd ~/.oh-my-zsh/custom/plugins</samp> |
| 85 | +2. <samp>git clone https://github.com/z-shell/zui.git</samp> |
| 86 | +3. Add <samp>zui</samp> to your plugin list |
77 | 87 |
|
78 | 88 | ### Zgen |
79 | 89 |
|
80 | | -Add `zgen load z-shell/zui` to your .zshrc file in the same place you're doing your other `zgen load` calls in. |
| 90 | +Add <samp>zgen load z-shell/zui</samp> to your .zshrc file in the same place you're doing your other <samp>zgen load</samp> calls in. |
0 commit comments