Home > Blockchain >  Non-Linear Output to Command Line
Non-Linear Output to Command Line

Time:09-21

Recently I have begun to think about creating a basic two-way chat program for two users. I have been learning quite a bit about python3 lately and I ran into a roadblock of sorts. Unless I create a full GUI, I do not know how to have live messages be printed to the terminal without interrupting a message the user is actively typing. In other words, I am needing a way to have output displayed in a non-linear fashion in the terminal.

Any advice would be greatly appreciated.

Edit: Apologies if my question is a little confusing, I am unaware of any proper terminology that may exist for this sort of thing.

CodePudding user response:

A workaround of sorts may be to store all incomming messages in an array and have a command that can be typed in the chat prompt (like /m) with fetches all messages that are waiting.

Or you could implament a timer that checks how long the user hasn't pressed a key and that would prevent it too.

These both are a bit of a bodge, but they'll work when implemented.

CodePudding user response:

You might look for a Curses-like library

It basically allows you to display characters in a terminal where you want, with custom color, background, behavior, etc...

It seems this library does the job: python3/library/curses

But don't get me wrong, you will still have to build some sort of GUI, just it will stay in your terminal.

  • Related