Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bump ratatui to 0.26.1 #32

Merged
merged 2 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ console = "0.15.7"
crossterm = "0.27.0"
nu-plugin = "0.90.1"
nu-protocol = { version = "0.90.1", features = ["plugin"] }
ratatui = "0.22.0"
ratatui = "0.26.1"
url = "2.4.0"

[lib]
Expand Down
4 changes: 2 additions & 2 deletions src/edit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crossterm::event::KeyCode;
use ratatui::{
prelude::{Backend, Rect},
prelude::Rect,
style::Style,
widgets::{Block, Borders, Clear, Paragraph, Wrap},
Frame,
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Editor {
None
}

pub(super) fn render<B: Backend>(&self, frame: &mut Frame<'_, B>, config: &Config) {
pub(super) fn render(&self, frame: &mut Frame, config: &Config) {
let title = "Editor";

let block = Paragraph::new(self.buffer.as_str())
Expand Down
28 changes: 10 additions & 18 deletions src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use super::{App, Config, Mode};
use crossterm::event::KeyCode;
use nu_protocol::ast::PathMember;
use nu_protocol::{Record, Type, Value};
use ratatui::prelude::Backend;
use ratatui::{
prelude::{Alignment, Constraint, Rect},
style::{Color, Modifier, Style},
Expand All @@ -18,12 +17,7 @@ use ratatui::{
};

/// render the whole ui
pub(super) fn render_ui<B: Backend>(
frame: &mut Frame<'_, B>,
app: &App,
config: &Config,
error: Option<&str>,
) {
pub(super) fn render_ui(frame: &mut Frame, app: &App, config: &Config, error: Option<&str>) {
render_data(frame, app, config);
if config.show_cell_path {
render_cell_path(frame, app);
Expand All @@ -41,7 +35,7 @@ pub(super) fn render_ui<B: Backend>(
}
}

pub(super) fn render_error<B: Backend>(frame: &mut Frame<'_, B>, error: &str) {
pub(super) fn render_error(frame: &mut Frame, error: &str) {
let bottom_two_lines = Rect::new(0, frame.size().height - 2, frame.size().width, 2);

let lines = vec![
Expand Down Expand Up @@ -229,7 +223,7 @@ fn repr_table(table: &[Record]) -> (Vec<String>, Vec<String>, Vec<Vec<String>>)
///
/// the data will be rendered on top of the bar, and on top of the cell path in case
/// [`crate::config::Config::show_cell_path`] is set to `true`.
fn render_data<B: Backend>(frame: &mut Frame<'_, B>, app: &App, config: &Config) {
fn render_data(frame: &mut Frame, app: &App, config: &Config) {
let data_frame_height = if config.show_cell_path {
frame.size().height - 2
} else {
Expand Down Expand Up @@ -318,12 +312,11 @@ fn render_data<B: Backend>(frame: &mut Frame<'_, B>, app: &App, config: &Config)
.map(|r| Row::new(r.iter().cloned().map(Cell::from).collect::<Vec<Cell>>()))
.collect();

let table = Table::new(rows)
let table = Table::new(rows, widths)
.header(header)
.block(Block::default().borders(Borders::ALL))
.highlight_style(highlight_style)
.highlight_symbol(&config.colors.selected_symbol)
.widths(&widths);
.highlight_symbol(config.colors.selected_symbol.clone());

frame.render_stateful_widget(
table,
Expand Down Expand Up @@ -446,14 +439,13 @@ fn render_data<B: Backend>(frame: &mut Frame<'_, B>, app: &App, config: &Config)
};

let table = if config.show_table_header {
Table::new(rows).header(header.height(1))
Table::new(rows, constraints).header(header.height(1))
} else {
Table::new(rows)
Table::new(rows, constraints)
}
.block(Block::default().borders(Borders::ALL))
.highlight_style(highlight_style)
.highlight_symbol(&config.colors.selected_symbol)
.widths(&constraints);
.highlight_symbol(config.colors.selected_symbol.clone());

frame.render_stateful_widget(
table,
Expand Down Expand Up @@ -481,7 +473,7 @@ fn render_data<B: Backend>(frame: &mut Frame<'_, B>, app: &App, config: &Config)
/// ```text
/// ||cell path: $.foo.bar.2.baz ...||
/// ```
fn render_cell_path<B: Backend>(frame: &mut Frame<'_, B>, app: &App) {
fn render_cell_path(frame: &mut Frame, app: &App) {
let next_to_bottom_bar_rect = Rect::new(0, frame.size().height - 2, frame.size().width, 1);
let cell_path = format!(
"cell path: $.{}",
Expand Down Expand Up @@ -530,7 +522,7 @@ fn render_cell_path<B: Backend>(frame: &mut Frame<'_, B>, app: &App) {
/// ```text
/// ||PEEKING ... <esc> to NORMAL | a to peek all | c to peek current view | u to peek under cursor | q to quit||
/// ```
fn render_status_bar<B: Backend>(frame: &mut Frame<'_, B>, app: &App, config: &Config) {
fn render_status_bar(frame: &mut Frame, app: &App, config: &Config) {
let bottom_bar_rect = Rect::new(0, frame.size().height - 1, frame.size().width, 1);

let bg_style = match app.mode {
Expand Down
Loading