diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6de2b299..1fd1b396 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 }} diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 43aff5d7..52d02b38 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -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" diff --git a/cli/src/application/util/fancy_toml.rs b/cli/src/application/util/fancy_toml.rs index 1e074f88..ad5de7b9 100644 --- a/cli/src/application/util/fancy_toml.rs +++ b/cli/src/application/util/fancy_toml.rs @@ -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, } } diff --git a/cli/src/application/window/connect/tab/server/screen.rs b/cli/src/application/window/connect/tab/server/screen.rs index d21ca1e3..22753b46 100644 --- a/cli/src/application/window/connect/tab/server/screen.rs +++ b/cli/src/application/window/connect/tab/server/screen.rs @@ -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 @@ -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) { @@ -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,