extend colorize_states to 16 bits per line

* extend colorize_states to 16 bits to allow for more recursive
  coloring, such as html-src -> js...
* make htmlsrc-colorize_line public
This commit is contained in:
Charlie Gordon 2014-03-06 20:36:50 +00:00
commit 054ac2c141
3 changed files with 11 additions and 4 deletions

View file

@ -66,8 +66,8 @@ enum {
HTML_SCRIPT = 0x80, /* <SCRIPT> [...] </SCRIPT> */
};
static void htmlsrc_colorize_line(unsigned int *buf, int len,
int *colorize_state_ptr, int state_only)
void htmlsrc_colorize_line(unsigned int *buf, int len,
int *colorize_state_ptr, int state_only)
{
int c, state, js_state, l;
unsigned int *p, *p_start, *p_end;

4
qe.c
View file

@ -3246,8 +3246,10 @@ int generic_get_colorized_line(EditState *s, unsigned int *buf, int buf_size,
/* realloc line buffer if needed */
if ((line_num + 2) > s->colorize_nb_lines) {
s->colorize_nb_lines = line_num + 2 + COLORIZED_LINE_PREALLOC_SIZE;
if (!qe_realloc(&s->colorize_states, s->colorize_nb_lines))
if (!qe_realloc(&s->colorize_states,
s->colorize_nb_lines * sizeof(*s->colorize_states))) {
return 0;
}
}
/* propagate state if needed */

7
qe.h
View file

@ -1083,7 +1083,7 @@ struct EditState {
EditBuffer *b;
/* state before line n, one byte per line */
unsigned char *colorize_states;
unsigned short *colorize_states;
int colorize_nb_lines;
int colorize_nb_valid_lines;
/* maximum valid offset, INT_MAX if not modified. Needed to invalide
@ -1905,6 +1905,11 @@ void c_colorize_line(unsigned int *buf, int len,
extern ModeDef xml_mode;
/* htmlsrc.c */
void htmlsrc_colorize_line(unsigned int *buf, int len,
int *colorize_state_ptr, int state_only);
/* html.c */
extern ModeDef html_mode;