2015-02-14 15:14:06 -08:00
|
|
|
#ifdef HAVE_CONFIG
|
|
|
|
# include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "Elm_Code.h"
|
|
|
|
|
|
|
|
#include "elm_code_private.h"
|
|
|
|
|
2015-03-08 03:15:31 -07:00
|
|
|
EAPI void
|
|
|
|
elm_code_line_free(Elm_Code_Line *line)
|
|
|
|
{
|
|
|
|
if (!line)
|
|
|
|
return;
|
|
|
|
|
2015-03-27 16:54:28 -07:00
|
|
|
if (line->status_text)
|
|
|
|
free((char *)line->status_text);
|
2015-03-08 03:15:31 -07:00
|
|
|
if (line->modified)
|
|
|
|
free(line->modified);
|
|
|
|
|
|
|
|
free(line);
|
|
|
|
}
|
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
EAPI void elm_code_line_status_set(Elm_Code_Line *line, Elm_Code_Status_Type status)
|
|
|
|
{
|
|
|
|
if (!line)
|
|
|
|
return;
|
|
|
|
|
|
|
|
line->status = status;
|
|
|
|
}
|
|
|
|
|
2015-02-21 10:24:17 -08:00
|
|
|
EAPI void elm_code_line_token_add(Elm_Code_Line *line, int start, int end, int lines,
|
|
|
|
Elm_Code_Token_Type type)
|
2015-02-14 15:14:06 -08:00
|
|
|
{
|
|
|
|
Elm_Code_Token *tok;
|
2015-02-21 10:24:17 -08:00
|
|
|
unsigned int end_line;
|
|
|
|
Elm_Code_Line *next_line;
|
2015-02-14 15:14:06 -08:00
|
|
|
|
|
|
|
if (!line)
|
|
|
|
return;
|
|
|
|
|
|
|
|
tok = calloc(1, sizeof(Elm_Code_Token));
|
|
|
|
|
2015-02-21 10:24:17 -08:00
|
|
|
end_line = line->number;
|
|
|
|
if (lines > 1)
|
|
|
|
end_line += lines - 1;
|
|
|
|
|
2015-02-14 15:14:06 -08:00
|
|
|
tok->start = start;
|
|
|
|
tok->end = end;
|
2015-02-21 10:24:17 -08:00
|
|
|
tok->end_line = end_line;
|
2015-02-14 15:14:06 -08:00
|
|
|
tok->type = type;
|
|
|
|
|
|
|
|
line->tokens = eina_list_append(line->tokens, tok);
|
|
|
|
|
2015-02-21 10:24:17 -08:00
|
|
|
if (end_line > line->number)
|
|
|
|
{
|
|
|
|
next_line = elm_code_file_line_get(line->file, line->number + 1);
|
|
|
|
elm_code_line_token_add(next_line, 1, end, lines - 1, type);
|
|
|
|
}
|
|
|
|
}
|