unpack zips in src to better compression

This commit is contained in:
2022-10-20 13:28:49 +02:00
parent e25403bd5f
commit 87eb27f562
447 changed files with 55306 additions and 0 deletions

View File

@@ -0,0 +1,227 @@
/*
* Routines d'<27>dition de texte
* D.B<>r<EFBFBD>ziat 1998
* Insertion/Suppressions de caract<63>res
*/
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <windom1.h>
#include "../types2b.h"
#include "../pdf/goo/gmem.h"
#include "libtedit.h"
/* extern function */
extern EDLINE *line_new( char *buf);
extern void line_add( EDIT *edit, EDLINE *line, int16 mode);
extern void line_rem( EDIT *edit);
/* prototype */
void char_shift_right( char *buf);
void char_shift_left( char *buf);
/* d<>calage vers la droite du buffer */
void char_shift_right( char *buf)
{
int16 l = ( int16)strlen(buf);
buf += l;
*(buf+1) = '\0';
while( l)
{
*buf = *(buf-1);
buf --;
l --;
}
}
/* d<>calage vers la gauche du buffer */
void char_shift_left( char *buf)
{
do
{
*buf = *(buf+1);
} while (*buf++);
}
/* Insertion <20> la position courante
* et incr<63>mentation de la position */
void char_put( EDIT *edit, int16 c)
{
EDLINE *line;
int16 pos;
if( edit -> top == NULL)
{
edit -> top = line_new( NULL);
edit -> bot = edit -> cur.line = edit -> top;
}
pos = edit->cur.row;
if( c == NEWLINE)
{
line = line_new( edit->cur.line->buf+pos);
edit->cur.line->buf[pos] = ENDLINE;
edit->cur.line->len = (int)strlen( edit->cur.line->buf);
line_add( edit, line, ED_CUR);
edit->cur.row = 0;
edit->cur.line = line;
edit->cur.index ++;
}
else
{
line = edit->cur.line;
if( ++line->len >= line->size)
{
line->size += SIZE_REALLOC;
line->buf = ( char*)grealloc(line->buf,line->size);
}
char_shift_right( line->buf + pos);
line->buf[pos] = c;
edit->cur.row ++;
}
}
/* int char_get(void); */
/*
* Efface le caract<63>re derri<72>re le curseur
* retourne 1 si OK 0 si on a effacer une ligne
*/
int16 char_del( EDIT *edit)
{
if( edit -> top == NULL)
return 0;
if( edit -> cur.row)
{
edit -> cur.row --;
edit -> cur.line -> len --;
char_shift_left( edit -> cur.line->buf + edit -> cur.row);
}
else
{
EDLINE *line = edit -> cur.line;
int16 pos, tindex;
if( line -> prev)
{
/* Concat<61>ner la ligne pr<70>c<EFBFBD>dente avec la ligne courante */
pos = line -> prev -> len;
/* Adapter la taille */
if( line -> prev -> size < line -> prev -> len + line -> len)
{
line -> prev -> size = line -> prev -> len + line -> len + 1;
line -> prev -> buf = (char *) grealloc( line -> prev -> buf, line -> size);
}
strcat( line -> prev -> buf, line -> buf);
line -> prev -> len = (int) strlen( line -> prev -> buf);
/* Effacer la ligne courante */
line = line -> prev;
tindex = edit -> cur.index;
line_rem( edit);
/* Pointer la ligne pr<70>c<EFBFBD>dente <20> la bonne position */
edit -> cur.row = pos;
edit -> cur.line = line;
edit -> cur.index = tindex-1;
return 0;
}
}
return 1;
}
/* Mouvement du curseur */
int16 curs_left( EDIT *edit)
{
if( edit->cur.row )
{
edit->cur.row --;
edit->maxcur --;
}
else if( edit->cur.line->prev)
{
edit->cur.index --;
edit->cur.line = edit->cur.line->prev;
edit->maxcur = edit->cur.row = edit->cur.line->len;
}
else
return 0;
return 1;
}
int16 curs_right( EDIT *edit)
{
int16 c = edit->cur.line->buf[edit->cur.row];
if( c == '\0')
{
if( edit->cur.line->next)
{
edit->cur.index ++;
edit->cur.line = edit->cur.line->next;
edit->cur.row = 0;
edit->maxcur = 0;
}
else
return 0; /* fin du buffer */
}
else
{
edit->cur.row ++;
edit->maxcur ++;
}
return 1;
}
int16 curs_up( EDIT *edit)
{
if( edit -> cur.line -> prev)
{
edit -> cur.index --;
edit -> cur.line = edit -> cur.line -> prev;
edit -> cur.row = MAX( edit -> cur.row, edit -> maxcur);
edit -> cur.row = MIN( edit -> cur.row, edit -> cur.line -> len);
return 1;
}
return 0;
}
int16 curs_down( EDIT *edit)
{
if( edit -> cur.line -> next)
{
edit -> cur.index ++;
edit -> cur.line = edit -> cur.line -> next;
edit -> cur.row = MAX( edit -> cur.row, edit -> maxcur);
edit -> cur.row = MIN( edit -> cur.row, edit -> cur.line -> len);
return 1;
}
return 0;
}
/* Insertion d'une chaine dans une ligne */
void string_put( EDIT *edit, char *str)
{
for( ;*str;str++)
{
char_put( edit, *str);
}
}

