Re-land bbiggs changes to reduce margin on narrow screens with fixes + full width setting (#10522)

This commit is contained in:
Jacob Richman
2025-10-09 19:27:20 -07:00
committed by GitHub
parent c82c2c2b15
commit 558be87311
25 changed files with 492 additions and 385 deletions

View File

@@ -0,0 +1,31 @@
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import { lerp } from '../../utils/math.js';
import { type LoadedSettings } from '../../config/settings.js';
const getMainAreaWidthInternal = (terminalWidth: number): number => {
if (terminalWidth <= 80) {
return Math.round(0.98 * terminalWidth);
}
if (terminalWidth >= 132) {
return Math.round(0.9 * terminalWidth);
}
// Linearly interpolate between 80 columns (98%) and 132 columns (90%).
const t = (terminalWidth - 80) / (132 - 80);
const percentage = lerp(98, 90, t);
return Math.round(percentage * terminalWidth * 0.01);
};
export const calculateMainAreaWidth = (
terminalWidth: number,
settings: LoadedSettings,
): number =>
settings.merged.ui?.useFullWidth
? terminalWidth
: getMainAreaWidthInternal(terminalWidth);