Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub struct App {
pub counter: u16,

pub snapshot_notify: Arc<Notify>,
pub context_depth: u8,
}

impl App {
Expand All @@ -154,6 +155,7 @@ impl App {
history: History::default(),
client: Arc::new(Mutex::new(client)),
counter: 0,
context_depth: 4,

server_status: None,
command_input: Input::default(),
Expand Down Expand Up @@ -277,6 +279,10 @@ impl App {
AppEvent::ClientConnected(s) => {
let mut client = self.client.lock().await;
let response = client.deref_mut().connect(s).await?;
client.feature_set(
"max_depth",
self.context_depth.to_string().as_str()
).await?;
self.is_connected = true;
self.server_status = None;
self.view_current = CurrentView::Session;
Expand All @@ -301,6 +307,14 @@ impl App {
AppEvent::Run => {
self.exec_continuation(AppEvent::Run).await;
}
AppEvent::ContextDepth(inc) => {
let depth = self.context_depth as i8;
self.context_depth = depth.wrapping_add(inc).max(0) as u8;
self.client.lock().await.feature_set(
"max_depth",
self.context_depth.to_string().as_str()
).await?;
},
AppEvent::ScrollSource(amount) => {
self.session_view.source_scroll = self
.session_view
Expand Down
10 changes: 10 additions & 0 deletions src/dbgp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,16 @@ impl DbgpClient {
}
}

pub(crate) async fn feature_set(&mut self, feature: &str, value: &str) -> Result<()> {
match self.command("feature_set", &mut vec!["-n",feature,"-v",value]).await? {
Message::Response(r) => match r.command {
CommandResponse::Unknown => Ok(()),
_ => anyhow::bail!("Unexpected response"),
},
_ => anyhow::bail!("Unexpected response"),
}
}

pub(crate) async fn context_get(&mut self) -> Result<ContextGetResponse> {
match self.command("context_get", &mut vec![]).await? {
Message::Response(r) => match r.command {
Expand Down
1 change: 1 addition & 0 deletions src/event/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ pub enum AppEvent {
ToggleFullscreen,
ScrollStack(i16),
PushInputPlurality(char),
ContextDepth(i8),
}

pub type EventSender = Sender<AppEvent>;
Expand Down
2 changes: 2 additions & 0 deletions src/view/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ Key mappings (prefix with number to repeat):
[J] scroll down 10
[k] scroll up
[K] scroll up 10
[+] increase context depth
[-] decrease context depth
[enter] toggle pane focus (full screen)

Legend:
Expand Down
4 changes: 3 additions & 1 deletion src/view/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ impl View for SessionView {
let next_event: Option<AppEvent> = match app.session_view.mode {
SessionViewMode::Current => match input_event.code {
KeyCode::Char(char) => match char {
'+' => Some(AppEvent::ContextDepth(1)),
'-' => Some(AppEvent::ContextDepth(-1)),
'r' => Some(AppEvent::Run),
'n' => Some(AppEvent::StepInto),
'N' => Some(AppEvent::StepOver),
Expand Down Expand Up @@ -119,7 +121,7 @@ fn build_pane_widget(frame: &mut Frame, app: &App, pane: &Pane, area: Rect, inde
Some(c) => c.source.filename.to_string(),
None => "".to_string(),
},
ComponentType::Context => "Context".to_string(),
ComponentType::Context => format!("Context({})", app.context_depth),
ComponentType::Stack => "Stack".to_string(),
})
.style(
Expand Down