1

//---------------------------------------------------------------------------------------------
// name : Input_xy
// desc : Récupère une saisie au clavier
// author : Lightness1024! (lightness1024@aol.com)
// prototyp: short Input_xy (short x, short y, short maxlen, char* buffer);
//---------------------------------------------------------------------------------------------

short Input_xy (short x, short y, short maxlen, char* buffer)
{
/* --entrees:
x : position x de l'affichage
y : position y de l'affichage
maxlen : taille max en caracteres de l'entree
buffer : pointer vers chaine de sortie

-- sortie:
le nombre de caracères entrés par l'utilisateur (0 <= sortie <= maxlen)

NOTE:
-Cette fonction affiche a l'ecran ce que l'utilisateur saisi au clavier et le stoque dans la variable buffer
elle nécessite les headers kbd.h et stdio.h incluent dans le projet.
-Prévoyez un espace suffisant pour afficher le texte saisi, soit minimum maxlen+2 caractères.

ATTENTION:
-la taille de la chaine de sortie doit dépasser maxlen de 1 au moins !!
*/

short Key = 0;
short len = 0;
buffer[0] = '';

while( Key != 13 ) {
printf_xy( x, y, "%sx5f ", buffer );
Key = GKeyIn( 0, 0 );
switch( Key ) {
case 257:
if( len > 0 ) {
len --;
buffer[len] = '';
}
break;
case KEY_ESC:
buffer[0] = '';
return 0;
case 13:
break;
default:
if( len < maxlen ) {
buffer[len] = Key;
len ++; // j'incrémente dans une ligne séparée pour éviter un effet de bords (side effect)
buffer[len] = '';
}
}
}
return len;
}


ben voila si vous en avez besoin ya aucune contrainte d'utilisation, vous pouvez meme supprimer les commentaires si ca vous chante @# smile
[edit]Edité par Lightness1024 le 04-01-2002 à 15:11:17[/edit]

2

et l'avantage % la fonction InputSTR dans TiGCCLib ?????

3

où ca une fonction inputstr ? c ce ke je cherchait et ce ki ma obligé a en faire une d'ailleur..

4

Dasn la FAQ de TIGCC, ZelJko donne une fonciton InputStr...
Et je l'ai remise dans la FAQ de mon tuto (je crois)

et la fonction de ZelJko reconnait le menu char...
avatar
Tutorial C (TI-89/92+/v200) - Articles Développement Web (PHP, Javascript, ...)
« What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against? » - Larry Wall

5

Ou alors si on veut un curseur dynamique (c'est tres mal programme je sais mais c'etait jadis... pour gstoolswink)
void curseur(void) 	rectangleinv(xc,yc,1,hc);


void charsub(char *string,short pos,short leng)
{
	int i;
	for (i=pos-1;i<leng;i++) string[i]=string[i+1];
	
}

void charadd(char *string,short pos,short leng,int chr)
{
	int i;
	for (i=leng;i>pos;i--) string[i]=string[i-1];
	
	string[pos]=chr;
	if (pos==leng) string[pos+1]=0;
}

short inputloop()
{
	int keya,tmplng,pos;
	tmplng=0; pos=0;
	loop:
	rectangleblanc(xinput,yinput,(lngr+1)*7,8);
	DrawStr(xinput,yinput,inputc,A_NORMAL);
	rectangleinv(xc,yc,1,hc);	

	keya=ngetchx();

	if ((keya>= 'a' && keya<= 'z' && lngr>=tmplng && (ntype==0 || ntype==2)) || (keya>= '0' && keya <= '9' && lngr>=tmplng) || (keya>= 'A' && keya <= 'Z' && lngr>=tmplng && ntype==2) ||(keya==' ' && ntype==2 && lngr>=tmplng) )
	{
			charadd(inputc,pos,lngr,keya);
			inputc[pos]=keya;
			tmplng++;
			pos++;
			xc+=6;
	} 
	
	if (keya==KEY_BACKSPACE && pos>0) 
	{
			if (pos!=tmplng)
			{
					charsub(inputc,pos,lngr);
					inputc[tmplng--]=0;
					inputc[tmplng]=0;
			} 
			else	
			{
					inputc[tmplng--]=0;
					inputc[tmplng]=0;
			}
	pos--; xc-=6;
	}
	
	if (keya==338 && pos!=0 ) 
	{
	pos--;
	xc-=6;	
	}	
	
	if (keya==344 && tmplng!=pos ) 
	{
	pos++;
	xc+=6;	
	}	
	if (keya==264) return 0;
	if (keya==13) return 1;
	goto loop;
}

short ninput(short x,short y,short lng, short type)
{
	short i;
	ntype=type;
	xinput=x; yinput=y; lngr=lng;
	xc=x; yc=y; hc=8;
	memset(inputc,0,50);
	OSVRegisterTimer(1,8,curseur);
	i=inputloop();
	OSVFreeTimer(1);
	return i;
}
XLib v1.00 Powerrrrrrrrrrrrrrrrrrrr!

6

Elle est pas mal, mais le problème c'est qu'elle permet pas le menu char sad

7

c'est tres facile de rajouter le menu char tou comme le varlink .. cf doc tigcc..
XLib v1.00 Powerrrrrrrrrrrrrrrrrrrr!

8

ouep smile
LinuX Powa (:

9

si c la fonction cmd_inputSTR dont vous parlez fo surtout jamais utiliser ca.

sinon pour votre fonction, je c pas si c pas on peu long de faire nous meme le curseur.
alors ke avec la fonction GKeyIN on peu afficher un curseur juste en definissant une shape.

10

Si justement, regarde celle de TiMad "curseur dynamique".
Pour le menu char, il faut utiliser les fonction de events.h