Crappy updates...
This commit is contained in:
parent
44ba6563eb
commit
7982bab9a4
69
xyntax.c
69
xyntax.c
@ -11,6 +11,65 @@
|
|||||||
|
|
||||||
#include <xolatile/xyntax.h>
|
#include <xolatile/xyntax.h>
|
||||||
|
|
||||||
|
#ifdef XYNTAX_PREDEFINED_C_HIGHLIGHT
|
||||||
|
|
||||||
|
int syntax_count = SYNTAX_C_COUNT;
|
||||||
|
|
||||||
|
int syntax_mode [SYNTAX_C_COUNT] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
||||||
|
int syntax_enrange [SYNTAX_C_COUNT] = { 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 };
|
||||||
|
int syntax_derange [SYNTAX_C_COUNT] = { 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 };
|
||||||
|
|
||||||
|
char * syntax_begin [SYNTAX_C_COUNT] = {
|
||||||
|
"#", "//", "/*", "'", "\"", "()[]{}.,:;<=>+-*/%!&~^?|",
|
||||||
|
"register", "volatile", "auto", "const", "static", "extern", "if", "else",
|
||||||
|
"do", "while", "for", "continue", "switch", "case", "default", "break",
|
||||||
|
"enum", "union", "struct", "typedef", "goto", "void", "return", "sizeof",
|
||||||
|
"char", "short", "int", "long", "signed", "unsigned", "float", "double",
|
||||||
|
"0123456789", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "abcdefghijklmnopqrstuvwxyz"
|
||||||
|
};
|
||||||
|
|
||||||
|
char * syntax_end [SYNTAX_C_COUNT] = {
|
||||||
|
"\n", "\n", "*/", "'", "\"", "",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n",
|
||||||
|
".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n", ".,:;<=>+-*/%!&~^()[]{}'\" \t\r\n"
|
||||||
|
};
|
||||||
|
|
||||||
|
char syntax_escape [SYNTAX_C_COUNT] = {
|
||||||
|
'\\', '\0', '\0', '\\', '\\', '\0',
|
||||||
|
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
|
||||||
|
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
|
||||||
|
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
|
||||||
|
'\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0',
|
||||||
|
'\0', '\0', '\0'
|
||||||
|
};
|
||||||
|
|
||||||
|
int syntax_colour [SYNTAX_C_COUNT] = {
|
||||||
|
COLOUR_RED, COLOUR_GREY, COLOUR_GREY, COLOUR_RED, COLOUR_RED, COLOUR_BLUE,
|
||||||
|
COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE,
|
||||||
|
COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE,
|
||||||
|
COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE,
|
||||||
|
COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE, COLOUR_BLUE,
|
||||||
|
COLOUR_PINK, COLOUR_PINK, COLOUR_WHITE
|
||||||
|
};
|
||||||
|
|
||||||
|
int syntax_effect [SYNTAX_C_COUNT] = {
|
||||||
|
EFFECT_NORMAL, EFFECT_BOLD, EFFECT_BOLD, EFFECT_BOLD, EFFECT_NORMAL, EFFECT_BOLD,
|
||||||
|
EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL,
|
||||||
|
EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL,
|
||||||
|
EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL,
|
||||||
|
EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL, EFFECT_NORMAL,
|
||||||
|
EFFECT_BOLD, EFFECT_NORMAL, EFFECT_ITALIC
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
int syntax_count = 0;
|
int syntax_count = 0;
|
||||||
int * syntax_mode = NULL;
|
int * syntax_mode = NULL;
|
||||||
int * syntax_enrange = NULL;
|
int * syntax_enrange = NULL;
|
||||||
@ -21,6 +80,8 @@ char * syntax_escape = NULL;
|
|||||||
int * syntax_colour = NULL;
|
int * syntax_colour = NULL;
|
||||||
int * syntax_effect = NULL;
|
int * syntax_effect = NULL;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
static int compare_character_array (char character, char * character_array, int count) {
|
static int compare_character_array (char character, char * character_array, int count) {
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
@ -33,6 +94,7 @@ static int compare_character_array (char character, char * character_array, int
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef XYNTAX_PREDEFINED_C_HIGHLIGHT
|
||||||
void syntax_define (int * index, int enrange, int derange, char * begin, char * end, char escape, int colour, int effect) {
|
void syntax_define (int * index, int enrange, int derange, char * begin, char * end, char escape, int colour, int effect) {
|
||||||
syntax_mode = reallocate (syntax_mode, (unsigned long int) (syntax_count + 1) * sizeof (* syntax_mode));
|
syntax_mode = reallocate (syntax_mode, (unsigned long int) (syntax_count + 1) * sizeof (* syntax_mode));
|
||||||
syntax_enrange = reallocate (syntax_enrange, (unsigned long int) (syntax_count + 1) * sizeof (* syntax_enrange));
|
syntax_enrange = reallocate (syntax_enrange, (unsigned long int) (syntax_count + 1) * sizeof (* syntax_enrange));
|
||||||
@ -46,7 +108,7 @@ void syntax_define (int * index, int enrange, int derange, char * begin, char *
|
|||||||
syntax_begin [syntax_count] = allocate ((string_length (begin) + 1) * (int) sizeof (* * syntax_begin));
|
syntax_begin [syntax_count] = allocate ((string_length (begin) + 1) * (int) sizeof (* * syntax_begin));
|
||||||
syntax_end [syntax_count] = allocate ((string_length (end) + 1) * (int) sizeof (* * syntax_end));
|
syntax_end [syntax_count] = allocate ((string_length (end) + 1) * (int) sizeof (* * syntax_end));
|
||||||
|
|
||||||
syntax_mode [syntax_count] = index;
|
syntax_mode [syntax_count] = * index;
|
||||||
syntax_enrange [syntax_count] = enrange;
|
syntax_enrange [syntax_count] = enrange;
|
||||||
syntax_derange [syntax_count] = derange;
|
syntax_derange [syntax_count] = derange;
|
||||||
syntax_escape [syntax_count] = escape;
|
syntax_escape [syntax_count] = escape;
|
||||||
@ -60,6 +122,7 @@ void syntax_define (int * index, int enrange, int derange, char * begin, char *
|
|||||||
|
|
||||||
++syntax_count;
|
++syntax_count;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void syntax_select (char * string, int * index, int * length) {
|
void syntax_select (char * string, int * index, int * length) {
|
||||||
int offset = 0;
|
int offset = 0;
|
||||||
@ -124,9 +187,10 @@ void syntax_select (char * string, int * index, int * length) {
|
|||||||
}
|
}
|
||||||
} while (++subset != (int) string_length (syntax_end [select]));
|
} while (++subset != (int) string_length (syntax_end [select]));
|
||||||
}
|
}
|
||||||
} while (string [offset] != '\0');
|
} while (string [offset - 1] != '\0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef XYNTAX_PREDEFINED_C_HIGHLIGHT
|
||||||
void syntax_delete (void) {
|
void syntax_delete (void) {
|
||||||
--syntax_count;
|
--syntax_count;
|
||||||
|
|
||||||
@ -144,5 +208,6 @@ void syntax_delete (void) {
|
|||||||
syntax_colour = deallocate (syntax_colour);
|
syntax_colour = deallocate (syntax_colour);
|
||||||
syntax_effect = deallocate (syntax_effect);
|
syntax_effect = deallocate (syntax_effect);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
17
xyntax.h
17
xyntax.h
@ -12,6 +12,18 @@
|
|||||||
#include <xolatile/xtandard.h>
|
#include <xolatile/xtandard.h>
|
||||||
#include <xolatile/xtandard.c>
|
#include <xolatile/xtandard.c>
|
||||||
|
|
||||||
|
#ifdef XYNTAX_PREDEFINED_C_HIGHLIGHT
|
||||||
|
#define SYNTAX_C_COUNT (41)
|
||||||
|
extern int syntax_count;
|
||||||
|
extern int syntax_mode [SYNTAX_C_COUNT];
|
||||||
|
extern int syntax_enrange [SYNTAX_C_COUNT];
|
||||||
|
extern int syntax_derange [SYNTAX_C_COUNT];
|
||||||
|
extern char * syntax_begin [SYNTAX_C_COUNT];
|
||||||
|
extern char * syntax_end [SYNTAX_C_COUNT];
|
||||||
|
extern char syntax_escape [SYNTAX_C_COUNT];
|
||||||
|
extern int syntax_colour [SYNTAX_C_COUNT];
|
||||||
|
extern int syntax_effect [SYNTAX_C_COUNT];
|
||||||
|
#else
|
||||||
extern int syntax_count;
|
extern int syntax_count;
|
||||||
extern int * syntax_mode;
|
extern int * syntax_mode;
|
||||||
extern int * syntax_enrange;
|
extern int * syntax_enrange;
|
||||||
@ -21,11 +33,16 @@ extern char * * syntax_end;
|
|||||||
extern char * syntax_escape;
|
extern char * syntax_escape;
|
||||||
extern int * syntax_colour;
|
extern int * syntax_colour;
|
||||||
extern int * syntax_effect;
|
extern int * syntax_effect;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef XYNTAX_PREDEFINED_C_HIGHLIGHT
|
||||||
extern void syntax_define (int *, int, int, char *, char *, char, int, int);
|
extern void syntax_define (int *, int, int, char *, char *, char, int, int);
|
||||||
|
#endif
|
||||||
|
|
||||||
extern void syntax_select (char *, int *, int *);
|
extern void syntax_select (char *, int *, int *);
|
||||||
|
|
||||||
|
#ifndef XYNTAX_PREDEFINED_C_HIGHLIGHT
|
||||||
extern void syntax_delete (void);
|
extern void syntax_delete (void);
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user