From b10dcfd58930dbef7c6c6aac372a28a3cf4035d5 Mon Sep 17 00:00:00 2001 From: Howe829 Date: Thu, 16 Nov 2023 15:21:45 +0800 Subject: [PATCH] Ignore up arrow key --- smallchat-client.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/smallchat-client.c b/smallchat-client.c index e20b133..0b73f99 100644 --- a/smallchat-client.c +++ b/smallchat-client.c @@ -237,6 +237,11 @@ int main(int argc, char **argv) { } else if (FD_ISSET(stdin_fd, &readfds)) { /* Data from the user typing on the terminal? */ ssize_t count = read(stdin_fd,buf,sizeof(buf)); + /* Ignore up arrow otherwise horrible things happen. */ + if(count == 3 && + buf[0] == 27 && buf[1] == 91 && buf[2] == 65){ + continue; + } for (int j = 0; j < count; j++) { int res = inputBufferFeedChar(&ib,buf[j]); switch(res) {