From 0a11a88075bc6e44c473d54334b61e7bc973e163 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Fri, 21 Feb 2025 23:57:27 -0500 Subject: client: Print login information Signed-off-by: Ian Moffett --- src/client/client.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/client') diff --git a/src/client/client.c b/src/client/client.c index b711882..df90243 100644 --- a/src/client/client.c +++ b/src/client/client.c @@ -27,6 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include #include #include #include @@ -46,6 +47,25 @@ static char input[512]; static size_t input_i = 0; static struct termios orig_termios; +void set_title(const char *text) +{ + int rows, cols; + int col_position; + struct winsize w; + + ioctl(STDOUT_FILENO, TIOCGWINSZ, &w); + rows = w.ws_row; + cols = w.ws_col; + + col_position = (cols - strlen(text)) / 2; + + printf("\033[s"); + printf("\033[1;%dH%s", col_position, text); + printf("\033[3;1H"); + printf("\033[u"); +} + + static void enable_raw_mode(void) { @@ -65,6 +85,7 @@ disable_raw_mode(void) { tcsetattr(STDIN_FILENO, TCSAFLUSH, &orig_termios); } + static void * recv_td(void *args) { @@ -97,8 +118,12 @@ main(int argc, char **argv) { int error; char c, send_buf[2048]; + char title[256]; size_t len; + printf("\033c\n\n"); + set_title("OMOC - login"); + tcgetattr(STDIN_FILENO, &orig_termios); setbuf(stdin, NULL); setbuf(stdout, NULL); @@ -115,6 +140,9 @@ main(int argc, char **argv) return error; } + snprintf(title, sizeof(title), "OMOC - logged in as %s\n", s.username); + set_title(title); + atexit(disable_raw_mode); enable_raw_mode(); -- cgit v1.2.3