Skip to content

Commit 9a8d2e3

Browse files
authored
Context Filtering (#38)
- Make app mutable in view - Introduce `f` to show a filter dialog in the context pane - Filter with dot notation
1 parent a4a0553 commit 9a8d2e3

File tree

14 files changed

+261
-51
lines changed

14 files changed

+261
-51
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ CHANGELOG
44
main
55
----
66

7+
- Filter properties with dot notation in context pane (`f`)
78
- Stack traversal - select stack and inspect stack frames in current mode.
89
- Fixed light theme.
910

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ Prefix with number to repeat:
4545
- `enter` toggle pane focus (full screen)
4646
- `t` rotate the theme
4747
- `?` Show help
48+
- `f` Filter (context pane) - use dot notation to filter on multiple levels.
4849

4950
## Setting Breakpoints
5051

src/app.rs

Lines changed: 41 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -169,20 +169,21 @@ impl SourceContext {
169169
}
170170

171171
#[derive(Debug, Clone)]
172-
pub enum CurrentView {
172+
pub enum SelectedView {
173173
Listen,
174174
Session,
175175
Help,
176176
}
177177

178178
pub struct App {
179-
pub is_connected: bool,
180-
pub notification: Notification,
181-
pub config: Config,
182179
receiver: Receiver<AppEvent>,
183180
quit: bool,
184181
sender: Sender<AppEvent>,
185182

183+
pub is_connected: bool,
184+
pub notification: Notification,
185+
pub config: Config,
186+
186187
pub server_status: Option<ContinuationStatus>,
187188
pub command_input: Input,
188189
pub command_response: Option<String>,
@@ -191,7 +192,8 @@ pub struct App {
191192

192193
pub history: History,
193194

194-
pub view_current: CurrentView,
195+
pub view_current: SelectedView,
196+
pub focus_view: bool,
195197
pub session_view: SessionViewState,
196198
pub input_plurality: Vec<char>,
197199

@@ -229,7 +231,8 @@ impl App {
229231
server_status: None,
230232
command_input: Input::default(),
231233
command_response: None,
232-
view_current: CurrentView::Listen,
234+
view_current: SelectedView::Listen,
235+
focus_view: false,
233236
session_view: SessionViewState::new(),
234237

235238
snapshot_notify: Arc::new(Notify::new()),
@@ -401,6 +404,14 @@ impl App {
401404
.feature_set("max_depth", self.context_depth.to_string().as_str())
402405
.await?;
403406
}
407+
AppEvent::ContextFilterOpen => {
408+
self.session_view.context_filter.show = true;
409+
self.focus_view = true;
410+
},
411+
AppEvent::ContextSearchClose => {
412+
self.session_view.context_filter.show = false;
413+
self.focus_view = false;
414+
},
404415
AppEvent::ScrollSource(amount) => {
405416
self.session_view.source_scroll = apply_scroll(
406417
self.session_view.source_scroll,
@@ -440,19 +451,27 @@ impl App {
440451
.await?;
441452
}
442453
AppEvent::PushInputPlurality(char) => self.input_plurality.push(char),
443-
AppEvent::Input(key_event) => match key_event.code {
444-
KeyCode::Char('t') => {
445-
self.theme = self.theme.next();
446-
self.notification =
447-
Notification::info(format!("Switched to theme: {:?}", self.theme));
448-
}
449-
KeyCode::Char('?') => {
450-
self.sender
451-
.send(AppEvent::ChangeView(CurrentView::Help))
452-
.await
453-
.unwrap();
454+
AppEvent::Input(key_event) => {
455+
if self.focus_view {
456+
// event shandled exclusively by view (e.g. input needs focus)
457+
self.send_event_to_current_view(event).await;
458+
} else {
459+
// global events
460+
match key_event.code {
461+
KeyCode::Char('t') => {
462+
self.theme = self.theme.next();
463+
self.notification =
464+
Notification::info(format!("Switched to theme: {:?}", self.theme));
465+
}
466+
KeyCode::Char('?') => {
467+
self.sender
468+
.send(AppEvent::ChangeView(SelectedView::Help))
469+
.await
470+
.unwrap();
471+
}
472+
_ => self.send_event_to_current_view(event).await,
473+
}
454474
}
455-
_ => self.send_event_to_current_view(event).await,
456475
},
457476
_ => self.send_event_to_current_view(event).await,
458477
};
@@ -520,9 +539,9 @@ impl App {
520539
// route the event to the currently selected view
521540
async fn send_event_to_current_view(&mut self, event: AppEvent) {
522541
let subsequent_event = match self.view_current {
523-
CurrentView::Help => HelpView::handle(self, event),
524-
CurrentView::Listen => ListenView::handle(self, event),
525-
CurrentView::Session => SessionView::handle(self, event),
542+
SelectedView::Help => HelpView::handle(self, event),
543+
SelectedView::Listen => ListenView::handle(self, event),
544+
SelectedView::Session => SessionView::handle(self, event),
526545
};
527546
if let Some(event) = subsequent_event {
528547
self.sender.send(event).await.unwrap()
@@ -611,7 +630,7 @@ impl App {
611630

612631
fn reset(&mut self) {
613632
self.server_status = None;
614-
self.view_current = CurrentView::Session;
633+
self.view_current = SelectedView::Session;
615634
self.session_view.mode = SessionViewMode::Current;
616635
self.analyzed_files = HashMap::new();
617636
self.workspace.reset();

src/dbgp/client.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,12 @@ pub struct ContextGetResponse {
3838
pub properties: Vec<Property>,
3939
}
4040

41-
#[derive(PartialEq, Clone, Debug)]
41+
#[derive(PartialEq, Clone, Debug, Default)]
4242
pub enum PropertyType {
4343
Bool,
4444
Int,
4545
Float,
46+
#[default]
4647
String,
4748
Null,
4849
Array,
@@ -90,7 +91,7 @@ impl PropertyType {
9091
}
9192
}
9293

93-
#[derive(Debug, Clone, PartialEq)]
94+
#[derive(Debug, Clone, PartialEq, Default)]
9495
pub struct Property {
9596
pub name: String,
9697
pub fullname: String,

src/event/input.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ use std::time::Duration;
1111
use tokio::net::TcpStream;
1212
use tokio::sync::mpsc::Sender;
1313

14-
use crate::app::CurrentView;
14+
use crate::app::SelectedView;
1515
use crate::dbgp::client::ContinuationStatus;
1616
use crate::view::session::SessionViewMode;
1717
use crate::view::Scroll;
1818

1919
#[derive(Debug)]
2020
pub enum AppEvent {
2121
ChangeSessionViewMode(SessionViewMode),
22-
ChangeView(CurrentView),
22+
ChangeView(SelectedView),
2323
ClientConnected(TcpStream),
2424
Disconnect,
2525
HistoryNext,
@@ -47,6 +47,8 @@ pub enum AppEvent {
4747
PushInputPlurality(char),
4848
ContextDepth(i8),
4949
NextTheme,
50+
ContextFilterOpen,
51+
ContextSearchClose,
5052
}
5153

5254
pub type EventSender = Sender<AppEvent>;

src/theme.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ impl Theme {
6161
widget_mode_history: Style::default().fg(Solarized::Red.to_color()).bg(Solarized::Base03.to_color()),
6262

6363
background: Style::default().bg(Color::Black),
64+
cursor: Style::default().bg(Color::White),
6465
},
6566
Theme::Dark => Scheme {
6667
syntax_variable: Style::default().fg(Color::LightBlue),
@@ -89,6 +90,7 @@ impl Theme {
8990
widget_mode_debug: Style::default().bg(Color::Blue),
9091
widget_mode_history: Style::default().bg(Color::Red),
9192
background: Style::default().bg(Color::Black),
93+
cursor: Style::default().bg(Color::White)
9294
},
9395
}
9496
}
@@ -121,6 +123,7 @@ pub struct Scheme {
121123
pub widget_inactive: Style,
122124
pub widget_mode_debug: Style,
123125
pub widget_mode_history: Style,
126+
pub cursor: Style,
124127
}
125128

126129
pub enum Role {}

0 commit comments

Comments
 (0)