View File

@@ -0,0 +1,196 @@
/*
* Routines d'<27>dition de texte
* Dominique B<>r<EFBFBD>ziat, tous droits r<>serv<72>s
* module : edit.c
* descr. :
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../types2b.h"
#include "../pdf/goo/gmem.h"
#include "libtedit.h"
/* NewLine: cr<63><72> une nouvelle ligne */
EDLINE *line_new( char *buf)
{
EDLINE *line = (EDLINE*)gmalloc(sizeof(EDLINE));
if( line == NULL) return NULL;
if( buf)
{
line -> buf = copyString( buf);
if( line -> buf)
{
line -> len = (int)strlen( buf);
line -> size = line -> len + 1;
line -> next = line ->prev = NULL;
return line;
}
}
else
{
line -> buf = gmalloc( sizeof(char)*SIZE_REALLOC);
if( line -> buf)
{
*line -> buf = '\0';
line -> len = 0;
line -> size = SIZE_REALLOC;
line -> next = line ->prev = NULL;
return line;
}
}
gfree( line);
return NULL;
}
/* Addline : ajoute une ligne dans le buffer */
void line_add( EDIT *edit, EDLINE *line, int16 mode)
{
EDLINE *tmp;
edit -> maxline ++;
if( edit->top == NULL)
edit->top = edit->bot = edit->cur.line = line;
else
switch( mode)
{
case ED_TOP:
tmp = edit -> top;
edit -> top = line;
line -> next = tmp;
tmp -> prev = line;
break;
case ED_BOT:
tmp = edit -> bot;
edit -> bot = line;
line -> prev = tmp;
tmp -> next = line;
break;
/* Insertion <20> la position du curseur */
case ED_CUR:
tmp = edit -> cur.line;
/* la ligne ajout<75>e devient la ligne courante */
edit -> cur.line = line;
/* lien avec la ligne suivante (si elle existe ) */
line -> next = tmp->next;
if( tmp -> next)
tmp -> next -> prev = line;
/* lien avec la ligne pr<70>c<EFBFBD>dente */
line -> prev = tmp;
tmp -> next = line;
break;
}
}
/* RemLine : retire la ligne courante */
void line_rem( EDIT *edit)
{
EDLINE *line = edit -> cur.line;
if( edit -> top == NULL)
return;
edit -> maxline --;
if( line -> prev)
{
/* connecter les lignes pr<70>c<EFBFBD>dente et suivante */
if( line -> prev)
line -> prev -> next = line -> next;
else
edit -> top = line -> next;
if( line -> next)
line -> next -> prev = line -> prev;
else
edit -> bot = line -> prev;
/* nouvelle ligne courante */
if( line->next)
edit -> cur.line = line->next;
else
{
edit -> cur.line = line->prev?line->prev:NULL;
if( line->prev)
edit -> cur.index --;
}
edit -> cur.row = 0;
}
else
{
/* Connecter <20> la ligne suiante */
edit -> top = edit->cur.line = line->next;
if( edit->cur.line)
edit->cur.line->prev = NULL;
edit -> cur.row = 0;
}
gfree( line -> buf);
gfree( line);
}
/*
* D<>clare un nouveau texte
*/
EDIT* edit_new( void)
{
EDIT *edit = ( EDIT *)gmalloc( sizeof( EDIT));
if( edit == NULL)
return NULL;
edit -> top = edit -> bot = edit -> cur.line = NULL;
edit -> cur.row = 0;
edit -> cur.index = 1;
edit -> maxline = 0L;
edit -> maxcur = 0;
edit -> type = T_DOS;
*edit -> name = '\0';
return edit;
}
void edit_free( EDIT *edit) {
EDLINE *scan = edit -> top;
EDLINE *next;
while( scan)
{
next = scan -> next;
gfree( scan->buf);
gfree( scan);
scan = next;
}
gfree( edit);
}
int16 diff_line( EDLINE *up, EDLINE *dn)
{
EDLINE *scan;
int16 diff;
for( diff = 0, scan = up; scan!=dn && scan!=NULL; diff ++, scan = scan->next);
if( scan == NULL)
for( diff = 0, scan = up; scan!=dn && scan!=NULL; diff --, scan = scan->prev);
return diff;
}

