Skip to content

Commit 2aaeeff

Browse files
committed
update readme about form
1 parent 53d5884 commit 2aaeeff

File tree

2 files changed

+84
-0
lines changed

2 files changed

+84
-0
lines changed

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ promkit = "0.4.4"
2323
- [Readline](#readline)
2424
- [Confirm](#confirm)
2525
- [Password](#password)
26+
- [Form](#form)
2627
- [Listbox](#listbox)
2728
- [QuerySelector](#queryselector)
2829
- [Checkbox](#checkbox)
@@ -147,6 +148,72 @@ fn main() -> Result {
147148

148149
![password](https://github.com/ynqa/promkit/assets/6745370/396356ef-47de-44bc-a8d4-d03c7ac66a2f)
149150

151+
### Form
152+
153+
<details>
154+
<summary>Command</summary>
155+
156+
```bash
157+
cargo run --example form
158+
```
159+
160+
</details>
161+
162+
<details>
163+
<summary>Code</summary>
164+
165+
```rust
166+
use promkit::{crossterm::style::Color, preset::form::Form, style::StyleBuilder, text_editor};
167+
168+
fn main() -> anyhow::Result<()> {
169+
let mut p = Form::new([
170+
text_editor::State {
171+
texteditor: Default::default(),
172+
history: Default::default(),
173+
prefix: String::from("❯❯ "),
174+
mask: Default::default(),
175+
prefix_style: StyleBuilder::new().fgc(Color::DarkRed).build(),
176+
active_char_style: StyleBuilder::new().bgc(Color::DarkCyan).build(),
177+
inactive_char_style: StyleBuilder::new().build(),
178+
edit_mode: Default::default(),
179+
word_break_chars: Default::default(),
180+
lines: Default::default(),
181+
},
182+
text_editor::State {
183+
texteditor: Default::default(),
184+
history: Default::default(),
185+
prefix: String::from("❯❯ "),
186+
mask: Default::default(),
187+
prefix_style: StyleBuilder::new().fgc(Color::DarkGreen).build(),
188+
active_char_style: StyleBuilder::new().bgc(Color::DarkCyan).build(),
189+
inactive_char_style: StyleBuilder::new().build(),
190+
edit_mode: Default::default(),
191+
word_break_chars: Default::default(),
192+
lines: Default::default(),
193+
},
194+
text_editor::State {
195+
texteditor: Default::default(),
196+
history: Default::default(),
197+
prefix: String::from("❯❯ "),
198+
mask: Default::default(),
199+
prefix_style: StyleBuilder::new().fgc(Color::DarkBlue).build(),
200+
active_char_style: StyleBuilder::new().bgc(Color::DarkCyan).build(),
201+
inactive_char_style: StyleBuilder::new().build(),
202+
edit_mode: Default::default(),
203+
word_break_chars: Default::default(),
204+
lines: Default::default(),
205+
},
206+
])
207+
.prompt()?;
208+
println!("result: {:?}", p.run()?);
209+
Ok(())
210+
}
211+
```
212+
213+
</details>
214+
215+
![form](https://github.com/ynqa/promkit/assets/6745370/c3dc88a7-d0f0-42f4-90b8-bc4d2e23e36d)
216+
150217
### Listbox
151218

152219
<details>

tapes/form.tape

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Output tapes/form.gif
2+
3+
Require cargo
4+
5+
Set Shell "bash"
6+
Set Theme "Dracula"
7+
Set FontSize 32
8+
Set Width 1200
9+
Set Height 600
10+
11+
Type@50ms "cargo run -q --example form" Enter Sleep 1s
12+
Type "Hello" Sleep 1s
13+
Down 1 Sleep 1s
14+
Type "promkit" Sleep 1s
15+
Down 1 Sleep 1s
16+
Type "!!!" Sleep 1s
17+
Enter Sleep 2s

0 commit comments

Comments
 (0)