@@ -30,6 +30,8 @@ use std::borrow::Cow;
30use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
30use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
31use tui::buffer::Buffer as Surface;
31use tui::buffer::Buffer as Surface;
33+use super::{Prompt, PromptEvent};
33pub struct EditorView {
35pub struct EditorView {
34 keymaps: Keymaps,
36 keymaps: Keymaps,
35 on_next_key: Option<Box<dyn FnOnce(&mut commands::Context, KeyEvent)>>,
37 on_next_key: Option<Box<dyn FnOnce(&mut commands::Context, KeyEvent)>>,
@@ -712,6 +714,45 @@ impl EditorView {
712 ) -> Option<KeymapResult> {
714 ) -> Option<KeymapResult> {
713 self.autoinfo = None;
715 self.autoinfo = None;
717+ if let Some(picker) = cxt.editor.debug_config_picker.clone() {
720+ code: KeyCode::Esc, ..
723+ code: KeyCode::Char(char),
726+ let name = match picker.iter().find(|t| t.starts_with(char)) {
727+ Some(n) => n.clone(),
728+ None => return None,
730+ let prompt = Prompt::new(
733+ |_input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
734+ move |cx: &mut crate::compositor::Context,
736+ event: PromptEvent| {
737+ if event != PromptEvent::Validate {
740+ commands::dap_start_impl(
748+ cxt.push_layer(Box::new(prompt));
752+ cxt.editor.debug_config_picker = None;
715 if cxt.editor.variables.is_some() {
756 if cxt.editor.variables.is_some() {
716 match event {
757 match event {
717 KeyEvent {
758 KeyEvent {
@@ -735,6 +776,7 @@ impl EditorView {
736 return None;
777 return None;
738 match self.keymaps.get_mut(&mode).unwrap().get(event) {
780 match self.keymaps.get_mut(&mode).unwrap().get(event) {
739 KeymapResult::Matched(command) => command.execute(cxt),
781 KeymapResult::Matched(command) => command.execute(cxt),
740 KeymapResult::Pending(node) => self.autoinfo = Some(node.into()),
782 KeymapResult::Pending(node) => self.autoinfo = Some(node.into()),
@@ -1137,6 +1179,26 @@ impl Component for EditorView {
1137 info.render(area, surface, cx);
1179 info.render(area, surface, cx);
1182+ if let Some(ref configs) = cx.editor.debug_config_picker {
1183+ let mut text = String::new();
1184+ let mut height = 0;
1185+ let mut max_len = 20;
1187+ for line in configs {
1188+ max_len = max_len.max(line.len() as u16 + 2);
1190+ text.push_str(&format!("{} {}\n", line.chars().next().unwrap(), line));
1193+ let mut info = Info {
1194+ height: 20.min(height + 1),
1195+ width: 70.min(max_len),
1196+ title: "Debug targets".to_owned(),
1197+ text: text + "Exit Esc",
1199+ info.render(area, surface, cx);
1140 if let Some(ref mut info) = self.autoinfo {
1202 if let Some(ref mut info) = self.autoinfo {
1141 info.render(area, surface, cx);
1203 info.render(area, surface, cx);