Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function printReceivedMessage(message: MessageEvent, callsign: string): Promise {
const pos: { x: number, y: number } = await term.getCursorLocation()
if (pos) {
term.moveTo(0, pos.y)
term.insertLine(1)
printStyledText(message)
term.move(pos.x - 1, 0)
if (term.height === pos.y) {
if (input) {
// term.moveTo(0, term.height)
term.moveTo(0, term.height)
myColorFunction(`${callsign}`)(': ')
input.redraw()
}
}
}
}
const delta = h / len;
for (let i = 0; i < len; i++) {
const threadId = threadIds[i];
const thread = threads[threadId];
thread.idx = i + 1;
thread.y1 = Math.floor(i * delta);
thread.y2 = Math.floor((i + 1) * delta) - 1;
thread.shown = true;
this.termRefreshThread(threadId, i);
}
for (let i = len; i < threadIds.length; i++) {
threads[threadIds[i]].shown = false;
}
if (truncated) {
const numHidden = threadIds.length - len;
term.moveTo(1, h0, this.chalk.bgRed(` ${numHidden} hidden thread${numHidden > 1 ? 's' : ''}`));
// TODO: show warning that more stories are available
}
this.resetCursorPos();
}
function resetTerminal() {
term.saveCursor();
term.moveTo(1, showStatus ? 2 : 1);
lineNum = 0;
term.eraseDisplayBelow();
var data = input.map(cropLine).map(highlightLine).join('\n');
data = data.replace(/(#\sCommands:[^]*?#\s*\n)/, '$1' + editorCommands.join('\n# ') + '\n#\n');
data = data.replace(/#\sx, exec.*\s*\n/, '');
data = data.replace(/#\sd, drop.*\s*\n/, '');
data = data.split('\n').slice(0, term.height - 1).join('\n');
status('Status');
term(data);
term.restoreCursor();
}
function render(state, key, rawKey) {
term.clear();
term('Cursor: ' + state.cursor.pos + ' Key: ' + key + ' Raw key: ' + rawKey);
let index = 2;
state.lines.forEach((line) => {
term.moveTo(1, index);
term(line.action + ' ' + line.message);
index++;
});
index++;
state.info.forEach((line) => {
term.moveTo(1, index);
term(line);
index++;
});
term.moveTo(1, state.cursor.pos + 2);
}
resetCursorPos() {
term.moveTo(1, this.height);
}
}
function render() {
term.eraseDisplay();
renderHeader();
renderBody();
renderFooter();
term.moveTo(state.cursor.x, state.cursor.y);
}
resetCursorPos() {
if (!term.height) return;
term.moveTo(1, this.height);
}
}
} else {
barContentString += item.trim() + " "
}
})
companyBarContent += barContentString
term.moveTo(1, playerLines + 1)
let companyLines = Math.ceil(companyBarContent.length / term.width)
for (let line = 1; line <= companyLines; line += 1) {
term.bgYellow()
term.black()
term(new Array(term.width + 1).join(" "))
term.nextLine()
}
term.moveTo(1, playerLines + 1)
term(companyBarContent)
term.restoreCursor()
}
function flushDiff(diff: RenderDiff) {
for (let i = 0; i < diff.length; i++) {
terminal.moveTo(1, diff[i].line + 1);
terminal(diff[i].text);
}
}