Bonjour a tous,
je désirerais pouvoir me déplacer dans le terminal a l'aide des flèches
exemple en pascal :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
program test;
uses crt;
var i, j : integer;
    fleches : char;
begin
     i := 39; j := 15;
     fleches := #0;
	 gotoxy (i,j);
     while ( fleches <> #27 ) do {escape}
     begin
          fleches := readkey;
          if ( fleches = #13 ) then writeln('enter');
		  if ( fleches = #32 ) then writeln('espace');
          if ( fleches = #0 ) then
          begin
               fleches := readkey;
               case ( ord ( fleches ) ) of
           {gauche}75 : i := i - 4;
           {droite}77 : i := i + 4;
             {haut}72 : j := j - 2;
              {bas}80 : j := j + 2;
               end;
          end;
          if ( i = 31) then i := 35;
          if ( i = 47) then i := 43;
          if ( j = 19 ) then j := 17;
          if ( j = 11 ) then j := 13;
          gotoxy (i,j); 
     end;
end.
en recherchant sur le forum je n'ai trouvé que des solutions pour windows
j'ai essayé de faire un bout de programme en m inspirant de la fac dont voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
 
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
static void mode_raw(int);
int main(void) {
   unsigned char c;
   mode_raw(1);
   c = getchar();
   if(c == 0 || c == 224) {c = getchar();}
   if(c == 65||c == 66||c == 67||c == 68) {printf("fleches\n");}
   mode_raw(0);
}
void mode_raw(int activer) {
   static struct termios cooked;
   static int raw_actif = 0;
   if (raw_actif == activer) {return;}
   if (activer) { 
      struct termios raw;
        tcgetattr(STDIN_FILENO, &cooked);
        raw = cooked;
        cfmakeraw(&raw);
        tcsetattr(STDIN_FILENO, TCSANOW, &raw);
    }
    else
   {tcsetattr(STDIN_FILENO, TCSANOW, &cooked);}
           raw_actif = activer;
}
pouvez-vous m'aider?