Add --top flag to zed-local script, for making windows take up half the screen
This commit is contained in:
parent
02ef6fc973
commit
0dca67fc33
1 changed files with 24 additions and 12 deletions
|
@ -4,20 +4,28 @@ const { spawn, execFileSync } = require("child_process");
|
||||||
|
|
||||||
const RESOLUTION_REGEX = /(\d+) x (\d+)/;
|
const RESOLUTION_REGEX = /(\d+) x (\d+)/;
|
||||||
const DIGIT_FLAG_REGEX = /^--?(\d+)$/;
|
const DIGIT_FLAG_REGEX = /^--?(\d+)$/;
|
||||||
const RELEASE_MODE = "--release";
|
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
|
||||||
|
|
||||||
// Parse the number of Zed instances to spawn.
|
// Parse the number of Zed instances to spawn.
|
||||||
let instanceCount = 1;
|
let instanceCount = 1;
|
||||||
const digitMatch = args[0]?.match(DIGIT_FLAG_REGEX);
|
let isReleaseMode = false;
|
||||||
if (digitMatch) {
|
let isTop = false;
|
||||||
instanceCount = parseInt(digitMatch[1]);
|
|
||||||
args.shift();
|
const args = process.argv.slice(2);
|
||||||
}
|
for (const arg of args) {
|
||||||
const isReleaseMode = args.some((arg) => arg === RELEASE_MODE);
|
const digitMatch = arg.match(DIGIT_FLAG_REGEX);
|
||||||
if (instanceCount > 4) {
|
if (digitMatch) {
|
||||||
throw new Error("Cannot spawn more than 4 instances");
|
instanceCount = parseInt(digitMatch[1]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "--release") {
|
||||||
|
isReleaseMode = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg == "--top") {
|
||||||
|
isTop = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse the resolution of the main screen
|
// Parse the resolution of the main screen
|
||||||
|
@ -34,7 +42,11 @@ if (!mainDisplayResolution) {
|
||||||
throw new Error("Could not parse screen resolution");
|
throw new Error("Could not parse screen resolution");
|
||||||
}
|
}
|
||||||
const screenWidth = parseInt(mainDisplayResolution[1]);
|
const screenWidth = parseInt(mainDisplayResolution[1]);
|
||||||
const screenHeight = parseInt(mainDisplayResolution[2]);
|
let screenHeight = parseInt(mainDisplayResolution[2]);
|
||||||
|
|
||||||
|
if (isTop) {
|
||||||
|
screenHeight = Math.floor(screenHeight / 2);
|
||||||
|
}
|
||||||
|
|
||||||
// Determine the window size for each instance
|
// Determine the window size for each instance
|
||||||
let instanceWidth = screenWidth;
|
let instanceWidth = screenWidth;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue