statusbar message
This commit is contained in:
parent
7d7febea39
commit
b90a76ebc8
|
|
@ -1,5 +1,5 @@
|
||||||
////
|
////
|
||||||
// version: 66c75ff
|
// version: 7d7febe
|
||||||
|
|
||||||
// src/js/dom.ts
|
// src/js/dom.ts
|
||||||
var content2 = $("content");
|
var content2 = $("content");
|
||||||
|
|
@ -1058,6 +1058,25 @@ async function runCommand(input) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// src/js/statusbar.ts
|
||||||
|
var STATUS_MSG_LENGTH = 3000;
|
||||||
|
var statusbar = $("statusbar");
|
||||||
|
var statusbarMsg = $("statusbar-msg");
|
||||||
|
var timer;
|
||||||
|
function status(msg) {
|
||||||
|
showStatusMsg();
|
||||||
|
statusbarMsg.textContent = msg;
|
||||||
|
if (timer)
|
||||||
|
clearTimeout(timer);
|
||||||
|
timer = setTimeout(hideStatusMsg, STATUS_MSG_LENGTH);
|
||||||
|
}
|
||||||
|
function showStatusMsg() {
|
||||||
|
statusbar.classList.add("showing-msg");
|
||||||
|
}
|
||||||
|
function hideStatusMsg() {
|
||||||
|
statusbar.className = "";
|
||||||
|
}
|
||||||
|
|
||||||
// src/js/hyperlink.ts
|
// src/js/hyperlink.ts
|
||||||
function initHyperlink() {
|
function initHyperlink() {
|
||||||
window.addEventListener("click", handleClick);
|
window.addEventListener("click", handleClick);
|
||||||
|
|
@ -1076,6 +1095,9 @@ async function handleClick(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
await runCommand(href.slice(1));
|
await runCommand(href.slice(1));
|
||||||
focusInput();
|
focusInput();
|
||||||
|
} else {
|
||||||
|
e.preventDefault();
|
||||||
|
status(href);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1133,7 +1155,7 @@ function clearInput() {
|
||||||
// src/js/vram.ts
|
// src/js/vram.ts
|
||||||
var vramCounter = $("vram-size");
|
var vramCounter = $("vram-size");
|
||||||
var startVramCounter = () => {
|
var startVramCounter = () => {
|
||||||
const timer = setInterval(() => {
|
const timer2 = setInterval(() => {
|
||||||
const count = parseInt(vramCounter.textContent) + 1;
|
const count = parseInt(vramCounter.textContent) + 1;
|
||||||
let val = count + "KB";
|
let val = count + "KB";
|
||||||
if (count < 10)
|
if (count < 10)
|
||||||
|
|
@ -1141,7 +1163,7 @@ var startVramCounter = () => {
|
||||||
vramCounter.textContent = val;
|
vramCounter.textContent = val;
|
||||||
if (count >= 64) {
|
if (count >= 64) {
|
||||||
vramCounter.textContent += " OK";
|
vramCounter.textContent += " OK";
|
||||||
clearInterval(timer);
|
clearInterval(timer2);
|
||||||
}
|
}
|
||||||
}, 15);
|
}, 15);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
#statusline {
|
#statusbar {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
|
|
@ -177,7 +177,24 @@
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
#statusline a {
|
#statusbar .line-msg {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#statusbar.showing-msg .line-cwd {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
#statusbar.showing-msg {
|
||||||
|
background: var(--purple);
|
||||||
|
}
|
||||||
|
|
||||||
|
#statusbar.showing-msg .line-msg {
|
||||||
|
color: var(--cyan);
|
||||||
|
display: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
#statusbar a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
@ -35,6 +35,9 @@ export const Terminal: FC = async () => (
|
||||||
<li class="center">VRAM <span id="vram-size">000KB</span></li>
|
<li class="center">VRAM <span id="vram-size">000KB</span></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div id="statusline"><div><a href="#projects" id="project-name">root</a>: <a href="#ls" id="project-cwd">/</a></div></div>
|
<div id="statusbar">
|
||||||
|
<div class="line-cwd"><a href="#projects" id="project-name">root</a>: <a href="#ls" id="project-cwd">/</a></div>
|
||||||
|
<div class="line-msg"><span id="statusbar-msg"></span></div>
|
||||||
|
</div>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
import { runCommand } from "./shell"
|
import { runCommand } from "./shell"
|
||||||
import { focusInput } from "./focus"
|
import { focusInput } from "./focus"
|
||||||
|
import { status } from "./statusbar"
|
||||||
|
|
||||||
export function initHyperlink() {
|
export function initHyperlink() {
|
||||||
window.addEventListener("click", handleClick)
|
window.addEventListener("click", handleClick)
|
||||||
|
|
@ -20,5 +21,8 @@ async function handleClick(e: MouseEvent) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
await runCommand(href.slice(1))
|
await runCommand(href.slice(1))
|
||||||
focusInput()
|
focusInput()
|
||||||
|
} else {
|
||||||
|
e.preventDefault()
|
||||||
|
status(href)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
27
src/js/statusbar.ts
Normal file
27
src/js/statusbar.ts
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
////
|
||||||
|
// Temporarily display a message to the user in the status bar.
|
||||||
|
|
||||||
|
import { $ } from "./dom"
|
||||||
|
|
||||||
|
const STATUS_MSG_LENGTH = 3000
|
||||||
|
|
||||||
|
const statusbar = $("statusbar") as HTMLDivElement
|
||||||
|
const statusbarMsg = $("statusbar-msg") as HTMLSpanElement
|
||||||
|
|
||||||
|
let timer: NodeJS.Timeout
|
||||||
|
|
||||||
|
export function status(msg: string) {
|
||||||
|
showStatusMsg()
|
||||||
|
statusbarMsg.textContent = msg
|
||||||
|
|
||||||
|
if (timer) clearTimeout(timer)
|
||||||
|
timer = setTimeout(hideStatusMsg, STATUS_MSG_LENGTH)
|
||||||
|
}
|
||||||
|
|
||||||
|
function showStatusMsg() {
|
||||||
|
statusbar.classList.add("showing-msg")
|
||||||
|
}
|
||||||
|
|
||||||
|
function hideStatusMsg() {
|
||||||
|
statusbar.className = ""
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user