summaryrefslogtreecommitdiff
path: root/lib/interface.c
diff options
context:
space:
mode:
authorPixel <Pixel>2001-05-02 22:14:21 +0000
committerPixel <Pixel>2001-05-02 22:14:21 +0000
commitecd16166cde1ffa3edfbaa897b049d532e234ab6 (patch)
tree192b47251b141e0dd0f53530e3a4a2a5f961ea0f /lib/interface.c
parent8626b278cdccd95e628f14c027ae8a1c47133c48 (diff)
Pouet
Diffstat (limited to 'lib/interface.c')
-rw-r--r--lib/interface.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/interface.c b/lib/interface.c
index f698318..3a3c6fc 100644
--- a/lib/interface.c
+++ b/lib/interface.c
@@ -1,5 +1,6 @@
#include <stdio.h>
#include <string.h>
+#include <stdlib.h>
#include "config.h"
#include "interface.h"
#include "terminal.h"
@@ -9,6 +10,11 @@
int quit;
+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 */
+
void supprime(char * ch) {
for (; *ch; ch++) {
*ch = *(ch + 1);
@@ -26,6 +32,9 @@ void inserer(char * ch, char c) {
*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. */
+
void ifloop(void) {
int cread, i, insert = 0;
int gotesc = 0;
@@ -44,9 +53,6 @@ void ifloop(void) {
cread = fgetc(input);
switch (cread) {
case 49: /* Home */
- for (i = 0; i < position; i++) {
- printf("\010");
- }
position = 0;
break;
case 50: /* Insert */
@@ -72,6 +78,23 @@ void ifloop(void) {
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;
@@ -98,6 +121,8 @@ void ifloop(void) {
case 10: /* Entrée */
printf("\n");
clearterm();
+ if (ancien) free(ancien);
+ ancien = Estrdup(buffer);
parse_line(buffer);
if (quit) break;
initterm();
@@ -124,7 +149,7 @@ void ifloop(void) {
printf("\010");
}
break;
- default:
+ default: /* Tout caractère autre, on le rajoute à la position en cours */
if (insert) {
inserer(&(buffer[position]), cread);
printf("%s", &(buffer[position]));