-
Notifications
You must be signed in to change notification settings - Fork 175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add optional buffered input for terminal #530
Conversation
Forgot to make |
minichlink/minichlink.c
Outdated
if( buffer[r - 1] == '\n' ) new_line = 1; | ||
if( new_line == 0 ) strcpy( print_buf, TERMINAL_CLEAR_PREV ); // Go one line up and erase it | ||
else strcpy( print_buf, TERMINAL_CLEAR_CUR ); // Go to the start of the line and erase it | ||
strncat( pline_buf, (char *)buffer, r ); // Add newely received chars to line buffer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please protect the sizes of these buffers from overflow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should I use strncat or better switch to sprintf?
minichlink/minichlink.c
Outdated
uint32_t appendword = 0; | ||
do | ||
{ | ||
uint8_t buffer[256]; | ||
#if TERMINAL_INPUT_BUFFER | ||
char print_buf[300]; // Buffer that is filled with everything and will be written to stdout (basically it's for formatting) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not large enough to encapsulate the pline and input buffers.
minichlink/minichlink.h
Outdated
@@ -195,6 +195,24 @@ struct InternalState | |||
#define DLLDECORATE | |||
#endif | |||
|
|||
#define TERMINAL_INPUT_BUFFER 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to ifdef this, but I Do want to hide it behind a flag of some kind. Or maybe a flag to turn it off.
There's a LOT of setups where using terminal colors will just look uuuugly. So it would be better to make sure we aren't on one of them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned I forgot to set it to 0. Or do you mean something else?
How hard would it be to instead make this configurable runtime? I'd love to include this in the binary but you have to use some other flag to invoke it? |
With new commit it now detects file/pipe stdout automagically. BUT it doesn't work with |
I would rather it be a manual on/off thing... Maybe we should wait until we get better command support? |
What do you mean by better command support? |
Sounds good. Let's do that. |
Spaces/tabs but I'll merge anyway! |
Yeah sorry for that. I'll fix in other commits. |
As discussed in discord.