Skip to content

Commit a36e5c0

Browse files
authored
Merge pull request #111 from fioletoven/feature/init-containers
Add init containers to combined logs
2 parents 083400f + 34210eb commit a36e5c0

18 files changed

Lines changed: 94 additions & 63 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Change Log
22

3-
## WIP
3+
## 0.4.1 - 2026-02-10
44

55
### Features
66

@@ -9,7 +9,7 @@
99
### Bug fixes
1010

1111
- do not wait on CRDs for OOB resources
12-
- fix double click select behaviour
12+
- fix double click behaviour for word select
1313

1414
### Compatibility
1515

Cargo.lock

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ members = [
1010
]
1111

1212
[workspace.package]
13-
version = "0.4.0"
13+
version = "0.4.1"
1414
edition = "2024"
1515
rust-version = "1.88"
1616
license = "MIT"

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,14 @@ The following features are currently supported:
3434
- View a list of Kubernetes resources.
3535
- Create, read, update and delete Kubernetes resources.
3636
- View events for the highlighted resource.
37-
- View logs for the highlighted container.
37+
- View logs for the highlighted pod or container.
3838
- Open a shell session in the highlighted container.
3939
- Enable port forwarding for the highlighted container.
4040

4141
### Planned
4242

4343
The following features are planned for future development:
4444

45-
- View combined logs for all containers in a pod.
4645
- Describe Kubernetes resources.
4746

4847
## Default Key Bindings
@@ -59,6 +58,7 @@ The following features are planned for future development:
5958
| Go back to namespaces; clear filter | `ESC` | Also clears input in the filter widget |
6059
| Navigate to the involved object | `i` | Works only for `events` kind |
6160
| Open / switch to the edit mode | `i` | Press `Esc` to exit, then `Esc` for save dialog |
61+
| Open right mouse button menu | `m` | Navigate using `` or `` |
6262
| Quit the application | `CTRL` + `c` | |
6363
| Reverse selection | `CTRL` + ` ` | (`CTRL` + `SPACE`) |
6464
| Select resource | ` ` | (`SPACE`) |
@@ -68,7 +68,7 @@ The following features are planned for future development:
6868
| Show events for the highlighted resource | `e` | |
6969
| Show filter / search input | `/` | Filter operators: and `&`, or `\|`, negation `!`, `(`, `)` |
7070
| Show footer messages history pane | `h` | Also works left mouse button click on the footer |
71-
| Show logs for the highlighted container | `l` | Press `p` to display previous logs for the container |
71+
| Show logs for the pod or container | `l` | Press `p` to display previous logs |
7272
| Show namespaces selector | `` | To select `all` quickly press `` again |
7373
| Show resources selector | `` | To select the first item quickly press `` again |
7474
| Show YAML for the highlighted resource | `y` | |

assets/themes/dark.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ colors:
5050
disconnected: white:light_red
5151
previous: text:no_bg
5252
footer:
53-
text: fg_dark:black:bg_dark
53+
text: fg_dark:#A4A6B8:bg_dark
5454
trail: blue:yellow:bg_dark
5555
info: light_green:bg_dark
5656
error: light_red:bg_dark
57-
hint: fg_light:bg_light
57+
details: fg_light:bg_light
58+
hint: black:yellow:bg_dark
5859
filter: *filter
5960
search: *filter
6061
command_palette: *filter

assets/themes/light.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ palette:
2222
light_cyan: LightCyan
2323
select_yellow: '#D9C49B'
2424
select_light: '#E9E9E9'
25+
hint: '#A4A6B8'
2526

2627
# style anchors
2728
filter: &filter
@@ -49,11 +50,12 @@ colors:
4950
disconnected: white:light_red
5051
previous: text_light:no_bg
5152
footer:
52-
text: fg_dark:#A4A6B8:bg_dark
53+
text: fg_dark:hint:bg_dark
5354
trail: light_blue:yellow:bg_dark
5455
info: light_green:bg_dark
5556
error: light_red:bg_dark
56-
hint: fg_light:bg_light
57+
details: fg_light:bg_light
58+
hint: hint:yellow:bg_dark
5759
filter: *filter
5860
search: *filter
5961
command_palette: *filter

b4n-config/themes/theme.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ pub struct FooterColors {
4646
pub trail: TextColors,
4747
pub info: TextColors,
4848
pub error: TextColors,
49+
pub details: TextColors,
4950
pub hint: TextColors,
5051
}
5152

@@ -56,7 +57,8 @@ impl Default for FooterColors {
5657
trail: TextColors::dim(Color::Blue, Color::Yellow, Color::DarkGray),
5758
info: TextColors::bg(Color::LightGreen, Color::DarkGray),
5859
error: TextColors::bg(Color::LightRed, Color::DarkGray),
59-
hint: TextColors::bg(Color::DarkGray, Color::Gray),
60+
details: TextColors::bg(Color::DarkGray, Color::Gray),
61+
hint: TextColors::dim(Color::Black, Color::Yellow, Color::DarkGray),
6062
}
6163
}
6264
}

