Skip to content

Commit

Permalink
Merge pull request #1 from veeso/0.6.0
Browse files Browse the repository at this point in the history
tui-realm 0.6.0
  • Loading branch information
veeso committed Aug 3, 2021
2 parents 57e49f4 + 12daff0 commit 65a3c24
Show file tree
Hide file tree
Showing 35 changed files with 361 additions and 306 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# Changelog

- [Changelog](#changelog)
- [0.6.0](#060)
- [0.5.0](#050)

---

## 0.6.0

Released on 03/08/2021

- Compatibility with `tui-realm 0.6.0`
- ❗ Breaking changes ❗
- from now on `with_title` functions takes both title text and alignment

## 0.5.0

Released on 31/07/2021
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tui-realm-stdlib"
version = "0.5.0"
version = "0.6.0"
authors = ["Christian Visintin"]
edition = "2018"
categories = ["command-line-utilities"]
Expand All @@ -14,12 +14,12 @@ readme = "README.md"
repository = "https://github.com/veeso/tui-realm-stdlib"

[dependencies]
tuirealm = "0.5.1"
tuirealm = "0.6.0"
textwrap = "0.14.0"
unicode-width = "0.1.8"

[dev-dependencies]
crossterm = { version = "0.19" }
crossterm = { version = "0.20" }
pretty_assertions = "0.7.2"
rand = "0.8.4"

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![Build](https://github.com/veeso/tui-realm-stdlib/workflows/Linux/badge.svg)](https://github.com/veeso/tui-realm-stdlib/actions) [![Build](https://github.com/veeso/tui-realm-stdlib/workflows/MacOS/badge.svg)](https://github.com/veeso/tui-realm-stdlib/actions) [![Build](https://github.com/veeso/tui-realm-stdlib/workflows/Windows/badge.svg)](https://github.com/veeso/tui-realm-stdlib/actions) [![Coverage Status](https://coveralls.io/repos/github/veeso/tui-realm-stdlib/badge.svg?branch=main)](https://coveralls.io/github/veeso/tui-realm-stdlib?branch=main)

Developed by Christian Visintin
Current version: 0.5.0 (31/07/2021)
Current version: 0.6.0 (03/08/2021)

---

Expand Down Expand Up @@ -55,19 +55,19 @@ tui-realm-stdlib is the standard component library for [tui-realm](https://githu
### Add tui-realm to your Cargo.toml 🦀

```toml
tui-realm-stdlib = "0.5.0"
tui-realm-stdlib = "0.6.0"
```

Since this library requires `crossterm` too, you'll also need to add it to your Cargo.toml

```toml
crossterm = "0.19.0"
crossterm = "0.20.0"
```

Latest version of tui-realm-stdlib requires **tui-realm 0.5.1**
Latest version of tui-realm-stdlib requires **tui-realm 0.6.0**

```toml
tuirealm = "0.5.1"
tuirealm = "0.6.0"
```

## Examples
Expand Down
11 changes: 6 additions & 5 deletions examples/bar_chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use tui_realm_stdlib::components::{
label,
};
use tuirealm::props::borders::{BorderType, Borders};
use tuirealm::props::Alignment;
use tuirealm::{Msg, PropsBuilder, Update, View};
// tui
use tuirealm::tui::layout::{Constraint, Direction, Layout};
Expand Down Expand Up @@ -95,7 +96,7 @@ fn main() {
.hidden()
.visible()
.disabled(false)
.with_title(String::from("my incomes"))
.with_title("my incomes", Alignment::Center)
.with_label_style(Style::default().fg(Color::Yellow))
.with_bar_style(Style::default().fg(Color::LightYellow))
.with_bar_gap(6)
Expand Down Expand Up @@ -129,7 +130,7 @@ fn main() {
.disabled(true)
.with_background(Color::White)
.with_foreground(Color::Black)
.with_title(String::from("my incomes"))
.with_title("my incomes", Alignment::Left)
.with_label_style(Style::default().fg(Color::Yellow))
.with_bar_style(Style::default().fg(Color::LightYellow))
.with_bar_gap(4)
Expand Down Expand Up @@ -216,15 +217,15 @@ impl Update for Model {
match ref_msg {
None => None, // Exit after None
Some(msg) => match msg {
(COMPONENT_CHART1, &MSG_KEY_TAB) => {
(COMPONENT_CHART1, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_CHART2);
None
}
(COMPONENT_CHART2, &MSG_KEY_TAB) => {
(COMPONENT_CHART2, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_CHART1);
None
}
(_, &MSG_KEY_ESC) => {
(_, key) if key == &MSG_KEY_ESC => {
// Quit on esc
self.quit();
None
Expand Down
5 changes: 3 additions & 2 deletions examples/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ use std::time::{Duration, Instant};

use tui_realm_stdlib::components::{label, Canvas, CanvasPropsBuilder};
use tuirealm::props::borders::{BorderType, Borders};
use tuirealm::props::Alignment;
use tuirealm::tui::widgets::canvas::MapResolution;
use tuirealm::{Msg, PropsBuilder, Update, View};
// tui
Expand Down Expand Up @@ -92,7 +93,7 @@ fn main() {
.hidden()
.visible()
.with_background(Color::Reset)
.with_title(String::from("playing risiko"))
.with_title(String::from("playing risiko"), Alignment::Center)
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightYellow)
.with_x_bounds((-180.0, 180.0))
.with_y_bounds((-90.0, 90.0))
Expand Down Expand Up @@ -171,7 +172,7 @@ impl Update for Model {
match ref_msg {
None => None, // Exit after None
Some(msg) => match msg {
(_, &MSG_KEY_ESC) => {
(_, key) if key == &MSG_KEY_ESC => {
// Quit on esc
self.quit();
None
Expand Down
6 changes: 3 additions & 3 deletions examples/chart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ use tui_realm_stdlib::components::{
};
use tuirealm::props::{
borders::{BorderType, Borders},
Dataset,
Alignment, Dataset,
};
use tuirealm::{Msg, PropsBuilder, Update, View};
// tui
Expand Down Expand Up @@ -130,7 +130,7 @@ fn main() {
.disabled(true)
.with_background(Color::Reset)
.with_foreground(Color::Reset)
.with_title(String::from("Temperatures in room"))
.with_title(String::from("Temperatures in room"), Alignment::Center)
.with_borders(Borders::ALL, BorderType::Double, Color::Yellow)
.with_x_style(Style::default().fg(Color::LightBlue))
.with_x_title("Time")
Expand Down Expand Up @@ -228,7 +228,7 @@ impl Update for Model {
match ref_msg {
None => None, // Exit after None
Some(msg) => match msg {
(_, &MSG_KEY_ESC) => {
(_, key) if key == &MSG_KEY_ESC => {
// Quit on esc
self.quit();
None
Expand Down
15 changes: 9 additions & 6 deletions examples/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ use std::thread::sleep;
use std::time::{Duration, Instant};

use tui_realm_stdlib::components::{checkbox, label};
use tuirealm::props::borders::{BorderType, Borders};
use tuirealm::props::{
borders::{BorderType, Borders},
Alignment,
};
use tuirealm::{Msg, PropsBuilder, Update, View};
// tui
use tuirealm::tui::layout::{Constraint, Direction, Layout};
Expand Down Expand Up @@ -91,7 +94,7 @@ fn main() {
checkbox::CheckboxPropsBuilder::default()
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightYellow)
.with_color(Color::LightYellow)
.with_title("Select flavour")
.with_title("Select flavour", Alignment::Left)
.with_options(&["vanilla", "chocolate", "coconut", "hazelnut"])
.build(),
)),
Expand All @@ -102,7 +105,7 @@ fn main() {
checkbox::CheckboxPropsBuilder::default()
.with_borders(Borders::ALL, BorderType::Rounded, Color::Black)
.with_color(Color::Black)
.with_title("Select flavour")
.with_title("Select flavour", Alignment::Right)
.with_options(&["vanilla", "chocolate", "coconut", "hazelnut"])
.rewind(true)
.build(),
Expand Down Expand Up @@ -170,15 +173,15 @@ impl Update for Model {
match ref_msg {
None => None, // Exit after None
Some(msg) => match msg {
(COMPONENT_CHECKBOX, &MSG_KEY_TAB) => {
(COMPONENT_CHECKBOX, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_CHECKBOX_INVERTED);
None
}
(COMPONENT_CHECKBOX_INVERTED, &MSG_KEY_TAB) => {
(COMPONENT_CHECKBOX_INVERTED, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_CHECKBOX);
None
}
(_, &MSG_KEY_ESC) => {
(_, key) if key == &MSG_KEY_ESC => {
// Quit on esc
self.quit();
None
Expand Down
9 changes: 6 additions & 3 deletions examples/demo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ use std::thread::sleep;
use std::time::{Duration, Instant};

use tui_realm_stdlib::components::{input, label};
use tuirealm::props::borders::{BorderType, Borders};
use tuirealm::props::{
borders::{BorderType, Borders},
Alignment,
};
use tuirealm::{InputType, Msg, Payload, PropsBuilder, Update, Value, View};
// tui
use tuirealm::tui::layout::{Constraint, Direction, Layout};
Expand Down Expand Up @@ -91,7 +94,7 @@ fn main() {
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightYellow)
.with_foreground(Color::LightYellow)
.with_input(InputType::Text)
.with_label(String::from("Type in something nice"))
.with_label(String::from("Type in something nice"), Alignment::Center)
.build(),
)),
);
Expand Down Expand Up @@ -160,7 +163,7 @@ impl Update for Model {
let msg = self.view.update(COMPONENT_LABEL, props);
self.update(msg)
}
(_, &MSG_KEY_ESC) => {
(_, key) if key == &MSG_KEY_ESC => {
// Quit on esc
self.quit();
None
Expand Down
36 changes: 21 additions & 15 deletions examples/gallery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ use tui_realm_stdlib::components::{
checkbox, input, label, list, paragraph, progress_bar, radio, span, textarea,
};
use tuirealm::props::borders::{BorderType, Borders};
use tuirealm::props::{TableBuilder, TextSpan};
use tuirealm::props::{Alignment, TableBuilder, TextSpan};
use tuirealm::{InputType, Msg, PropPayload, PropValue, PropsBuilder, Update, View};
// tui
use tuirealm::tui::layout::{Constraint, Direction, Layout};
Expand Down Expand Up @@ -133,7 +133,7 @@ fn init_view() -> View {
.with_color(Color::Cyan)
.with_borders(Borders::ALL, BorderType::Rounded, Color::Magenta)
.with_value(vec![1])
.with_title("Select ice-cream flavours")
.with_title("Select ice-cream flavours", Alignment::Left)
.with_options(&[
"Vanilla",
"Chocolate",
Expand All @@ -154,7 +154,10 @@ fn init_view() -> View {
.with_foreground(Color::LightYellow)
.with_input(InputType::Text)
.with_input_len(16)
.with_label(String::from("Type in your username (max length 16)"))
.with_label(
String::from("Type in your username (max length 16)"),
Alignment::Left,
)
.build(),
)),
);
Expand Down Expand Up @@ -185,7 +188,7 @@ fn init_view() -> View {
.with_background(Color::White)
.with_foreground(Color::Black)
.with_borders(Borders::ALL, BorderType::Rounded, Color::Gray)
.with_title("A poem for you")
.with_title("A poem for you", Alignment::Center)
.with_texts(vec![
TextSpan::new("Lorem ipsum dolor sit amet").underlined().fg(Color::Green),
TextSpan::from(", consectetur adipiscing elit. Praesent mauris est, vehicula et imperdiet sed, tincidunt sed est. Sed sed dui odio. Etiam nunc neque, sodales ut ex nec, tincidunt malesuada eros. Sed quis eros non felis sodales accumsan in ac risus"),
Expand All @@ -203,7 +206,7 @@ fn init_view() -> View {
.with_progbar_color(Color::Yellow)
.with_borders(Borders::ALL, BorderType::Thick, Color::Yellow)
.with_progress(0.64)
.with_title("Downloading termscp 0.5.0")
.with_title("Downloading termscp 0.5.0", Alignment::Center)
.with_label("64.2% - ETA 00:48")
.build(),
)),
Expand All @@ -221,7 +224,10 @@ fn init_view() -> View {
)
.with_inverted_color(Color::Black)
.with_value(1)
.with_title("Will you use tui-realm in your next project?")
.with_title(
"Will you use tui-realm in your next project?",
Alignment::Right,
)
.with_options(&["Yes!", "No", "Maybe"])
.build(),
)),
Expand Down Expand Up @@ -260,7 +266,7 @@ fn init_view() -> View {
.with_max_scroll_step(4)
.with_highlighted_color(Color::LightBlue)
.scrollable(true)
.with_title("My scrollable data")
.with_title("My scrollable data", Alignment::Center)
.with_rows(
TableBuilder::default()
.add_col(TextSpan::from("0"))
Expand Down Expand Up @@ -322,7 +328,7 @@ fn init_view() -> View {
list::ListPropsBuilder::default()
.with_foreground(Color::Green)
.with_borders(Borders::ALL, BorderType::Thick, Color::LightGreen)
.with_title("My data")
.with_title("My data", Alignment::Center)
.with_rows(
TableBuilder::default()
.add_col(TextSpan::from("2021-04-17T18:32:00"))
Expand Down Expand Up @@ -363,7 +369,7 @@ fn init_view() -> View {
.with_borders(Borders::ALL, BorderType::Rounded, Color::LightRed)
.with_highlighted_str(Some("🎵"))
.with_max_scroll_step(3)
.with_title("Scrollable textarea")
.with_title("Scrollable textarea", Alignment::Left)
.with_texts(
vec![
TextSpan::new("About TermSCP").bold().underlined().fg(Color::Yellow),
Expand Down Expand Up @@ -440,31 +446,31 @@ impl Update for Model {
match ref_msg {
None => None, // Exit after None
Some(msg) => match msg {
(COMPONENT_CHECKBOX, &MSG_KEY_TAB) => {
(COMPONENT_CHECKBOX, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_INPUT);
// Update progress
let msg = update_progress(&mut self.view);
self.update(msg)
}
(COMPONENT_INPUT, &MSG_KEY_TAB) => {
(COMPONENT_INPUT, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_RADIO);
// Update progress
let msg = update_progress(&mut self.view);
self.update(msg)
}
(COMPONENT_RADIO, &MSG_KEY_TAB) => {
(COMPONENT_RADIO, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_SCROLLIST);
// Update progress
let msg = update_progress(&mut self.view);
self.update(msg)
}
(COMPONENT_SCROLLIST, &MSG_KEY_TAB) => {
(COMPONENT_SCROLLIST, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_TEXTAREA);
// Update progress
let msg = update_progress(&mut self.view);
self.update(msg)
}
(COMPONENT_TEXTAREA, &MSG_KEY_TAB) => {
(COMPONENT_TEXTAREA, key) if key == &MSG_KEY_TAB => {
self.view.active(COMPONENT_CHECKBOX);
// Update progress
let msg = update_progress(&mut self.view);
Expand All @@ -482,7 +488,7 @@ impl Update for Model {
let msg = update_progress(&mut self.view);
self.update(msg)
}
(_, &MSG_KEY_ESC) => {
(_, key) if key == &MSG_KEY_ESC => {
// Quit
self.quit();
None
Expand Down

0 comments on commit 65a3c24

Please sign in to comment.