Hmm... I got it sorta working, using escape codes. The only problem is that when I've inserted the line that came in from another client, I cant figure out how to put the cursor back in the correct column. I tell it to move to the first col in row 1, but I cant figure out a way to put it at the end of the user's input. My proof of concept code is as follows.
Code:
#include <stdio.h>
int main() {
printf("\033[2J"); /*clear screen*/
printf("\033[2;1H"); /*put in seperator between User input and chat text*/
printf("-----------------------------\n"); /*barrier*/
printf("\033[1;1H"); /*put at upper left*/
printf(">some user text not done yet... "); /*user is in the middle of typing*/
printf("\033[3;1H"); /*move to 2nd line on screen*/
printf("\033[1L"); /*insert line here*/
printf("comment one\n"); /*some text arrives*/
printf("\033[1;1H"); /*go back to first row*/
printf("\033[4~"); /*supposed to be "END" key but doesnt work (hitting the end key doesnt seem to work either, so I dont know what to put here)*/
printf("more text... ");
printf("\033[3;1H"); /*move to 2nd line on screen*/
printf("\033[1L"); /*insert line here*/
printf("comment two\n"); /*some more text arrives*/
printf("\033[1;1H"); /*go back to first row*/
printf("\033[4~"); /*supposed to be "END" key but doesnt work (hitting the end key doesnt seem to work either, so I dont know what to put here)*/
char ui[255];
fgets(ui, 255, stdin);
printf("%s\n", ui);
return 0;
}