refactor: 🚨 use string templates

This commit is contained in:
Mikhail Zolotukhin 2021-09-16 20:18:30 +03:00
parent cc693602f4
commit 86db2ebf8c
9 changed files with 19 additions and 38 deletions

View File

@ -70,7 +70,7 @@ export class TilingController implements Controller {
public start(): void {
console.log("Let's get down to bismuth!");
this.debug.debug(() => "Config: " + this.config);
this.debug.debug(() => `Config: ${this.config}`);
this.driver.bindEvents();
this.driver.bindShortcuts();

View File

@ -173,7 +173,7 @@ export class KWinDriver implements DriverContext {
*/
public bindEvents(): void {
const onNumberScreensChanged = (count: number): void => {
this.controller.onSurfaceUpdate("screens=" + count);
this.controller.onSurfaceUpdate(`screens=${count}`);
};
const onScreenResized = (screen: number): void => {
@ -250,7 +250,7 @@ export class KWinDriver implements DriverContext {
): void => {
this.controller.onWindowChanged(
this.windowMap.get(client),
"fullscreen=" + fullScreen + " user=" + user
`fullscreen=${fullScreen} user=${user}`
);
};
@ -483,7 +483,7 @@ export class KWinDriver implements DriverContext {
});
this.connect(client.screenChanged, () =>
this.controller.onWindowChanged(window, "screen=" + client.screen)
this.controller.onWindowChanged(window, `screen=${client.screen}`)
);
this.connect(client.activitiesChanged, () =>
@ -494,7 +494,7 @@ export class KWinDriver implements DriverContext {
);
this.connect(client.desktopChanged, () =>
this.controller.onWindowChanged(window, "desktop=" + client.desktop)
this.controller.onWindowChanged(window, `desktop=${client.desktop}`)
);
}

View File

@ -27,7 +27,7 @@ export interface DriverWindow {
export class KWinWindow implements DriverWindow {
public static generateID(client: KWin.Client): string {
return String(client) + "/" + client.windowId;
return `${String(client)}/${client.windowId}`;
}
public readonly client: KWin.Client;
@ -188,14 +188,10 @@ export class KWinWindow implements DriverWindow {
}
public toString(): string {
/* using a shorthand name to keep debug message tidy */
return (
"KWin(" +
this.client.windowId.toString(16) +
"." +
this.client.resourceClass +
")"
);
// Using a shorthand name to keep debug message tidy
return `KWin(${this.client.windowId.toString(16)}.${
this.client.resourceClass
})`;
}
public visible(srf: DriverSurface): boolean {

View File

@ -74,6 +74,6 @@ export default class SpreadLayout implements WindowsLayout {
}
public toString(): string {
return "SpreadLayout(" + this.space + ")";
return `SpreadLayout(${this.space})`;
}
}

View File

@ -71,6 +71,6 @@ export default class StairLayout implements WindowsLayout {
}
public toString(): string {
return "StairLayout(" + this.space + ")";
return `StairLayout(${this.space})`;
}
}

View File

@ -26,7 +26,7 @@ export default class ThreeColumnLayout implements WindowsLayout {
public readonly classID = ThreeColumnLayout.id;
public get description(): string {
return "Three-Column [" + this.masterSize + "]";
return `Three-Column [${this.masterSize}]`;
}
private masterRatio: number;
@ -218,7 +218,7 @@ export default class ThreeColumnLayout implements WindowsLayout {
}
public toString(): string {
return "ThreeColumnLayout(nmaster=" + this.masterSize + ")";
return `ThreeColumnLayout(nmaster=${this.masterSize})`;
}
private resizeMaster(engine: Engine, step: -1 | 1): void {

View File

@ -30,7 +30,7 @@ export default class TileLayout implements WindowsLayout {
public readonly classID = TileLayout.id;
public get description(): string {
return "Tile [" + this.numMaster + "]";
return `Tile [${this.numMaster}]`;
}
private parts: RotateLayoutPart<
@ -134,12 +134,6 @@ export default class TileLayout implements WindowsLayout {
}
public toString(): string {
return (
"TileLayout(nmaster=" +
this.numMaster +
", ratio=" +
this.masterRatio +
")"
);
return `TileLayout(nmaster=${this.numMaster}, ratio=${this.masterRatio})`;
}
}

View File

@ -17,7 +17,7 @@ export default class Debug {
public debug(f: () => any): void {
if (this.enabled) {
const timestamp = (new Date().getTime() - this.started) / 1000;
console.log("[" + timestamp + "]", f()); // tslint:disable-line:no-console
console.log(`[${timestamp}]`, f());
}
}
@ -28,7 +28,7 @@ export default class Debug {
const buf = [];
for (const i in obj) buf.push(i + "=" + obj[i]);
console.log("[" + timestamp + "]", name + ": " + buf.join(" ")); // tslint:disable-line:no-console
console.log(`[${timestamp}]`, `${name}: ${buf.join(" ")}`);
}
}
}

View File

@ -29,15 +29,6 @@ export default class RectDelta {
) {}
public toString(): string {
return (
"WindowResizeDelta(" +
[
"east=" + this.east,
"west=" + this.west,
"north=" + this.north,
"south=" + this.south,
].join(" ") +
")"
);
return `WindowResizeDelta(east=${this.east} west=${this.west} north=${this.north} south=${this.south}}`;
}
}