This commit is contained in:
Jana Dönszelmann 2026-04-03 18:07:35 +02:00
parent bb8f6bedf6
commit 4a6c1020f4
No known key found for this signature in database
10 changed files with 113 additions and 34 deletions

View file

@ -15,7 +15,7 @@ use tui_widget_list::{ListBuilder, ListState, ListView};
use crate::tui::{
block_around,
log_viewer::LogViewer,
model::{FieldsName, LogEntry, LogFields},
model::{SpanDescriptor, LogEntry, LogFields},
widgets::{line_text::style_span, styled::Styled},
};
@ -91,7 +91,7 @@ impl<'a> FieldTree<'a> {
self.lv.selected().map(|(s, _)| s)
}
fn current_span_fields(&mut self, spans: &[(FieldsName, &LogFields)]) -> Vec<(String, String)> {
fn current_span_fields(&mut self, spans: &[(SpanDescriptor, &LogFields)]) -> Vec<(String, String)> {
let mut selected = self.state().current_span.selected.unwrap_or(0);
if selected > spans.len() {
selected = spans.len().saturating_sub(1);
@ -120,7 +120,7 @@ impl<'a> FieldTree<'a> {
}
impl Styled<'_, &mut FieldTree<'_>> {
fn areas(&self, area: Rect, buf: &mut Buffer, name: Option<&FieldsName>) -> (Rect, Rect, Rect) {
fn areas(&self, area: Rect, buf: &mut Buffer, name: Option<&SpanDescriptor>) -> (Rect, Rect, Rect) {
let [spans_area, fields_area] = Layout::horizontal([
Constraint::Length(if self.spans_focussed() || !self.focussed {
25
@ -146,9 +146,9 @@ impl Styled<'_, &mut FieldTree<'_>> {
self.styles,
Some(if let Some(i) = name {
match i {
FieldsName::Main => "own fields".to_string(),
FieldsName::Span(s) => format!("fields of {s}"),
FieldsName::Numbered(idx) => format!("fields of span #{idx}"),
SpanDescriptor::Main => "own fields".to_string(),
SpanDescriptor::Span(s) => format!("fields of {s}"),
SpanDescriptor::Numbered(idx) => format!("fields of span #{idx}"),
}
} else {
"fields".to_string()
@ -191,9 +191,9 @@ impl Widget for Styled<'_, &mut FieldTree<'_>> {
};
let mut item = Line::from(match span_name {
FieldsName::Main => "own fields".to_string(),
FieldsName::Span(s) => s.to_string(),
FieldsName::Numbered(idx) => format!("span #{idx}"),
SpanDescriptor::Main => "own fields".to_string(),
SpanDescriptor::Span(s) => s.to_string(),
SpanDescriptor::Numbered(idx) => format!("span #{idx}"),
});
if cx.is_selected && self_focussed {
item = item.style(self.styles.highlighted);