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.padding_x` and `window.padding_y` to control the inner padding between a pane's border and its grid
- 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ width = 800
height = 600
title = "mmterm"
cursor_blink_ms = 500
padding_x = 4 # inner padding (px) between a pane's left/right border and its grid
padding_y = 4 # inner padding (px) between a pane's top/bottom border and its grid

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

[shell]
# program = "/bin/zsh"
Expand Down
6 changes: 5 additions & 1 deletion doc/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ vim-style modal input, split panes, and multi-tab sessions.
- Baseline alignment per glyph using fontdue `ymin` metric.
- SGR overline (`\e[53m` / `\e[55m`): rendered as a 1 px line at the top of
the cell; cleared with `\e[55m`.
- 4 px inner padding on all pane edges so text never touches the border.
- Inner padding on all pane edges so text never touches the border; the
horizontal and vertical amounts are configurable via `window.padding_x` and
`window.padding_y` (both default `4` px, DPI-scaled).

### Input
- Four modal modes: **Insert** (default), **Normal**, **Visual**, **Search**.
Expand Down Expand Up @@ -221,6 +223,8 @@ 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 | padding_x | uint | `4` |
| window | padding_y | uint | `4` |
| terminal | scrollback_lines | uint | `10000` (min 100) |
| shell | program | string? | `$SHELL` |
| logging | auto_log | bool | `false` |
Expand Down
5 changes: 3 additions & 2 deletions src/app_event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,9 @@ impl App {
self.state.tabs[ai].layout.move_separator(handle, new_pos);
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 pad_x = self.pane_padding_x();
let pad_y = self.pane_padding_y();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, pad_x, pad_y);
let icon = match handle.dir {
SplitDir::H => CursorIcon::ColResize,
SplitDir::V => CursorIcon::RowResize,
Expand Down
7 changes: 7 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_padding() -> u32 {
4
}

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

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
Expand Down
54 changes: 39 additions & 15 deletions src/config/tui_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,23 @@ const F_WIN_TITLE: usize = 7;
const F_BLINK_MS: usize = 8;
const F_DIM: usize = 9;
const F_DETECT_URLS: usize = 10;
const F_SHELL: usize = 11;
const F_SCROLLBACK: usize = 12;
const F_LOG_AUTO: usize = 13;
const F_LOG_DIR: usize = 14;
const F_THEME_NAME: usize = 15;
const F_COLOR_BG: usize = 16;
const F_COLOR_FG: usize = 17;
const F_COLOR_CUR: usize = 18;
const F_COLOR_SEL: usize = 19;
const F_PALETTE: usize = 20; // F_PALETTE + 0..15
const F_STATUS_BAR_RIGHT: usize = 36;
const F_AUTO_UPDATE_CHECK: usize = 37;
const F_AUTO_UPDATE_INSTALL: usize = 38;
const F_SHELL_INTEGRATION: usize = 39;
const F_DESKTOP_NOTIFICATIONS: usize = 40;
const F_PADDING_X: usize = 11;
const F_PADDING_Y: usize = 12;
const F_SHELL: usize = 13;
const F_SCROLLBACK: usize = 14;
const F_LOG_AUTO: usize = 15;
const F_LOG_DIR: usize = 16;
const F_THEME_NAME: usize = 17;
const F_COLOR_BG: usize = 18;
const F_COLOR_FG: usize = 19;
const F_COLOR_CUR: usize = 20;
const F_COLOR_SEL: usize = 21;
const F_PALETTE: usize = 22; // F_PALETTE + 0..15
const F_STATUS_BAR_RIGHT: usize = 38;
const F_AUTO_UPDATE_CHECK: usize = 39;
const F_AUTO_UPDATE_INSTALL: usize = 40;
const F_SHELL_INTEGRATION: usize = 41;
const F_DESKTOP_NOTIFICATIONS: usize = 42;

const PALETTE_LABELS: [&str; 16] = [
"Palette 0 black",
Expand Down Expand Up @@ -176,6 +178,20 @@ impl ConfigPanel {
kind: FieldKind::Bool,
section: None,
},
Field {
label: "Padding X",
hint: "pixels between a pane's left/right border and its grid",
value: cfg.window.padding_x.to_string(),
kind: FieldKind::UInt,
section: None,
},
Field {
label: "Padding Y",
hint: "pixels between a pane's top/bottom border and its grid",
value: cfg.window.padding_y.to_string(),
kind: FieldKind::UInt,
section: None,
},
// ── Shell ───────────────────────────────────────────────────────
Field {
label: "Shell",
Expand Down Expand Up @@ -624,6 +640,12 @@ impl ConfigPanel {
let detect_urls = get(F_DETECT_URLS)
.parse::<bool>()
.map_err(|_| "Invalid detect_urls — use true or false")?;
let padding_x = get(F_PADDING_X)
.parse::<u32>()
.map_err(|_| "Invalid padding_x — use a whole number of pixels")?;
let padding_y = get(F_PADDING_Y)
.parse::<u32>()
.map_err(|_| "Invalid padding_y — use a whole number of pixels")?;
let shell = {
let s = get(F_SHELL);
if s.is_empty() { None } else { Some(s) }
Expand Down Expand Up @@ -687,6 +709,8 @@ impl ConfigPanel {
cursor_blink_ms: blink_ms,
inactive_dim,
detect_urls,
padding_x,
padding_y,
},
shell: ShellConfig { program: shell },
terminal: TerminalConfig { scrollback_lines },
Expand Down
16 changes: 10 additions & 6 deletions src/config/tui_config_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ fn make_panel() -> ConfigPanel {
#[test]
fn from_config_has_correct_field_count() {
let panel = make_panel();
// 9 base + 1 scrollback + 2 logging + 1 theme + 4 colors + 16 palette + 1 status_bar + 3 general + 2 updates + 2 shell/notify = 41
assert_eq!(panel.fields.len(), 41);
// 9 base + 2 padding + 1 scrollback + 2 logging + 1 theme + 4 colors + 16 palette + 1 status_bar + 3 general + 2 updates + 2 shell/notify = 43
assert_eq!(panel.fields.len(), 43);
}

#[test]
Expand Down Expand Up @@ -305,6 +305,8 @@ fn distinct_config() -> Config {
cursor_blink_ms: 523,
inactive_dim: 0.42,
detect_urls: true,
padding_x: 6,
padding_y: 9,
},
shell: ShellConfig {
program: Some("/bin/xyzsh".into()),
Expand Down Expand Up @@ -361,6 +363,8 @@ fn field_index_sanity() {
F_BLINK_MS,
F_DIM,
F_DETECT_URLS,
F_PADDING_X,
F_PADDING_Y,
F_SHELL,
F_SCROLLBACK,
F_LOG_AUTO,
Expand Down Expand Up @@ -680,8 +684,8 @@ fn palette_collapsed_by_default() {
#[test]
fn visible_indices_hides_palette_body() {
let panel = make_panel();
// 41 total - 15 palette body fields = 26 visible
assert_eq!(panel.visible_indices().len(), 26);
// 43 total - 15 palette body fields = 28 visible
assert_eq!(panel.visible_indices().len(), 28);
}

#[test]
Expand All @@ -690,7 +694,7 @@ fn toggle_on_palette_header_expands() {
panel.selected = F_PALETTE;
panel.toggle_collapse();
assert!(!panel.collapsed.contains("Palette"));
assert_eq!(panel.visible_indices().len(), 41);
assert_eq!(panel.visible_indices().len(), 43);
}

#[test]
Expand All @@ -700,7 +704,7 @@ fn toggle_twice_restores_collapsed() {
panel.toggle_collapse();
panel.toggle_collapse();
assert!(panel.collapsed.contains("Palette"));
assert_eq!(panel.visible_indices().len(), 26);
assert_eq!(panel.visible_indices().len(), 28);
}

#[test]
Expand Down
50 changes: 50 additions & 0 deletions src/geometry_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,56 @@ fn pixel_to_cell_offset_rect() {
assert_eq!(result, Some((1, 1)));
}

#[test]
fn pixel_to_cell_padded_origin_maps_to_first_cell() {
// App::pixel_to_cell insets the pane rect by (pad_x, pad_y) so the grid is
// hit-tested from the padded origin (matching the padded render origin). A
// click exactly at the padded origin must resolve to cell (0, 0).
let (rx, ry, rw, rh) = (100u32, 50u32, 200u32, 120u32);
let (pad_x, pad_y) = (8u32, 3u32);
let inset = [rx + pad_x, ry + pad_y, rw - pad_x * 2, rh - pad_y * 2];
// Click at the padded top-left origin → first cell.
assert_eq!(
pixel_to_cell(
inset,
10,
12,
18,
9,
(rx + pad_x) as f64,
(ry + pad_y) as f64
),
Some((0, 0))
);
// One cell in on each axis from the padded origin → cell (1, 1).
assert_eq!(
pixel_to_cell(
inset,
10,
12,
18,
9,
(rx + pad_x + 10) as f64,
(ry + pad_y + 12) as f64
),
Some((1, 1))
);
// A click inside the left/top padding gutter (before the padded origin) is
// outside the inset rect → None.
assert_eq!(
pixel_to_cell(
inset,
10,
12,
18,
9,
(rx + pad_x - 1) as f64,
(ry + pad_y) as f64
),
None
);
}

// ── cell_url_at_scroll ────────────────────────────────────────────────────────

use crate::terminal::grid::{Color, Grid, GridColors};
Expand Down
13 changes: 12 additions & 1 deletion src/input/mouse_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,26 @@ impl App {
}

pub(crate) fn pixel_to_cell(&self, pane_id: usize, px: f64, py: f64) -> Option<(usize, usize)> {
let (pad_x, pad_y) = (self.pane_padding_x(), self.pane_padding_y());
let tab = self.tab();
let entry = tab.panes.get(&pane_id)?;
let m = &entry.metrics;
let (grid_cols, grid_rows) = {
let g = entry.pane.grid_read()?;
(g.cols, g.rows)
};
// The grid is rendered inset by (pad_x, pad_y) from the pane rect origin
// (see renderer `render_row`). Inset the rect the same way so a click at
// the padded origin maps to cell (0, 0); the padding gutters map to None.
let [rx, ry, rw, rh] = entry.pane.rect;
let inset = [
rx + pad_x,
ry + pad_y,
rw.saturating_sub(pad_x * 2),
rh.saturating_sub(pad_y * 2),
];
geometry::pixel_to_cell(
entry.pane.rect,
inset,
m.cell_width,
m.cell_height,
grid_cols,
Expand Down
15 changes: 9 additions & 6 deletions src/input_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ impl App {
.nudge_pane(active, split_h, delta);
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 pad_x = self.pane_padding_x();
let pad_y = self.pane_padding_y();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, pad_x, pad_y);
if let Some(w) = &self.window {
w.request_redraw();
}
Expand All @@ -139,8 +140,9 @@ impl App {
self.state.tabs[ai].layout.rotate_leaves(forward);
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 pad_x = self.pane_padding_x();
let pad_y = self.pane_padding_y();
Self::sync_pane_sizes_tab(&mut self.state.tabs[ai], tab_h, status_h, pad_x, pad_y);
self.request_redraw();
}

Expand Down Expand Up @@ -232,10 +234,11 @@ impl App {
}
let tab_h = self.tab_h();
let status_h = self.status_h();
let pane_padding = self.pane_padding();
let pad_x = self.pane_padding_x();
let pad_y = self.pane_padding_y();
// 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, pad_x, pad_y);
}

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

pub(crate) fn pane_padding(&self) -> u32 {
self.scale.chrome(crate::ui::layout::PANE_PADDING)
pub(crate) fn pane_padding_x(&self) -> u32 {
self.scale.chrome(self.state.config.window.padding_x)
}

pub(crate) fn pane_padding_y(&self) -> u32 {
self.scale.chrome(self.state.config.window.padding_y)
}

fn handle_resize(&mut self, w: u32, h: u32) {
Expand Down
Loading