You'd think i'd have got it right by now

This commit is contained in:
Andrew Pamment 2016-04-22 15:43:47 +10:00
parent 3b3cc6557b
commit b13da799d1

View File

@ -820,38 +820,50 @@ void read_message(int socket, struct user_record *user, struct msg_headers *msgh
ansi = z; ansi = z;
while (strchr("ABCDEFGHIGJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", body[z]) == NULL) while (strchr("ABCDEFGHIGJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", body[z]) == NULL)
z++; z++;
if (body[z] == 'm' || body[z] == 'C' || body[z] == 'D') { if (body[z] == 'm') {
strncpy(buffer, &body[ansi], (z - ansi) + 1); strncpy(buffer, &body[ansi], (z - ansi) + 1);
buffer[z - ansi + 1] = '\0'; buffer[z - ansi + 1] = '\0';
s_putstring(socket, buffer); s_putstring(socket, buffer);
} }
if (body[z] == 'A') { if (body[z] == 'A') {
if (lines >= atoi(&body[ansi + 2])) { for (i=0;i<atoi(&body[ansi + 2]);i++) {
lines -= atoi(&body[ansi + 2]); if (lines - (i + 1) > 0) {
strncpy(buffer, &body[ansi], (z - ansi) + 1); s_putstring(socket, "\e[1A");
buffer[z - ansi + 1] = '\0'; lines--;
s_putstring(socket, buffer); } else {
break;
}
} }
} }
if (body[z] == 'C') { if (body[z] == 'C') {
chars += atoi(&body[ansi + 2]); for (i=0;i<atoi(&body[ansi + 2]);i++) {
if (chars > 79) { if (chars + (i + 1) < 79) {
lines++; s_putstring(socket, "\e[1C");
chars -= 79; chars++;
} else {
break;
}
} }
} }
if (body[z] == 'B') { if (body[z] == 'B') {
lines += atoi(&body[ansi + 2]); for (i=0;i<atoi(&body[ansi + 2]);i++) {
if (lines <= 17) { if (lines + (i + 1) < 17) {
strncpy(buffer, &body[ansi], (z - ansi) + 1); s_putstring(socket, "\e[1B");
buffer[z - ansi + 1] = '\0'; lines++;
s_putstring(socket, buffer); } else {
} break;
} }
} }
if (body[z] == 'D') { if (body[z] == 'D') {
chars -= atoi(&body[ansi + 2]); for (i=0;i<atoi(&body[ansi + 2]);i++) {
if (chars - (i + 1) > 0) {
s_putstring(socket, "\e[1D");
chars--;
} else {
break;
}
}
} }
} else if (body[z] != '\n') { } else if (body[z] != '\n') {
chars++; chars++;
s_putchar(socket, body[z]); s_putchar(socket, body[z]);