chjj / blessed

A high-level terminal interface library for node.js.
Other
11.27k stars 533 forks source link

Screen is restored on exit #359

Closed tom-seddon closed 3 years ago

tom-seddon commented 5 years ago

When my program exits, the terminal's previous contents are restored. How do I prevent this when using TypeScript and @types/blessed?

Thanks,

--Tom

tom-seddon commented 5 years ago

I already have this in my code:

function printError(error: Error): never {
    if (gFatalVerbose) {
        process.stderr.write('Stack trace:\n');
        process.stderr.write(error.stack + '\n');
    }
    process.stderr.write('FATAL: ' + error + '\n');
    return process.exit(1);
}

process.on('uncaughtException', (error) => {
    printError(error);
});

I was hoping that process.exit(1) would just stop things dead, so I can see the stack trace, but the screen gets restored anyway.

Thanks,

--Tom

dacoffey commented 3 years ago

You can call screen.destroy() prior to your process.exit(1) call

tom-seddon commented 3 years ago

Found this going through old issues looking for something... thanks for the note. I'm not working on that code any more (and I can't remember what I did about this...), but this sounds like a fix for my problem.

Thanks,

--Tom