b4n-tui/utils.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use anyhow::Result;
2+
use b4n_config::themes::TextColors;
23
use crossterm::ExecutableCommand;
34
use crossterm::cursor::SetCursorStyle;
45
use crossterm::terminal::{LeaveAlternateScreen, disable_raw_mode};
56
use ratatui_core::layout::{Constraint, Direction, Flex, Layout, Rect};
67
use ratatui_core::style::{Color, Style};
78
use ratatui_core::terminal::Frame;
9+
use ratatui_core::text::{Line, Span};
810
use ratatui_widgets::block::Block;
911
use ratatui_widgets::clear::Clear;
1012
use std::io::stdout;
@@ -58,6 +60,22 @@ pub fn get_proportional_width(area_width: u16, width: u16, use_proportion: bool)
5860
area_width.min(width).saturating_sub(2)
5961
}
6062

63+
/// Gets [`Line`] from string slice colored using specified [`TextColors`].
64+
pub fn get_styled_line(line: &str, color: TextColors) -> Line<'_> {
65+
Line::from(get_styled_spans(line, color))
66+
}
67+
68+
/// Gets [`Span`]s from string slice colored using specified [`TextColors`].
69+
pub fn get_styled_spans(line: &str, color: TextColors) -> Vec<Span<'_>> {
70+
line.split('␝')
71+
.enumerate()
72+
.map(|(idx, element)| {
73+
let fg = if idx % 2 == 0 { color.fg } else { color.dim };
74+
Span::styled(element, Style::default().fg(fg).bg(color.bg))
75+
})
76+
.collect::<Vec<_>>()
77+
}
78+
6179
/// Sets panic hook that additionally leaves alternate screen mode on panic.
6280
pub fn init_panic_hook() {
6381
let original_hook = take_hook();

b4n-tui/widgets/footer.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ use std::collections::VecDeque;
1010
use std::{rc::Rc, time::Instant};
1111
use tokio::sync::mpsc::{self, UnboundedReceiver};
1212

13+
use crate::utils::{get_styled_line, get_styled_spans};
1314
use crate::widgets::history::{BottomPane, MessageItem};
1415
use crate::{ResponseEvent, Responsive, TuiEvent};
1516

16-
const FOOTER_APP_VERSION: &str = concat!(" b4n v", env!("CARGO_PKG_VERSION"), " ");
17+
const FOOTER_APP_VERSION: &str = concat!(" b4n ␝v␝", env!("CARGO_PKG_VERSION"), " ");
18+
const FOOTER_APP_VERSION_LEN: usize = FOOTER_APP_VERSION.len() - 4;
1719
const MESSAGE_HISTORY_SIZE: usize = 20;
1820

1921
/// Footer widget.
@@ -154,8 +156,8 @@ impl Footer {
154156
.split(area);
155157

156158
if draw_hint && let Some(hint) = &self.hint {
157-
let style = Style::new().fg(colors.footer.text.dim).bg(colors.footer.text.bg);
158-
frame.render_widget(Paragraph::new(Line::styled(hint, style)), layout[1]);
159+
let line = get_styled_line(hint, colors.footer.hint);
160+
frame.render_widget(Paragraph::new(line), layout[1]);
159161
} else {
160162
frame.render_widget(Block::new().style(&colors.footer.text), layout[1]);
161163
}
@@ -174,7 +176,7 @@ impl Footer {
174176
fn get_hint_length(&self) -> u16 {
175177
self.hint
176178
.as_deref()
177-
.map(|h| h.chars().count())
179+
.map(|h| h.chars().filter(|ch| *ch != '␝').count())
178180
.and_then(|l| u16::try_from(l).ok())
179181
.unwrap_or_default()
180182
}
@@ -295,11 +297,11 @@ impl Footer {
295297
let width = usize::from(width);
296298
let mut rendered = 0;
297299
let mut spans = Vec::with_capacity(10);
298-
let mut total = FOOTER_APP_VERSION.len();
300+
let mut total = FOOTER_APP_VERSION_LEN;
299301

300302
spans.push(Span::styled("", Style::new().fg(colors.footer.text.bg).bg(colors.text.bg)));
301303
spans.push(Span::styled(" ", &colors.footer.text));
302-
spans.push(Span::styled(FOOTER_APP_VERSION, &colors.footer.text));
304+
spans.extend(get_styled_spans(FOOTER_APP_VERSION, colors.footer.text));
303305

304306
if self.show_trail && !self.trail.is_empty() {
305307
spans.push(Span::styled(" ", &colors.footer.text));

b4n-tui/widgets/history/bottom_pane.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ impl BottomPane {
6969
self.area = layout[1].union(layout[2]);
7070

7171
if show_hint {
72-
let block = get_block(theme.colors.footer.hint.bg, theme.colors.text.bg);
72+
let block = get_block(theme.colors.footer.details.bg, theme.colors.text.bg);
7373
let inner_area = block.inner(layout[1]).inner(Margin::new(1, 0));
7474
frame.render_widget(Clear, layout[1]);
7575
frame.render_widget(block, layout[1]);
76-
frame.render_widget(Paragraph::new(hint_lines).fg(theme.colors.footer.hint.fg), inner_area);
76+
frame.render_widget(Paragraph::new(hint_lines).fg(theme.colors.footer.details.fg), inner_area);
7777
}
7878

7979
let block = get_block(theme.colors.footer.text.bg, theme.colors.text.bg);

0 commit comments

Comments
 (0)