Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
## [Unreleased]

### Added
- add `window.separator_px` to configure the width of the separator between panes
- add `--maximized` and `--fullscreen` flags to start the window in that mode
- persist and restore window size, maximized, and fullscreen state per session
- REP (`CSI Ps b`): repeat the last printed character `Ps` times
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ width = 800
height = 600
title = "mmterm"
cursor_blink_ms = 500
separator_px = 1 # width in px of the separator between panes (DPI-scaled)

[shell]
# program = "/bin/zsh" # defaults to $SHELL
Expand Down
1 change: 1 addition & 0 deletions assets/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ title = "mmterm"
cursor_blink_ms = 500
inactive_dim = 0.55
detect_urls = true
separator_px = 1

[shell]
# program = "/bin/zsh"
Expand Down
1 change: 1 addition & 0 deletions doc/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ Screenshot capture is a two-step flow: region selection followed by a name promp
| window | cursor_blink_ms | uint | `500` |
| window | inactive_dim | float | `0.55` |
| window | detect_urls | bool | `true` |
| window | separator_px | uint | `1` |
| terminal | scrollback_lines | uint | `10000` (min 100) |
| shell | program | string? | `$SHELL` |
| logging | auto_log | bool | `false` |
Expand Down
13 changes: 10 additions & 3 deletions src/app_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,8 +461,14 @@ impl App {
fn separator_at_pixel(&self, px: u32, py: u32) -> Option<crate::ui::layout::SeparatorHandle> {
let tab = &self.state.tabs[self.state.active_tab];
if !tab.zoomed {
tab.layout
.separator_at_pixel_scaled(px, py, 4, self.tab_h(), self.status_h())
tab.layout.separator_at_pixel_scaled(
px,
py,
4,
self.tab_h(),
self.status_h(),
self.separator_px(),
)
} else {
None
}
Expand Down Expand Up @@ -601,7 +607,8 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, pane_padding);
let sep = self.separator_px();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, sep, pane_padding);
let icon = match handle.dir {
SplitDir::H => CursorIcon::ColResize,
SplitDir::V => CursorIcon::RowResize,
Expand Down
5 changes: 5 additions & 0 deletions src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ fn default_inactive_dim() -> f32 {
fn default_detect_urls() -> bool {
true
}
fn default_separator_px() -> u32 {
1
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WindowConfig {
Expand All @@ -158,6 +161,8 @@ pub struct WindowConfig {
pub inactive_dim: f32,
#[serde(default = "default_detect_urls")]
pub detect_urls: bool,
#[serde(default = "default_separator_px")]
pub separator_px: u32,
}

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
4 changes: 4 additions & 0 deletions src/config/tui_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ pub struct ConfigPanel {
/// Section names that are currently collapsed (body fields hidden).
pub collapsed: HashSet<&'static str>,
pub version: &'static str,
/// Preserved verbatim from the loaded config (not exposed as an editable field).
pub separator_px: u32,
}

impl ConfigPanel {
Expand Down Expand Up @@ -313,6 +315,7 @@ impl ConfigPanel {
status: None,
collapsed,
version: env!("MMTERM_VERSION"),
separator_px: cfg.window.separator_px,
}
}

Expand Down Expand Up @@ -687,6 +690,7 @@ impl ConfigPanel {
cursor_blink_ms: blink_ms,
inactive_dim,
detect_urls,
separator_px: self.separator_px,
},
shell: ShellConfig { program: shell },
terminal: TerminalConfig { scrollback_lines },
Expand Down
1 change: 1 addition & 0 deletions src/config/tui_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ fn distinct_config() -> Config {
cursor_blink_ms: 523,
inactive_dim: 0.42,
detect_urls: true,
separator_px: 7,
},
shell: ShellConfig {
program: Some("/bin/xyzsh".into()),
Expand Down
5 changes: 4 additions & 1 deletion src/input/mouse_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ impl App {

pub(crate) fn pane_at_pixel(&self, px: f64, py: f64) -> Option<usize> {
let (tab_h, status_h) = (self.tab_h(), self.status_h());
let rects = self.tab().layout.rects_scaled(tab_h, status_h);
let rects = self
.tab()
.layout
.rects_scaled(tab_h, status_h, self.separator_px());
geometry::pane_at_pixel(&rects, px, py)
}

Expand Down
18 changes: 14 additions & 4 deletions src/input_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,11 @@ impl App {
let active = self.tab().active;
let tab_h = self.tab_h();
let status_h = self.status_h();
let sep = self.separator_px();
let rect = self
.tab()
.layout
.rects_scaled(tab_h, status_h)
.rects_scaled(tab_h, status_h, sep)
.into_iter()
.find(|(id, _)| *id == active)
.map(|(_, r)| r)
Expand All @@ -128,7 +129,8 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, pane_padding);
let sep = self.separator_px();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, sep, pane_padding);
if let Some(w) = &self.window {
w.request_redraw();
}
Expand All @@ -140,7 +142,8 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, pane_padding);
let sep = self.separator_px();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, sep, pane_padding);
self.request_redraw();
}

Expand Down Expand Up @@ -233,9 +236,16 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
let sep = self.separator_px();
// Re-grids only the active pane: sibling metrics + rects are unchanged,
// so their cols/rows don't change and they are left alone.
Self::sync_pane_sizes_tab(&mut self.state.tabs[idx], tab_h, status_h, pane_padding);
Self::sync_pane_sizes_tab(
&mut self.state.tabs[idx],
tab_h,
status_h,
sep,
pane_padding,
);
}

pub(crate) fn should_swallow_key(&mut self, event: &KeyEvent) -> bool {
Expand Down
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ impl App {
self.scale.chrome(crate::ui::layout::PANE_PADDING)
}

/// DPI-scaled pane separator width from config. `.max(1)` keeps hit-testing
/// and rendering sane even when the configured value is 0.
pub(crate) fn separator_px(&self) -> u32 {
self.scale
.chrome(self.state.config.window.separator_px)
.max(1)
}

fn handle_resize(&mut self, w: u32, h: u32) {
for tab in &mut self.state.tabs {
tab.layout.resize(w, h);
Expand Down
38 changes: 31 additions & 7 deletions src/pane_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,10 @@ impl App {
.and_then(|e| e.pty.cwd());
let tab_h = self.tab_h();
let status_h = self.status_h();
let sep = self.separator_px();
let layout = Layout::new(0, win_w, win_h);
let initial_rect = layout
.rects_scaled(tab_h, status_h)
.rects_scaled(tab_h, status_h, sep)
.first()
.map(|(_, r)| *r)
.unwrap_or([0, tab_h, win_w, win_h]);
Expand Down Expand Up @@ -244,17 +245,25 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[tab_idx], tab_h, status_h, pane_padding);
let sep = self.separator_px();
Self::sync_pane_sizes_tab(
&mut self.state.tabs[tab_idx],
tab_h,
status_h,
sep,
pane_padding,
);
}

pub(crate) fn sync_pane_sizes_tab(
tab: &mut TabState,
tab_h: u32,
status_h: u32,
sep: u32,
pane_padding: u32,
) {
// rows*cell_height may be < pane_h by up to (cell_height-1)px — intentional bottom gutter; do not force equality.
let rects = tab.layout.rects_scaled(tab_h, status_h);
let rects = tab.layout.rects_scaled(tab_h, status_h, sep);
for (id, rect) in rects {
if let Some(entry) = tab.panes.get_mut(&id) {
let [_, _, w, h] = rect;
Expand Down Expand Up @@ -290,8 +299,9 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
let sep = self.separator_px();
for tab in &mut self.state.tabs {
Self::sync_pane_sizes_tab(tab, tab_h, status_h, pane_padding);
Self::sync_pane_sizes_tab(tab, tab_h, status_h, sep, pane_padding);
}
}

Expand All @@ -300,10 +310,11 @@ impl App {
let active = self.tab().active;
let tab_h = self.tab_h();
let status_h = self.status_h();
let sep = self.separator_px();
let active_rect = self
.tab()
.layout
.rects_scaled(tab_h, status_h)
.rects_scaled(tab_h, status_h, sep)
.into_iter()
.find(|(id, _)| *id == active)
.map(|(_, r)| r)
Expand All @@ -330,7 +341,13 @@ impl App {
tab.active = new_id;
let idx = self.state.active_tab;
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[idx], tab_h, status_h, pane_padding);
Self::sync_pane_sizes_tab(
&mut self.state.tabs[idx],
tab_h,
status_h,
sep,
pane_padding,
);
}

pub(crate) fn do_close_pane(&mut self, event_loop: &ActiveEventLoop) {
Expand Down Expand Up @@ -358,7 +375,14 @@ impl App {
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[idx], tab_h, status_h, pane_padding);
let sep = self.separator_px();
Self::sync_pane_sizes_tab(
&mut self.state.tabs[idx],
tab_h,
status_h,
sep,
pane_padding,
);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/pane_ops_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn sync_uses_per_pane_metrics() {
AppState::test_pane_entry(Logical(32.0), metrics(32.0, 16, 32)),
);

App::sync_pane_sizes_tab(&mut tab, 22, 22, 0);
App::sync_pane_sizes_tab(&mut tab, 22, 22, 1, 0);

// sync_pane_sizes_tab writes target dimensions to pending_resize; the parser
// thread applies them asynchronously. Test the contract that sync_pane_sizes_tab
Expand Down
2 changes: 2 additions & 0 deletions src/renderer/overlays_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ fn make_panel(value: &str, kind: FieldKind) -> ConfigPanel {
status: None,
collapsed: HashSet::new(),
version: "",
separator_px: 1,
}
}

Expand Down Expand Up @@ -331,6 +332,7 @@ fn make_section_panel(collapsed: bool) -> ConfigPanel {
status: None,
collapsed: c,
version: "",
separator_px: 1,
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/renderer/render_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ impl App {
// Compute scaled chrome heights before any mutable borrow of self.surface.
let tab_h = self.tab_h();
let status_h = self.status_h();
let sep = self.separator_px();

let Some(surface) = &mut self.surface else {
return;
Expand Down Expand Up @@ -137,7 +138,7 @@ impl App {
let (separators, zoomed, active_id) = {
let tab = &self.state.tabs[self.state.active_tab];
(
tab.layout.separators_scaled(tab_h, status_h),
tab.layout.separators_scaled(tab_h, status_h, sep),
tab.zoomed,
tab.active,
)
Expand Down Expand Up @@ -205,7 +206,7 @@ impl App {
}
})
.collect();
let views = views::collect_pane_views(&self.state, &guards, w, h, tab_h, status_h);
let views = views::collect_pane_views(&self.state, &guards, w, h, tab_h, status_h, sep);

let draw_separators: &[[u32; 4]] = if zoomed { &[] } else { &separators };
let right_text = statusbar::resolve(
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/views.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pub fn collect_pane_views<'a>(
h: u32,
tab_h: u32,
status_h: u32,
sep: u32,
) -> Vec<PaneView<'a>> {
if state.tabs.is_empty() {
return vec![];
Expand Down Expand Up @@ -88,7 +89,7 @@ pub fn collect_pane_views<'a>(
metrics: &entry.metrics,
}]
} else {
let rects = tab.layout.rects_scaled(tab_h, status_h);
let rects = tab.layout.rects_scaled(tab_h, status_h, sep);
rects
.iter()
.filter_map(|(id, rect)| {
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/views_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ fn views(state: &AppState, w: u32, h: u32) -> Vec<PaneView<'_>> {
let guards = acquire_grid_guards(state);
// We need to keep guards alive for the duration of use. Since we can't
// return views that borrow guards in a test helper, call the fn inline.
let _views = collect_pane_views(state, &guards, w, h, TAB_BAR_H, STATUS_BAR_H);
let _views = collect_pane_views(state, &guards, w, h, TAB_BAR_H, STATUS_BAR_H, 1);
drop(guards);
// Return a simplified view of the data we need to test
vec![]
Expand All @@ -41,7 +41,7 @@ struct ViewSnapshot {

fn collect_snapshots(state: &AppState, w: u32, h: u32) -> Vec<ViewSnapshot> {
let guards = acquire_grid_guards(state);
let views = collect_pane_views(state, &guards, w, h, TAB_BAR_H, STATUS_BAR_H);
let views = collect_pane_views(state, &guards, w, h, TAB_BAR_H, STATUS_BAR_H, 1);
views
.iter()
.map(|v| ViewSnapshot {
Expand Down
9 changes: 8 additions & 1 deletion src/restore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ impl App {
continue;
}
let pane_padding = self.pane_padding();
Self::sync_pane_sizes_tab(&mut self.state.tabs[tab_idx], tab_h, status_h, pane_padding);
let sep = self.separator_px();
Self::sync_pane_sizes_tab(
&mut self.state.tabs[tab_idx],
tab_h,
status_h,
sep,
pane_padding,
);
for (slot, &pane_id) in slot_to_id.iter().enumerate() {
let path = session::scrollback_path_for(self.scope.as_deref(), tab_i, slot);
let lines = session::load_scrollback(&path);
Expand Down
Loading