T18: Terminal: scrollback lines, Option as Alt on macOS, copy on select, each applied at once to every session; the settings pages share one switch and one segmented choice
This commit is contained in:
4 files changed
+122
-46
No files matched your search
@@ -23,7 +23,7 @@ ELYTerminal. A terminal on GPUI and Ely components. `PRD.md` says what it does;
|
||||
## Layout
|
||||
|
||||
- `src/main.rs`: start. `src/lib.rs`: the modules, public so tests and examples reach them. `src/app.rs`: fonts, settings, integration, then the main window. `src/workspace.rs`: the window's content, Ely's `ColumnShell` with the sessions, terminal and right columns, their toggles, the right column's Git and Files switch, the title, and the sessions' lifecycle. `src/sessions.rs`: a session and its row. `src/files.rs`: the Files panel, the shown session's folder as Ely's `Tree` with Git's marks. `src/git.rs`: git through its command line: Files' marks, and the Git panel's status, stage, unstage, discard, commit and log; `src/git/diff.rs` reads git's diff into Ely's stretches. `src/git/panel.rs`: the Git panel's state and actions; `src/git/panel/view.rs`: how it draws.
|
||||
- `src/settings`: the model, its ranges, and `SettingsStore`, the global that loads, checks and saves `settings.json`; `window` is the settings window, `window/appearance` its Appearance page. `tests/fonts.rs` brings its own main: gpui builds its Mac platform only on the main thread.
|
||||
- `src/settings`: the model, its ranges, and `SettingsStore`, the global that loads, checks and saves `settings.json`; `window` is the settings window, `window/appearance` its Appearance page, `window/terminal` its Terminal page. `tests/fonts.rs` brings its own main: gpui builds its Mac platform only on the main thread.
|
||||
- `src/themes`: built-in terminal themes, the chrome palette each maps to, and `apply`, which dresses the app for the system's appearance.
|
||||
- `src/term`: the terminal engine. `pty` starts a program through alacritty's event loop; `tap` wraps the pty so its reader scans OSC 7 and the mouse modes before the parser. `unix` starts the program itself, so a failed `chdir` fails the start; Windows uses alacritty's ConPTY. `shell` writes the integration scripts at start and builds each shell's launch. `frame` reads the grid into styled rows, `boxes` turns box drawing, block elements and powerline arrows into rects and polygons (`boxes/outline` strokes curves and diagonals into polygons), `ink` resolves colors, `paint` draws rows, decorations and the cursor, `view` is the entity: pty events, metrics, blink, resize. `keys` turns key events into bytes, the kitty protocol and, in `keys/legacy`, xterm's encoding, with no gpui types; `input` is the view's key listeners, the bindings that keep Tab and F6 from Ely's focus moves, and its IME handler; `mac` reads the Option side and repeat flag of AppKit's current event, keeps held keys repeating, and hands Command key-ups to the focused view. `mouse` encodes mouse reports, with no gpui types; `links` finds the link at a cell; `pointer` is the view's mouse listeners: selection, reports, wheel, links, copy and paste. `find` is the find box: Ely's `FindWidget`, and Ely's `find_all` over the grid's shown text.
|
||||
- `assets/shell-integration`: ELYTerminal's own scripts (not Ghostty's, which are GPL): zsh through `ZDOTDIR`, bash through `--rcfile`, fish through `XDG_DATA_DIRS`, PowerShell through `-NoExit -Command`. Each prompt sends OSC 7 and, except in fish, whose `fish_title` stays, a title.
|
||||
@@ -68,3 +68,4 @@ ELYTerminal. A terminal on GPUI and Ely components. `PRD.md` says what it does;
|
||||
- 2026-10-14: Cmd-, opens the settings window, or brings the open one forward, and Cmd-W closes it; off macOS Ctrl-, and Ctrl-Shift-W, as Ghostty's. Categories sit in Ely's `SettingsLayout`, rows in its `SettingsRow`; a category joins the list with its rows. Each change goes through `SettingsStore::update`, which checks and saves, and every view reads the global, so it applies at once. A shell saves only when it names a program the running user may run, as the system's `access` answers, ACLs too: empty for the login shell, a file at a full path, or a name found in one of `PATH`'s full folders; a relative folder counts for none, since it would hang on each session's own folder. On Windows a name without an extension means its `.exe`, as `CreateProcess` reads it; a name with one keeps it. A program whose path is not UTF-8 counts for none: a session starts its program by text. A session runs that same full path, so the check and the start agree; else the row says why and the saved one stays, since a bad shell stops the next start. The window takes focus inside when it opens, so its keys find its context. The app quits with its last terminal window: settings alone hold no terminal.
|
||||
- 2026-10-14: settings refuse unknown fields; a bad settings file stops the start and is never overwritten.
|
||||
- 2026-10-14: Appearance shows every built-in theme as Ely's `RadioCard` in a `SimpleGrid`, each over a small window in the theme's colors. Separate dark theme copies the theme into `dark_theme`, so turning it on changes nothing until a dark card is picked. A theme change re-dresses the chrome at once. Font family comes from Ely's `FontPicker`; size, line height and padding from its `NumberInput`, which saves a number on Enter, on leaving the field and on each step. A font saves, and a settings file starts, only when gpui loads it as the terminal draws it: gpui falls back to another font without a word and loads none without an `m`, so the terminal draws with no font but its own. The cursor preview is a prompt in the terminal's font and theme, its cursor drawn as the terminal draws it, blinking on the terminal's beat. Opacity moves by whole percents, so the saved fraction carries no float noise. Blur saves here and reaches the window in T19. A change the store refuses leaves the setting as it was, and the page says why at its top; a number field drops its draft, and the font picker shows the saved family again. The settings window opens at 900 by 640, room for three theme columns.
|
||||
- 2026-10-14: Terminal shows scrollback lines, Option as Alt, on macOS only, since elsewhere Alt is Alt, and copy on select. The engine reads each when it needs it, so a change applies at once to every session; a smaller scrollback drops the history past it.
|
||||
+54
-2
@@ -1,7 +1,9 @@
|
||||
use std::fmt::Debug;
|
||||
|
||||
use ely_gpui_component::{
|
||||
buttons::SegmentedControl,
|
||||
feedback::InlineMessage,
|
||||
forms::{InputEvent, PathInput, TextInput},
|
||||
forms::{InputEvent, PathInput, Switch, TextInput},
|
||||
primitives::{FocusScope, IconName, Severity},
|
||||
settings::{SettingsLayout, SettingsRow, SettingsSection},
|
||||
shell::{ColumnShell, ResizeBorder, ShellColumn},
|
||||
@@ -18,6 +20,7 @@ use super::{Settings, SettingsStore, StartIn};
|
||||
use crate::term::BLINK;
|
||||
|
||||
mod appearance;
|
||||
mod terminal;
|
||||
|
||||
actions!(elyterminal, [OpenSettings, CloseSettings]);
|
||||
|
||||
@@ -25,9 +28,10 @@ actions!(elyterminal, [OpenSettings, CloseSettings]);
|
||||
const CONTEXT: &str = "Settings";
|
||||
|
||||
/// Each category's key, name and icon.
|
||||
const SECTIONS: [(&str, &str, IconName); 2] = [
|
||||
const SECTIONS: [(&str, &str, IconName); 3] = [
|
||||
("general", "General", IconName::Settings),
|
||||
("appearance", "Appearance", IconName::Palette),
|
||||
("terminal", "Terminal", IconName::Terminal),
|
||||
];
|
||||
|
||||
/// Cmd-, opens the settings, Cmd-W closes them; off macOS Ctrl-, and Ctrl-Shift-W, as Ghostty's.
|
||||
@@ -204,6 +208,53 @@ fn start_in(this: &Entity<SettingsWindow>, value: &SharedString, cx: &mut App) {
|
||||
);
|
||||
}
|
||||
|
||||
/// A switch that saves through `put`.
|
||||
fn switch(
|
||||
this: &Entity<SettingsWindow>,
|
||||
field: &'static str,
|
||||
on: bool,
|
||||
put: fn(&mut Settings, bool),
|
||||
) -> Switch {
|
||||
let this = this.clone();
|
||||
Switch::new(field, on).on_change(move |on, _, cx| {
|
||||
set(&this, format!("{field} is {on}"), cx, |settings| {
|
||||
put(settings, on)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/// Segments for `choices`, each a value, its key and its name, that save the chosen value through `put`.
|
||||
fn choice<T: Copy + PartialEq + Debug + 'static>(
|
||||
this: &Entity<SettingsWindow>,
|
||||
field: &'static str,
|
||||
choices: &'static [(T, &'static str, &'static str)],
|
||||
now: T,
|
||||
put: fn(&mut Settings, T),
|
||||
) -> SegmentedControl {
|
||||
let (_, key, _) = choices
|
||||
.iter()
|
||||
.find(|(each, ..)| *each == now)
|
||||
.expect("every choice is offered");
|
||||
let this = this.clone();
|
||||
choices
|
||||
.iter()
|
||||
.fold(
|
||||
SegmentedControl::new(field, *key),
|
||||
|control, (_, key, name)| control.segment(*key, *name, None),
|
||||
)
|
||||
.size(ControlSize::Sm)
|
||||
.on_change(move |key, _, cx| {
|
||||
let (value, ..) = choices
|
||||
.iter()
|
||||
.find(|(_, each, _)| *each == key.as_ref())
|
||||
.expect("a choice the control offers");
|
||||
let value = *value;
|
||||
set(&this, format!("{field} is {value:?}"), cx, |settings| {
|
||||
put(settings, value)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/// Saves one change and logs it, telling whether the settings hold it; a refused one changes nothing, and the window says why.
|
||||
fn set(
|
||||
this: &Entity<SettingsWindow>,
|
||||
@@ -241,6 +292,7 @@ impl Render for SettingsWindow {
|
||||
let page = match self.section.as_ref() {
|
||||
"general" => self.general(cx).into_any_element(),
|
||||
"appearance" => self.appearance(window, cx).into_any_element(),
|
||||
"terminal" => self.terminal(cx).into_any_element(),
|
||||
other => unreachable!("settings: no section {other}"),
|
||||
};
|
||||
let page = div()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use ely_gpui_component::{
|
||||
buttons::SegmentedControl,
|
||||
forms::{FontPicker, NumberInput, RadioCard, Slider, Switch},
|
||||
layout::SimpleGrid,
|
||||
settings::{SettingsRow, SettingsSection},
|
||||
@@ -12,7 +11,7 @@ use gpui::{
|
||||
px, relative, rems,
|
||||
};
|
||||
|
||||
use super::{SettingsWindow, set};
|
||||
use super::{SettingsWindow, choice, set, switch};
|
||||
use crate::{
|
||||
settings::{CursorStyle, FONT_SIZE, LINE_HEIGHT, OPACITY, PADDING, Settings, SettingsStore},
|
||||
themes::{self, TerminalTheme},
|
||||
@@ -97,33 +96,13 @@ impl SettingsWindow {
|
||||
settings.ligatures,
|
||||
|settings, on| settings.ligatures = on,
|
||||
)));
|
||||
let (_, now, _) = CURSORS
|
||||
.iter()
|
||||
.find(|(style, ..)| *style == settings.cursor_style)
|
||||
.expect("every cursor style is offered");
|
||||
let style = CURSORS
|
||||
.iter()
|
||||
.fold(
|
||||
SegmentedControl::new("cursor_style", *now),
|
||||
|control, (_, key, name)| control.segment(*key, *name, None),
|
||||
)
|
||||
.size(ControlSize::Sm)
|
||||
.on_change({
|
||||
let this = this.clone();
|
||||
move |key, _, cx| {
|
||||
let (style, ..) = CURSORS
|
||||
.iter()
|
||||
.find(|(_, each, _)| *each == key.as_ref())
|
||||
.expect("a cursor style the control offers");
|
||||
let style = *style;
|
||||
set(
|
||||
&this,
|
||||
format!("cursor_style is {style:?}"),
|
||||
cx,
|
||||
|settings| settings.cursor_style = style,
|
||||
);
|
||||
}
|
||||
});
|
||||
let style = choice(
|
||||
&this,
|
||||
"cursor_style",
|
||||
&CURSORS,
|
||||
settings.cursor_style,
|
||||
|settings, style| settings.cursor_style = style,
|
||||
);
|
||||
let active = themes::active(settings, window.appearance());
|
||||
let lit = self.lit || !settings.cursor_blink;
|
||||
let cursor = SettingsSection::new("Cursor")
|
||||
@@ -228,20 +207,6 @@ fn fraction(percent: f64) -> f32 {
|
||||
(percent / 100.) as f32
|
||||
}
|
||||
|
||||
fn switch(
|
||||
this: &Entity<SettingsWindow>,
|
||||
field: &'static str,
|
||||
on: bool,
|
||||
put: fn(&mut Settings, bool),
|
||||
) -> Switch {
|
||||
let this = this.clone();
|
||||
Switch::new(field, on).on_change(move |on, _, cx| {
|
||||
set(&this, format!("{field} is {on}"), cx, |settings| {
|
||||
put(settings, on)
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
/// Every built-in theme as a card over its preview; `dark` picks the one a dark system wears.
|
||||
fn grid(
|
||||
this: &Entity<SettingsWindow>,
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
use ely_gpui_component::{
|
||||
forms::NumberInput,
|
||||
settings::{SettingsRow, SettingsSection},
|
||||
theme::ControlSize,
|
||||
};
|
||||
use gpui::Context;
|
||||
|
||||
use super::{SettingsWindow, choice, set, switch};
|
||||
use crate::settings::{OptionAsAlt, SCROLLBACK, SettingsStore};
|
||||
|
||||
/// Each way Option types Alt, its key and its name.
|
||||
const OPTIONS: [(OptionAsAlt, &str, &str); 4] = [
|
||||
(OptionAsAlt::Off, "off", "Off"),
|
||||
(OptionAsAlt::Left, "left", "Left"),
|
||||
(OptionAsAlt::Right, "right", "Right"),
|
||||
(OptionAsAlt::Both, "both", "Both"),
|
||||
];
|
||||
|
||||
impl SettingsWindow {
|
||||
/// Scrollback, Option as Alt on macOS, and copy on select.
|
||||
pub(super) fn terminal(&self, cx: &Context<Self>) -> SettingsSection {
|
||||
let settings = SettingsStore::get(cx);
|
||||
let this = cx.entity();
|
||||
let lines = NumberInput::new(("scrollback", self.drafts), f64::from(settings.scrollback))
|
||||
.range(f64::from(*SCROLLBACK.start()), f64::from(*SCROLLBACK.end()))
|
||||
.step(1000.)
|
||||
.size(ControlSize::Sm)
|
||||
.on_commit({
|
||||
let this = this.clone();
|
||||
move |lines, _, cx| {
|
||||
let lines = lines as u32;
|
||||
set(&this, format!("scrollback is {lines}"), cx, |settings| {
|
||||
settings.scrollback = lines
|
||||
});
|
||||
}
|
||||
});
|
||||
let mut section = SettingsSection::new("Terminal")
|
||||
.row(SettingsRow::new("Scrollback lines").control(lines));
|
||||
// Off macOS, Alt is always Alt.
|
||||
if cfg!(target_os = "macos") {
|
||||
let option = choice(
|
||||
&this,
|
||||
"option_as_alt",
|
||||
&OPTIONS,
|
||||
settings.option_as_alt,
|
||||
|settings, option| settings.option_as_alt = option,
|
||||
);
|
||||
section = section.row(SettingsRow::new("Option as Alt").control(option));
|
||||
}
|
||||
let copy = switch(
|
||||
&this,
|
||||
"copy_on_select",
|
||||
settings.copy_on_select,
|
||||
|settings, on| settings.copy_on_select = on,
|
||||
);
|
||||
section.row(SettingsRow::new("Copy on select").control(copy))
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user