Skip to content

Commit 43cb31f

Browse files
committed
feat: manually cycle output formats
1 parent 93d0806 commit 43cb31f

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/app/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@ impl App {
5656
)
5757
}
5858

59+
pub fn cycle_output_fmt(&mut self) {
60+
self.output_fmt = match self.output_fmt {
61+
OutputFmt::Line => OutputFmt::Bullet,
62+
OutputFmt::Bullet => OutputFmt::Line,
63+
};
64+
}
65+
5966
pub fn next_log_conn(&mut self) {
6067
if self.log_conn_idx != self.connections.lock().unwrap().len() - 1 {
6168
self.log_conn_idx += 1;

src/main.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fn handle_events(app: &mut App) -> io::Result<()> {
108108
KeyCode::Char('q' | 'Q') => app.close(),
109109
KeyCode::Char('l') => app.next_tab(),
110110
KeyCode::Char('h') => app.prev_tab(),
111+
KeyCode::Char('o') if app.selected_tab == SelectedTab::Live => app.cycle_output_fmt(),
111112
KeyCode::Char('j') if app.selected_tab == SelectedTab::Log => {
112113
app.next_log_conn();
113114
}
@@ -142,10 +143,5 @@ fn test_conn(conns: &Arc<Mutex<Vec<Connection>>>, idx: usize) {
142143
}
143144
};
144145

145-
conns
146-
.lock()
147-
.unwrap()
148-
.get_mut(idx)
149-
.unwrap()
150-
.push_status(code);
146+
conns.lock().unwrap().get_mut(idx).unwrap().push_status(code);
151147
}

src/ui/tab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn render_tab_live(f: &mut Frame, app: &App) {
3939
list_items.push(conn_output);
4040
}
4141

42-
let block = Block::bordered().title_bottom(" q: Quit ");
42+
let block = Block::bordered().title_bottom(" q: Quit | o: Cycle formats ");
4343

4444
f.render_widget(
4545
List::new(list_items).block(block),

0 commit comments

Comments
 (0)