Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
);
const screen1 = new ScreenBuffer({ dst: term, noFill: true });
screen1.fill({
attr: {
// Both foreground and background must have the same color
color: 0,
bgColor: 0
}
});
ScreenBuffer.loadImage(
path_to_image,
{ terminal: term, shrink: { width: term.width, height: term.height * 2 } },
(error: any, image: any) => {
if (error) {
throw error;
} // Doh!
image.draw({ dst: screen, blending: true });
screen.draw();
}
);
termInit() {
/* eslint-disable no-console */
for (let i = 0; i < term.height; i++) console.log('');
/* eslint-enable no-console */
}
}
term.windowTitle(get_title());
// Clear Screen
term.clear();
b_main = tkit.ScreenBuffer.create({
dst: term,
x: 0,
y: 0,
width: term.width,
height: term.height,
});
b_main.fill({
attr: theme.main,
});
b_main.draw();
// Events
term.on('resize', (width, height) => {
// console.log('TERM RESIZED:', width, height);
load_layout(delta=false);
})
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()
}
}
}
}
});
b_coin[product_id].fill({
attr: theme.coins.container,
});
b_coin[product_id].draw({ delta: delta });
i++;
});
b_footer = tkit.ScreenBuffer.create({
dst: term,
x: 1,
y: term.height,
width: term.width,
height: 1,
// blending: true,
// noFill: true,
});
b_footer.fill({
attr: theme.footer.container,
});
b_footer.draw({ delta: delta });
}
resetCursorPos() {
if (!term.height) return;
term.moveTo(1, this.height);
}
}
const render = () => {
term.fullscreen();
term.inverse( padLine( 'Use the arrow keys and BACKSPACE to navigate, ENTER to select, and ESC to quit' ) );
term( '\n' );
term.bold( padLine( `--- ${ current.path } `, '-' ) );
if ( menu ) {
menu.abort();
}
menu = term.singleColumnMenu(
getMenu( current, term.height - 4 ),
{ selectedIndex: current.index },
( error, { selectedIndex } ) => {
const selectedDirectory = current.items[ selectedIndex ].name;
const selectedPath = path.resolve( current.path, selectedDirectory );
const stats = fs.statSync( selectedPath );
if ( stats.isDirectory() ) {
current = Folder( selectedPath );
} else {
current.index = selectedIndex;
term.bell();
}
render();
} );
menu.on( 'submit' , data => {
term.saveCursor() ;
term.moveTo( 1 , term.height - 1 , "Submit: %s" , data.selectedText ) ;
term.restoreCursor() ;
} ) ;