move keyboard cursor

hi people, im creating a text editor in c language, n the point is that i cant move the cursor with the keyboard arrows, n im asking for some help here.

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>

struct lista {
char letra;
struct lista* ant;
struct lista* prox;
}texto;

typedef struct lista lista;

// conta o tamanho da lista
int tamanho(lista* first)
{
lista* aux = first;
int cont=0;
do{
aux = aux->prox;
cont++;
}while(aux != NULL);
return cont;
}

//(patrick)
void mostrarTexto (lista* first){
system("cls");

lista* aux = first;
if (aux != NULL){
do{
printf("%c", aux->letra);
aux = aux->prox;
}while(aux != NULL);
}
}

tratarEspecial(int cod1, char ch){
if(cod1 == -32){
switch (ch){
default: break;
}
}

if(cod1 == 0){
switch (ch){
default: break;
}
}
}

lista* add (lista* last, char c)//qq = qualquer
{
lista* novo = (lista*) malloc(sizeof(lista));
novo->letra = c;
novo->prox = NULL;
novo->ant = last;
last->prox = novo;
return novo;
}

//teste
lista* apagar (lista* last){
if(last->ant==NULL)
{}
else{
lista* aux = last->ant;
aux->prox=NULL;
free (last);
return aux;}
}

void save(lista* last, int x)
{
FILE *arq;
char array[x++];
int i;
lista* aux=last;
for(i=0;i<x;i++);
{
array[i]=aux->letra;
aux=aux->prox;
}
arq=fopen("texto.txt","w");
fputs(array, arq);
}

main()
{
system("color f1");
lista* texto;
lista* primeiro;
primeiro = texto;
char ch;
do{
ch = getch();
switch(ch){
case -32://esquerda, delete, direita...
tratarEspecial(-32, getch());
break;
case 0://... 59 a 68 (F1 a F10)
tratarEspecial(0, getch());
break;
case 8://backspace
texto = apagar(texto);
mostrarTexto(primeiro);
break;
case 27://esc
break;

default: texto = add(texto,ch); break; //add
}
mostrarTexto(primeiro);
}while(ch != 27);
save(texto,tamanho(primeiro));

}
Using [code] blocks really helps.

Check out the Windows Console Functions to do things in the Windows Console, like positioning the cursor and changing colors.
http://www.google.com/search?btnI=1&q=msdn+Console+Functions

Que le ayude.
Topic archived. No new replies allowed.