diff options
author | Jesse Luehrs <doy@tozt.net> | 2013-04-03 01:01:47 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2013-04-03 01:01:47 -0500 |
commit | 30f95efebb4ce102cdae25e0c837709f830a106d (patch) | |
tree | 1631ea329c98910b0db5a5c01ce402d086979772 /test/attrs.rs | |
parent | 0867d1894ce27b06e7ffce7ef3d52c8048e359d1 (diff) | |
download | rust-term-30f95efebb4ce102cdae25e0c837709f830a106d.tar.gz rust-term-30f95efebb4ce102cdae25e0c837709f830a106d.zip |
add a few more examples
Diffstat (limited to 'test/attrs.rs')
-rw-r--r-- | test/attrs.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/test/attrs.rs b/test/attrs.rs new file mode 100644 index 0000000..6d8086b --- /dev/null +++ b/test/attrs.rs @@ -0,0 +1,46 @@ +extern mod term; + +fn main () { + term::info::init(); + print(term::info::exit_attribute_mode()); + loop { + print("Attribute? "); + + let attr = io::stdin().read_line(); + + if attr.starts_with("fg:") || attr.starts_with("bg:") { + let set = if attr.starts_with("fg:") { + |c| { print(term::info::set_a_foreground(c)) } + } + else { + |c| { print(term::info::set_a_background(c)) } + }; + + match attr.slice(3, attr.len()) { + &"black" => set(term::info::ColorBlack), + &"red" => set(term::info::ColorRed), + &"green" => set(term::info::ColorGreen), + &"yellow" => set(term::info::ColorYellow), + &"blue" => set(term::info::ColorBlue), + &"magenta" => set(term::info::ColorMagenta), + &"cyan" => set(term::info::ColorCyan), + &"white" => set(term::info::ColorWhite), + _ => (), + } + } + else { + match attr { + ~"underline" => print(term::info::enter_underline_mode()), + ~"standout" => print(term::info::enter_standout_mode()), + ~"reverse" => print(term::info::enter_reverse_mode()), + ~"bold" => print(term::info::enter_bold_mode()), + ~"blink" => print(term::info::enter_blink_mode()), + ~"reset" => print(term::info::exit_attribute_mode()), + ~"reset_color" => print(term::info::orig_pair()), + ~"" => break, + _ => (), + } + } + } + print(term::info::exit_attribute_mode()); +} |