Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/Arteiii/zenity
Browse files Browse the repository at this point in the history
  • Loading branch information
Arteiii committed Apr 17, 2024
2 parents 85553c0 + 22a2991 commit 6ae28b9
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zenity"
version = "3.0.1"
version = "3.1.0"
authors = ["Arteii <[email protected]>"]
edition = "2021"
license-file = "LICENSE.md"
Expand Down
8 changes: 5 additions & 3 deletions examples/input.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use regex::Regex;
use zenity::menu::input::{valid_regex, valid_path};
use zenity::menu::input::{valid_path, valid_regex};

fn main() {
println!("\n\nReturn: {}", valid_regex(Regex::new(r"^\d{3}$").unwrap()));
println!(
"\n\nReturn: {}",
valid_regex(Regex::new(r"^\d{3}$").unwrap())
);
println!("\n\nPath: {:?}", valid_path());

}
17 changes: 8 additions & 9 deletions examples/selection.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
// rmeoved for now will work on it soon


// use zenity::menu::selection::{MenuOption, SelectionMenu};
// use zenity::style::{Color, StyledString};
//
//
// fn main() {
// let hello_world = MenuOption {
// text: StyledString::new("Hello World"),
// notes: StyledString::new("bli bla blub"),
// };
//
//
// let method2 = MenuOption {
// text: StyledString::new("method2 says Hi"),
// notes: StyledString::new("No!"),
// };
//
//
// let menu = SelectionMenu {
// title: StyledString::simple("Selection Menu", Some(Color::Red), None, None),
// options: [hello_world.clone(), method2.clone()].to_vec(),
// };
//
//
// let selected_option = menu.single();
//
//
// if selected_option == hello_world {
// println!("User selected Hello World");
// } else if selected_option == method2 {
// println!("Method2 says Hi");
// } else {
// // handle other cases (shouldn't be any...)
// }
//
//
//
//
// }
fn main() {}
fn main() {}
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@

pub mod color;
pub(crate) mod iterators;
pub mod menu;
pub mod progress;
pub mod spinner;
pub mod style;
pub(crate) mod terminal;
pub mod menu;
4 changes: 2 additions & 2 deletions src/menu/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ use std::path::{Path, PathBuf};
use crossterm::{
cursor::MoveTo,
event::{Event, KeyCode, KeyEvent},
ExecutableCommand,
execute,
terminal::{disable_raw_mode, enable_raw_mode},
ExecutableCommand,
};
use regex::Regex;

Expand Down Expand Up @@ -185,7 +185,7 @@ fn validate_input(buffer: &str, regex: &Regex, stdout: &mut std::io::Stdout) ->
crossterm::terminal::ClearType::CurrentLine,
))
.unwrap();
false
false
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/terminal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ pub(crate) mod console_render {

pub fn render_line(frame: &Vec<String>, row: u16) {
let mut stdout = stdout();
queue!(stdout, cursor::RestorePosition, cursor::MoveToNextLine(row + 1),).unwrap();
queue!(
stdout,
cursor::RestorePosition,
cursor::MoveToNextLine(row + 1),
)
.unwrap();

for content in frame {
queue!(stdout, style::Print(content),).unwrap();
Expand Down

0 comments on commit 6ae28b9

Please sign in to comment.