Skip to content
This repository has been archived by the owner on Apr 11, 2023. It is now read-only.

Added visual indicator to the entire window, when active, vim-vixen should interpret keystrokes (as opposed to when a textbox has focus and recieves keyboard input) #744 #782

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/content/Application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import MarkController from "./controllers/MarkController";
import FollowMasterController from "./controllers/FollowMasterController";
import FollowSlaveController from "./controllers/FollowSlaveController";
import FollowKeyController from "./controllers/FollowKeyController";
import InputIndicator from "./InputIndicator";
import InputDriver from "./InputDriver";
import KeymapController from "./controllers/KeymapController";
import AddonEnabledUseCase from "./usecases/AddonEnabledUseCase";
Expand Down Expand Up @@ -110,6 +111,7 @@ export default class Application {
}
});

new InputIndicator();
const inputDriver = new InputDriver(window.document.body);
inputDriver.onKey((key) => this.followKeyController.press(key));
inputDriver.onKey((key) => this.markKeyController.press(key));
Expand Down
17 changes: 17 additions & 0 deletions src/content/InputIndicator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export default class InputIndicator {

constructor() {
document.addEventListener("DOMContentLoaded", this.onDetectFocus, true)
window.addEventListener("focus", this.onDetectFocus, true);
window.addEventListener("blur", this.onDetectFocus, true);
this.onDetectFocus();
}

private onDetectFocus() {
if (document!.activeElement!.tagName === "BODY"){
document.getElementById("vimvixen-console-frame")!.classList.add("vimvixen-indicate-border-active");
} else {
document.getElementById("vimvixen-console-frame")!.classList.remove("vimvixen-indicate-border-active");
}
}
}
10 changes: 10 additions & 0 deletions src/content/site-style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,14 @@ export default `
font-size: 12px;
color: black;
}

.vimvixen-indicate-border-active {
box-sizing: border-box;
border: 8px solid #fa6600 !important;
}

.vimvixen-indicate-border {
border: 7px solid #ffffff00;
border-bottom: 8px solid #ffffff00;
}
`;