elm_code editor: adjust tokens when we insert text
This commit is contained in:
parent
9e184f6270
commit
2e5d0e7e02
|
@ -92,6 +92,7 @@ static Evas_Object *
|
||||||
_elm_code_test_editor_setup(Evas_Object *parent)
|
_elm_code_test_editor_setup(Evas_Object *parent)
|
||||||
{
|
{
|
||||||
Elm_Code *code;
|
Elm_Code *code;
|
||||||
|
Elm_Code_Line *line;
|
||||||
Elm_Code_Widget *widget;
|
Elm_Code_Widget *widget;
|
||||||
|
|
||||||
code = elm_code_create();
|
code = elm_code_create();
|
||||||
|
@ -108,6 +109,10 @@ _elm_code_test_editor_setup(Evas_Object *parent)
|
||||||
_append_line(code->file, "");
|
_append_line(code->file, "");
|
||||||
_append_line(code->file, "...Please?");
|
_append_line(code->file, "...Please?");
|
||||||
|
|
||||||
|
line = elm_code_file_line_get(code->file, 1);
|
||||||
|
elm_code_line_token_add(line, 6, 7, 1, ELM_CODE_TOKEN_TYPE_COMMENT);
|
||||||
|
elm_code_callback_fire(code, &ELM_CODE_EVENT_LINE_LOAD_DONE, line);
|
||||||
|
|
||||||
evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||||
evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||||
evas_object_show(widget);
|
evas_object_show(widget);
|
||||||
|
|
|
@ -20,6 +20,22 @@ elm_code_line_text_get(Elm_Code_Line *line, int *length)
|
||||||
return line->content;
|
return line->content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_elm_code_line_tokens_move_right(Elm_Code_Line *line, int position, int move)
|
||||||
|
{
|
||||||
|
Eina_List *item;
|
||||||
|
Elm_Code_Token *token;
|
||||||
|
|
||||||
|
EINA_LIST_FOREACH(line->tokens, item, token)
|
||||||
|
{
|
||||||
|
if (token->end >= position)
|
||||||
|
token->end += move;
|
||||||
|
|
||||||
|
if (token->start > position)
|
||||||
|
token->start += move;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
EAPI void
|
EAPI void
|
||||||
elm_code_line_text_insert(Elm_Code_Line *line, int position, const char *string, int length)
|
elm_code_line_text_insert(Elm_Code_Line *line, int position, const char *string, int length)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +52,8 @@ elm_code_line_text_insert(Elm_Code_Line *line, int position, const char *string,
|
||||||
if (position < 0)
|
if (position < 0)
|
||||||
position = 0;
|
position = 0;
|
||||||
|
|
||||||
|
_elm_code_line_tokens_move_right(line, position + 1, length);
|
||||||
|
|
||||||
if (line->modified)
|
if (line->modified)
|
||||||
{
|
{
|
||||||
strncpy(inserted, line->modified, position);
|
strncpy(inserted, line->modified, position);
|
||||||
|
|
Loading…
Reference in New Issue