Fix linefeeds

This commit is contained in:
Kevin Lange 2011-12-03 19:57:59 -06:00
parent cedbee69a2
commit db216877b8

View File

@ -58,6 +58,9 @@ char * colors[256] = {NULL};
*/ */
char * output = " "; char * output = " ";
/* Telnet mode? */
int telnet = 0;
/* /*
* These values crop the animation, as we have a full 64x64 stored, * These values crop the animation, as we have a full 64x64 stored,
* but we only want to display 80x24. * but we only want to display 80x24.
@ -76,6 +79,19 @@ void SIGINT_handler(int sig){
exit(0); exit(0);
} }
void newline(int n) {
int i = 0;
for (i = 0; i < n; ++i) {
if (telnet) {
putc('\r', stdout);
putc(0, stdout);
putc('\n', stdout);
} else {
putc('\n', stdout);
}
}
}
/* /*
* These are the options we want to use as * These are the options we want to use as
* a telnet server. These are set in set_options() * a telnet server. These are set in set_options()
@ -155,6 +171,7 @@ int main(int argc, char ** argv) {
if (argc > 1) { if (argc > 1) {
if (!strcmp(argv[1], "-t")) { if (!strcmp(argv[1], "-t")) {
/* Yes, I know, lame way to get arguments, whatever, we only want one of them. */ /* Yes, I know, lame way to get arguments, whatever, we only want one of them. */
telnet = 1;
/* Set the default options */ /* Set the default options */
set_options(); set_options();
@ -391,19 +408,23 @@ ready:
/* Display the MOTD */ /* Display the MOTD */
int countdown_clock = 5; int countdown_clock = 5;
for (k = 0; k < countdown_clock; ++k) { for (k = 0; k < countdown_clock; ++k) {
printf("\n\n\n"); newline(3);
printf(" Nyancat Telnet Server\n"); printf(" Nyancat Telnet Server");
printf("\n"); newline(2);
printf(" written and run by \033[1;32mKevin Lange\033[1;34m @kevinlange\033[0m\n"); printf(" written and run by \033[1;32mKevin Lange\033[1;34m @kevinlange\033[0m");
printf("\n"); newline(2);
printf(" If things don't look right, try:\n"); printf(" If things don't look right, try:");
printf(" TERM=fallback telnet ...\n"); newline(1);
printf(" Or on Windows:\n"); printf(" TERM=fallback telnet ...");
printf(" telnet -t vtnt ...\n"); newline(1);
printf("\n"); printf(" Or on Windows:");
printf(" Problems? I am also a webserver:\n"); newline(1);
printf(" \033[1;34mhttp://miku.acm.uiuc.edu\033[0m\n"); printf(" telnet -t vtnt ...");
printf("\n"); newline(2);
printf(" Problems? I am also a webserver:");
newline(1);
printf(" \033[1;34mhttp://miku.acm.uiuc.edu\033[0m");
newline(2);
printf(" Starting in %d... \n", countdown_clock-k); printf(" Starting in %d... \n", countdown_clock-k);
fflush(stdout); fflush(stdout);
@ -438,7 +459,7 @@ ready:
} }
/* End of row, send newline */ /* End of row, send newline */
if (y != MAX_ROW - 1) if (y != MAX_ROW - 1)
printf("\n"); newline(1);
} }
/* Update frame crount */ /* Update frame crount */
++i; ++i;