repl_settings.rs

 1use settings::{RegisterSetting, Settings};
 2
 3/// Settings for configuring REPL display and behavior.
 4#[derive(Clone, Debug, RegisterSetting)]
 5pub struct ReplSettings {
 6    /// Maximum number of lines to keep in REPL's scrollback buffer.
 7    /// Clamped with [4, 256] range.
 8    ///
 9    /// Default: 32
10    pub max_lines: usize,
11    /// Maximum number of columns to keep in REPL's scrollback buffer.
12    /// Clamped with [20, 512] range.
13    ///
14    /// Default: 128
15    pub max_columns: usize,
16    /// Whether to show small single-line outputs inline instead of in a block.
17    ///
18    /// Default: true
19    pub inline_output: bool,
20    /// Maximum number of characters for an output to be shown inline.
21    /// Only applies when `inline_output` is true.
22    ///
23    /// Default: 50
24    pub inline_output_max_length: usize,
25    /// Maximum number of lines of output to display before scrolling.
26    /// Set to 0 to disable output height limits.
27    ///
28    /// Default: 0
29    pub output_max_height_lines: usize,
30}
31
32impl Settings for ReplSettings {
33    fn from_settings(content: &settings::SettingsContent) -> Self {
34        let repl = content.repl.as_ref().unwrap();
35
36        Self {
37            max_lines: repl.max_lines.unwrap(),
38            max_columns: repl.max_columns.unwrap(),
39            inline_output: repl.inline_output.unwrap_or(true),
40            inline_output_max_length: repl.inline_output_max_length.unwrap_or(50),
41            output_max_height_lines: repl.output_max_height_lines.unwrap_or(0),
42        }
43    }
44}