mirror of
https://github.com/Bismuth-Forge/bismuth.git
synced 2024-09-11 00:15:37 +03:00
refactor: 🎨 rename shortcut to action
Action here it more applicable, since the shortcut is Ctrl-A or Super+Up, but here it is used to denote action.
This commit is contained in:
parent
9710c664ae
commit
dd1212c2b4
@ -3,7 +3,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
export enum Shortcut {
|
||||
export enum Action {
|
||||
Left,
|
||||
Right,
|
||||
Up,
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { Shortcut } from "./shortcut";
|
||||
import { Action } from "./action";
|
||||
|
||||
import { Engine, TilingEngine } from "../engine";
|
||||
import Window from "../engine/window";
|
||||
@ -144,7 +144,7 @@ export interface Controller {
|
||||
* @param input the shortcut action. For example focus the next window, or change the layout.
|
||||
* @param data the action optional data, that it could held. For example the layout name to which user want to change.
|
||||
*/
|
||||
onShortcut(input: Shortcut, data?: any): void;
|
||||
onShortcut(input: Action, data?: any): void;
|
||||
|
||||
/**
|
||||
* Ask engine to manage the window
|
||||
@ -348,33 +348,33 @@ export class TilingController implements Controller {
|
||||
window.timestamp = new Date().getTime();
|
||||
}
|
||||
|
||||
public onShortcut(input: Shortcut, data?: string): void {
|
||||
public onShortcut(input: Action, data?: string): void {
|
||||
if (this.config.directionalKeyMode === "focus") {
|
||||
switch (input) {
|
||||
case Shortcut.Up:
|
||||
input = Shortcut.FocusUp;
|
||||
case Action.Up:
|
||||
input = Action.FocusUp;
|
||||
break;
|
||||
case Shortcut.Down:
|
||||
input = Shortcut.FocusDown;
|
||||
case Action.Down:
|
||||
input = Action.FocusDown;
|
||||
break;
|
||||
case Shortcut.Left:
|
||||
input = Shortcut.FocusLeft;
|
||||
case Action.Left:
|
||||
input = Action.FocusLeft;
|
||||
break;
|
||||
case Shortcut.Right:
|
||||
input = Shortcut.FocusRight;
|
||||
case Action.Right:
|
||||
input = Action.FocusRight;
|
||||
break;
|
||||
|
||||
case Shortcut.ShiftUp:
|
||||
input = Shortcut.SwapUp;
|
||||
case Action.ShiftUp:
|
||||
input = Action.SwapUp;
|
||||
break;
|
||||
case Shortcut.ShiftDown:
|
||||
input = Shortcut.SwapDown;
|
||||
case Action.ShiftDown:
|
||||
input = Action.SwapDown;
|
||||
break;
|
||||
case Shortcut.ShiftLeft:
|
||||
input = Shortcut.SwapLeft;
|
||||
case Action.ShiftLeft:
|
||||
input = Action.SwapLeft;
|
||||
break;
|
||||
case Shortcut.ShiftRight:
|
||||
input = Shortcut.SwapRight;
|
||||
case Action.ShiftRight:
|
||||
input = Action.SwapRight;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -386,92 +386,92 @@ export class TilingController implements Controller {
|
||||
|
||||
const window = this.currentWindow;
|
||||
switch (input) {
|
||||
case Shortcut.Up:
|
||||
case Action.Up:
|
||||
this.engine.focusOrder(-1);
|
||||
break;
|
||||
case Shortcut.Down:
|
||||
case Action.Down:
|
||||
this.engine.focusOrder(+1);
|
||||
break;
|
||||
|
||||
case Shortcut.FocusUp:
|
||||
case Action.FocusUp:
|
||||
this.engine.focusDir("up");
|
||||
break;
|
||||
case Shortcut.FocusDown:
|
||||
case Action.FocusDown:
|
||||
this.engine.focusDir("down");
|
||||
break;
|
||||
case Shortcut.FocusLeft:
|
||||
case Action.FocusLeft:
|
||||
this.engine.focusDir("left");
|
||||
break;
|
||||
case Shortcut.FocusRight:
|
||||
case Action.FocusRight:
|
||||
this.engine.focusDir("right");
|
||||
break;
|
||||
|
||||
case Shortcut.GrowWidth:
|
||||
case Action.GrowWidth:
|
||||
if (window) {
|
||||
this.engine.resizeWindow(window, "east", 1);
|
||||
}
|
||||
break;
|
||||
case Shortcut.ShrinkWidth:
|
||||
case Action.ShrinkWidth:
|
||||
if (window) {
|
||||
this.engine.resizeWindow(window, "east", -1);
|
||||
}
|
||||
break;
|
||||
case Shortcut.GrowHeight:
|
||||
case Action.GrowHeight:
|
||||
if (window) {
|
||||
this.engine.resizeWindow(window, "south", 1);
|
||||
}
|
||||
break;
|
||||
case Shortcut.ShrinkHeight:
|
||||
case Action.ShrinkHeight:
|
||||
if (window) {
|
||||
this.engine.resizeWindow(window, "south", -1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Shortcut.ShiftUp:
|
||||
case Action.ShiftUp:
|
||||
if (window) {
|
||||
this.engine.swapOrder(window, -1);
|
||||
}
|
||||
break;
|
||||
case Shortcut.ShiftDown:
|
||||
case Action.ShiftDown:
|
||||
if (window) {
|
||||
this.engine.swapOrder(window, +1);
|
||||
}
|
||||
break;
|
||||
|
||||
case Shortcut.SwapUp:
|
||||
case Action.SwapUp:
|
||||
this.engine.swapDirOrMoveFloat("up");
|
||||
break;
|
||||
case Shortcut.SwapDown:
|
||||
case Action.SwapDown:
|
||||
this.engine.swapDirOrMoveFloat("down");
|
||||
break;
|
||||
case Shortcut.SwapLeft:
|
||||
case Action.SwapLeft:
|
||||
this.engine.swapDirOrMoveFloat("left");
|
||||
break;
|
||||
case Shortcut.SwapRight:
|
||||
case Action.SwapRight:
|
||||
this.engine.swapDirOrMoveFloat("right");
|
||||
break;
|
||||
|
||||
case Shortcut.SetMaster:
|
||||
case Action.SetMaster:
|
||||
if (window) {
|
||||
this.engine.setMaster(window);
|
||||
}
|
||||
break;
|
||||
case Shortcut.ToggleFloat:
|
||||
case Action.ToggleFloat:
|
||||
if (window) {
|
||||
this.engine.toggleFloat(window);
|
||||
}
|
||||
break;
|
||||
case Shortcut.ToggleFloatAll:
|
||||
case Action.ToggleFloatAll:
|
||||
this.engine.floatAll(this.currentSurface);
|
||||
break;
|
||||
|
||||
case Shortcut.NextLayout:
|
||||
case Action.NextLayout:
|
||||
this.engine.cycleLayout(1);
|
||||
break;
|
||||
case Shortcut.PreviousLayout:
|
||||
case Action.PreviousLayout:
|
||||
this.engine.cycleLayout(-1);
|
||||
break;
|
||||
case Shortcut.SetLayout:
|
||||
case Action.SetLayout:
|
||||
if (typeof data === "string") {
|
||||
this.engine.setLayout(data);
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import { KWinSurface } from "./surface";
|
||||
import { KWinWindow } from "./window";
|
||||
|
||||
import { Controller } from "../controller";
|
||||
import { Shortcut } from "../controller/shortcut";
|
||||
import { Action } from "../controller/action";
|
||||
|
||||
import Window from "../engine/window";
|
||||
|
||||
@ -344,42 +344,42 @@ export class KWinDriver implements DriverContext {
|
||||
}
|
||||
|
||||
private bindMainShortcuts(): void {
|
||||
const bind = (seq: string, title: string, input: Shortcut): void => {
|
||||
const bind = (seq: string, title: string, action: Action): void => {
|
||||
title = "Bismuth: " + title;
|
||||
seq = "Meta+" + seq;
|
||||
this.kwinApi.KWin.registerShortcut(title, "", seq, () => {
|
||||
this.enter(() => this.controller.onShortcut(input));
|
||||
this.enter(() => this.controller.onShortcut(action));
|
||||
});
|
||||
};
|
||||
|
||||
bind("J", "Down/Next", Shortcut.Down);
|
||||
bind("K", "Up/Prev", Shortcut.Up);
|
||||
bind("H", "Left", Shortcut.Left);
|
||||
bind("L", "Right", Shortcut.Right);
|
||||
bind("J", "Down/Next", Action.Down);
|
||||
bind("K", "Up/Prev", Action.Up);
|
||||
bind("H", "Left", Action.Left);
|
||||
bind("L", "Right", Action.Right);
|
||||
|
||||
bind("Shift+J", "Move Down/Next", Shortcut.ShiftDown);
|
||||
bind("Shift+K", "Move Up/Prev", Shortcut.ShiftUp);
|
||||
bind("Shift+H", "Move Left", Shortcut.ShiftLeft);
|
||||
bind("Shift+L", "Move Right", Shortcut.ShiftRight);
|
||||
bind("Shift+J", "Move Down/Next", Action.ShiftDown);
|
||||
bind("Shift+K", "Move Up/Prev", Action.ShiftUp);
|
||||
bind("Shift+H", "Move Left", Action.ShiftLeft);
|
||||
bind("Shift+L", "Move Right", Action.ShiftRight);
|
||||
|
||||
bind("Ctrl+J", "Grow Height", Shortcut.GrowHeight);
|
||||
bind("Ctrl+K", "Shrink Height", Shortcut.ShrinkHeight);
|
||||
bind("Ctrl+H", "Shrink Width", Shortcut.ShrinkWidth);
|
||||
bind("Ctrl+L", "Grow Width", Shortcut.GrowWidth);
|
||||
bind("Ctrl+J", "Grow Height", Action.GrowHeight);
|
||||
bind("Ctrl+K", "Shrink Height", Action.ShrinkHeight);
|
||||
bind("Ctrl+H", "Shrink Width", Action.ShrinkWidth);
|
||||
bind("Ctrl+L", "Grow Width", Action.GrowWidth);
|
||||
|
||||
bind("I", "Increase", Shortcut.Increase);
|
||||
bind("D", "Decrease", Shortcut.Decrease);
|
||||
bind("I", "Increase", Action.Increase);
|
||||
bind("D", "Decrease", Action.Decrease);
|
||||
|
||||
bind("F", "Float", Shortcut.ToggleFloat);
|
||||
bind("Shift+F", "Float All", Shortcut.ToggleFloatAll);
|
||||
bind("", "Cycle Layout", Shortcut.NextLayout); // TODO: remove this shortcut
|
||||
bind("\\", "Next Layout", Shortcut.NextLayout);
|
||||
bind("|", "Previous Layout", Shortcut.PreviousLayout);
|
||||
bind("F", "Float", Action.ToggleFloat);
|
||||
bind("Shift+F", "Float All", Action.ToggleFloatAll);
|
||||
bind("", "Cycle Layout", Action.NextLayout); // TODO: remove this shortcut
|
||||
bind("\\", "Next Layout", Action.NextLayout);
|
||||
bind("|", "Previous Layout", Action.PreviousLayout);
|
||||
|
||||
bind("R", "Rotate", Shortcut.Rotate);
|
||||
bind("Shift+R", "Rotate Part", Shortcut.RotatePart);
|
||||
bind("R", "Rotate", Action.Rotate);
|
||||
bind("Shift+R", "Rotate Part", Action.RotatePart);
|
||||
|
||||
bind("Return", "Set master", Shortcut.SetMaster);
|
||||
bind("Return", "Set master", Action.SetMaster);
|
||||
}
|
||||
|
||||
private bindLayoutShortcuts(): void {
|
||||
@ -392,7 +392,7 @@ export class KWinDriver implements DriverContext {
|
||||
seq = seq !== "" ? "Meta+" + seq : "";
|
||||
this.kwinApi.KWin.registerShortcut(title, "", seq, () => {
|
||||
this.enter(() =>
|
||||
this.controller.onShortcut(Shortcut.SetLayout, layoutClass.id)
|
||||
this.controller.onShortcut(Action.SetLayout, layoutClass.id)
|
||||
);
|
||||
});
|
||||
};
|
||||
|
@ -11,7 +11,7 @@ import Window from "./window";
|
||||
import { WindowState } from "./window";
|
||||
|
||||
import { Controller } from "../controller";
|
||||
import { Shortcut } from "../controller/shortcut";
|
||||
import { Action } from "../controller/action";
|
||||
|
||||
import { DriverSurface } from "../driver/surface";
|
||||
|
||||
@ -49,7 +49,7 @@ export interface Engine {
|
||||
step: -1 | 1
|
||||
): void;
|
||||
enforceSize(window: Window): void;
|
||||
handleLayoutShortcut(input: Shortcut, data?: any): boolean;
|
||||
handleLayoutShortcut(input: Action, data?: any): boolean;
|
||||
focusOrder(step: -1 | 1): void;
|
||||
focusDir(dir: Direction): void;
|
||||
swapOrder(window: Window, step: -1 | 1): void;
|
||||
@ -566,7 +566,7 @@ export class TilingEngine implements Engine {
|
||||
*
|
||||
* @returns True if the layout overrides the shortcut. False, otherwise.
|
||||
*/
|
||||
public handleLayoutShortcut(input: Shortcut, data?: string): boolean {
|
||||
public handleLayoutShortcut(input: Action, data?: string): boolean {
|
||||
const layout = this.layouts.getCurrentLayout(
|
||||
this.controller.currentSurface
|
||||
);
|
||||
|
@ -9,7 +9,7 @@ import { Engine } from "..";
|
||||
import Window from "../window";
|
||||
import { WindowState } from "../window";
|
||||
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
import { Controller } from "../../controller";
|
||||
|
||||
import Rect from "../../util/rect";
|
||||
@ -97,15 +97,15 @@ export default class CascadeLayout implements WindowsLayout {
|
||||
|
||||
public handleShortcut(
|
||||
engine: Engine,
|
||||
input: Shortcut,
|
||||
input: Action,
|
||||
_data?: string
|
||||
): boolean {
|
||||
switch (input) {
|
||||
case Shortcut.Increase:
|
||||
case Action.Increase:
|
||||
this.dir = (this.dir + 1 + 8) % 8;
|
||||
engine.showNotification(this.description);
|
||||
break;
|
||||
case Shortcut.Decrease:
|
||||
case Action.Decrease:
|
||||
this.dir = (this.dir - 1 + 8) % 8;
|
||||
engine.showNotification(this.description);
|
||||
break;
|
||||
|
@ -7,7 +7,7 @@ import Window from "../window";
|
||||
import { Engine } from "..";
|
||||
|
||||
import { Controller } from "../../controller";
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
|
||||
import Rect from "../../util/rect";
|
||||
import RectDelta from "../../util/rectdelta";
|
||||
@ -24,7 +24,7 @@ export interface WindowsLayout {
|
||||
|
||||
adjust?(area: Rect, tiles: Window[], basis: Window, delta: RectDelta): void;
|
||||
apply(controller: Controller, tileables: Window[], area: Rect): void;
|
||||
handleShortcut?(engine: Engine, input: Shortcut, data?: any): boolean;
|
||||
handleShortcut?(engine: Engine, input: Action, data?: any): boolean;
|
||||
|
||||
toString(): string;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import { WindowState } from "../window";
|
||||
|
||||
import { KWinWindow } from "../../driver/window";
|
||||
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
|
||||
import Rect from "../../util/rect";
|
||||
import Config from "../../config";
|
||||
@ -62,20 +62,20 @@ export default class MonocleLayout implements WindowsLayout {
|
||||
|
||||
public handleShortcut(
|
||||
engine: Engine,
|
||||
input: Shortcut,
|
||||
input: Action,
|
||||
_data?: string
|
||||
): boolean {
|
||||
switch (input) {
|
||||
case Shortcut.Up:
|
||||
case Shortcut.FocusUp:
|
||||
case Shortcut.Left:
|
||||
case Shortcut.FocusLeft:
|
||||
case Action.Up:
|
||||
case Action.FocusUp:
|
||||
case Action.Left:
|
||||
case Action.FocusLeft:
|
||||
engine.focusOrder(-1);
|
||||
return true;
|
||||
case Shortcut.Down:
|
||||
case Shortcut.FocusDown:
|
||||
case Shortcut.Right:
|
||||
case Shortcut.FocusRight:
|
||||
case Action.Down:
|
||||
case Action.FocusDown:
|
||||
case Action.Right:
|
||||
case Action.FocusRight:
|
||||
engine.focusOrder(1);
|
||||
return true;
|
||||
default:
|
||||
|
@ -8,7 +8,7 @@ import { WindowsLayout } from ".";
|
||||
import Window from "../window";
|
||||
import { WindowState } from "../window";
|
||||
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
|
||||
import Rect from "../../util/rect";
|
||||
import { Controller } from "../../controller";
|
||||
@ -58,13 +58,13 @@ export default class SpreadLayout implements WindowsLayout {
|
||||
return other;
|
||||
}
|
||||
|
||||
public handleShortcut(_engine: Engine, input: Shortcut): boolean {
|
||||
public handleShortcut(_engine: Engine, input: Action): boolean {
|
||||
switch (input) {
|
||||
case Shortcut.Decrease:
|
||||
case Action.Decrease:
|
||||
// TODO: define arbitrary constants
|
||||
this.space = Math.max(0.04, this.space - 0.01);
|
||||
break;
|
||||
case Shortcut.Increase:
|
||||
case Action.Increase:
|
||||
// TODO: define arbitrary constants
|
||||
this.space = Math.min(0.1, this.space + 0.01);
|
||||
break;
|
||||
|
@ -8,7 +8,7 @@ import { WindowsLayout } from ".";
|
||||
import Window from "../window";
|
||||
import { WindowState } from "../window";
|
||||
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
|
||||
import Rect from "../../util/rect";
|
||||
import { Controller } from "../../controller";
|
||||
@ -54,13 +54,13 @@ export default class StairLayout implements WindowsLayout {
|
||||
return other;
|
||||
}
|
||||
|
||||
public handleShortcut(_engine: Engine, input: Shortcut): boolean {
|
||||
public handleShortcut(_engine: Engine, input: Action): boolean {
|
||||
switch (input) {
|
||||
case Shortcut.Decrease:
|
||||
case Action.Decrease:
|
||||
// TODO: define arbitrary constants
|
||||
this.space = Math.max(16, this.space - 8);
|
||||
break;
|
||||
case Shortcut.Increase:
|
||||
case Action.Increase:
|
||||
// TODO: define arbitrary constants
|
||||
this.space = Math.min(160, this.space + 8);
|
||||
break;
|
||||
|
@ -9,7 +9,7 @@ import LayoutUtils from "./layout_utils";
|
||||
import Window from "../window";
|
||||
import { WindowState } from "../window";
|
||||
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
|
||||
import { partitionArrayBySizes, clip, slide } from "../../util/func";
|
||||
import Rect from "../../util/rect";
|
||||
@ -199,24 +199,24 @@ export default class ThreeColumnLayout implements WindowsLayout {
|
||||
|
||||
public handleShortcut(
|
||||
engine: Engine,
|
||||
input: Shortcut,
|
||||
input: Action,
|
||||
_data?: string
|
||||
): boolean {
|
||||
switch (input) {
|
||||
case Shortcut.Increase:
|
||||
case Action.Increase:
|
||||
this.resizeMaster(engine, +1);
|
||||
return true;
|
||||
case Shortcut.Decrease:
|
||||
case Action.Decrease:
|
||||
this.resizeMaster(engine, -1);
|
||||
return true;
|
||||
case Shortcut.Left:
|
||||
case Action.Left:
|
||||
this.masterRatio = clip(
|
||||
slide(this.masterRatio, -0.05),
|
||||
ThreeColumnLayout.MIN_MASTER_RATIO,
|
||||
ThreeColumnLayout.MAX_MASTER_RATIO
|
||||
);
|
||||
return true;
|
||||
case Shortcut.Right:
|
||||
case Action.Right:
|
||||
this.masterRatio = clip(
|
||||
slide(this.masterRatio, +0.05),
|
||||
ThreeColumnLayout.MIN_MASTER_RATIO,
|
||||
|
@ -13,7 +13,7 @@ import {
|
||||
import Window from "../window";
|
||||
import { WindowState } from "../window";
|
||||
|
||||
import { Shortcut } from "../../controller/shortcut";
|
||||
import { Action } from "../../controller/action";
|
||||
|
||||
import { clip, slide } from "../../util/func";
|
||||
import Rect from "../../util/rect";
|
||||
@ -96,39 +96,39 @@ export default class TileLayout implements WindowsLayout {
|
||||
return other;
|
||||
}
|
||||
|
||||
public handleShortcut(engine: Engine, input: Shortcut): boolean {
|
||||
public handleShortcut(engine: Engine, input: Action): boolean {
|
||||
switch (input) {
|
||||
case Shortcut.Left:
|
||||
case Action.Left:
|
||||
this.masterRatio = clip(
|
||||
slide(this.masterRatio, -0.05),
|
||||
TileLayout.MIN_MASTER_RATIO,
|
||||
TileLayout.MAX_MASTER_RATIO
|
||||
);
|
||||
break;
|
||||
case Shortcut.Right:
|
||||
case Action.Right:
|
||||
this.masterRatio = clip(
|
||||
slide(this.masterRatio, +0.05),
|
||||
TileLayout.MIN_MASTER_RATIO,
|
||||
TileLayout.MAX_MASTER_RATIO
|
||||
);
|
||||
break;
|
||||
case Shortcut.Increase:
|
||||
case Action.Increase:
|
||||
// TODO: define arbitrary constant
|
||||
if (this.numMaster < 10) {
|
||||
this.numMaster += 1;
|
||||
}
|
||||
engine.showNotification(this.description);
|
||||
break;
|
||||
case Shortcut.Decrease:
|
||||
case Action.Decrease:
|
||||
if (this.numMaster > 0) {
|
||||
this.numMaster -= 1;
|
||||
}
|
||||
engine.showNotification(this.description);
|
||||
break;
|
||||
case Shortcut.Rotate:
|
||||
case Action.Rotate:
|
||||
this.parts.rotate(90);
|
||||
break;
|
||||
case Shortcut.RotatePart:
|
||||
case Action.RotatePart:
|
||||
this.parts.inner.primary.rotate(90);
|
||||
break;
|
||||
default:
|
||||
|
Loading…
Reference in New Issue
Block a user