View File

@@ -0,0 +1,94 @@
/*
* Routines d'<27>dition de texte
* D.B<>r<EFBFBD>ziat 1998/1999/200
* D<>finition g<>n<EFBFBD>rales
*
* version 1.02 bug fix<69> dans line_rem()
* version 1.01 bug fix<69> dans la r<>allocation des lignes
* version 1.00 premi<6D>re version fonctionnelle
*/
#ifndef pos_t
typedef size_t pos_t;
#endif
#define MAXBUF 256
#define SIZE_REALLOC 128
#define NEWLINE '\n'
#define ENDLINE '\0'
#define TABULATOR '\t'
/* type */
#define T_AUTO -1
#define T_DOS 0
#define T_NULL 1
#define T_BIN 2
#define T_UNIX 3
#define T_MAC 4
#define T_USER 5
/* typedef unsigned int uint; */
typedef struct edline
{
char *buf; /* adresse buffer ligne */
int16 len; /* longueur de la ligne */
int16 size; /* taille en octet de la ligne, octet en surplus y compris */
struct edline *prev, *next;
} EDLINE;
typedef struct cursor
{
EDLINE *line; /* ligne */
int16 row; /* colonne */
int16 index; /* index de la ligne */
} CURSOR;
typedef struct edit
{
EDLINE *top; /* premiere ligne */
EDLINE *bot; /* derniere ligne */
CURSOR cur; /* position curseur */
int16 maxcur; /* col max curseur */
pos_t maxline; /* nombre de lignes */
int16 type; /* Type du buffer */
char name[255]; /* Nom du buffer */
void *gr; /* Interface utilisateur */
} EDIT;
/* mode de line_add */
#define ED_TOP 1
#define ED_BOT 2
#define ED_CUR 3
/* qqs macros */
#define IS_TOP( edit) ((!(edit)->cur.row && !(edit)->cur.line->prev)?1:0)
#define IS_BOT( edit) (((edit)->cur.line->buf[(edit)->cur.row] == ENDLINE && !edit->cur.line->next) ? 1:0)
#define IS_UP( edit) (((edit)->cur.line->prev)?0:1)
#define IS_DN( edit) (((edit)->cur.line->next)?0:1)
#define GET_CHAR( edit) ((edit)->cur.line->buf[(edit)->cur.row])
#define GET_ROW( edit) ((edit)->cur.row)
#ifndef NOPROTO
int16 curs_left ( EDIT *edit);
int16 curs_right ( EDIT *edit);
int16 curs_up ( EDIT *edit);
int16 curs_down ( EDIT *edit);
int16 char_del ( EDIT *edit);
void char_put ( EDIT *edit, int16 c);
void string_put ( EDIT *edit, char *str);
EDIT * edit_new ( void);
void edit_free ( EDIT *edit);
EDLINE *line_new ( char *buf);
void line_add ( EDIT *edit, EDLINE *line, int16 mode);
void line_rem ( EDIT *edit);
char * tab2spc ( int16 tab, char *dest, char *src, int16 );
size_t edit_size ( EDIT *edit);
int16 diff_line ( EDLINE *up, EDLINE *dn);
#endif

