Here is solution:
$.terminal.defaults.formatters.unshift([
/(^|[^\x08]|[\r\n]{2}|&[^;]+;)\x08|[^\r\n]+\r\x1B(?:\[|[)K/g, '', {loop: true}
]);
It almost work except that last ]
because regex is removing character before \b
and not moving the cursor.
(?:\[|[)K
is needed because command line accept first encode input with html entities, so you can't type formatting.
options are new feature for version 1.18.0 that replace in a loop until it don't match the regex.
var term = $('body').terminal();
$.terminal.defaults.formatters.unshift([
/(^|[^\x08]|[\r\n]{2}|&[^;]+;)\x08|[^\r\n]+\r\x1B(?:\[|[)K/g, '', {loop: true}
]);
var str = 'Checking current state.\t[ ]\b\b\b\b\b-\r\u001B[KChecking current state.\t[ ]\b\b\b\b\bFAIL\n\r\u001B';
term.insert(str).echo(str);
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script><script src="https://rawgit.com/jcubic/leash/master/lib/wcwidth.js"></script><script src="https://unpkg.com/jquery.terminal/js/jquery.terminal.js"></script><script src="https://rawgit.com/inexorabletash/polyfill/master/keyboard.js"></script><script src="https://unpkg.com/jquery.terminal/js/unix_formatting.js"></script><script src="https://unpkg.com/prismjs@1.8.1/prism.js"></script><script src="https://unpkg.com/jquery.terminal/js/less.js"></script><script src="https://unpkg.com/jquery.terminal/js/prism.js"></script><link rel="stylesheet prefetch" href="https://unpkg.com/prismjs/themes/prism-coy.css"><link rel="stylesheet prefetch" href="https://unpkg.com/jquery.terminal/css/jquery.terminal.css">
EDIT
The fix with better overtyping is in devel branch in unix_formatting file but it require more to work to make it work with command line right now it only work with echo.
var term = $('body').terminal();
var str = 'Checking current state.\t[ ]\b\b\b\b\b-\r\u001B[KChecking current state.\t[ ]\b\b\b\b\bFAIL\r\n';
term.insert(str).echo(str);
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script><script src="https://rawgit.com/jcubic/leash/master/lib/wcwidth.js"></script><script src="https://rawgit.com/jcubic/jquery.terminal/devel/js/jquery.terminal.js"></script><script src="https://rawgit.com/inexorabletash/polyfill/master/keyboard.js"></script><script src="https://rawgit.com/jcubic/jquery.terminal/devel/js/unix_formatting.js"></script><script src="https://unpkg.com/prismjs@1.8.1/prism.js"></script><script src="https://unpkg.com/jquery.terminal/js/less.js"></script><script src="https://unpkg.com/jquery.terminal/js/prism.js"></script><link rel="stylesheet prefetch" href="https://unpkg.com/prismjs/themes/prism-coy.css"><link rel="stylesheet prefetch" href="https://unpkg.com/jquery.terminal/css/jquery.terminal.css">
This functions is already replacing naive version of overtyping in unix_formatting. But for fully working I'll need update the API to allow to return string and position from function formatter like with tracking_replace utility used for regex formatters that can change length of the string, without this you will not have correct position when you insert this into terminal (using copy/paste or using insert function), but it will work for echo.