jquery-terminal

Prompt not showing up after a sequence of typing animations in jQuery Terminal


 eth_atr_d9: function() {
                this.echo('Entering... ', { typing: true, delay: 10 });
                this.echo('Text1', { typing: true, delay: 30 });
                this.echo('Text2', { typing: true, delay: 30 });

On entering this command 'eth_atr_d9', the text to be echoed is printed normally but the ">" does not come, still it allows to enter another command which too works perfectly fine.

I tried changing the length of the text but the problem is occurring with only this command rest 6 commands work normally. I tried it locally and on codepen.io


Solution

  • The problem is that animation is asynchronous. You can't call the next animation before the first finishes. Otherwise, you will end up with an odd state.

    try something like this:

    const commands = {
       eth_atr_d9: async function() {
           await this.echo('Entering... ', { typing: true, delay: 10 }); 
           await this.echo('Text1', { typing: true, delay: 30 });
           await this.echo('Text2', { typing: true, delay: 30 });
       }
    };
    

    Here is a CodePen demo.

    I've added this to Wiki.