From 6e5f6775d16e9730ccf1edbecf14da52d0ef134a Mon Sep 17 00:00:00 2001 From: Pixel Date: Thu, 3 May 2001 00:20:43 +0000 Subject: Indentation --- lib/interface.c | 327 +++++++++++++++++++++++++++++++------------------------- 1 file changed, 181 insertions(+), 146 deletions(-) (limited to 'lib/interface.c') diff --git a/lib/interface.c b/lib/interface.c index 3a3c6fc..0ba058d 100644 --- a/lib/interface.c +++ b/lib/interface.c @@ -10,163 +10,198 @@ int quit; -char * ancien = NULL; +char *ancien = NULL; -/* Ces deux fonctions nous servent à insérer ou supprimer un caractère dans une chaîne. Utile pour l'utilisation des -touches backspace, suppr et insert */ +/* + * Ces deux fonctions nous servent a inserer ou supprimer un caractere dans une chaine. Utile pour + * l'utilisation des touches backspace, suppr et insert + */ -void supprime(char * ch) { - for (; *ch; ch++) { - *ch = *(ch + 1); - } +void supprime(char *ch) +{ + for (; *ch; ch++) { + *ch = *(ch + 1); + } } -void inserer(char * ch, char c) { - int i; - - ch[strlen(ch) + 1] = '\0'; - - for (i = strlen(ch) - 1; i != -1; i--) { - *(ch + i + 1) = *(ch + i); - } - *ch = c; +void inserer(char *ch, char c) +{ + int i; + + ch[strlen(ch) + 1] = '\0'; + + for (i = strlen(ch) - 1; i != -1; i--) { + *(ch + i + 1) = *(ch + i); + } + *ch = c; } -/* La boucle de l'interface. Même si elle a l'air longue, elle ne fait que tester les différents cas -en fonction des touches enfoncées. */ +/* + * La boucle de l'interface. Meme si elle a l'air longue, elle ne fait que tester les differents + * cas en fonction des touches enfoncees. + */ + +void ifloop(void) +{ + int cread, i, insert = 0; + int gotesc = 0; + char buffer[BUFSIZ] = ""; + int position = 0; + + printf("> "); -void ifloop(void) { - int cread, i, insert = 0; - int gotesc = 0; - char buffer[BUFSIZ] = ""; - int position = 0; - - printf("> "); + quit = 0; + while (!quit) { + cread = fgetc(input); - quit = 0; - while (!quit) { + if (gotesc) { + switch (cread) { + case 91: cread = fgetc(input); - - if (gotesc) { - switch (cread) { - case 91: - cread = fgetc(input); - switch (cread) { - case 49: /* Home */ - position = 0; - break; - case 50: /* Insert */ - insert ^= 1; - break; - case 52: /* End */ - printf("%s", &(buffer[position])); - position = strlen(buffer); - break; - case 67: /* Droite */ - if (buffer[position]) { - printf("%c", buffer[position++]); - } - break; - case 68: /* Gauche */ - if (position) { - printf("\010"); - position--; - } - break; - default: - gotesc = 0; - break; - } - break; - case 79: - cread = fgetc(input); - switch (cread) { - case 82: /* F3 */ - for (i = 0; i < position; i++) { - printf("\010"); - } - strcpy(buffer, ancien); - position = strlen(buffer); - printf("%s", buffer); - break; - default: - gotesc = 0; - break; + switch (cread) { + case 49: /* + * Home + */ + position = 0; + break; + case 50: /* + * Insert + */ + insert ^= 1; + break; + case 52: /* + * End + */ + printf("%s", &(buffer[position])); + position = strlen(buffer); + break; + case 67: /* + * Droite + */ + if (buffer[position]) { + printf("%c", buffer[position++]); + } + break; + case 68: /* + * Gauche + */ + if (position) { + printf("\010"); + position--; + } + break; + default: + gotesc = 0; + break; + } + break; + case 79: + cread = fgetc(input); + switch (cread) { + case 82: /* + * F3 + */ + for (i = 0; i < position; i++) { + printf("\010"); + } + strcpy(buffer, ancien); + position = strlen(buffer); + printf("%s", buffer); + break; + default: + gotesc = 0; + break; - } - break; - default: - gotesc = 0; - break; - } - if (gotesc) { - cread = fgetc(input); - gotesc = 0; - } } - switch(cread) { - case 3: /* CTRL-C */ - printf(_("*CTRL-C*\n")); - quit = 1; - break; - case 8: /* backspace */ - if (position) { - supprime(&(buffer[--position])); - printf("\010%s ", &(buffer[position])); - for (i = 0; i <= strlen(&(buffer[position])); i++) { - printf("\010"); - } - } - break; - case 10: /* Entrée */ - printf("\n"); - clearterm(); - if (ancien) free(ancien); - ancien = Estrdup(buffer); - parse_line(buffer); - if (quit) break; - initterm(); - position = 0; - buffer[0] = 0; - printf("\n"); - while (has_resultat()) { - printf(" . %s\n", pop_resultat()); - } - printf("\n> "); - global_error = 0; - break; - case 27: /* ESC */ - gotesc = 1; - break; - case 126: /* ~ */ - break; - case 127: /* Suppr */ - if (buffer[position]) { - supprime(&(buffer[position])); - } - printf("%s ", &(buffer[position])); - for (i = 0; i <= strlen(&(buffer[position])); i++) { - printf("\010"); - } - break; - default: /* Tout caractère autre, on le rajoute à la position en cours */ - if (insert) { - inserer(&(buffer[position]), cread); - printf("%s", &(buffer[position])); - position++; - for (i = 0; i < strlen(&(buffer[position])); i++) { - printf("\010"); - } - } else { - printf("%c", cread); - if (buffer[position]) { - buffer[position++] = cread; - } else { - buffer[position++] = cread; - buffer[position] = 0; - } - } - break; + break; + default: + gotesc = 0; + break; + } + if (gotesc) { + cread = fgetc(input); + gotesc = 0; + } + } + switch (cread) { + case 3: /* + * CTRL-C + */ + printf(_("*CTRL-C*\n")); + quit = 1; + break; + case 8: /* + * backspace + */ + if (position) { + supprime(&(buffer[--position])); + printf("\010%s ", &(buffer[position])); + for (i = 0; i <= strlen(&(buffer[position])); i++) { + printf("\010"); + } + } + break; + case 10: /* + * Entree + */ + printf("\n"); + clearterm(); + if (ancien) + free(ancien); + ancien = Estrdup(buffer); + parse_line(buffer); + if (quit) + break; + initterm(); + position = 0; + buffer[0] = 0; + printf("\n"); + while (has_resultat()) { + printf(" . %s\n", pop_resultat()); + } + printf("\n> "); + global_error = 0; + break; + case 27: /* + * ESC + */ + gotesc = 1; + break; + case 126: /* + * ~ + */ + break; + case 127: /* + * Suppr + */ + if (buffer[position]) { + supprime(&(buffer[position])); + } + printf("%s ", &(buffer[position])); + for (i = 0; i <= strlen(&(buffer[position])); i++) { + printf("\010"); + } + break; + default: /* + * Tout caractere autre, on le rajoute a la position en cours + */ + if (insert) { + inserer(&(buffer[position]), cread); + printf("%s", &(buffer[position])); + position++; + for (i = 0; i < strlen(&(buffer[position])); i++) { + printf("\010"); + } + } else { + printf("%c", cread); + if (buffer[position]) { + buffer[position++] = cread; + } else { + buffer[position++] = cread; + buffer[position] = 0; } + } + break; } + } } -- cgit v1.2.3