ui: store the last selected spoken text when not focused
This commit is contained in:
@@ -31,6 +31,7 @@ pub struct Ui {
|
||||
tts: TtsControl,
|
||||
predictions: SessionControl,
|
||||
conversation: Vec<ConversationEntry>,
|
||||
last_spoken_idx: Option<usize>,
|
||||
sfx: SfxControl
|
||||
}
|
||||
|
||||
@@ -60,6 +61,7 @@ impl Ui {
|
||||
last_tick: Instant::now(),
|
||||
conversation: vec![],
|
||||
reply_options: Default::default(),
|
||||
last_spoken_idx: None,
|
||||
sfx
|
||||
}
|
||||
}
|
||||
@@ -212,6 +214,7 @@ impl Ui {
|
||||
match key.code {
|
||||
KeyCode::Tab => {
|
||||
self.focus_state = FocusState::UserInput;
|
||||
self.last_spoken_idx = self.conversation_state.selected();
|
||||
self.conversation_state.select(None);
|
||||
self.reply_state.select_first();
|
||||
},
|
||||
@@ -227,6 +230,7 @@ impl Ui {
|
||||
self.tts.speak(text.clone()).await.unwrap();
|
||||
self.sfx.play_ambient().await.unwrap();
|
||||
self.focus_state = FocusState::UserInput;
|
||||
self.last_spoken_idx = self.conversation_state.selected();
|
||||
self.conversation_state.select(None);
|
||||
self.reply_state.select_first();
|
||||
}
|
||||
@@ -238,7 +242,7 @@ impl Ui {
|
||||
match key.code {
|
||||
KeyCode::Tab => {
|
||||
self.focus_state = FocusState::Conversation;
|
||||
self.conversation_state.select_first();
|
||||
self.conversation_state.select(self.last_spoken_idx);
|
||||
self.reply_state.select(None);
|
||||
},
|
||||
KeyCode::Char('r') if key.modifiers.contains(KeyModifiers::CONTROL) => self.predictions.regenerate_options().await,
|
||||
|
||||
Reference in New Issue
Block a user