View File

@@ -0,0 +1,141 @@
#include "../general.h"
#include "../catalog/catalog.h"
#include "../zaes.h"
#include "../custom_font.h"
/* prototype */
void cursor_position( WINDOW *win, int16 *x, int16 *y, int16 *w, int16 *h);
void edit_icon_txt( WINDOW *win, Entry *entry);
void init_edit_mode( WINDOW *win, Entry *entry);
void exit_edit_mode( WINDOW *win, Entry *entry);
/*==================================================================================*
* cursor_position: *
* compute the cursor position in edition_mode. *
*----------------------------------------------------------------------------------*
* returns: - *
*----------------------------------------------------------------------------------*
* win: The Target Window. *
* x, y, w, h: Returned Cursor Positions. *
*==================================================================================*/
void cursor_position( WINDOW *win, int16 *x, int16 *y, int16 *w, int16 *h)
{
WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON);
CURSOR *cur = &wicones->edit->cur;
WindGet( win, WF_WORKXYWH, x, y, w, h);
*h = 8;
if( cur->line)
{
char txt[] = " ";
char *p;
*txt = cur -> line -> buf [ cur -> row];
cur -> line -> buf [ cur -> row] = '\0';
p = cur -> line -> buf;
*x += get_text_width( p);
cur -> line -> buf [ cur -> row] = *txt;
*w = MAX( get_text_width( p), 8);
}
else
{
*w = 8;
*x += cur -> row * 8; /* Must be 0 ? */
}
}
/*==================================================================================*
* edit_icon_txt: *
* edit the selected icon 's text in real time in the WINDOW *win. *
*----------------------------------------------------------------------------------*
* wind = the target window *
* entry = the selected entry to be edited *
*----------------------------------------------------------------------------------*
* returns: - *
*==================================================================================*/
void edit_icon_txt( WINDOW *win, Entry *entry)
{
int16 xw, yw, x, y, w, h;
WindGet ( win, WF_WORKXYWH, &xw, &yw, &w, &h);
x = entry->txt_pos.x1 - 5;
y = entry->txt_pos.y1 - 1;
w = entry->txt_pos.x2 + 10 - x;
h = entry->txt_pos.y2 + 2 - y;
x += xw;
y += yw;
draw_page( win, x, y, w, h);
}
/*==================================================================================*
* init_edit_mode: *
* initialize the edition mode. *
*----------------------------------------------------------------------------------*
* win = the target window *
* entry = the icon to be edited *
*----------------------------------------------------------------------------------*
* returns: - *
*==================================================================================*/
void init_edit_mode( WINDOW *win, Entry *entry)
{
WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON);
if ( wicones->edit == NULL)
wicones->edit = edit_new();
string_put( wicones->edit, entry->name);
WinCatalog_Refresh( win);
edit_icon_txt( win, entry);
}
/*==================================================================================*
* exit_edit_mode: *
* Exit edition mode and refresh the edited icon. *
*----------------------------------------------------------------------------------*
* wind = the target window *
* entry = the last edited icon *
*----------------------------------------------------------------------------------*
* returns: - *
*==================================================================================*/
void exit_edit_mode( WINDOW *win, Entry *entry)
{
WINDICON *wicones = (WINDICON *)DataSearch( win, WD_ICON);
int16 xw, yw, x, y, w, h;
WindGet( win, WF_WORKXYWH, &xw, &yw, &w, &h);
x = entry->txt_pos.x1 - 5;
y = entry->txt_pos.y1 - 1;
w = entry->txt_pos.x2 + 10 - x;
h = entry->txt_pos.y2 + 2 - y;
x += xw;
y += yw;
edit_free( wicones->edit);
wicones->edit = NULL;
draw_page( win, x, y, w, h);
}

View File

@@ -0,0 +1,4 @@
extern void edit_icon_txt( WINDOW *win, Entry *entry);
extern void init_edit_mode( WINDOW *win, Entry *entry);
extern void exit_edit_mode( WINDOW *win, Entry *entry);
extern void cursor_position( WINDOW *win, int16 *x, int16 *y, int16 *w, int16 *h);