Skip to content

Commit

Permalink
Merge pull request #284 from replydev/migrate-to-ratatui
Browse files Browse the repository at this point in the history
Migrate to ratatui
  • Loading branch information
replydev authored Jul 30, 2023
2 parents f5f46c3 + 6591fa7 commit fbc714c
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 51 deletions.
98 changes: 65 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ serde = { version = "1.0.177", features = ["derive"] }
dirs = "5.0.1"
rpassword = "7.2.0"
data-encoding = "2.4.0"
crossterm = "0.26.1"
tui = "0.19.0"
copypasta-ext = "0.4.4"
zeroize = "1.6.0"
clap = { version = "4.3.19", features = ["derive"] }
Expand All @@ -52,3 +50,5 @@ regex = "1.9.1"
once_cell = "1.18.0"
base64 = "0.21.2"
md-5 = "0.10.5"
ratatui = { version = "0.22.0", features = ["all-widgets"] }
crossterm = "0.26.1"
12 changes: 6 additions & 6 deletions src/interface/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use crate::interface::enums::Focus;
use crate::interface::enums::Page;
use crate::interface::enums::Page::{Main, Qrcode};
use crate::otp::otp_element::OTPDatabase;
use tui::backend::Backend;
use tui::layout::Rect;
use tui::layout::{Alignment, Constraint, Direction, Layout};
use tui::style::{Color, Modifier, Style};
use tui::terminal::Frame;
use tui::widgets::{Block, Borders, Cell, Clear, Gauge, Paragraph, Row, Table, Wrap};
use ratatui::backend::Backend;
use ratatui::layout::Rect;
use ratatui::layout::{Alignment, Constraint, Direction, Layout};
use ratatui::style::{Color, Modifier, Style};
use ratatui::terminal::Frame;
use ratatui::widgets::{Block, Borders, Cell, Clear, Gauge, Paragraph, Row, Table, Wrap};

use crate::interface::stateful_table::{fill_table, StatefulTable};
use crate::utils::percentage;
Expand Down
4 changes: 2 additions & 2 deletions src/interface/popup.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use tui::layout::{Constraint, Direction};
use tui::layout::{Layout, Rect};
use ratatui::layout::{Constraint, Direction};
use ratatui::layout::{Layout, Rect};

/// helper function to create a centered rect using up certain percentage of the available rect `r`
pub(crate) fn centered_rect(percent_x: u16, percent_y: u16, r: Rect) -> Rect {
Expand Down
6 changes: 3 additions & 3 deletions src/interface/row.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use tui::style::Color::{Black, Yellow};
use tui::style::Style;
use tui::widgets::Cell;
use ratatui::style::Color::{Black, Yellow};
use ratatui::style::Style;
use ratatui::widgets::Cell;

pub(crate) struct Row {
pub(crate) values: Vec<String>,
Expand Down
2 changes: 1 addition & 1 deletion src/interface/stateful_table.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::interface::row::Row;
use tui::widgets::TableState;
use ratatui::widgets::TableState;

use crate::otp::{otp_element::OTPElement, otp_type::OTPType};

Expand Down
4 changes: 2 additions & 2 deletions src/interface/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ use std::io;

use crossterm::event::{DisableMouseCapture, EnableMouseCapture};
use crossterm::terminal::{self, EnterAlternateScreen, LeaveAlternateScreen};
use tui::backend::Backend;
use tui::Terminal;
use ratatui::prelude::Backend;
use ratatui::Terminal;

use crate::interface::app::{App, AppResult};
use crate::interface::event::EventHandler;
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ use interface::event::{Event, EventHandler};
use interface::handler::handle_key_events;
use interface::ui::Tui;
use otp::otp_element::{OTPDatabase, CURRENT_DATABASE_VERSION};
use ratatui::prelude::CrosstermBackend;
use ratatui::Terminal;
use reading::{get_elements, ReadResult};
use std::{io, vec};
use tui::backend::CrosstermBackend;
use tui::Terminal;
use zeroize::Zeroize;

mod args;
Expand Down

0 comments on commit fbc714c

Please sign in to comment.