nu_protocol/config/
shell_integration.rs

1use super::prelude::*;
2use crate as nu_protocol;
3
4#[derive(Clone, Copy, Debug, IntoValue, PartialEq, Eq, Serialize, Deserialize)]
5pub struct ShellIntegrationConfig {
6    pub osc2: bool,
7    pub osc7: bool,
8    pub osc8: bool,
9    pub osc9_9: bool,
10    pub osc133: bool,
11    pub osc633: bool,
12    pub reset_application_mode: bool,
13}
14
15#[allow(clippy::derivable_impls)]
16impl Default for ShellIntegrationConfig {
17    fn default() -> Self {
18        Self {
19            osc2: true,
20            osc7: !cfg!(windows),
21            osc8: true,
22            osc9_9: cfg!(windows),
23            osc133: true,
24            osc633: true,
25            reset_application_mode: true,
26        }
27    }
28}
29
30impl UpdateFromValue for ShellIntegrationConfig {
31    fn update<'a>(
32        &mut self,
33        value: &'a Value,
34        path: &mut ConfigPath<'a>,
35        errors: &mut ConfigErrors,
36    ) {
37        let Value::Record { val: record, .. } = value else {
38            errors.type_mismatch(path, Type::record(), value);
39            return;
40        };
41
42        for (col, val) in record.iter() {
43            let path = &mut path.push(col);
44            match col.as_str() {
45                "osc2" => self.osc2.update(val, path, errors),
46                "osc7" => self.osc7.update(val, path, errors),
47                "osc8" => self.osc8.update(val, path, errors),
48                "osc9_9" => self.osc9_9.update(val, path, errors),
49                "osc133" => self.osc133.update(val, path, errors),
50                "osc633" => self.osc633.update(val, path, errors),
51                "reset_application_mode" => self.reset_application_mode.update(val, path, errors),
52                _ => errors.unknown_option(path, val),
53            }
54        }
55    }
56}