Blank line in history

This commit is contained in:
Adrien Bourmault 2021-07-12 18:10:25 +02:00
parent 4c1763f6c4
commit 2774726c65
No known key found for this signature in database
GPG Key ID: 6EB408FE0ACEC664
1 changed files with 4 additions and 4 deletions

View File

@ -86,7 +86,7 @@ void connectedCommunication(int sockfd)
char sendBuff[SEND_BUFFER_SIZE] = {0}; char sendBuff[SEND_BUFFER_SIZE] = {0};
char receiveBuff[RECEIVE_BUFFER_SIZE] = {0}; char receiveBuff[RECEIVE_BUFFER_SIZE] = {0};
char historyBuff[SEND_BUFFER_SIZE * NHISTORY] = {0}; char historyBuff[SEND_BUFFER_SIZE * NHISTORY + 1] = {0};
int historyIndex = 0, historyModifier; int historyIndex = 0, historyModifier;
char curChar; char curChar;
@ -136,7 +136,7 @@ void connectedCommunication(int sockfd)
if (historyIndex <= 0) if (historyIndex <= 0)
break; break;
historyModifier = (historyModifier + 1) historyModifier = (historyModifier + 1)
% (historyIndex); % (historyIndex + 1);
printf("\33[2K\r%s%s", printf("\33[2K\r%s%s",
promptString, promptString,
&historyBuff[ &historyBuff[
@ -155,8 +155,8 @@ void connectedCommunication(int sockfd)
if (historyIndex <= 0) if (historyIndex <= 0)
break; break;
historyModifier = (historyModifier + historyIndex - 1) historyModifier = (historyModifier + historyIndex)
% (historyIndex); % (historyIndex + 1);
printf("\33[2K\r%s%s", printf("\33[2K\r%s%s",
promptString, promptString,
&historyBuff[ &historyBuff[