Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ jobs:
- name: Build Projects
run: |
rustup target add x86_64-pc-windows-gnu
cargo build --release --all --all-features --target x86_64-unknown-linux-gnu --verbose
cargo build --release --all --all-features --target x86_64-pc-windows-gnu --verbose
cargo build --release --all --all-features --target x86_64-unknown-linux-gnu
cargo build --release --all --all-features --target x86_64-pc-windows-gnu
env:
CURRENT_COMMIT: ${{ steps.vars.outputs.sha_short }}
CURRENT_BUILD: ${{ github.run_number }}
Expand Down
2 changes: 1 addition & 1 deletion cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ common = { path = "../common" }

# Terminal
crossterm = { version = "0.28.1", features = ["event-stream"] }
ratatui = "0.29.0"
ratatui = { version = "0.29.0", features = ["unstable-rendered-line-info"] }
tui-textarea = "0.7.0"
ansi-to-tui = "7.0.0"

Expand Down
8 changes: 5 additions & 3 deletions cli/src/application/util/fancy_toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,16 @@ impl FancyToml {
fn word_to_color(key: &str) -> Color {
match key {
"name" | "id" => WARN_SELECTED_COLOR,
"group" | "node" | "plugin" | "ctrl_addr" | "nodes" => AMBER.c600,
"group" | "node" | "plugin" | "controller_address" | "nodes" => AMBER.c600,
"state" | "ready" | "users" | "token" | "enabled" | "start_threshold"
| "stop_empty" => OK_SELECTED_COLOR,
"host" | "port" => INFO_SELECTED_COLOR,
"memory" | "swap" | "cpu" | "io" | "disk" | "ports" => Color::Magenta,
"img" | "max_players" | "settings" | "env" | "retention" => Color::Blue,
"image" | "max_players" | "settings" | "environment" | "retention" => Color::Blue,
"key" | "value" | "protocol" | "version" => Color::LightYellow,
"max" | "min" | "prio" | "child" => Color::LightCyan,
"max_servers" | "min_servers" | "servers" | "priority" | "child_node" => {
Color::LightCyan
}
_ => TEXT_FG_COLOR,
}
}
Expand Down
43 changes: 24 additions & 19 deletions cli/src/application/window/connect/tab/server/screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,6 @@ impl Window for ScreenTab {
}
}
}

// Update the scrollbar
// This will check if the user is at the bottom if so it will scroll to the new bottom
if self.scroll >= self.scrollable_lines {
self.update_lines(self.available_lines);
self.update_scroll(self.scrollable_lines);
}
}
Some(Err(error)) => {
// Handle error
Expand Down Expand Up @@ -229,9 +222,15 @@ impl ScreenTab {
self.scroll_state = self.scroll_state.position(scroll);
}

fn update_lines(&mut self, height: u16) {
self.available_lines = height;
self.scrollable_lines = self.lines.len().saturating_sub(height as usize);
fn update_lines(&mut self, total_lines: usize, viewport_height: u16) {
let should_scroll_to_bottom = self.scroll == self.scrollable_lines;
self.available_lines = viewport_height;
self.scrollable_lines = total_lines.saturating_sub(viewport_height as usize);

if should_scroll_to_bottom {
// Automatically scroll to the bottom if previously at the bottom
self.update_scroll(self.scrollable_lines);
}
}

fn render_footer(area: Rect, buffer: &mut Buffer) {
Expand All @@ -256,20 +255,26 @@ impl ScreenTab {
let [content_area, scrollbar_area] =
Layout::horizontal([Constraint::Fill(1), Constraint::Length(1)]).areas(main_area);

// Calculate the height/lines of the content area
self.update_lines(content_area.height);

// Update the content length of the scrollbar
self.scroll_state = self.scroll_state.content_length(self.scrollable_lines);

// Content area
{
#[allow(clippy::cast_possible_truncation)]
Paragraph::new(self.lines.clone())
let paragraph = Paragraph::new(self.lines.clone())
.gray()
.wrap(Wrap { trim: false })
.scroll((self.scroll as u16, 0))
.render(content_area, buffer);
.scroll((self.scroll as u16, 0));

// Calculate the height/lines of the content area
self.update_lines(
paragraph.line_count(content_area.width), // Might be removed in the future my ratatui
content_area.height,
);

// Update the content length of the scrollbar
self.scroll_state = self.scroll_state.content_length(self.scrollable_lines);

// Render paragraph
paragraph.render(content_area, buffer);

StatefulWidget::render(
Scrollbar::new(ScrollbarOrientation::VerticalRight).style(TEXT_FG_COLOR),
scrollbar_area,
Expand Down