Open juliuszfedyk opened 1 year ago
you can use term.clear()
or term.eraseDisplay()
fo this things
Theres a code snippet for what you asked:
...
const menuOptions = {
y: 1,
style: term.inverse,
selectedStyle: term.dim.blue.bgGreen,
cancelable: true
};
function displayMenu() {
term.clear();
term.singleLineMenu(menuItems, menuOptions, function (error, response) {
if (error) {
term.red.bold('Error: %s\n', error);
process.exit(1);
}
if (response.canceled) {
term.red.bold('Menu canceled\n');
process.exit();
}
// After selecting clear screen and write new content
term.clear();
switch (response.selectedText) {
case 'Home':
term.green('Welcome to the Home page!\n');
break;
case 'Settings':
term.yellow('Here are the Settings.\n');
break;
case 'Profile':
term.blue('This is your Profile.\n');
break;
case 'Exit':
term.red('Exiting...\n');
process.exit();
break;
default:
term('Unknown selection.\n');
break;
}
// after drawing new content return to the menu
setTimeout(displayMenu, 2000); // after 2 secs show menu
});
}
// show first menu
displayMenu();
Hi, I'm playing around with terminal-kit and what I'm trying to do is to create a navigation. Once the users submits on a menu I want to rewrite everything and draw a new document. However the menu never gets removed from the screen.
https://github.com/juliuszfedyk/termigram