Add "Increase column width to maximum/minimum" actions (#148)

The width is set to the maximum/minimum of preset widths.
This commit is contained in:
Jin Liu
2026-03-15 16:13:17 +08:00
committed by GitHub
parent 19f275325d
commit b8650a2e1f
4 changed files with 51 additions and 0 deletions

View File

@@ -86,4 +86,22 @@ class ContextualResizer {
column.setWidth(newWidth, true);
desktop.scrollCenterVisible(column);
}
public maximizeWidth(column: Column) {
const grid = column.grid;
const desktop = grid.desktop;
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
const maxWidth = presetWidths[presetWidths.length-1];
column.setWidth(maxWidth, true);
desktop.scrollCenterVisible(column);
}
public minimizeWidth(column: Column) {
const grid = column.grid;
const desktop = grid.desktop;
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
const minWidth = presetWidths[0];
column.setWidth(minWidth, true);
desktop.scrollCenterVisible(column);
}
}

View File

@@ -28,4 +28,16 @@ class RawResizer {
}
column.setWidth(newWidth, true);
}
public maximizeWidth(column: Column) {
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
const maxWidth = presetWidths[presetWidths.length-1];
column.setWidth(maxWidth, true);
}
public minimizeWidth(column: Column) {
const presetWidths = this.presetWidths.getWidths(column.getMinWidth(), column.getMaxWidth());
const minWidth = presetWidths[0];
column.setWidth(minWidth, true);
}
}

View File

@@ -192,6 +192,15 @@ class Actions {
this.config.columnResizer.decreaseWidth(column);
};
public readonly columnWidthMaximize = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
this.config.columnResizer.maximizeWidth(column);
};
public readonly columnWidthMinimize = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
this.config.columnResizer.minimizeWidth(column);
};
public readonly cyclePresetWidths = (cm: ClientManager, dm: DesktopManager, window: Window, column: Column, grid: Grid) => {
const nextWidth = this.config.presetWidths.next(column.getWidth(), column.getMinWidth(), column.getMaxWidth());
column.setWidth(nextWidth, true);
@@ -471,5 +480,7 @@ namespace Actions {
export interface ColumnResizer {
increaseWidth(column: Column): void;
decreaseWidth(column: Column): void;
maximizeWidth(column: Column): void;
minimizeWidth(column: Column): void;
}
}

View File

@@ -146,6 +146,16 @@ function getKeyBindings(world: World, actions: Actions): KeyBinding[] {
defaultKeySequence: "Meta+Ctrl+-",
action: () => world.doIfTiledFocused(actions.columnWidthDecrease),
},
{
name: "column-width-maximize",
description: "Increase column width to maximum",
action: () => world.doIfTiledFocused(actions.columnWidthMaximize),
},
{
name: "column-width-minimize",
description: "Decrease column width to minimum",
action: () => world.doIfTiledFocused(actions.columnWidthMinimize),
},
{
name: "cycle-preset-widths",
description: "Cycle through preset column widths",