86 lines
1.3 KiB
C++
86 lines
1.3 KiB
C++
#define ANCHO 80;
|
|
|
|
typedef struct PTexto
|
|
{
|
|
char *LineaC;
|
|
};
|
|
|
|
void RefreshTexto( PTexto *PT, int NLineas, int NLinicio )
|
|
{
|
|
int i, j;
|
|
|
|
for ( i = 0; i < NLinicio; i++ )
|
|
PT++;
|
|
|
|
for ( i = NLinicio, j = 0; i < NLineas && j < 21; i++, j++ )
|
|
{
|
|
gotoxy( 2, j );
|
|
printf( "%s", PT -> LineaC );
|
|
PT++;
|
|
}
|
|
}
|
|
|
|
void PTextos( char *file )
|
|
{
|
|
FILE *PFio;
|
|
PTexto *PTxt, *p_aux;
|
|
int NumL;
|
|
|
|
if ( ( PFio = fopen( file, "rw+" ) ) == NULL )
|
|
{
|
|
// No se puede abrir el fichero -ERROR-
|
|
return;
|
|
} else {
|
|
// Seguimos
|
|
// No hay memoria -ERROR-
|
|
return;
|
|
p_aux = PTxt;
|
|
NumL = 1;
|
|
while ( !eof( PFio ) )
|
|
{
|
|
NumL++;
|
|
if ( ( PTxt = (PTexto *)calloc( sizeof(PTexto *), NumL ) ) == NULL )
|
|
{
|
|
// -ERROR
|
|
return;
|
|
}
|
|
if ( p_aux -> LineaC = (char *)calloc( sizeof( char ), 80 ) ) == NULL )
|
|
{
|
|
// -ERROR-
|
|
return;
|
|
} else {
|
|
// Leemos el caracter
|
|
fscanf( PFio, "%80s", p_aux -> LineaC );
|
|
}
|
|
p_aux = &paux[NumL];
|
|
};
|
|
|
|
RefreshTexto( PTxt, NumL, 0 );
|
|
|
|
NLvisual = 0;
|
|
NLvistras = 0;
|
|
ok = 0;
|
|
while ( !ok )
|
|
{
|
|
while( !kbhit() );
|
|
switch( getch() )
|
|
{
|
|
// Teclas especiales
|
|
case 0:
|
|
switch( getch() )
|
|
{
|
|
|
|
};
|
|
break;
|
|
default:
|
|
// Editamos la linea
|
|
Captura( 2, NLvisual, PTxt[NLvisual+NLvistras].PLinea );
|
|
}
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
}
|