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 /// Maximum number of columns of output to display before scaling images.
31 /// Set to 0 to disable output width limits.
32 ///
33 /// Default: 0
34 pub output_max_width_columns: usize,
35}
36
37impl Settings for ReplSettings {
38 fn from_settings(content: &settings::SettingsContent) -> Self {
39 let repl = content.repl.as_ref().unwrap();
40
41 Self {
42 max_lines: repl.max_lines.unwrap(),
43 max_columns: repl.max_columns.unwrap(),
44 inline_output: repl.inline_output.unwrap_or(true),
45 inline_output_max_length: repl.inline_output_max_length.unwrap_or(50),
46 output_max_height_lines: repl.output_max_height_lines.unwrap_or(0),
47 output_max_width_columns: repl.output_max_width_columns.unwrap_or(0),
48 }
49 }
50}