MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / handle_global_settings_key

Method handle_global_settings_key

crates/openshell-tui/src/app.rs:1212–1272  ·  view source on GitHub ↗
(&mut self, key: KeyEvent)

Source from the content-addressed store, hash-verified

1210 }
1211
1212 fn handle_global_settings_key(&mut self, key: KeyEvent) {
1213 match key.code {
1214 KeyCode::Char('q') => self.running = false,
1215 KeyCode::Tab => self.focus = Focus::Sandboxes,
1216 KeyCode::BackTab => self.focus = Focus::Gateways,
1217 KeyCode::Char(':') => {
1218 self.input_mode = InputMode::Command;
1219 self.command_input.clear();
1220 }
1221 KeyCode::Char('j') | KeyCode::Down if !self.global_settings.is_empty() => {
1222 self.global_settings_selected =
1223 (self.global_settings_selected + 1).min(self.global_settings.len() - 1);
1224 }
1225 KeyCode::Char('k') | KeyCode::Up => {
1226 self.global_settings_selected = self.global_settings_selected.saturating_sub(1);
1227 }
1228 KeyCode::Char('h' | 'l') | KeyCode::Left | KeyCode::Right => {
1229 self.middle_pane_tab = self.middle_pane_tab.next();
1230 }
1231 KeyCode::Enter => {
1232 // Open edit for the selected setting.
1233 if let Some(entry) = self.global_settings.get(self.global_settings_selected) {
1234 if entry.kind == SettingValueKind::Bool {
1235 // Toggle bool inline and go straight to confirmation.
1236 let new_val = match &entry.value {
1237 Some(setting_value::Value::BoolValue(v)) => !v,
1238 _ => true,
1239 };
1240 self.setting_edit = Some(SettingEditState {
1241 index: self.global_settings_selected,
1242 input: new_val.to_string(),
1243 error: None,
1244 });
1245 self.confirm_setting_set = Some(self.global_settings_selected);
1246 } else {
1247 // Open text editor.
1248 let current = entry.display_value();
1249 let input = if current == "<unset>" {
1250 String::new()
1251 } else {
1252 current
1253 };
1254 self.setting_edit = Some(SettingEditState {
1255 index: self.global_settings_selected,
1256 input,
1257 error: None,
1258 });
1259 }
1260 }
1261 }
1262 KeyCode::Char('d') => {
1263 // Delete the selected global setting (only if it has a value).
1264 if let Some(entry) = self.global_settings.get(self.global_settings_selected)
1265 && entry.value.is_some()
1266 {
1267 self.confirm_setting_delete = Some(self.global_settings_selected);
1268 }
1269 }

Callers 1

handle_normal_keyMethod · 0.80

Calls 6

lenMethod · 0.80
display_valueMethod · 0.80
clearMethod · 0.45
is_emptyMethod · 0.45
nextMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected