File tree Expand file tree Collapse file tree 8 files changed +44
-2
lines changed Expand file tree Collapse file tree 8 files changed +44
-2
lines changed Original file line number Diff line number Diff line change 11[package ]
22name = " swordfish-rs"
3- version = " 0.5.2 "
3+ version = " 0.6.0 "
44edition = " 2021"
55license-file = " LICENSE"
66description = " Cli tool for typing effect in Termainl for screencasts"
Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ use swordfishlib;
22use std:: fs;
33
44fn main ( ) {
5- let data = fs:: read_to_string ( "examples/screenplay .yaml" ) . expect ( "Unable to read screenplay file" ) ;
5+ let data = fs:: read_to_string ( "examples/intro .yaml" ) . expect ( "Unable to read screenplay file" ) ;
66 let commands = swordfishlib:: from_yaml ( & data) . expect ( "Parsing errors in screenplay file" ) ;
77 swordfishlib:: execute ( commands) . unwrap ( ) ;
88}
File renamed without changes.
Original file line number Diff line number Diff line change 1+ use swordfishlib;
2+ use std:: fs;
3+
4+ fn main ( ) {
5+ let data = fs:: read_to_string ( "examples/set_title.yaml" ) . expect ( "Unable to read screenplay file" ) ;
6+ let commands = swordfishlib:: from_yaml ( & data) . expect ( "Parsing errors in screenplay file" ) ;
7+ swordfishlib:: execute ( commands) . unwrap ( ) ;
8+ }
Original file line number Diff line number Diff line change 1+ - !clear
2+ - !prompt {text: "$", color: green}
3+ - !write {msec: 20, text: "swordfish can set the terminal title, look up..."}
4+ - !wait {msec: 2000}
5+ - !new_line
6+ - !title {text: "swordfish demo"}
7+ - !write {msec: 20, text: "nice!"}
8+ - !wait {msec: 2000}
9+ - !erase {msec: 20, amount: 100}
10+ - !wait {msec: 1000}
11+ - !write {msec: 20, text: "super nice!"}
12+ - !wait {msec: 3000}
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ pub enum Command<'a> {
1818 Pause ( Pause ) ,
1919 #[ serde( borrow) ]
2020 Prompt ( Prompt < ' a > ) ,
21+ #[ serde( borrow) ]
22+ Title ( Title < ' a > ) ,
2123 Turbo ( Turbo ) ,
2224 Wait ( Wait ) ,
2325 #[ serde( borrow) ]
@@ -136,6 +138,20 @@ impl Runnable for Prompt<'_> {
136138 }
137139}
138140
141+ /// `!title`
142+ /// Title specify a constant text that is shown after every `execute` and cis not affected by `erase`.
143+ #[ derive( Debug , Deserialize ) ]
144+ pub struct Title < ' a > {
145+ pub text : & ' a str ,
146+ }
147+
148+ impl Runnable for Title < ' _ > {
149+ fn run ( & self , _state : & mut State ) -> Result < ( ) > {
150+ functions:: show_title ( self . text ) ?;
151+ Ok ( ( ) )
152+ }
153+ }
154+
139155/// `!turbo`
140156/// Speed everything, useful when iterating over the screenplay.
141157#[ derive( Debug , Deserialize ) ]
Original file line number Diff line number Diff line change @@ -23,4 +23,9 @@ pub fn show_prompt(prompt: &Option<String>) -> Result<()> {
2323 stdout ( ) . flush ( ) ?;
2424 }
2525 Ok ( ( ) )
26+ }
27+
28+ pub fn show_title ( text : & str ) -> Result < ( ) > {
29+ write ! ( stdout( ) , "\x1B ]0;{text}\x07 " ) ?;
30+ Ok ( ( ) )
2631}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ use swordfishlib;
44fn play_commands ( ) {
55 let screenplay = r###"
66 - !clear
7+ - !title {text: "title here"}
78 - !prompt {color: bright_green, text: "$"}
89 - !write {msec: 0, color: blue, text: "$ "}
910 - !write {msec: 0, text: "i am going to list this dir"}
You can’t perform that action at this time.
0 commit comments