Merging in refactoring of elm_code file lookups and edi mime lookups.

Elm_Code file no longer required for elm_code to function (in memory is created automatically).
This commit is contained in:
Andy Williams 2014-11-28 23:53:23 +00:00
commit 688a89fc75
7 changed files with 15 additions and 15 deletions

View File

@ -38,7 +38,6 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
Evas_Object *widget;
code = elm_code_create();
elm_code_file_new(code);
widget = elm_code_widget_add(parent, code);
elm_code_widget_font_size_set(widget, 14);
_append_line(code->file, "Hello World, Elm Code!");

View File

@ -86,7 +86,7 @@ EAPI int elm_code_init(void);
*
* @return Elm Code's init counter value.
*
* @see elm_code_init().
* @see elm_code_init()
*
* @ingroup Init
*/
@ -95,11 +95,12 @@ EAPI int elm_code_shutdown(void);
/**
* Create a new Elm Code instance
*
* This method creates a new Elm Code instance which will need a
* backing file set for storage.
* This method creates a new Elm Code instance using an in-memory file for backing changes.
* A regular file can be set after creation if required.
* Once an Elm Code has been created you can create widgets that render the content.
*
* "return an allocated Elm_Code that references the given file
* @return an allocated Elm_Code that references the given file
* @see elm_code_file_open()
*/
EAPI Elm_Code *elm_code_create();

View File

@ -72,6 +72,8 @@ elm_code_create()
ret = calloc(1, sizeof(Elm_Code));
// create an in-memory backing for this elm_code by default
elm_code_file_new(ret);
return ret;
}

View File

@ -94,7 +94,6 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
// left side of diff
wcode1 = elm_code_create();
elm_code_file_new(wcode1);
widget_left = elm_code_widget_add(parent, wcode1);
evas_object_size_hint_weight_set(widget_left, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
@ -105,7 +104,6 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
// right side of diff
wcode2 = elm_code_create();
elm_code_file_new(wcode2);
widget_right = elm_code_widget_add(parent, wcode2);
evas_object_size_hint_weight_set(widget_right, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);

View File

@ -53,6 +53,9 @@ EAPI Elm_Code_File *elm_code_file_new(Elm_Code *code)
{
Elm_Code_File *ret;
if (code->file)
elm_code_file_free(code->file);
ret = calloc(1, sizeof(Elm_Code_File));
code->file = ret;
ret->parent = code;

View File

@ -6,16 +6,14 @@
START_TEST (elm_code_file_memory_lines)
{
Elm_Code_File *file;
Elm_Code *code;
code = elm_code_create();
file = elm_code_file_new(code);
ck_assert_uint_eq(0, elm_code_file_lines_get(file));
ck_assert_uint_eq(0, elm_code_file_lines_get(code->file));
elm_code_file_line_append(file, "a line", 6);
elm_code_file_line_append(code->file, "a line", 6);
ck_assert_uint_eq(1, elm_code_file_lines_get(file));
ck_assert_uint_eq(1, elm_code_file_lines_get(code->file));
elm_code_free(code);
}
END_TEST
@ -27,8 +25,7 @@ START_TEST (elm_code_file_memory_tokens)
Elm_Code *code;
code = elm_code_create();
file = elm_code_file_new(code);
file = code->file;
elm_code_file_line_append(file, "a line", 6);
elm_code_file_line_token_add(file, 1, 2, 5, ELM_CODE_TOKEN_TYPE_COMMENT);

View File

@ -19,7 +19,7 @@ START_TEST (elm_code_widget_token_render_simple_test)
Evas_Textgrid_Cell cells[25];
code = elm_code_create();
file = elm_code_file_new(code);
file = code->file;
elm_code_file_line_append(file, "some \"test content\", 45", 23);
line = elm_code_file_line_get(file, 1);
length = line->length;