From d9c5fe08b960d9933112da1f20b38b9453a9a75e Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 5 Dec 2014 09:20:11 -0600 Subject: [PATCH 01/14] Add a cursor to the view. Create a backing data structure to start tracking more useful widget information --- elm_code/bin/elm_code_test_main.c | 2 ++ elm_code/lib/elm_code_common.h | 1 + elm_code/lib/elm_code_widget.c | 36 ++++++++++++++++++++++++++----- elm_code/lib/elm_code_widget.h | 31 ++++++++++++++++++++++++-- 4 files changed, 63 insertions(+), 7 deletions(-) diff --git a/elm_code/bin/elm_code_test_main.c b/elm_code/bin/elm_code_test_main.c index 698e411..bfb13bb 100644 --- a/elm_code/bin/elm_code_test_main.c +++ b/elm_code/bin/elm_code_test_main.c @@ -40,6 +40,8 @@ _elm_code_test_welcome_setup(Evas_Object *parent) code = elm_code_create(); widget = elm_code_widget_add(parent, code); elm_code_widget_font_size_set(widget, 14); + elm_code_widget_editable_set(widget, EINA_TRUE); + _append_line(code->file, "Hello World, Elm Code!"); elm_code_file_line_token_add(code->file, 1, 14, 21, ELM_CODE_TOKEN_TYPE_COMMENT); _append_line(code->file, ""); diff --git a/elm_code/lib/elm_code_common.h b/elm_code/lib/elm_code_common.h index 79f5d6c..2520356 100644 --- a/elm_code/lib/elm_code_common.h +++ b/elm_code/lib/elm_code_common.h @@ -33,6 +33,7 @@ typedef enum { ELM_CODE_TOKEN_TYPE_REMOVED, ELM_CODE_TOKEN_TYPE_CHANGED, + ELM_CODE_TOKEN_TYPE_CURSOR, // a pseudo type used for styling but may not be set on a cell ELM_CODE_TOKEN_TYPE_COUNT } Elm_Code_Token_Type; diff --git a/elm_code/lib/elm_code_widget.c b/elm_code/lib/elm_code_widget.c index 24a70d6..2b633e8 100644 --- a/elm_code/lib/elm_code_widget.c +++ b/elm_code/lib/elm_code_widget.c @@ -45,7 +45,7 @@ static void _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int coun } } -EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, int count, Elm_Code_Line *line) +EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line) { Eina_List *item; Elm_Code_Token *token; @@ -73,6 +73,7 @@ static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells char *chr; unsigned int length, x; int w; + ELM_CODE_WIDGET_DATA_GET(o, widget); if (!_elm_code_widget_resize(o)) return; @@ -103,6 +104,11 @@ static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells } elm_code_widget_fill_line_tokens(cells, w, line); + if (widget->editable && widget->cursor_line == line->number) + { + if (widget->cursor_col < (unsigned int) w) + cells[widget->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR; + } evas_object_textgrid_update_add(o, 0, line->number - 1, w, 1); } @@ -180,11 +186,10 @@ _elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) { Evas_Object *o; + Elm_Code_Widget *widget; o = evas_object_textgrid_add(parent); - elm_code_widget_font_size_set(o, 10); - // setup status colors evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT, 36, 36, 36, 255); @@ -216,17 +221,38 @@ EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED, 54, 54, 255, 255); + // the style for a cursor - this is a special token and will be applied to the background + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CURSOR, + 205, 205, 54, 255); evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, code); eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, code)); eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, code)); + widget = calloc(1, sizeof(*widget)); + widget->code = code; + widget->cursor_line = 1; + widget->cursor_col = 1; + evas_object_data_set(o, ELM_CODE_WIDGET_DATA_KEY, widget); code->widgets = eina_list_append(code->widgets, o); + + elm_code_widget_font_size_set(o, 10); return o; } -EAPI void elm_code_widget_font_size_set(Evas_Object *widget, int size) +EAPI void elm_code_widget_font_size_set(Evas_Object *obj, Evas_Font_Size size) { - evas_object_textgrid_font_set(widget, "Mono", size * elm_config_scale_get()); + ELM_CODE_WIDGET_DATA_GET(obj, widget); + + widget->font_size = size; + evas_object_textgrid_font_set(obj, "Mono", size * elm_config_scale_get()); } +EAPI void elm_code_widget_editable_set(Evas_Object *obj, Eina_Bool editable) +{ + ELM_CODE_WIDGET_DATA_GET(obj, widget); + + widget->editable = editable; +} + + diff --git a/elm_code/lib/elm_code_widget.h b/elm_code/lib/elm_code_widget.h index 2302914..286fcab 100644 --- a/elm_code/lib/elm_code_widget.h +++ b/elm_code/lib/elm_code_widget.h @@ -13,6 +13,31 @@ extern "C" { * @brief These routines are used for rendering instances of Elm Code. */ +typedef struct _Elm_Code_Widget +{ + Elm_Code *code; + + Evas_Font_Size font_size; + unsigned int cursor_line, cursor_col; + Eina_Bool editable; + +} Elm_Code_Widget; + +#define ELM_CODE_WIDGET_DATA_KEY "Elm_Code_Widget" +#define ELM_CODE_WIDGET_DATA_GET(o, ptr, ...) \ + Elm_Code_Widget *ptr; \ + ptr = evas_object_data_get(o, ELM_CODE_WIDGET_DATA_KEY); + +#define ELM_CODE_WIDGET_DATA_GET_OR_RETURN(o, ptr, ...) \ + Elm_Code_Widget *ptr; \ + ptr = evas_object_data_get(o, ELM_CODE_WIDGET_DATA_KEY);\ + if (EINA_UNLIKELY(!ptr)) \ + { \ + CRI("no widget data for object %p (%s)", \ + o, evas_object_type_get(o)); \ + return __VA_ARGS__; \ + } + /** * @brief UI Loading functions. * @defgroup Init Creating a widget to render an Elm Code backend @@ -25,11 +50,13 @@ extern "C" { EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code); -EAPI void elm_code_widget_font_size_set(Evas_Object *widget, int size); +EAPI void elm_code_widget_font_size_set(Evas_Object *widget, Evas_Font_Size size); + +EAPI void elm_code_widget_editable_set(Evas_Object *widget, Eina_Bool editable); EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code); -EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, int count, Elm_Code_Line *line); +EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line); /** * @} From 4e0b183f347bd831de1c21b0fc5e88586c086d27 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 5 Dec 2014 09:39:40 -0600 Subject: [PATCH 02/14] Fix up headers and tests to remove the exposure of some private methods. Add some documentation whilst we're there too --- elm_code/lib/elm_code_widget.c | 30 ++++++++++++-------- elm_code/lib/elm_code_widget.h | 40 ++++++++++++++++++++++++--- elm_code/tests/elm_code_test_widget.c | 4 ++- src/tests/edi_test_content_provider.c | 2 +- 4 files changed, 59 insertions(+), 17 deletions(-) diff --git a/elm_code/lib/elm_code_widget.c b/elm_code/lib/elm_code_widget.c index 2b633e8..bce5d61 100644 --- a/elm_code/lib/elm_code_widget.c +++ b/elm_code/lib/elm_code_widget.c @@ -23,7 +23,8 @@ Eina_Unicode status_icons[] = { 0 }; -static Eina_Bool _elm_code_widget_resize(Evas_Object *o) +static Eina_Bool +_elm_code_widget_resize(Evas_Object *o) { int w, h, cw, ch; @@ -35,7 +36,8 @@ static Eina_Bool _elm_code_widget_resize(Evas_Object *o) return h > 0 && w > 0; } -static void _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start, int end, Elm_Code_Token_Type type) +static void +_elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start, int end, Elm_Code_Token_Type type) { int x; @@ -45,7 +47,8 @@ static void _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int coun } } -EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line) +static void +_elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line) { Eina_List *item; Elm_Code_Token *token; @@ -68,7 +71,8 @@ EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned i _elm_code_widget_fill_line_token(cells, count, start, length, ELM_CODE_TOKEN_TYPE_DEFAULT); } -static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells, Elm_Code_Line *line) +static void +_elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells, Elm_Code_Line *line) { char *chr; unsigned int length, x; @@ -103,7 +107,7 @@ static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells cells[x].bg = line->status; } - elm_code_widget_fill_line_tokens(cells, w, line); + _elm_code_widget_fill_line_tokens(cells, w, line); if (widget->editable && widget->cursor_line == line->number) { if (widget->cursor_col < (unsigned int) w) @@ -113,7 +117,8 @@ static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells evas_object_textgrid_update_add(o, 0, line->number - 1, w, 1); } -EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code) +static void +_elm_code_widget_fill(Evas_Object *o, Elm_Code *code) { Elm_Code_Line *line; Evas_Textgrid_Cell *cells; @@ -168,7 +173,7 @@ _elm_code_widget_file_cb(void *data, Eo *obj, const Eo_Event_Description *desc E code = (Elm_Code *)data; o = (Evas_Object *)obj; - elm_code_widget_fill(o, code); + _elm_code_widget_fill(o, code); return EINA_TRUE; } @@ -180,10 +185,11 @@ _elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, code = (Elm_Code *)data; - elm_code_widget_fill(obj, code); + _elm_code_widget_fill(obj, code); } -EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) +EAPI Evas_Object * +elm_code_widget_add(Evas_Object *parent, Elm_Code *code) { Evas_Object *o; Elm_Code_Widget *widget; @@ -240,7 +246,8 @@ EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) return o; } -EAPI void elm_code_widget_font_size_set(Evas_Object *obj, Evas_Font_Size size) +EAPI void +elm_code_widget_font_size_set(Evas_Object *obj, Evas_Font_Size size) { ELM_CODE_WIDGET_DATA_GET(obj, widget); @@ -248,7 +255,8 @@ EAPI void elm_code_widget_font_size_set(Evas_Object *obj, Evas_Font_Size size) evas_object_textgrid_font_set(obj, "Mono", size * elm_config_scale_get()); } -EAPI void elm_code_widget_editable_set(Evas_Object *obj, Eina_Bool editable) +EAPI void +elm_code_widget_editable_set(Evas_Object *obj, Eina_Bool editable) { ELM_CODE_WIDGET_DATA_GET(obj, widget); diff --git a/elm_code/lib/elm_code_widget.h b/elm_code/lib/elm_code_widget.h index 286fcab..b173a82 100644 --- a/elm_code/lib/elm_code_widget.h +++ b/elm_code/lib/elm_code_widget.h @@ -50,14 +50,46 @@ typedef struct _Elm_Code_Widget EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code); +/** + * @} + * + * @brief UI Manipulation functions. + * @defgroup UI Manage aspects of an Elm_Code widget + * + * @{ + * + * Functions for UI manipulation. + * + */ + +/** + * Set the font size of a widget + * + * Change the size of the monospaced font used by this widget instance. + * 10 pt is the default font size for an elm_code widget. + * + * @param widget The widget to change + * @param size The font size to set on this widget + * + * @ingroup UI + */ EAPI void elm_code_widget_font_size_set(Evas_Object *widget, Evas_Font_Size size); +/** + * Set this widget to be editable + * + * An editable widget displays a cursor and accepts user input. + * It will also accept focus. + * If EINA_FALSE is passed this widget will return to being read-only. + * EINA_FALSE is the default value for editable. + * + * @param widget The widget to change + * @param editable Whether or not this widget should be editable + * + * @ingroup UI + */ EAPI void elm_code_widget_editable_set(Evas_Object *widget, Eina_Bool editable); -EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code); - -EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line); - /** * @} */ diff --git a/elm_code/tests/elm_code_test_widget.c b/elm_code/tests/elm_code_test_widget.c index f6b0a46..6efdce8 100644 --- a/elm_code/tests/elm_code_test_widget.c +++ b/elm_code/tests/elm_code_test_widget.c @@ -4,6 +4,8 @@ #include "elm_code_suite.h" +#include "elm_code_widget.c" + static void _assert_cell_type(Evas_Textgrid_Cell cell, Elm_Code_Token_Type type, int id) { ck_assert_msg(cell.fg == type, "Wrong type for cell %d", id); @@ -27,7 +29,7 @@ START_TEST (elm_code_widget_token_render_simple_test) elm_code_file_line_token_add(file, 1, 6+1, 17+1, ELM_CODE_TOKEN_TYPE_COMMENT); elm_code_file_line_token_add(file, 1, 21+1, 22+1, ELM_CODE_TOKEN_TYPE_COMMENT); - elm_code_widget_fill_line_tokens(cells, length+1, line); + _elm_code_widget_fill_line_tokens(cells, length+1, line); _assert_cell_type(cells[1], ELM_CODE_TOKEN_TYPE_DEFAULT, 1); _assert_cell_type(cells[4], ELM_CODE_TOKEN_TYPE_DEFAULT, 4); _assert_cell_type(cells[6], ELM_CODE_TOKEN_TYPE_DEFAULT, 6); diff --git a/src/tests/edi_test_content_provider.c b/src/tests/edi_test_content_provider.c index 655db95..8e8a570 100644 --- a/src/tests/edi_test_content_provider.c +++ b/src/tests/edi_test_content_provider.c @@ -7,7 +7,7 @@ #include "edi_suite.h" // Add some no-op methods here so linking works without having to import the whole UI! -EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item) +EAPI Evas_Object *edi_editor_add(Evas_Object *parent EINA_UNUSED, Edi_Mainview_Item *item EINA_UNUSED) { return NULL; } From 4c6328c6363feb41ab9c19cb282e0cb2944fcd04 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sat, 6 Dec 2014 15:23:32 -0600 Subject: [PATCH 03/14] Improvement to incremental highlighting - its not fast but it will not get slower. Next the refresh window needs to reduce and any edits should adjust the tokens we have loaded --- src/bin/editor/edi_editor.c | 67 ++++++++++++++++++++++++++----------- 1 file changed, 47 insertions(+), 20 deletions(-) diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index 9215eb8..b65ec09 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -240,6 +240,7 @@ _scroll_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSE Edi_Editor *editor = data; Evas_Coord y, h; +// TODO ignore y scrolls - just return; elm_scroller_region_get(editor->entry, NULL, &y, NULL, NULL); elm_scroller_region_get(editor->lines, NULL, NULL, NULL, &h); elm_scroller_region_show(editor->lines, 0, y, 10, h); @@ -313,8 +314,43 @@ _edi_editor_statusbar_add(Evas_Object *panel, Edi_Editor *editor, Edi_Mainview_I } #if HAVE_LIBCLANG +// TODO on any refresh heck mtime - then re-run clang if changed - it should be fast enough now... static void -_edi_range_color_set(Edi_Editor *editor EINA_UNUSED, Edi_Range range, Edi_Color color) +_clang_remove_highlighting(Edi_Editor *editor) +{ + Eina_List *formats; + Evas_Object *textblock; + Evas_Textblock_Cursor *start, *end; + Evas_Object_Textblock_Node_Format *format; + unsigned int i; + + ecore_thread_main_loop_begin(); + textblock = elm_entry_textblock_get(editor->entry); + start = evas_object_textblock_cursor_new(textblock); + end = evas_object_textblock_cursor_new(textblock); + + evas_textblock_cursor_visible_range_get(start, end); + + i = 0; + formats = evas_textblock_cursor_range_formats_get(start, end); + while (eina_list_count(formats) > i) + { + format = eina_list_nth(formats, i); + + if (!strncmp("+ color", evas_textblock_node_format_text_get(format), 7)) + evas_textblock_node_format_remove_pair(textblock, format); + else + i++; + + formats = evas_textblock_cursor_range_formats_get(start, end); + } + evas_textblock_cursor_free(start); + evas_textblock_cursor_free(end); + ecore_thread_main_loop_end(); +} + +static void +_edi_range_color_set(Edi_Editor *editor, Edi_Range range, Edi_Color color) { Evas_Textblock *textblock; Evas_Textblock_Cursor *cursor; @@ -323,17 +359,17 @@ _edi_range_color_set(Edi_Editor *editor EINA_UNUSED, Edi_Range range, Edi_Color if (!((Evas_Coord)range.start.line > editor->format_end || (Evas_Coord)range.end.line < editor->format_start)) { - textblock = elm_entry_textblock_get(editor->entry); - cursor = evas_object_textblock_cursor_new(textblock); - evas_textblock_cursor_line_set(cursor, range.start.line - 1); - evas_textblock_cursor_pos_set(cursor, evas_textblock_cursor_pos_get(cursor) + range.start.col - 1); - evas_textblock_cursor_format_prepend(cursor, color); + textblock = elm_entry_textblock_get(editor->entry); + cursor = evas_object_textblock_cursor_new(textblock); + evas_textblock_cursor_line_set(cursor, range.start.line - 1); + evas_textblock_cursor_pos_set(cursor, evas_textblock_cursor_pos_get(cursor) + range.start.col - 1); + evas_textblock_cursor_format_prepend(cursor, color); - evas_textblock_cursor_line_set(cursor, range.end.line - 1); - evas_textblock_cursor_pos_set(cursor, evas_textblock_cursor_pos_get(cursor) + range.end.col - 1); - evas_textblock_cursor_format_append(cursor, ""); + evas_textblock_cursor_line_set(cursor, range.end.line - 1); + evas_textblock_cursor_pos_set(cursor, evas_textblock_cursor_pos_get(cursor) + range.end.col - 1); + evas_textblock_cursor_format_append(cursor, ""); - evas_textblock_cursor_free(cursor); + evas_textblock_cursor_free(cursor); } ecore_thread_main_loop_end(); } @@ -354,16 +390,6 @@ _clang_load_highlighting(const char *path, Edi_Editor *editor) clang_annotateTokens(editor->tx_unit, editor->tokens, editor->token_count, editor->cursors); } -static void -_clang_remove_highlighting(Edi_Editor *editor) -{ - Eina_List *formats; - -// TODO remove the formats on the lines we're updating -// formats = evas_textblock_cursor_range_formats_get(begin, limit); - -} - static void * _clang_show_highlighting(void *data) { @@ -585,6 +611,7 @@ _edi_clang_setup(void *data) /* FIXME: Possibly activate more options? */ editor->tx_unit = clang_parseTranslationUnit(editor->idx, path, clang_argv, clang_argc, NULL, 0, clang_defaultEditingTranslationUnitOptions() | CXTranslationUnit_DetailedPreprocessingRecord); + _clang_remove_highlighting(editor); _clang_load_errors(path, editor); _clang_load_highlighting(path, editor); From 3fb3564d05e120cec056ce4160a578bebb996d1f Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 23 Jan 2015 22:55:13 +0000 Subject: [PATCH 04/14] Experimental eo commit - structure in place and it's resizing but won't render --- configure.ac | 10 ++++ elm_code/bin/elm_code_test_main.c | 11 ++++ elm_code/lib/Makefile.am | 3 ++ elm_code/lib/elm_code_widget2.c | 82 ++++++++++++++++++++++++++++++ elm_code/lib/elm_code_widget2.eo | 30 +++++++++++ elm_code/lib/elm_code_widget2.eo.c | 53 +++++++++++++++++++ elm_code/lib/elm_code_widget2.eo.h | 50 ++++++++++++++++++ elm_code/lib/regen.sh | 7 +++ 8 files changed, 246 insertions(+) create mode 100644 elm_code/lib/elm_code_widget2.c create mode 100644 elm_code/lib/elm_code_widget2.eo create mode 100644 elm_code/lib/elm_code_widget2.eo.c create mode 100644 elm_code/lib/elm_code_widget2.eo.h create mode 100755 elm_code/lib/regen.sh diff --git a/configure.ac b/configure.ac index c9b3a42..45e7eb7 100644 --- a/configure.ac +++ b/configure.ac @@ -84,6 +84,14 @@ EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"]) # Check edje_cc EFL_WITH_BIN([edje], [edje-cc], [edje_cc]) +EFL_WITH_BIN([eolian], [eolian-gen], [eolian_gen]) +# Force the helper to try external eolian generators +AM_CONDITIONAL([HAVE_EOLIAN_GEN], [true]) + +# Needs to be moved into a macro, and also, needs a way to automatically fetch +# from all the dependencies using the Requires. +DEPS_EOLIAN_FLAGS=`${PKG_CONFIG} --variable=eolian_flags eo evas edje ecore efl` +AC_SUBST([DEPS_EOLIAN_FLAGS]) # Checks for library functions. AC_CHECK_FUNCS([setlocale]) @@ -127,6 +135,8 @@ echo " CFLAGS.................: $CFLAGS" echo " edje_cc................: ${edje_cc}" echo " highlighting (libclang): ${build_clang}" echo +echo "eolian_gen...............: ${eolian_gen}" +echo echo "Building documentation...: ${build_doc}" echo "Building tests...........: ${have_tests}" echo "Generate coverage .......: ${have_lcov}" diff --git a/elm_code/bin/elm_code_test_main.c b/elm_code/bin/elm_code_test_main.c index c422c7d..b462ef0 100644 --- a/elm_code/bin/elm_code_test_main.c +++ b/elm_code/bin/elm_code_test_main.c @@ -12,6 +12,7 @@ #include "gettext.h" #include +#include "elm_code_widget2.eo.h" #include "elm_code_test_private.h" @@ -50,6 +51,16 @@ _elm_code_test_welcome_setup(Evas_Object *parent) Evas_Object *widget; code = elm_code_create(); + + Elm_Code_Widget2 *obj = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + eo_do(obj, + elm_code_widget2_font_size_set(14)); + + evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(obj); +return obj; +// TODO - add all this good stuff into the eo api widget = elm_code_widget_add(parent, code); elm_code_widget_font_size_set(widget, 14); elm_code_widget_editable_set(widget, EINA_TRUE); diff --git a/elm_code/lib/Makefile.am b/elm_code/lib/Makefile.am index 9510cad..193b9e4 100644 --- a/elm_code/lib/Makefile.am +++ b/elm_code/lib/Makefile.am @@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in AM_CPPFLAGS = \ -I$(top_srcdir)/elm_code/lib \ -DEFL_BETA_API_SUPPORT \ +-DEFL_EO_API_SUPPORT \ @EFL_CFLAGS@ \ -DEFL_ELM_CODE_BUILD @@ -20,8 +21,10 @@ libelm_code_la_SOURCES = \ elm_code_file.c \ elm_code_parse.c \ elm_code_widget.c \ +elm_code_widget2.c \ elm_code_diff_widget.c \ elm_code.c \ elm_code_private.h + libelm_code_la_LIBADD = @EFL_LIBS@ -lm libelm_code_la_LDFLAGS = -no-undefined @EFL_LTLIBRARY_FLAGS@ diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget2.c new file mode 100644 index 0000000..24dc8df --- /dev/null +++ b/elm_code/lib/elm_code_widget2.c @@ -0,0 +1,82 @@ +#ifdef HAVE_CONFIG +# include "config.h" +#endif + +#include +#include +#include +#include +#include "elm_code_widget2.eo.h" + +typedef struct +{ + Elm_Code *code; + + Evas_Font_Size font_size; + unsigned int cursor_line, cursor_col; + Eina_Bool editable; + +} Elm_Code_Widget2_Data; + +EOLIAN static void +_elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd) +{ + eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, eo_constructor()); +printf("constr\n"); +} + +EOLIAN static void +_elm_code_widget2_evas_object_smart_resize(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord w, Evas_Coord h) +{ +printf("size %d, %d\n", w, h); +} + +EOLIAN static void +_elm_code_widget2_class_constructor(Eo_Class *klass) +{ + +} + +EOLIAN static void +_elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig) +{ + +} + +EOLIAN static void +_elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) +{ + Evas_Object *text; + +printf("add\n"); + eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add()); + elm_widget_sub_object_parent_add(obj); +// elm_widget_can_focus_set(obj, EINA_TRUE); + + text = elm_label_add(obj); + elm_object_text_set(text, "HELLO"); + elm_widget_sub_object_add(obj, text); + + evas_object_size_hint_weight_set(text, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(text, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(text); + + eo_do(obj, elm_obj_widget_theme_apply()); + + elm_layout_sizing_eval(obj); +} + +EOLIAN static void +_elm_code_widget2_font_size_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size) +{ + printf("set\n"); + pd->font_size = font_size; +} + +EOLIAN static Evas_Font_Size +_elm_code_widget2_font_size_get(Eo *obj, Elm_Code_Widget2_Data *pd) +{ + return pd->font_size; +} + +#include "elm_code_widget2.eo.c" diff --git a/elm_code/lib/elm_code_widget2.eo b/elm_code/lib/elm_code_widget2.eo new file mode 100644 index 0000000..9104233 --- /dev/null +++ b/elm_code/lib/elm_code_widget2.eo @@ -0,0 +1,30 @@ +class Elm_Code_Widget2 (Elm_Layout, Elm_Interface_Scrollable, + Elm_Interface_Atspi_Text) +{ + eo_prefix: elm_code_widget2; + properties { + font_size { + set { + } + get { + } + values { + Evas_Font_Size font_size; + } + } + } + methods { + } + implements { + class.constructor; + Eo.Base.constructor; + Evas.Object_Smart.add; + Evas.Object_Smart.resize; + Elm_Interface_Scrollable.content_pos_set; + } + events { + focused; + unfocused; + } + +} diff --git a/elm_code/lib/elm_code_widget2.eo.c b/elm_code/lib/elm_code_widget2.eo.c new file mode 100644 index 0000000..2b3a597 --- /dev/null +++ b/elm_code/lib/elm_code_widget2.eo.c @@ -0,0 +1,53 @@ +EOAPI const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_FOCUSED = + EO_EVENT_DESCRIPTION("focused", ""); +EOAPI const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_UNFOCUSED = + EO_EVENT_DESCRIPTION("unfocused", ""); + +void _elm_code_widget2_font_size_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size); + +EOAPI EO_VOID_FUNC_BODYV(elm_code_widget2_font_size_set, EO_FUNC_CALL(font_size), Evas_Font_Size font_size); + +Evas_Font_Size _elm_code_widget2_font_size_get(Eo *obj, Elm_Code_Widget2_Data *pd); + +EOAPI EO_FUNC_BODY(elm_code_widget2_font_size_get, Evas_Font_Size, 0); + +void _elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd); + + +void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd); + + +void _elm_code_widget2_evas_object_smart_resize(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord w, Evas_Coord h); + + +void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig); + + +static Eo_Op_Description _elm_code_widget2_op_desc[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor), + EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add), + EO_OP_FUNC_OVERRIDE(evas_obj_smart_resize, _elm_code_widget2_evas_object_smart_resize), + EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set), + EO_OP_FUNC(elm_code_widget2_font_size_set, _elm_code_widget2_font_size_set, ""), + EO_OP_FUNC(elm_code_widget2_font_size_get, _elm_code_widget2_font_size_get, ""), + EO_OP_SENTINEL +}; + +static const Eo_Event_Description *_elm_code_widget2_event_desc[] = { + ELM_CODE_WIDGET2_EVENT_FOCUSED, + ELM_CODE_WIDGET2_EVENT_UNFOCUSED, + NULL +}; + +static const Eo_Class_Description _elm_code_widget2_class_desc = { + EO_VERSION, + "Elm_Code_Widget2", + EO_CLASS_TYPE_REGULAR, + EO_CLASS_DESCRIPTION_OPS(_elm_code_widget2_op_desc), + _elm_code_widget2_event_desc, + sizeof(Elm_Code_Widget2_Data), + _elm_code_widget2_class_constructor, + NULL +}; + +EO_DEFINE_CLASS(elm_code_widget2_class_get, &_elm_code_widget2_class_desc, ELM_LAYOUT_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); \ No newline at end of file diff --git a/elm_code/lib/elm_code_widget2.eo.h b/elm_code/lib/elm_code_widget2.eo.h new file mode 100644 index 0000000..75d1b4d --- /dev/null +++ b/elm_code/lib/elm_code_widget2.eo.h @@ -0,0 +1,50 @@ +#ifndef _ELM_CODE_WIDGET2_EO_H_ +#define _ELM_CODE_WIDGET2_EO_H_ + +#ifndef _ELM_CODE_WIDGET2_EO_CLASS_TYPE +#define _ELM_CODE_WIDGET2_EO_CLASS_TYPE + +typedef Eo Elm_Code_Widget2; + +#endif + +#ifndef _ELM_CODE_WIDGET2_EO_TYPES +#define _ELM_CODE_WIDGET2_EO_TYPES + + +#endif +#define ELM_CODE_WIDGET2_CLASS elm_code_widget2_class_get() + +const Eo_Class *elm_code_widget2_class_get(void) EINA_CONST; + +/** + * + * No description supplied. + * + * @param[in] font_size No description supplied. + * + */ +EOAPI void elm_code_widget2_font_size_set(Evas_Font_Size font_size); + +/** + * + * No description supplied. + * + * + */ +EOAPI Evas_Font_Size elm_code_widget2_font_size_get(void); + +EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_FOCUSED; +EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_UNFOCUSED; + +/** + * No description + */ +#define ELM_CODE_WIDGET2_EVENT_FOCUSED (&(_ELM_CODE_WIDGET2_EVENT_FOCUSED)) + +/** + * No description + */ +#define ELM_CODE_WIDGET2_EVENT_UNFOCUSED (&(_ELM_CODE_WIDGET2_EVENT_UNFOCUSED)) + +#endif diff --git a/elm_code/lib/regen.sh b/elm_code/lib/regen.sh new file mode 100755 index 0000000..51acc50 --- /dev/null +++ b/elm_code/lib/regen.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +INCLUDE="-I /usr/local/share/eolian/include/eo-1 -I /usr/local/share/eolian/include/elementary-1 -I /usr/local/share/eolian/include/evas-1 -I /usr/local/share/eolian/include/efl-1" + +eolian_gen $INCLUDE --gh --eo -o elm_code_widget2.eo.h elm_code_widget2.eo +eolian_gen $INCLUDE --gc --eo -o elm_code_widget2.eo.c elm_code_widget2.eo +eolian_gen $INCLUDE --gi --eo -o elm_code_widget2.c elm_code_widget2.eo From 4ed86910aff1c05e21261c3a2f6d06b93751f864 Mon Sep 17 00:00:00 2001 From: Stephen Houston Date: Fri, 23 Jan 2015 20:35:14 -0600 Subject: [PATCH 05/14] Elm_Code_Widget2: Inherit from box instead of layout since a layout is not provided. --- elm_code/lib/elm_code_widget2.c | 5 +---- elm_code/lib/elm_code_widget2.eo.c | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget2.c index 24dc8df..b9ba337 100644 --- a/elm_code/lib/elm_code_widget2.c +++ b/elm_code/lib/elm_code_widget2.c @@ -55,15 +55,12 @@ printf("add\n"); text = elm_label_add(obj); elm_object_text_set(text, "HELLO"); - elm_widget_sub_object_add(obj, text); - evas_object_size_hint_weight_set(text, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(text, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(text); + elm_box_pack_end(obj, text); eo_do(obj, elm_obj_widget_theme_apply()); - - elm_layout_sizing_eval(obj); } EOLIAN static void diff --git a/elm_code/lib/elm_code_widget2.eo.c b/elm_code/lib/elm_code_widget2.eo.c index 2b3a597..827bba3 100644 --- a/elm_code/lib/elm_code_widget2.eo.c +++ b/elm_code/lib/elm_code_widget2.eo.c @@ -26,7 +26,7 @@ void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Cod static Eo_Op_Description _elm_code_widget2_op_desc[] = { EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor), EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add), - EO_OP_FUNC_OVERRIDE(evas_obj_smart_resize, _elm_code_widget2_evas_object_smart_resize), +// EO_OP_FUNC_OVERRIDE(evas_obj_smart_resize, _elm_code_widget2_evas_object_smart_resize), EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set), EO_OP_FUNC(elm_code_widget2_font_size_set, _elm_code_widget2_font_size_set, ""), EO_OP_FUNC(elm_code_widget2_font_size_get, _elm_code_widget2_font_size_get, ""), @@ -50,4 +50,4 @@ static const Eo_Class_Description _elm_code_widget2_class_desc = { NULL }; -EO_DEFINE_CLASS(elm_code_widget2_class_get, &_elm_code_widget2_class_desc, ELM_LAYOUT_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); \ No newline at end of file +EO_DEFINE_CLASS(elm_code_widget2_class_get, &_elm_code_widget2_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); From 5e21f9da54205b5ff1eeb3b4a9412fe5e2651254 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sat, 24 Jan 2015 08:26:09 +0000 Subject: [PATCH 06/14] Fix eo and regen to generate the right code based on okra's changes. We need to inherit from Elm_Box and not get in the way of smart resizing... --- elm_code/lib/elm_code_widget2.eo | 3 +-- elm_code/lib/elm_code_widget2.eo.c | 6 +----- elm_code/lib/regen.sh | 1 + 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/elm_code/lib/elm_code_widget2.eo b/elm_code/lib/elm_code_widget2.eo index 9104233..63bc5d2 100644 --- a/elm_code/lib/elm_code_widget2.eo +++ b/elm_code/lib/elm_code_widget2.eo @@ -1,4 +1,4 @@ -class Elm_Code_Widget2 (Elm_Layout, Elm_Interface_Scrollable, +class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable, Elm_Interface_Atspi_Text) { eo_prefix: elm_code_widget2; @@ -19,7 +19,6 @@ class Elm_Code_Widget2 (Elm_Layout, Elm_Interface_Scrollable, class.constructor; Eo.Base.constructor; Evas.Object_Smart.add; - Evas.Object_Smart.resize; Elm_Interface_Scrollable.content_pos_set; } events { diff --git a/elm_code/lib/elm_code_widget2.eo.c b/elm_code/lib/elm_code_widget2.eo.c index 827bba3..b689d76 100644 --- a/elm_code/lib/elm_code_widget2.eo.c +++ b/elm_code/lib/elm_code_widget2.eo.c @@ -17,16 +17,12 @@ void _elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd); void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd); -void _elm_code_widget2_evas_object_smart_resize(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord w, Evas_Coord h); - - void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig); static Eo_Op_Description _elm_code_widget2_op_desc[] = { EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor), EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add), -// EO_OP_FUNC_OVERRIDE(evas_obj_smart_resize, _elm_code_widget2_evas_object_smart_resize), EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set), EO_OP_FUNC(elm_code_widget2_font_size_set, _elm_code_widget2_font_size_set, ""), EO_OP_FUNC(elm_code_widget2_font_size_get, _elm_code_widget2_font_size_get, ""), @@ -50,4 +46,4 @@ static const Eo_Class_Description _elm_code_widget2_class_desc = { NULL }; -EO_DEFINE_CLASS(elm_code_widget2_class_get, &_elm_code_widget2_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); +EO_DEFINE_CLASS(elm_code_widget2_class_get, &_elm_code_widget2_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); \ No newline at end of file diff --git a/elm_code/lib/regen.sh b/elm_code/lib/regen.sh index 51acc50..055f8e7 100755 --- a/elm_code/lib/regen.sh +++ b/elm_code/lib/regen.sh @@ -1,4 +1,5 @@ #!/bin/sh +cd `dirname $0` INCLUDE="-I /usr/local/share/eolian/include/eo-1 -I /usr/local/share/eolian/include/elementary-1 -I /usr/local/share/eolian/include/evas-1 -I /usr/local/share/eolian/include/efl-1" From 29f683d08419e4e9c19594654cd2a86c00b1ec7e Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sat, 24 Jan 2015 22:07:00 +0000 Subject: [PATCH 07/14] Complete port of elm_code widget to eo as widget2 --- elm_code/bin/elm_code_test_main.c | 22 +- elm_code/lib/elm_code.c | 2 +- elm_code/lib/elm_code_widget2.c | 339 ++++++++++++++++++++++++++--- elm_code/lib/elm_code_widget2.eo | 21 +- elm_code/lib/elm_code_widget2.eo.c | 29 ++- elm_code/lib/elm_code_widget2.eo.h | 44 +++- 6 files changed, 392 insertions(+), 65 deletions(-) diff --git a/elm_code/bin/elm_code_test_main.c b/elm_code/bin/elm_code_test_main.c index 7180eb7..755c532 100644 --- a/elm_code/bin/elm_code_test_main.c +++ b/elm_code/bin/elm_code_test_main.c @@ -48,23 +48,15 @@ static Evas_Object * _elm_code_test_welcome_setup(Evas_Object *parent) { Elm_Code *code; - Evas_Object *widget; + Elm_Code_Widget2 *widget; code = elm_code_create(); - - Elm_Code_Widget2 *obj = eo_add(ELM_CODE_WIDGET2_CLASS, parent); - eo_do(obj, - elm_code_widget2_font_size_set(14)); - - evas_object_size_hint_weight_set(obj, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(obj, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(obj); -return obj; -// TODO - add all this good stuff into the eo api - widget = elm_code_widget_add(parent, code); - elm_code_widget_font_size_set(widget, 14); - elm_code_widget_editable_set(widget, EINA_TRUE); - eo_do(widget,eo_event_callback_add(&ELM_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code)); + widget = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + eo_do(widget, + elm_code_widget2_code_set(code); + elm_code_widget2_font_size_set(14); + elm_code_widget2_editable_set(EINA_TRUE); + eo_event_callback_add(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code)); _append_line(code->file, "Hello World, Elm Code!"); elm_code_file_line_token_add(code->file, 1, 14, 21, ELM_CODE_TOKEN_TYPE_COMMENT); diff --git a/elm_code/lib/elm_code.c b/elm_code/lib/elm_code.c index d1e3282..1f96512 100644 --- a/elm_code/lib/elm_code.c +++ b/elm_code/lib/elm_code.c @@ -105,7 +105,7 @@ EAPI void elm_code_callback_fire(Elm_Code *code, const Eo_Event_Description *signal, void *data) { Eina_List *item; - Evas_Object *widget; + Eo *widget; EINA_LIST_FOREACH(code->widgets, item, widget) { diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget2.c index b9ba337..fa16532 100644 --- a/elm_code/lib/elm_code_widget2.c +++ b/elm_code/lib/elm_code_widget2.c @@ -11,69 +11,342 @@ typedef struct { Elm_Code *code; + Evas_Object *grid; Evas_Font_Size font_size; unsigned int cursor_line, cursor_col; Eina_Bool editable; - } Elm_Code_Widget2_Data; +Eina_Unicode status_icons2[] = { + ' ', + '!', + + '+', + '-', + ' ', + + 0x2713, + 0x2717, + + 0 +}; + + EOLIAN static void -_elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd) +_elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd EINA_UNUSED) { eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, eo_constructor()); -printf("constr\n"); + + pd->cursor_line = 1; + pd->cursor_col = 1; } EOLIAN static void -_elm_code_widget2_evas_object_smart_resize(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord w, Evas_Coord h) -{ -printf("size %d, %d\n", w, h); -} - -EOLIAN static void -_elm_code_widget2_class_constructor(Eo_Class *klass) +_elm_code_widget2_class_constructor(Eo_Class *klass EINA_UNUSED) { } -EOLIAN static void -_elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig) +static Eina_Bool +_elm_code_widget_resize(Evas_Object *o) { + int w, h, cw, ch; + evas_object_geometry_get(o, NULL, NULL, &w, &h); + evas_object_textgrid_cell_size_get(o, &cw, &ch); + + evas_object_textgrid_size_set(o, ceil(((double) w) / cw), + ceil(((double) h) / ch)); + + return h > 0 && w > 0; +} + +static void +_elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start, int end, Elm_Code_Token_Type type) +{ + int x; + + for (x = start; x <= end && x < count; x++) + { + cells[x].fg = type; + } +} + +static void +_elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line) +{ + Eina_List *item; + Elm_Code_Token *token; + int start, length; + + start = 1; + length = line->length; + + EINA_LIST_FOREACH(line->tokens, item, token) + { + + _elm_code_widget_fill_line_token(cells, count, start, token->start, ELM_CODE_TOKEN_TYPE_DEFAULT); + + // TODO handle a token starting before the previous finishes + _elm_code_widget_fill_line_token(cells, count, token->start, token->end, token->type); + + start = token->end + 1; + } + + _elm_code_widget_fill_line_token(cells, count, start, length, ELM_CODE_TOKEN_TYPE_DEFAULT); +} + +static void +_elm_code_widget_fill_line(Elm_Code_Widget2_Data *pd, Evas_Textgrid_Cell *cells, Elm_Code_Line *line) +{ + char *chr; + unsigned int length, x; + int w; + + if (!_elm_code_widget_resize(pd->grid)) + return; + + length = line->length; + evas_object_textgrid_size_get(pd->grid, &w, NULL); + + cells[0].codepoint = status_icons2[line->status]; + cells[0].bold = 1; + cells[0].fg = ELM_CODE_TOKEN_TYPE_DEFAULT; + cells[0].bg = line->status; + + if (line->modified) + chr = line->modified; + else + chr = (char *)line->content; + for (x = 1; x < (unsigned int) w && x <= length; x++) + { + cells[x].codepoint = *chr; + cells[x].bg = line->status; + + chr++; + } + for (; x < (unsigned int) w; x++) + { + cells[x].codepoint = 0; + cells[x].bg = line->status; + } + + _elm_code_widget_fill_line_tokens(cells, w, line); + if (pd->editable && pd->cursor_line == line->number) + { + if (pd->cursor_col < (unsigned int) w) + cells[pd->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR; + } + + evas_object_textgrid_update_add(pd->grid, 0, line->number - 1, w, 1); +} + +static void +_elm_code_widget_fill(Elm_Code_Widget2_Data *pd) +{ + Elm_Code_Line *line; + Evas_Textgrid_Cell *cells; + int w, h; + unsigned int y; + + if (!_elm_code_widget_resize(pd->grid)) + return; + evas_object_textgrid_size_get(pd->grid, &w, &h); + + for (y = 1; y <= (unsigned int) h && y <= elm_code_file_lines_get(pd->code->file); y++) + { + line = elm_code_file_line_get(pd->code->file, y); + + cells = evas_object_textgrid_cellrow_get(pd->grid, y - 1); + _elm_code_widget_fill_line(pd, cells, line); + } +} + +static Eina_Bool +_elm_code_widget2_line_cb(void *data, Eo *obj EINA_UNUSED, + const Eo_Event_Description *desc EINA_UNUSED, void *event_info) +{ + Elm_Code_Widget2_Data *widget; + Elm_Code_Line *line; + int h; + + Evas_Textgrid_Cell *cells; + + widget = (Elm_Code_Widget2_Data *)data; + line = (Elm_Code_Line *)event_info; + + evas_object_textgrid_size_get(widget->grid, NULL, &h); + + if (line->number > (unsigned int) h) + return EINA_TRUE; + + cells = evas_object_textgrid_cellrow_get(widget->grid, line->number - 1); + _elm_code_widget_fill_line(widget, cells, line); + + return EINA_TRUE; +} + + +static Eina_Bool +_elm_code_widget2_file_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Elm_Code_Widget2_Data *widget; + + widget = (Elm_Code_Widget2_Data *)data; + + _elm_code_widget_fill(widget); + return EINA_TRUE; +} + +static void +_elm_code_widget2_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, + void *event_info EINA_UNUSED) +{ + Elm_Code_Widget2_Data *widget; + + widget = (Elm_Code_Widget2_Data *)data; + + _elm_code_widget_fill(widget); +} + +static void +_elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, + void *event_info) +{ + Elm_Code_Widget2 *widget; + Elm_Code_Widget2_Data *pd; + Elm_Code_Line *line; + Evas_Event_Mouse_Up *event; + Evas_Coord y; + int ch; + unsigned int row; + + widget = (Elm_Code_Widget2 *)data; + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + event = (Evas_Event_Mouse_Up *)event_info; + y = event->canvas.y; + + evas_object_textgrid_cell_size_get(pd->grid, NULL, &ch); + row = ((double) y / ch) + 1; + + line = elm_code_file_line_get(pd->code->file, row); + if (line) + eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, line)); +} + +EOLIAN static void +_elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, + Elm_Code_Widget2_Data *pd EINA_UNUSED, + Evas_Coord x, Evas_Coord y, + Eina_Bool sig EINA_UNUSED) +{ + printf("scroll to %d, %d\n", x, y); +} + +EOLIAN static void +_elm_code_widget2_font_size_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size) +{ + evas_object_textgrid_font_set(pd->grid, "Mono", font_size * elm_config_scale_get()); + pd->font_size = font_size; +} + +EOLIAN static Evas_Font_Size +_elm_code_widget2_font_size_get(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd) +{ + return pd->font_size; +} + +EOLIAN static void +_elm_code_widget2_code_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd, Elm_Code *code) +{ + pd->code = code; + + code->widgets = eina_list_append(code->widgets, pd); +} + +EOLIAN static Elm_Code * +_elm_code_widget2_code_get(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd) +{ + return pd->code; +} + +EOLIAN static void +_elm_code_widget2_editable_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd, Eina_Bool editable) +{ + pd->editable = editable; +} + +EOLIAN static Eina_Bool +_elm_code_widget2_editable_get(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd) +{ + return pd->editable; +} + +static void +_elm_code_widget2_setup_palette(Evas_Object *o) +{ + // setup status colors + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT, + 36, 36, 36, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ERROR, + 205, 54, 54, 255); + + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ADDED, + 36, 96, 36, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_REMOVED, + 96, 36, 36, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_CHANGED, + 36, 36, 96, 255); + + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_PASSED, + 54, 96, 54, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_FAILED, + 96, 54, 54, 255); + + // setup token colors + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_DEFAULT, + 205, 205, 205, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_COMMENT, + 54, 205, 255, 255); + + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_ADDED, + 54, 255, 54, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_REMOVED, + 255, 54, 54, 255); + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED, + 54, 54, 255, 255); + + // the style for a cursor - this is a special token and will be applied to the background + evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CURSOR, + 205, 205, 54, 255); } EOLIAN static void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) { - Evas_Object *text; + Evas_Object *grid; -printf("add\n"); eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add()); - elm_widget_sub_object_parent_add(obj); // elm_widget_can_focus_set(obj, EINA_TRUE); - text = elm_label_add(obj); - elm_object_text_set(text, "HELLO"); - evas_object_size_hint_weight_set(text, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(text, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(text); - elm_box_pack_end(obj, text); + grid = evas_object_textgrid_add(obj); + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(grid); + elm_box_pack_end(obj, grid); + pd->grid = grid; + _elm_code_widget2_setup_palette(grid); - eo_do(obj, elm_obj_widget_theme_apply()); -} + evas_object_event_callback_add(grid, EVAS_CALLBACK_RESIZE, _elm_code_widget2_resize_cb, pd); + evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget2_clicked_cb, obj); -EOLIAN static void -_elm_code_widget2_font_size_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size) -{ - printf("set\n"); - pd->font_size = font_size; -} + eo_do(obj, + eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget2_line_cb, pd); + eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget2_file_cb, pd)); -EOLIAN static Evas_Font_Size -_elm_code_widget2_font_size_get(Eo *obj, Elm_Code_Widget2_Data *pd) -{ - return pd->font_size; + _elm_code_widget2_font_size_set(obj, pd, 10); } #include "elm_code_widget2.eo.c" diff --git a/elm_code/lib/elm_code_widget2.eo b/elm_code/lib/elm_code_widget2.eo index 63bc5d2..d71f78f 100644 --- a/elm_code/lib/elm_code_widget2.eo +++ b/elm_code/lib/elm_code_widget2.eo @@ -3,6 +3,15 @@ class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable, { eo_prefix: elm_code_widget2; properties { + code { + set { + } + get { + } + values { + Elm_Code *code; + } + } font_size { set { } @@ -12,6 +21,15 @@ class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable, Evas_Font_Size font_size; } } + editable { + set { + } + get { + } + values { + Eina_Bool editable; + } + } } methods { } @@ -22,8 +40,7 @@ class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable, Elm_Interface_Scrollable.content_pos_set; } events { - focused; - unfocused; + line,clicked; } } diff --git a/elm_code/lib/elm_code_widget2.eo.c b/elm_code/lib/elm_code_widget2.eo.c index b689d76..bf34af5 100644 --- a/elm_code/lib/elm_code_widget2.eo.c +++ b/elm_code/lib/elm_code_widget2.eo.c @@ -1,7 +1,13 @@ -EOAPI const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_FOCUSED = - EO_EVENT_DESCRIPTION("focused", ""); -EOAPI const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_UNFOCUSED = - EO_EVENT_DESCRIPTION("unfocused", ""); +EOAPI const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_LINE_CLICKED = + EO_EVENT_DESCRIPTION("line,clicked", ""); + +void _elm_code_widget2_code_set(Eo *obj, Elm_Code_Widget2_Data *pd, Elm_Code *code); + +EOAPI EO_VOID_FUNC_BODYV(elm_code_widget2_code_set, EO_FUNC_CALL(code), Elm_Code *code); + +Elm_Code * _elm_code_widget2_code_get(Eo *obj, Elm_Code_Widget2_Data *pd); + +EOAPI EO_FUNC_BODY(elm_code_widget2_code_get, Elm_Code *, 0); void _elm_code_widget2_font_size_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size); @@ -11,6 +17,14 @@ Evas_Font_Size _elm_code_widget2_font_size_get(Eo *obj, Elm_Code_Widget2_Data *p EOAPI EO_FUNC_BODY(elm_code_widget2_font_size_get, Evas_Font_Size, 0); +void _elm_code_widget2_editable_set(Eo *obj, Elm_Code_Widget2_Data *pd, Eina_Bool editable); + +EOAPI EO_VOID_FUNC_BODYV(elm_code_widget2_editable_set, EO_FUNC_CALL(editable), Eina_Bool editable); + +Eina_Bool _elm_code_widget2_editable_get(Eo *obj, Elm_Code_Widget2_Data *pd); + +EOAPI EO_FUNC_BODY(elm_code_widget2_editable_get, Eina_Bool, 0); + void _elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd); @@ -24,14 +38,17 @@ static Eo_Op_Description _elm_code_widget2_op_desc[] = { EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor), EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add), EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set), + EO_OP_FUNC(elm_code_widget2_code_set, _elm_code_widget2_code_set, ""), + EO_OP_FUNC(elm_code_widget2_code_get, _elm_code_widget2_code_get, ""), EO_OP_FUNC(elm_code_widget2_font_size_set, _elm_code_widget2_font_size_set, ""), EO_OP_FUNC(elm_code_widget2_font_size_get, _elm_code_widget2_font_size_get, ""), + EO_OP_FUNC(elm_code_widget2_editable_set, _elm_code_widget2_editable_set, ""), + EO_OP_FUNC(elm_code_widget2_editable_get, _elm_code_widget2_editable_get, ""), EO_OP_SENTINEL }; static const Eo_Event_Description *_elm_code_widget2_event_desc[] = { - ELM_CODE_WIDGET2_EVENT_FOCUSED, - ELM_CODE_WIDGET2_EVENT_UNFOCUSED, + ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, NULL }; diff --git a/elm_code/lib/elm_code_widget2.eo.h b/elm_code/lib/elm_code_widget2.eo.h index 75d1b4d..cbad231 100644 --- a/elm_code/lib/elm_code_widget2.eo.h +++ b/elm_code/lib/elm_code_widget2.eo.h @@ -17,6 +17,23 @@ typedef Eo Elm_Code_Widget2; const Eo_Class *elm_code_widget2_class_get(void) EINA_CONST; +/** + * + * No description supplied. + * + * @param[in] code No description supplied. + * + */ +EOAPI void elm_code_widget2_code_set(Elm_Code *code); + +/** + * + * No description supplied. + * + * + */ +EOAPI Elm_Code * elm_code_widget2_code_get(void); + /** * * No description supplied. @@ -34,17 +51,28 @@ EOAPI void elm_code_widget2_font_size_set(Evas_Font_Size font_size); */ EOAPI Evas_Font_Size elm_code_widget2_font_size_get(void); -EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_FOCUSED; -EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_UNFOCUSED; +/** + * + * No description supplied. + * + * @param[in] editable No description supplied. + * + */ +EOAPI void elm_code_widget2_editable_set(Eina_Bool editable); + +/** + * + * No description supplied. + * + * + */ +EOAPI Eina_Bool elm_code_widget2_editable_get(void); + +EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_LINE_CLICKED; /** * No description */ -#define ELM_CODE_WIDGET2_EVENT_FOCUSED (&(_ELM_CODE_WIDGET2_EVENT_FOCUSED)) - -/** - * No description - */ -#define ELM_CODE_WIDGET2_EVENT_UNFOCUSED (&(_ELM_CODE_WIDGET2_EVENT_UNFOCUSED)) +#define ELM_CODE_WIDGET2_EVENT_LINE_CLICKED (&(_ELM_CODE_WIDGET2_EVENT_LINE_CLICKED)) #endif From d017c06339ac9caa3518fd7dacefdee2f2197ec9 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sun, 25 Jan 2015 17:18:21 +0000 Subject: [PATCH 08/14] elm_code: Add focus support for the elm_code widget. Hook into the internal elementary API to be part of the focus chain --- elm_code/bin/elm_code_test_main.c | 9 ++------- elm_code/lib/elm_code_widget2.c | 26 +++++++++++++++++++++++--- elm_code/lib/elm_code_widget2.eo | 1 + elm_code/lib/elm_code_widget2.eo.c | 4 ++++ 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/elm_code/bin/elm_code_test_main.c b/elm_code/bin/elm_code_test_main.c index 755c532..d83c116 100644 --- a/elm_code/bin/elm_code_test_main.c +++ b/elm_code/bin/elm_code_test_main.c @@ -92,8 +92,7 @@ _elm_code_test_diff_setup(Evas_Object *parent) static Evas_Object * elm_code_test_win_setup(void) { - Evas_Object *win; - Evas_Object *vbox; + Evas_Object *win,*vbox; win = elm_win_util_standard_add("main", "Elm_Code Test"); if (!win) return NULL; @@ -104,15 +103,11 @@ elm_code_test_win_setup(void) elm_box_homogeneous_set(vbox, EINA_TRUE); evas_object_show(vbox); - elm_win_focus_highlight_enabled_set(win, EINA_TRUE); - evas_object_smart_callback_add(win, "delete,request", _elm_code_test_win_del, NULL); - elm_box_pack_end(vbox, _elm_code_test_welcome_setup(vbox)); - elm_box_pack_end(vbox, _elm_code_test_diff_setup(vbox)); - elm_win_resize_object_add(win, vbox); + evas_object_smart_callback_add(win, "delete,request", _elm_code_test_win_del, NULL); evas_object_resize(win, 380 * elm_config_scale_get(), 240 * elm_config_scale_get()); evas_object_show(win); diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget2.c index fa16532..0856012 100644 --- a/elm_code/lib/elm_code_widget2.c +++ b/elm_code/lib/elm_code_widget2.c @@ -5,6 +5,9 @@ #include #include #include +#define ELM_INTERNAL_API_ARGESFSDFEFC +#include + #include #include "elm_code_widget2.eo.h" @@ -15,7 +18,7 @@ typedef struct Evas_Font_Size font_size; unsigned int cursor_line, cursor_col; - Eina_Bool editable; + Eina_Bool editable, focussed; } Elm_Code_Widget2_Data; Eina_Unicode status_icons2[] = { @@ -133,7 +136,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget2_Data *pd, Evas_Textgrid_Cell *cells, } _elm_code_widget_fill_line_tokens(cells, w, line); - if (pd->editable && pd->cursor_line == line->number) + if (pd->editable && pd->focussed && pd->cursor_line == line->number) { if (pd->cursor_col < (unsigned int) w) cells[pd->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR; @@ -225,6 +228,10 @@ _elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E widget = (Elm_Code_Widget2 *)data; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + + if (pd->editable && !pd->focussed) + return; + event = (Evas_Event_Mouse_Up *)event_info; y = event->canvas.y; @@ -236,6 +243,19 @@ _elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, line)); } +EOLIAN static Eina_Bool +_elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd) +{ + Eina_Bool int_ret = EINA_FALSE; + eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, int_ret = elm_obj_widget_on_focus()); + if (!int_ret) return EINA_TRUE; + + pd->focussed = elm_widget_focus_get(obj); + + _elm_code_widget_fill(pd); + return EINA_TRUE; +} + EOLIAN static void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd EINA_UNUSED, @@ -329,7 +349,7 @@ _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) Evas_Object *grid; eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add()); -// elm_widget_can_focus_set(obj, EINA_TRUE); + elm_widget_can_focus_set(obj, EINA_TRUE); grid = evas_object_textgrid_add(obj); evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); diff --git a/elm_code/lib/elm_code_widget2.eo b/elm_code/lib/elm_code_widget2.eo index d71f78f..39f6f4d 100644 --- a/elm_code/lib/elm_code_widget2.eo +++ b/elm_code/lib/elm_code_widget2.eo @@ -37,6 +37,7 @@ class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable, class.constructor; Eo.Base.constructor; Evas.Object_Smart.add; + Elm_Widget.on_focus; Elm_Interface_Scrollable.content_pos_set; } events { diff --git a/elm_code/lib/elm_code_widget2.eo.c b/elm_code/lib/elm_code_widget2.eo.c index bf34af5..0aa2208 100644 --- a/elm_code/lib/elm_code_widget2.eo.c +++ b/elm_code/lib/elm_code_widget2.eo.c @@ -31,12 +31,16 @@ void _elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd); void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd); +Eina_Bool _elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd); + + void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig); static Eo_Op_Description _elm_code_widget2_op_desc[] = { EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor), EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add), + EO_OP_FUNC_OVERRIDE(elm_obj_widget_on_focus, _elm_code_widget2_elm_widget_on_focus), EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set), EO_OP_FUNC(elm_code_widget2_code_set, _elm_code_widget2_code_set, ""), EO_OP_FUNC(elm_code_widget2_code_get, _elm_code_widget2_code_get, ""), From f236f78cd42c0c2ee5eaf6c8145e12755dcee166 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Sun, 25 Jan 2015 23:15:37 +0000 Subject: [PATCH 09/14] Manipulate the position of the cursor. When clicking in edit mode just change the position of it to where was clicked. Known issue that this does not work with the keyboard --- elm_code/lib/elm_code_widget2.c | 112 ++++++++++++++++++++++++++++---- 1 file changed, 99 insertions(+), 13 deletions(-) diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget2.c index 0856012..834201c 100644 --- a/elm_code/lib/elm_code_widget2.c +++ b/elm_code/lib/elm_code_widget2.c @@ -215,26 +215,45 @@ _elm_code_widget2_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EI } static void -_elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, - void *event_info) +_elm_code_widget2_clicked_editable_cb(Elm_Code_Widget2 *widget, Evas_Coord x, Evas_Coord y) +{ + Elm_Code_Widget2_Data *pd; + Elm_Code_Line *line; + int cw, ch; + unsigned int row, col; + + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + + evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch); + col = ((double) x / cw) + 2; + row = ((double) y / ch) + 1; + + line = elm_code_file_line_get(pd->code->file, row); + if (line) + { + pd->cursor_line = row; + + if (col <= (unsigned int) line->length + 2) + pd->cursor_col = col - 2; + else + pd->cursor_col = line->length + 1; + } + if (pd->cursor_col == 0) + pd->cursor_col = 1; + + _elm_code_widget_fill(pd); +} + +static void +_elm_code_widget2_clicked_readonly_cb(Elm_Code_Widget2 *widget, Evas_Coord y) { - Elm_Code_Widget2 *widget; Elm_Code_Widget2_Data *pd; Elm_Code_Line *line; - Evas_Event_Mouse_Up *event; - Evas_Coord y; int ch; unsigned int row; - widget = (Elm_Code_Widget2 *)data; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); - if (pd->editable && !pd->focussed) - return; - - event = (Evas_Event_Mouse_Up *)event_info; - y = event->canvas.y; - evas_object_textgrid_cell_size_get(pd->grid, NULL, &ch); row = ((double) y / ch) + 1; @@ -243,6 +262,71 @@ _elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, line)); } +static void +_elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, + void *event_info) +{ + Elm_Code_Widget2 *widget; + Elm_Code_Widget2_Data *pd; + Evas_Event_Mouse_Up *event; + Evas_Coord x, y; + + widget = (Elm_Code_Widget2 *)data; + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + event = (Evas_Event_Mouse_Up *)event_info; + + x = event->canvas.x; + y = event->canvas.y; + + if (pd->editable) + _elm_code_widget2_clicked_editable_cb(widget, x, y); + else + _elm_code_widget2_clicked_readonly_cb(widget, y); +} + +static void +_elm_code_widget2_cursor_move_up(Elm_Code_Widget2 *widget) +{ + Elm_Code_Widget2_Data *pd; + + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + + if (pd->cursor_line > 1) + pd->cursor_line--; + + _elm_code_widget_fill(pd); +} + +static void +_elm_code_widget2_cursor_move_down(Elm_Code_Widget2 *widget) +{ + Elm_Code_Widget2_Data *pd; + + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + + if (pd->cursor_line < elm_code_file_lines_get(pd->code->file)) + pd->cursor_line++; + + _elm_code_widget_fill(pd); +} + +static void +_elm_code_widget2_key_down_cb(void *data, Evas *evas EINA_UNUSED, + Evas_Object *obj EINA_UNUSED, void *event_info) +{ + Elm_Code_Widget2 *widget; + + widget = (Elm_Code_Widget2 *)data; + + Evas_Event_Key_Down *ev = event_info; + + printf("KEY %s\n", ev->key); + if (!(strcmp(ev->key, "Up"))) + _elm_code_widget2_cursor_move_up(widget); + if (!(strcmp(ev->key, "Down"))) + _elm_code_widget2_cursor_move_down(widget); +} + EOLIAN static Eina_Bool _elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd) { @@ -349,7 +433,7 @@ _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) Evas_Object *grid; eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add()); - elm_widget_can_focus_set(obj, EINA_TRUE); + elm_object_focus_allow_set(obj, EINA_TRUE); grid = evas_object_textgrid_add(obj); evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -361,6 +445,8 @@ _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) evas_object_event_callback_add(grid, EVAS_CALLBACK_RESIZE, _elm_code_widget2_resize_cb, pd); evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget2_clicked_cb, obj); +// FIXME find why obj is not getting key_down events + evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _elm_code_widget2_key_down_cb, obj); eo_do(obj, eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget2_line_cb, pd); From 159c47d340b0e418b50ca22b4dda99e4412af50a Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 26 Jan 2015 14:00:37 +0000 Subject: [PATCH 10/14] Port everything to use new widget API. Remove old widget API --- elm_code/lib/Elm_Code.h | 2 +- elm_code/lib/Makefile.am | 3 +- elm_code/lib/elm_code_diff_widget.c | 21 +- elm_code/lib/elm_code_widget.c | 289 -------------------------- elm_code/lib/elm_code_widget.h | 100 --------- elm_code/tests/Makefile.am | 2 + elm_code/tests/elm_code_test_widget.c | 2 +- src/bin/edi_consolepanel.c | 8 +- src/bin/edi_logpanel.c | 8 +- src/tests/edi_test_content_provider.c | 2 +- 10 files changed, 29 insertions(+), 408 deletions(-) delete mode 100644 elm_code/lib/elm_code_widget.c delete mode 100644 elm_code/lib/elm_code_widget.h diff --git a/elm_code/lib/Elm_Code.h b/elm_code/lib/Elm_Code.h index 35071a2..8a30dfe 100644 --- a/elm_code/lib/Elm_Code.h +++ b/elm_code/lib/Elm_Code.h @@ -34,7 +34,7 @@ #include "elm_code_common.h" #include "elm_code_file.h" #include "elm_code_parse.h" -#include "elm_code_widget.h" +#include "elm_code_widget2.eo.h" #include "elm_code_diff_widget.h" #ifdef __cplusplus diff --git a/elm_code/lib/Makefile.am b/elm_code/lib/Makefile.am index 193b9e4..bf84811 100644 --- a/elm_code/lib/Makefile.am +++ b/elm_code/lib/Makefile.am @@ -12,7 +12,7 @@ lib_LTLIBRARIES = libelm_code.la includes_HEADERS = \ elm_code_file.h \ elm_code_parse.h \ -elm_code_widget.h \ +elm_code_widget2.eo.h \ elm_code_diff_widget.h \ Elm_Code.h includesdir = $(includedir)/edi-@VMAJ@ @@ -20,7 +20,6 @@ includesdir = $(includedir)/edi-@VMAJ@ libelm_code_la_SOURCES = \ elm_code_file.c \ elm_code_parse.c \ -elm_code_widget.c \ elm_code_widget2.c \ elm_code_diff_widget.c \ elm_code.c \ diff --git a/elm_code/lib/elm_code_diff_widget.c b/elm_code/lib/elm_code_diff_widget.c index f008159..3db4fbb 100644 --- a/elm_code/lib/elm_code_diff_widget.c +++ b/elm_code/lib/elm_code_diff_widget.c @@ -80,7 +80,8 @@ static void _elm_code_diff_widget_parse_diff(Elm_Code_File *diff, Elm_Code_File EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) { Elm_Code *wcode1, *wcode2; - Evas_Object *widget_left, *widget_right, *hbox; + Elm_Code_Widget2 *widget_left, *widget_right; + Evas_Object *hbox; hbox = elm_panes_add(parent); evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); @@ -90,7 +91,9 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) // left side of diff wcode1 = elm_code_create(); - widget_left = elm_code_widget_add(parent, wcode1); + widget_left = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + eo_do(widget_left, + elm_code_widget2_code_set(wcode1)); evas_object_size_hint_weight_set(widget_left, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(widget_left, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -100,7 +103,9 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) // right side of diff wcode2 = elm_code_create(); - widget_right = elm_code_widget_add(parent, wcode2); + widget_right = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + eo_do(widget_right, + elm_code_widget2_code_set(wcode2)); evas_object_size_hint_weight_set(widget_right, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(widget_right, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -114,11 +119,11 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) EAPI void elm_code_diff_widget_font_size_set(Evas_Object *widget, int size) { - Evas_Object *child; + Elm_Code_Widget2 *child; - child = evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_LEFT); - elm_code_widget_font_size_set(child, size); - child = evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_RIGHT); - elm_code_widget_font_size_set(child, size); + child = (Elm_Code_Widget2 *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_LEFT); + eo_do(child, elm_code_widget2_font_size_set(size)); + child = (Elm_Code_Widget2 *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_RIGHT); + eo_do(child, elm_code_widget2_font_size_set(size)); } diff --git a/elm_code/lib/elm_code_widget.c b/elm_code/lib/elm_code_widget.c deleted file mode 100644 index d91412a..0000000 --- a/elm_code/lib/elm_code_widget.c +++ /dev/null @@ -1,289 +0,0 @@ -#ifdef HAVE_CONFIG -# include "config.h" -#endif - -#include "Elm_Code.h" - -#include "elm_code_private.h" - -EAPI const Eo_Event_Description ELM_CODE_WIDGET_EVENT_LINE_CLICKED = - EO_EVENT_DESCRIPTION("line,clicked", ""); - -Eina_Unicode status_icons[] = { - ' ', - '!', - - '+', - '-', - ' ', - - 0x2713, - 0x2717, - - 0 -}; - -static Eina_Bool -_elm_code_widget_resize(Evas_Object *o) -{ - int w, h, cw, ch; - - evas_object_geometry_get(o, NULL, NULL, &w, &h); - evas_object_textgrid_cell_size_get(o, &cw, &ch); - evas_object_textgrid_size_set(o, ceil(((double) w) / cw), - ceil(((double) h) / ch)); - - return h > 0 && w > 0; -} - -static void -_elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start, int end, Elm_Code_Token_Type type) -{ - int x; - - for (x = start; x <= end && x < count; x++) - { - cells[x].fg = type; - } -} - -static void -_elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line) -{ - Eina_List *item; - Elm_Code_Token *token; - int start, length; - - start = 1; - length = line->length; - - EINA_LIST_FOREACH(line->tokens, item, token) - { - - _elm_code_widget_fill_line_token(cells, count, start, token->start, ELM_CODE_TOKEN_TYPE_DEFAULT); - - // TODO handle a token starting before the previous finishes - _elm_code_widget_fill_line_token(cells, count, token->start, token->end, token->type); - - start = token->end + 1; - } - - _elm_code_widget_fill_line_token(cells, count, start, length, ELM_CODE_TOKEN_TYPE_DEFAULT); -} - -static void -_elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells, Elm_Code_Line *line) -{ - char *chr; - unsigned int length, x; - int w; - ELM_CODE_WIDGET_DATA_GET(o, widget); - - if (!_elm_code_widget_resize(o)) - return; - - length = line->length; - evas_object_textgrid_size_get(o, &w, NULL); - - cells[0].codepoint = status_icons[line->status]; - cells[0].bold = 1; - cells[0].fg = ELM_CODE_TOKEN_TYPE_DEFAULT; - cells[0].bg = line->status; - - if (line->modified) - chr = line->modified; - else - chr = (char *)line->content; - for (x = 1; x < (unsigned int) w && x <= length; x++) - { - cells[x].codepoint = *chr; - cells[x].bg = line->status; - - chr++; - } - for (; x < (unsigned int) w; x++) - { - cells[x].codepoint = 0; - cells[x].bg = line->status; - } - - _elm_code_widget_fill_line_tokens(cells, w, line); - if (widget->editable && widget->cursor_line == line->number) - { - if (widget->cursor_col < (unsigned int) w) - cells[widget->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR; - } - - evas_object_textgrid_update_add(o, 0, line->number - 1, w, 1); -} - -static void -_elm_code_widget_fill(Evas_Object *o, Elm_Code *code) -{ - Elm_Code_Line *line; - Evas_Textgrid_Cell *cells; - int w, h; - unsigned int y; - - if (!_elm_code_widget_resize(o)) - return; - evas_object_textgrid_size_get(o, &w, &h); - - for (y = 1; y <= (unsigned int) h && y <= elm_code_file_lines_get(code->file); y++) - { - line = elm_code_file_line_get(code->file, y); - - cells = evas_object_textgrid_cellrow_get(o, y - 1); - _elm_code_widget_fill_line(o, cells, line); - } -} - -static Eina_Bool -_elm_code_widget_line_cb(void *data EINA_UNUSED, Eo *obj, - const Eo_Event_Description *desc EINA_UNUSED, void *event_info) -{ - Elm_Code_Line *line; - Evas_Object *o; - int h; - - Evas_Textgrid_Cell *cells; - - line = (Elm_Code_Line *)event_info; - o = (Evas_Object *)obj; - - evas_object_textgrid_size_get(o, NULL, &h); - - if (line->number > (unsigned int) h) - return EINA_TRUE; - - cells = evas_object_textgrid_cellrow_get(o, line->number - 1); - _elm_code_widget_fill_line(o, cells, line); - - return EINA_TRUE; -} - - -static Eina_Bool -_elm_code_widget_file_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED, - void *event_info EINA_UNUSED) -{ - Evas_Object *o; - Elm_Code *code; - - code = (Elm_Code *)data; - o = (Evas_Object *)obj; - - _elm_code_widget_fill(o, code); - return EINA_TRUE; -} - -static void -_elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, - void *event_info EINA_UNUSED) -{ - Elm_Code *code; - - code = (Elm_Code *)data; - - _elm_code_widget_fill(obj, code); -} - -static void -_elm_code_widget_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, - void *event_info) -{ - Elm_Code *code; - Elm_Code_Line *line; - Evas_Event_Mouse_Up *event; - Evas_Coord y; - int ch; - unsigned int row; - - code = (Elm_Code *)data; - event = (Evas_Event_Mouse_Up *)event_info; - y = event->canvas.y; - - evas_object_textgrid_cell_size_get(obj, NULL, &ch); - row = ((double) y / ch) + 1; - - line = elm_code_file_line_get(code->file, row); - if (line) - elm_code_callback_fire(code, &ELM_CODE_WIDGET_EVENT_LINE_CLICKED, line); -} - -EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code) -{ - Evas_Object *o; - Elm_Code_Widget *widget; - - o = evas_object_textgrid_add(parent); - - // setup status colors - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT, - 36, 36, 36, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ERROR, - 205, 54, 54, 255); - - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ADDED, - 36, 96, 36, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_REMOVED, - 96, 36, 36, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_CHANGED, - 36, 36, 96, 255); - - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_PASSED, - 54, 96, 54, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_FAILED, - 96, 54, 54, 255); - - // setup token colors - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_DEFAULT, - 205, 205, 205, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_COMMENT, - 54, 205, 255, 255); - - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_ADDED, - 54, 255, 54, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_REMOVED, - 255, 54, 54, 255); - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED, - 54, 54, 255, 255); - - // the style for a cursor - this is a special token and will be applied to the background - evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CURSOR, - 205, 205, 54, 255); - evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, code); - evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget_clicked_cb, code); - - eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, code)); - eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, code)); - - widget = calloc(1, sizeof(*widget)); - widget->code = code; - widget->cursor_line = 1; - widget->cursor_col = 1; - evas_object_data_set(o, ELM_CODE_WIDGET_DATA_KEY, widget); - code->widgets = eina_list_append(code->widgets, o); - - elm_code_widget_font_size_set(o, 10); - return o; -} - -EAPI void -elm_code_widget_font_size_set(Evas_Object *obj, Evas_Font_Size size) -{ - ELM_CODE_WIDGET_DATA_GET(obj, widget); - - widget->font_size = size; - evas_object_textgrid_font_set(obj, "Mono", size * elm_config_scale_get()); -} - -EAPI void -elm_code_widget_editable_set(Evas_Object *obj, Eina_Bool editable) -{ - ELM_CODE_WIDGET_DATA_GET(obj, widget); - - widget->editable = editable; -} - - diff --git a/elm_code/lib/elm_code_widget.h b/elm_code/lib/elm_code_widget.h deleted file mode 100644 index 1a17203..0000000 --- a/elm_code/lib/elm_code_widget.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef ELM_CODE_WIDGET_H_ -# define ELM_CODE_WIDGET_H_ - -EAPI extern const Eo_Event_Description ELM_CODE_WIDGET_EVENT_LINE_CLICKED; - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @file - * @brief These routines are used for rendering instances of Elm Code. - */ - -typedef struct _Elm_Code_Widget -{ - Elm_Code *code; - - Evas_Font_Size font_size; - unsigned int cursor_line, cursor_col; - Eina_Bool editable; - -} Elm_Code_Widget; - -#define ELM_CODE_WIDGET_DATA_KEY "Elm_Code_Widget" -#define ELM_CODE_WIDGET_DATA_GET(o, ptr, ...) \ - Elm_Code_Widget *ptr; \ - ptr = evas_object_data_get(o, ELM_CODE_WIDGET_DATA_KEY); - -#define ELM_CODE_WIDGET_DATA_GET_OR_RETURN(o, ptr, ...) \ - Elm_Code_Widget *ptr; \ - ptr = evas_object_data_get(o, ELM_CODE_WIDGET_DATA_KEY);\ - if (EINA_UNLIKELY(!ptr)) \ - { \ - CRI("no widget data for object %p (%s)", \ - o, evas_object_type_get(o)); \ - return __VA_ARGS__; \ - } - -/** - * @brief UI Loading functions. - * @defgroup Init Creating a widget to render an Elm Code backend - * - * @{ - * - * Functions for UI loading. - * - */ - -EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code); - -/** - * @} - * - * @brief UI Manipulation functions. - * @defgroup UI Manage aspects of an Elm_Code widget - * - * @{ - * - * Functions for UI manipulation. - * - */ - -/** - * Set the font size of a widget - * - * Change the size of the monospaced font used by this widget instance. - * 10 pt is the default font size for an elm_code widget. - * - * @param widget The widget to change - * @param size The font size to set on this widget - * - * @ingroup UI - */ -EAPI void elm_code_widget_font_size_set(Evas_Object *widget, Evas_Font_Size size); - -/** - * Set this widget to be editable - * - * An editable widget displays a cursor and accepts user input. - * It will also accept focus. - * If EINA_FALSE is passed this widget will return to being read-only. - * EINA_FALSE is the default value for editable. - * - * @param widget The widget to change - * @param editable Whether or not this widget should be editable - * - * @ingroup UI - */ -EAPI void elm_code_widget_editable_set(Evas_Object *widget, Eina_Bool editable); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* ELM_CODE_WIDGET_H_ */ diff --git a/elm_code/tests/Makefile.am b/elm_code/tests/Makefile.am index 2f63f38..712c389 100644 --- a/elm_code/tests/Makefile.am +++ b/elm_code/tests/Makefile.am @@ -12,6 +12,8 @@ elm_code_test_widget.c \ elm_code_suite.c elm_code_suite_CPPFLAGS = -I$(top_builddir)/elm_code/lib/ \ +-DEFL_BETA_API_SUPPORT \ +-DEFL_EO_API_SUPPORT \ -DPACKAGE_TESTS_DIR=\"$(top_srcdir)/elm_code/tests/\" \ -DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)/elm_code/tests/\" \ -DEFL_BETA_API_SUPPORT \ diff --git a/elm_code/tests/elm_code_test_widget.c b/elm_code/tests/elm_code_test_widget.c index 6efdce8..3b598a9 100644 --- a/elm_code/tests/elm_code_test_widget.c +++ b/elm_code/tests/elm_code_test_widget.c @@ -4,7 +4,7 @@ #include "elm_code_suite.h" -#include "elm_code_widget.c" +#include "elm_code_widget2.c" static void _assert_cell_type(Evas_Textgrid_Cell cell, Elm_Code_Token_Type type, int id) { diff --git a/src/bin/edi_consolepanel.c b/src/bin/edi_consolepanel.c index 0a300eb..a92fffc 100644 --- a/src/bin/edi_consolepanel.c +++ b/src/bin/edi_consolepanel.c @@ -336,13 +336,15 @@ EAPI void edi_consolepanel_add(Evas_Object *parent) EAPI void edi_testpanel_add(Evas_Object *parent) { Elm_Code *code; - Evas_Object *widget; + Elm_Code_Widget2 *widget; code = elm_code_create(); _edi_test_code = code; - widget = elm_code_widget_add(parent, code); - elm_code_widget_font_size_set(widget, _edi_cfg->font.size); + widget = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + eo_do(widget, + elm_code_widget2_code_set(code); + elm_code_widget2_font_size_set(_edi_cfg->font.size)); 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); diff --git a/src/bin/edi_logpanel.c b/src/bin/edi_logpanel.c index ebb0c02..2e32a61 100644 --- a/src/bin/edi_logpanel.c +++ b/src/bin/edi_logpanel.c @@ -40,12 +40,14 @@ static void _print_cb(const Eina_Log_Domain *domain, EAPI void edi_logpanel_add(Evas_Object *parent) { - Evas_Object *widget; + Elm_Code_Widget2 *widget; Elm_Code *code; code = elm_code_create(); - widget = elm_code_widget_add(parent, code); - elm_code_widget_font_size_set(widget, _edi_cfg->font.size); + widget = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + eo_do(widget, + elm_code_widget2_code_set(code); + elm_code_widget2_font_size_set(_edi_cfg->font.size)); 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_show(widget); diff --git a/src/tests/edi_test_content_provider.c b/src/tests/edi_test_content_provider.c index 8e8a570..3f0a82b 100644 --- a/src/tests/edi_test_content_provider.c +++ b/src/tests/edi_test_content_provider.c @@ -7,7 +7,7 @@ #include "edi_suite.h" // Add some no-op methods here so linking works without having to import the whole UI! -EAPI Evas_Object *edi_editor_add(Evas_Object *parent EINA_UNUSED, Edi_Mainview_Item *item EINA_UNUSED) +EAPI Evas_Object *_edi_editor_add(Evas_Object *parent EINA_UNUSED, Edi_Mainview_Item *item EINA_UNUSED) { return NULL; } From a90e8cf78926375217366ffc9463ebbac39fbb07 Mon Sep 17 00:00:00 2001 From: Stephen Houston Date: Mon, 26 Jan 2015 10:28:04 -0600 Subject: [PATCH 11/14] Elm_Code: For box to get key down, it needs to have a child receiving key down. --- elm_code/lib/elm_code_widget2.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget2.c index 834201c..3a70015 100644 --- a/elm_code/lib/elm_code_widget2.c +++ b/elm_code/lib/elm_code_widget2.c @@ -430,16 +430,22 @@ _elm_code_widget2_setup_palette(Evas_Object *o) EOLIAN static void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) { - Evas_Object *grid; + Evas_Object *grid, *scroller; eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add()); elm_object_focus_allow_set(obj, EINA_TRUE); - grid = evas_object_textgrid_add(obj); + scroller = elm_scroller_add(obj); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(scroller); + elm_box_pack_end(obj, scroller); + + grid = evas_object_textgrid_add(obj); evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL); evas_object_show(grid); - elm_box_pack_end(obj, grid); + elm_object_content_set(scroller, grid); pd->grid = grid; _elm_code_widget2_setup_palette(grid); From 50c5cb572b6bb2b43bde69108255a164ed2b671d Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 26 Jan 2015 19:05:34 +0000 Subject: [PATCH 12/14] Refactor eo widget2 to widget - update in edi too --- elm_code/bin/elm_code_test_main.c | 14 +- elm_code/lib/Elm_Code.h | 2 +- elm_code/lib/Makefile.am | 4 +- elm_code/lib/elm_code_diff_widget.c | 20 +-- .../{elm_code_widget2.c => elm_code_widget.c} | 130 +++++++++--------- ...elm_code_widget2.eo => elm_code_widget.eo} | 6 +- elm_code/lib/elm_code_widget.eo.c | 70 ++++++++++ elm_code/lib/elm_code_widget.eo.h | 78 +++++++++++ elm_code/lib/elm_code_widget2.eo.c | 70 ---------- elm_code/lib/elm_code_widget2.eo.h | 78 ----------- elm_code/lib/regen.sh | 6 +- elm_code/tests/elm_code_test_widget.c | 2 +- src/bin/edi_consolepanel.c | 8 +- src/bin/edi_logpanel.c | 8 +- 14 files changed, 248 insertions(+), 248 deletions(-) rename elm_code/lib/{elm_code_widget2.c => elm_code_widget.c} (72%) rename elm_code/lib/{elm_code_widget2.eo => elm_code_widget.eo} (82%) create mode 100644 elm_code/lib/elm_code_widget.eo.c create mode 100644 elm_code/lib/elm_code_widget.eo.h delete mode 100644 elm_code/lib/elm_code_widget2.eo.c delete mode 100644 elm_code/lib/elm_code_widget2.eo.h diff --git a/elm_code/bin/elm_code_test_main.c b/elm_code/bin/elm_code_test_main.c index d83c116..2897c3c 100644 --- a/elm_code/bin/elm_code_test_main.c +++ b/elm_code/bin/elm_code_test_main.c @@ -12,7 +12,7 @@ #include "gettext.h" #include -#include "elm_code_widget2.eo.h" +#include "elm_code_widget.eo.h" #include "elm_code_test_private.h" @@ -48,15 +48,15 @@ static Evas_Object * _elm_code_test_welcome_setup(Evas_Object *parent) { Elm_Code *code; - Elm_Code_Widget2 *widget; + Elm_Code_Widget *widget; code = elm_code_create(); - widget = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + widget = eo_add(ELM_CODE_WIDGET_CLASS, parent); eo_do(widget, - elm_code_widget2_code_set(code); - elm_code_widget2_font_size_set(14); - elm_code_widget2_editable_set(EINA_TRUE); - eo_event_callback_add(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code)); + elm_code_widget_code_set(code); + elm_code_widget_font_size_set(14); + elm_code_widget_editable_set(EINA_TRUE); + eo_event_callback_add(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code)); _append_line(code->file, "Hello World, Elm Code!"); elm_code_file_line_token_add(code->file, 1, 14, 21, ELM_CODE_TOKEN_TYPE_COMMENT); diff --git a/elm_code/lib/Elm_Code.h b/elm_code/lib/Elm_Code.h index 8a30dfe..21384c9 100644 --- a/elm_code/lib/Elm_Code.h +++ b/elm_code/lib/Elm_Code.h @@ -34,7 +34,7 @@ #include "elm_code_common.h" #include "elm_code_file.h" #include "elm_code_parse.h" -#include "elm_code_widget2.eo.h" +#include "elm_code_widget.eo.h" #include "elm_code_diff_widget.h" #ifdef __cplusplus diff --git a/elm_code/lib/Makefile.am b/elm_code/lib/Makefile.am index bf84811..447e052 100644 --- a/elm_code/lib/Makefile.am +++ b/elm_code/lib/Makefile.am @@ -12,7 +12,7 @@ lib_LTLIBRARIES = libelm_code.la includes_HEADERS = \ elm_code_file.h \ elm_code_parse.h \ -elm_code_widget2.eo.h \ +elm_code_widget.eo.h \ elm_code_diff_widget.h \ Elm_Code.h includesdir = $(includedir)/edi-@VMAJ@ @@ -20,7 +20,7 @@ includesdir = $(includedir)/edi-@VMAJ@ libelm_code_la_SOURCES = \ elm_code_file.c \ elm_code_parse.c \ -elm_code_widget2.c \ +elm_code_widget.c \ elm_code_diff_widget.c \ elm_code.c \ elm_code_private.h diff --git a/elm_code/lib/elm_code_diff_widget.c b/elm_code/lib/elm_code_diff_widget.c index 3db4fbb..2315d0a 100644 --- a/elm_code/lib/elm_code_diff_widget.c +++ b/elm_code/lib/elm_code_diff_widget.c @@ -80,7 +80,7 @@ static void _elm_code_diff_widget_parse_diff(Elm_Code_File *diff, Elm_Code_File EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) { Elm_Code *wcode1, *wcode2; - Elm_Code_Widget2 *widget_left, *widget_right; + Elm_Code_Widget *widget_left, *widget_right; Evas_Object *hbox; hbox = elm_panes_add(parent); @@ -91,9 +91,9 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) // left side of diff wcode1 = elm_code_create(); - widget_left = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + widget_left = eo_add(ELM_CODE_WIDGET_CLASS, parent); eo_do(widget_left, - elm_code_widget2_code_set(wcode1)); + elm_code_widget_code_set(wcode1)); evas_object_size_hint_weight_set(widget_left, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(widget_left, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -103,9 +103,9 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) // right side of diff wcode2 = elm_code_create(); - widget_right = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + widget_right = eo_add(ELM_CODE_WIDGET_CLASS, parent); eo_do(widget_right, - elm_code_widget2_code_set(wcode2)); + elm_code_widget_code_set(wcode2)); evas_object_size_hint_weight_set(widget_right, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(widget_right, EVAS_HINT_FILL, EVAS_HINT_FILL); @@ -119,11 +119,11 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code) EAPI void elm_code_diff_widget_font_size_set(Evas_Object *widget, int size) { - Elm_Code_Widget2 *child; + Elm_Code_Widget *child; - child = (Elm_Code_Widget2 *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_LEFT); - eo_do(child, elm_code_widget2_font_size_set(size)); - child = (Elm_Code_Widget2 *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_RIGHT); - eo_do(child, elm_code_widget2_font_size_set(size)); + child = (Elm_Code_Widget *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_LEFT); + eo_do(child, elm_code_widget_font_size_set(size)); + child = (Elm_Code_Widget *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_RIGHT); + eo_do(child, elm_code_widget_font_size_set(size)); } diff --git a/elm_code/lib/elm_code_widget2.c b/elm_code/lib/elm_code_widget.c similarity index 72% rename from elm_code/lib/elm_code_widget2.c rename to elm_code/lib/elm_code_widget.c index 834201c..22ace87 100644 --- a/elm_code/lib/elm_code_widget2.c +++ b/elm_code/lib/elm_code_widget.c @@ -9,7 +9,7 @@ #include #include -#include "elm_code_widget2.eo.h" +#include "elm_code_widget.eo.h" typedef struct { @@ -19,9 +19,9 @@ typedef struct Evas_Font_Size font_size; unsigned int cursor_line, cursor_col; Eina_Bool editable, focussed; -} Elm_Code_Widget2_Data; +} Elm_Code_Widget_Data; -Eina_Unicode status_icons2[] = { +Eina_Unicode status_icons[] = { ' ', '!', @@ -37,16 +37,16 @@ Eina_Unicode status_icons2[] = { EOLIAN static void -_elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd EINA_UNUSED) +_elm_code_widget_eo_base_constructor(Eo *obj, Elm_Code_Widget_Data *pd EINA_UNUSED) { - eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, eo_constructor()); + eo_do_super(obj, ELM_CODE_WIDGET_CLASS, eo_constructor()); pd->cursor_line = 1; pd->cursor_col = 1; } EOLIAN static void -_elm_code_widget2_class_constructor(Eo_Class *klass EINA_UNUSED) +_elm_code_widget_class_constructor(Eo_Class *klass EINA_UNUSED) { } @@ -101,7 +101,7 @@ _elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, } static void -_elm_code_widget_fill_line(Elm_Code_Widget2_Data *pd, Evas_Textgrid_Cell *cells, Elm_Code_Line *line) +_elm_code_widget_fill_line(Elm_Code_Widget_Data *pd, Evas_Textgrid_Cell *cells, Elm_Code_Line *line) { char *chr; unsigned int length, x; @@ -113,7 +113,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget2_Data *pd, Evas_Textgrid_Cell *cells, length = line->length; evas_object_textgrid_size_get(pd->grid, &w, NULL); - cells[0].codepoint = status_icons2[line->status]; + cells[0].codepoint = status_icons[line->status]; cells[0].bold = 1; cells[0].fg = ELM_CODE_TOKEN_TYPE_DEFAULT; cells[0].bg = line->status; @@ -146,7 +146,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget2_Data *pd, Evas_Textgrid_Cell *cells, } static void -_elm_code_widget_fill(Elm_Code_Widget2_Data *pd) +_elm_code_widget_fill(Elm_Code_Widget_Data *pd) { Elm_Code_Line *line; Evas_Textgrid_Cell *cells; @@ -167,16 +167,16 @@ _elm_code_widget_fill(Elm_Code_Widget2_Data *pd) } static Eina_Bool -_elm_code_widget2_line_cb(void *data, Eo *obj EINA_UNUSED, +_elm_code_widget_line_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) { - Elm_Code_Widget2_Data *widget; + Elm_Code_Widget_Data *widget; Elm_Code_Line *line; int h; Evas_Textgrid_Cell *cells; - widget = (Elm_Code_Widget2_Data *)data; + widget = (Elm_Code_Widget_Data *)data; line = (Elm_Code_Line *)event_info; evas_object_textgrid_size_get(widget->grid, NULL, &h); @@ -192,37 +192,37 @@ _elm_code_widget2_line_cb(void *data, Eo *obj EINA_UNUSED, static Eina_Bool -_elm_code_widget2_file_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, +_elm_code_widget_file_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info EINA_UNUSED) { - Elm_Code_Widget2_Data *widget; + Elm_Code_Widget_Data *widget; - widget = (Elm_Code_Widget2_Data *)data; + widget = (Elm_Code_Widget_Data *)data; _elm_code_widget_fill(widget); return EINA_TRUE; } static void -_elm_code_widget2_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, +_elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { - Elm_Code_Widget2_Data *widget; + Elm_Code_Widget_Data *widget; - widget = (Elm_Code_Widget2_Data *)data; + widget = (Elm_Code_Widget_Data *)data; _elm_code_widget_fill(widget); } static void -_elm_code_widget2_clicked_editable_cb(Elm_Code_Widget2 *widget, Evas_Coord x, Evas_Coord y) +_elm_code_widget_clicked_editable_cb(Elm_Code_Widget *widget, Evas_Coord x, Evas_Coord y) { - Elm_Code_Widget2_Data *pd; + Elm_Code_Widget_Data *pd; Elm_Code_Line *line; int cw, ch; unsigned int row, col; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch); col = ((double) x / cw) + 2; @@ -245,51 +245,51 @@ _elm_code_widget2_clicked_editable_cb(Elm_Code_Widget2 *widget, Evas_Coord x, Ev } static void -_elm_code_widget2_clicked_readonly_cb(Elm_Code_Widget2 *widget, Evas_Coord y) +_elm_code_widget_clicked_readonly_cb(Elm_Code_Widget *widget, Evas_Coord y) { - Elm_Code_Widget2_Data *pd; + Elm_Code_Widget_Data *pd; Elm_Code_Line *line; int ch; unsigned int row; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); evas_object_textgrid_cell_size_get(pd->grid, NULL, &ch); row = ((double) y / ch) + 1; line = elm_code_file_line_get(pd->code->file, row); if (line) - eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, line)); + eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, line)); } static void -_elm_code_widget2_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, +_elm_code_widget_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) { - Elm_Code_Widget2 *widget; - Elm_Code_Widget2_Data *pd; + Elm_Code_Widget *widget; + Elm_Code_Widget_Data *pd; Evas_Event_Mouse_Up *event; Evas_Coord x, y; - widget = (Elm_Code_Widget2 *)data; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + widget = (Elm_Code_Widget *)data; + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); event = (Evas_Event_Mouse_Up *)event_info; x = event->canvas.x; y = event->canvas.y; if (pd->editable) - _elm_code_widget2_clicked_editable_cb(widget, x, y); + _elm_code_widget_clicked_editable_cb(widget, x, y); else - _elm_code_widget2_clicked_readonly_cb(widget, y); + _elm_code_widget_clicked_readonly_cb(widget, y); } static void -_elm_code_widget2_cursor_move_up(Elm_Code_Widget2 *widget) +_elm_code_widget_cursor_move_up(Elm_Code_Widget *widget) { - Elm_Code_Widget2_Data *pd; + Elm_Code_Widget_Data *pd; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); if (pd->cursor_line > 1) pd->cursor_line--; @@ -298,11 +298,11 @@ _elm_code_widget2_cursor_move_up(Elm_Code_Widget2 *widget) } static void -_elm_code_widget2_cursor_move_down(Elm_Code_Widget2 *widget) +_elm_code_widget_cursor_move_down(Elm_Code_Widget *widget) { - Elm_Code_Widget2_Data *pd; + Elm_Code_Widget_Data *pd; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET2_CLASS); + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); if (pd->cursor_line < elm_code_file_lines_get(pd->code->file)) pd->cursor_line++; @@ -311,27 +311,27 @@ _elm_code_widget2_cursor_move_down(Elm_Code_Widget2 *widget) } static void -_elm_code_widget2_key_down_cb(void *data, Evas *evas EINA_UNUSED, +_elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) { - Elm_Code_Widget2 *widget; + Elm_Code_Widget *widget; - widget = (Elm_Code_Widget2 *)data; + widget = (Elm_Code_Widget *)data; Evas_Event_Key_Down *ev = event_info; printf("KEY %s\n", ev->key); if (!(strcmp(ev->key, "Up"))) - _elm_code_widget2_cursor_move_up(widget); + _elm_code_widget_cursor_move_up(widget); if (!(strcmp(ev->key, "Down"))) - _elm_code_widget2_cursor_move_down(widget); + _elm_code_widget_cursor_move_down(widget); } EOLIAN static Eina_Bool -_elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd) +_elm_code_widget_elm_widget_on_focus(Eo *obj, Elm_Code_Widget_Data *pd) { Eina_Bool int_ret = EINA_FALSE; - eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, int_ret = elm_obj_widget_on_focus()); + eo_do_super(obj, ELM_CODE_WIDGET_CLASS, int_ret = elm_obj_widget_on_focus()); if (!int_ret) return EINA_TRUE; pd->focussed = elm_widget_focus_get(obj); @@ -341,8 +341,8 @@ _elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd) } EOLIAN static void -_elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, - Elm_Code_Widget2_Data *pd EINA_UNUSED, +_elm_code_widget_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, + Elm_Code_Widget_Data *pd EINA_UNUSED, Evas_Coord x, Evas_Coord y, Eina_Bool sig EINA_UNUSED) { @@ -350,46 +350,46 @@ _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED, } EOLIAN static void -_elm_code_widget2_font_size_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size) +_elm_code_widget_font_size_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Evas_Font_Size font_size) { evas_object_textgrid_font_set(pd->grid, "Mono", font_size * elm_config_scale_get()); pd->font_size = font_size; } EOLIAN static Evas_Font_Size -_elm_code_widget2_font_size_get(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd) +_elm_code_widget_font_size_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) { return pd->font_size; } EOLIAN static void -_elm_code_widget2_code_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd, Elm_Code *code) +_elm_code_widget_code_set(Eo *obj, Elm_Code_Widget_Data *pd EINA_UNUSED, Elm_Code *code) { pd->code = code; - code->widgets = eina_list_append(code->widgets, pd); + code->widgets = eina_list_append(code->widgets, obj); } EOLIAN static Elm_Code * -_elm_code_widget2_code_get(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd) +_elm_code_widget_code_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) { return pd->code; } EOLIAN static void -_elm_code_widget2_editable_set(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd, Eina_Bool editable) +_elm_code_widget_editable_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Eina_Bool editable) { pd->editable = editable; } EOLIAN static Eina_Bool -_elm_code_widget2_editable_get(Eo *obj EINA_UNUSED, Elm_Code_Widget2_Data *pd) +_elm_code_widget_editable_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) { return pd->editable; } static void -_elm_code_widget2_setup_palette(Evas_Object *o) +_elm_code_widget_setup_palette(Evas_Object *o) { // setup status colors evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT, @@ -428,11 +428,11 @@ _elm_code_widget2_setup_palette(Evas_Object *o) } EOLIAN static void -_elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) +_elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd) { Evas_Object *grid; - eo_do_super(obj, ELM_CODE_WIDGET2_CLASS, evas_obj_smart_add()); + eo_do_super(obj, ELM_CODE_WIDGET_CLASS, evas_obj_smart_add()); elm_object_focus_allow_set(obj, EINA_TRUE); grid = evas_object_textgrid_add(obj); @@ -441,18 +441,18 @@ _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd) evas_object_show(grid); elm_box_pack_end(obj, grid); pd->grid = grid; - _elm_code_widget2_setup_palette(grid); + _elm_code_widget_setup_palette(grid); - evas_object_event_callback_add(grid, EVAS_CALLBACK_RESIZE, _elm_code_widget2_resize_cb, pd); - evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget2_clicked_cb, obj); + evas_object_event_callback_add(grid, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, pd); + evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget_clicked_cb, obj); // FIXME find why obj is not getting key_down events - evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _elm_code_widget2_key_down_cb, obj); + evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _elm_code_widget_key_down_cb, obj); eo_do(obj, - eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget2_line_cb, pd); - eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget2_file_cb, pd)); + eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, pd); + eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, pd)); - _elm_code_widget2_font_size_set(obj, pd, 10); + _elm_code_widget_font_size_set(obj, pd, 10); } -#include "elm_code_widget2.eo.c" +#include "elm_code_widget.eo.c" diff --git a/elm_code/lib/elm_code_widget2.eo b/elm_code/lib/elm_code_widget.eo similarity index 82% rename from elm_code/lib/elm_code_widget2.eo rename to elm_code/lib/elm_code_widget.eo index 39f6f4d..491c436 100644 --- a/elm_code/lib/elm_code_widget2.eo +++ b/elm_code/lib/elm_code_widget.eo @@ -1,7 +1,7 @@ -class Elm_Code_Widget2 (Elm_Box, Elm_Interface_Scrollable, - Elm_Interface_Atspi_Text) +class Elm_Code_Widget (Elm_Box, Elm_Interface_Scrollable, + Elm_Interface_Atspi_Text) { - eo_prefix: elm_code_widget2; + eo_prefix: elm_code_widget; properties { code { set { diff --git a/elm_code/lib/elm_code_widget.eo.c b/elm_code/lib/elm_code_widget.eo.c new file mode 100644 index 0000000..67fff69 --- /dev/null +++ b/elm_code/lib/elm_code_widget.eo.c @@ -0,0 +1,70 @@ +EOAPI const Eo_Event_Description _ELM_CODE_WIDGET_EVENT_LINE_CLICKED = + EO_EVENT_DESCRIPTION("line,clicked", ""); + +void _elm_code_widget_code_set(Eo *obj, Elm_Code_Widget_Data *pd, Elm_Code *code); + +EOAPI EO_VOID_FUNC_BODYV(elm_code_widget_code_set, EO_FUNC_CALL(code), Elm_Code *code); + +Elm_Code * _elm_code_widget_code_get(Eo *obj, Elm_Code_Widget_Data *pd); + +EOAPI EO_FUNC_BODY(elm_code_widget_code_get, Elm_Code *, 0); + +void _elm_code_widget_font_size_set(Eo *obj, Elm_Code_Widget_Data *pd, Evas_Font_Size font_size); + +EOAPI EO_VOID_FUNC_BODYV(elm_code_widget_font_size_set, EO_FUNC_CALL(font_size), Evas_Font_Size font_size); + +Evas_Font_Size _elm_code_widget_font_size_get(Eo *obj, Elm_Code_Widget_Data *pd); + +EOAPI EO_FUNC_BODY(elm_code_widget_font_size_get, Evas_Font_Size, 0); + +void _elm_code_widget_editable_set(Eo *obj, Elm_Code_Widget_Data *pd, Eina_Bool editable); + +EOAPI EO_VOID_FUNC_BODYV(elm_code_widget_editable_set, EO_FUNC_CALL(editable), Eina_Bool editable); + +Eina_Bool _elm_code_widget_editable_get(Eo *obj, Elm_Code_Widget_Data *pd); + +EOAPI EO_FUNC_BODY(elm_code_widget_editable_get, Eina_Bool, 0); + +void _elm_code_widget_eo_base_constructor(Eo *obj, Elm_Code_Widget_Data *pd); + + +void _elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd); + + +Eina_Bool _elm_code_widget_elm_widget_on_focus(Eo *obj, Elm_Code_Widget_Data *pd); + + +void _elm_code_widget_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig); + + +static Eo_Op_Description _elm_code_widget_op_desc[] = { + EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget_eo_base_constructor), + EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget_evas_object_smart_add), + EO_OP_FUNC_OVERRIDE(elm_obj_widget_on_focus, _elm_code_widget_elm_widget_on_focus), + EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget_elm_interface_scrollable_content_pos_set), + EO_OP_FUNC(elm_code_widget_code_set, _elm_code_widget_code_set, ""), + EO_OP_FUNC(elm_code_widget_code_get, _elm_code_widget_code_get, ""), + EO_OP_FUNC(elm_code_widget_font_size_set, _elm_code_widget_font_size_set, ""), + EO_OP_FUNC(elm_code_widget_font_size_get, _elm_code_widget_font_size_get, ""), + EO_OP_FUNC(elm_code_widget_editable_set, _elm_code_widget_editable_set, ""), + EO_OP_FUNC(elm_code_widget_editable_get, _elm_code_widget_editable_get, ""), + EO_OP_SENTINEL +}; + +static const Eo_Event_Description *_elm_code_widget_event_desc[] = { + ELM_CODE_WIDGET_EVENT_LINE_CLICKED, + NULL +}; + +static const Eo_Class_Description _elm_code_widget_class_desc = { + EO_VERSION, + "Elm_Code_Widget", + EO_CLASS_TYPE_REGULAR, + EO_CLASS_DESCRIPTION_OPS(_elm_code_widget_op_desc), + _elm_code_widget_event_desc, + sizeof(Elm_Code_Widget_Data), + _elm_code_widget_class_constructor, + NULL +}; + +EO_DEFINE_CLASS(elm_code_widget_class_get, &_elm_code_widget_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); diff --git a/elm_code/lib/elm_code_widget.eo.h b/elm_code/lib/elm_code_widget.eo.h new file mode 100644 index 0000000..4449601 --- /dev/null +++ b/elm_code/lib/elm_code_widget.eo.h @@ -0,0 +1,78 @@ +#ifndef _ELM_CODE_WIDGET_EO_H_ +#define _ELM_CODE_WIDGET_EO_H_ + +#ifndef _ELM_CODE_WIDGET_EO_CLASS_TYPE +#define _ELM_CODE_WIDGET_EO_CLASS_TYPE + +typedef Eo Elm_Code_Widget; + +#endif + +#ifndef _ELM_CODE_WIDGET_EO_TYPES +#define _ELM_CODE_WIDGET_EO_TYPES + + +#endif +#define ELM_CODE_WIDGET_CLASS elm_code_widget_class_get() + +const Eo_Class *elm_code_widget_class_get(void) EINA_CONST; + +/** + * + * No description supplied. + * + * @param[in] code No description supplied. + * + */ +EOAPI void elm_code_widget_code_set(Elm_Code *code); + +/** + * + * No description supplied. + * + * + */ +EOAPI Elm_Code * elm_code_widget_code_get(void); + +/** + * + * No description supplied. + * + * @param[in] font_size No description supplied. + * + */ +EOAPI void elm_code_widget_font_size_set(Evas_Font_Size font_size); + +/** + * + * No description supplied. + * + * + */ +EOAPI Evas_Font_Size elm_code_widget_font_size_get(void); + +/** + * + * No description supplied. + * + * @param[in] editable No description supplied. + * + */ +EOAPI void elm_code_widget_editable_set(Eina_Bool editable); + +/** + * + * No description supplied. + * + * + */ +EOAPI Eina_Bool elm_code_widget_editable_get(void); + +EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET_EVENT_LINE_CLICKED; + +/** + * No description + */ +#define ELM_CODE_WIDGET_EVENT_LINE_CLICKED (&(_ELM_CODE_WIDGET_EVENT_LINE_CLICKED)) + +#endif diff --git a/elm_code/lib/elm_code_widget2.eo.c b/elm_code/lib/elm_code_widget2.eo.c deleted file mode 100644 index 0aa2208..0000000 --- a/elm_code/lib/elm_code_widget2.eo.c +++ /dev/null @@ -1,70 +0,0 @@ -EOAPI const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_LINE_CLICKED = - EO_EVENT_DESCRIPTION("line,clicked", ""); - -void _elm_code_widget2_code_set(Eo *obj, Elm_Code_Widget2_Data *pd, Elm_Code *code); - -EOAPI EO_VOID_FUNC_BODYV(elm_code_widget2_code_set, EO_FUNC_CALL(code), Elm_Code *code); - -Elm_Code * _elm_code_widget2_code_get(Eo *obj, Elm_Code_Widget2_Data *pd); - -EOAPI EO_FUNC_BODY(elm_code_widget2_code_get, Elm_Code *, 0); - -void _elm_code_widget2_font_size_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Font_Size font_size); - -EOAPI EO_VOID_FUNC_BODYV(elm_code_widget2_font_size_set, EO_FUNC_CALL(font_size), Evas_Font_Size font_size); - -Evas_Font_Size _elm_code_widget2_font_size_get(Eo *obj, Elm_Code_Widget2_Data *pd); - -EOAPI EO_FUNC_BODY(elm_code_widget2_font_size_get, Evas_Font_Size, 0); - -void _elm_code_widget2_editable_set(Eo *obj, Elm_Code_Widget2_Data *pd, Eina_Bool editable); - -EOAPI EO_VOID_FUNC_BODYV(elm_code_widget2_editable_set, EO_FUNC_CALL(editable), Eina_Bool editable); - -Eina_Bool _elm_code_widget2_editable_get(Eo *obj, Elm_Code_Widget2_Data *pd); - -EOAPI EO_FUNC_BODY(elm_code_widget2_editable_get, Eina_Bool, 0); - -void _elm_code_widget2_eo_base_constructor(Eo *obj, Elm_Code_Widget2_Data *pd); - - -void _elm_code_widget2_evas_object_smart_add(Eo *obj, Elm_Code_Widget2_Data *pd); - - -Eina_Bool _elm_code_widget2_elm_widget_on_focus(Eo *obj, Elm_Code_Widget2_Data *pd); - - -void _elm_code_widget2_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget2_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig); - - -static Eo_Op_Description _elm_code_widget2_op_desc[] = { - EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget2_eo_base_constructor), - EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget2_evas_object_smart_add), - EO_OP_FUNC_OVERRIDE(elm_obj_widget_on_focus, _elm_code_widget2_elm_widget_on_focus), - EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget2_elm_interface_scrollable_content_pos_set), - EO_OP_FUNC(elm_code_widget2_code_set, _elm_code_widget2_code_set, ""), - EO_OP_FUNC(elm_code_widget2_code_get, _elm_code_widget2_code_get, ""), - EO_OP_FUNC(elm_code_widget2_font_size_set, _elm_code_widget2_font_size_set, ""), - EO_OP_FUNC(elm_code_widget2_font_size_get, _elm_code_widget2_font_size_get, ""), - EO_OP_FUNC(elm_code_widget2_editable_set, _elm_code_widget2_editable_set, ""), - EO_OP_FUNC(elm_code_widget2_editable_get, _elm_code_widget2_editable_get, ""), - EO_OP_SENTINEL -}; - -static const Eo_Event_Description *_elm_code_widget2_event_desc[] = { - ELM_CODE_WIDGET2_EVENT_LINE_CLICKED, - NULL -}; - -static const Eo_Class_Description _elm_code_widget2_class_desc = { - EO_VERSION, - "Elm_Code_Widget2", - EO_CLASS_TYPE_REGULAR, - EO_CLASS_DESCRIPTION_OPS(_elm_code_widget2_op_desc), - _elm_code_widget2_event_desc, - sizeof(Elm_Code_Widget2_Data), - _elm_code_widget2_class_constructor, - NULL -}; - -EO_DEFINE_CLASS(elm_code_widget2_class_get, &_elm_code_widget2_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); \ No newline at end of file diff --git a/elm_code/lib/elm_code_widget2.eo.h b/elm_code/lib/elm_code_widget2.eo.h deleted file mode 100644 index cbad231..0000000 --- a/elm_code/lib/elm_code_widget2.eo.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef _ELM_CODE_WIDGET2_EO_H_ -#define _ELM_CODE_WIDGET2_EO_H_ - -#ifndef _ELM_CODE_WIDGET2_EO_CLASS_TYPE -#define _ELM_CODE_WIDGET2_EO_CLASS_TYPE - -typedef Eo Elm_Code_Widget2; - -#endif - -#ifndef _ELM_CODE_WIDGET2_EO_TYPES -#define _ELM_CODE_WIDGET2_EO_TYPES - - -#endif -#define ELM_CODE_WIDGET2_CLASS elm_code_widget2_class_get() - -const Eo_Class *elm_code_widget2_class_get(void) EINA_CONST; - -/** - * - * No description supplied. - * - * @param[in] code No description supplied. - * - */ -EOAPI void elm_code_widget2_code_set(Elm_Code *code); - -/** - * - * No description supplied. - * - * - */ -EOAPI Elm_Code * elm_code_widget2_code_get(void); - -/** - * - * No description supplied. - * - * @param[in] font_size No description supplied. - * - */ -EOAPI void elm_code_widget2_font_size_set(Evas_Font_Size font_size); - -/** - * - * No description supplied. - * - * - */ -EOAPI Evas_Font_Size elm_code_widget2_font_size_get(void); - -/** - * - * No description supplied. - * - * @param[in] editable No description supplied. - * - */ -EOAPI void elm_code_widget2_editable_set(Eina_Bool editable); - -/** - * - * No description supplied. - * - * - */ -EOAPI Eina_Bool elm_code_widget2_editable_get(void); - -EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET2_EVENT_LINE_CLICKED; - -/** - * No description - */ -#define ELM_CODE_WIDGET2_EVENT_LINE_CLICKED (&(_ELM_CODE_WIDGET2_EVENT_LINE_CLICKED)) - -#endif diff --git a/elm_code/lib/regen.sh b/elm_code/lib/regen.sh index 055f8e7..b3c682e 100755 --- a/elm_code/lib/regen.sh +++ b/elm_code/lib/regen.sh @@ -3,6 +3,6 @@ cd `dirname $0` INCLUDE="-I /usr/local/share/eolian/include/eo-1 -I /usr/local/share/eolian/include/elementary-1 -I /usr/local/share/eolian/include/evas-1 -I /usr/local/share/eolian/include/efl-1" -eolian_gen $INCLUDE --gh --eo -o elm_code_widget2.eo.h elm_code_widget2.eo -eolian_gen $INCLUDE --gc --eo -o elm_code_widget2.eo.c elm_code_widget2.eo -eolian_gen $INCLUDE --gi --eo -o elm_code_widget2.c elm_code_widget2.eo +eolian_gen $INCLUDE --gh --eo -o elm_code_widget.eo.h elm_code_widget.eo +eolian_gen $INCLUDE --gc --eo -o elm_code_widget.eo.c elm_code_widget.eo +eolian_gen $INCLUDE --gi --eo -o elm_code_widget.c elm_code_widget.eo diff --git a/elm_code/tests/elm_code_test_widget.c b/elm_code/tests/elm_code_test_widget.c index 3b598a9..6efdce8 100644 --- a/elm_code/tests/elm_code_test_widget.c +++ b/elm_code/tests/elm_code_test_widget.c @@ -4,7 +4,7 @@ #include "elm_code_suite.h" -#include "elm_code_widget2.c" +#include "elm_code_widget.c" static void _assert_cell_type(Evas_Textgrid_Cell cell, Elm_Code_Token_Type type, int id) { diff --git a/src/bin/edi_consolepanel.c b/src/bin/edi_consolepanel.c index a92fffc..ccab71e 100644 --- a/src/bin/edi_consolepanel.c +++ b/src/bin/edi_consolepanel.c @@ -336,15 +336,15 @@ EAPI void edi_consolepanel_add(Evas_Object *parent) EAPI void edi_testpanel_add(Evas_Object *parent) { Elm_Code *code; - Elm_Code_Widget2 *widget; + Elm_Code_Widget *widget; code = elm_code_create(); _edi_test_code = code; - widget = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + widget = eo_add(ELM_CODE_WIDGET_CLASS, parent); eo_do(widget, - elm_code_widget2_code_set(code); - elm_code_widget2_font_size_set(_edi_cfg->font.size)); + elm_code_widget_code_set(code); + elm_code_widget_font_size_set(_edi_cfg->font.size)); 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); diff --git a/src/bin/edi_logpanel.c b/src/bin/edi_logpanel.c index 2e32a61..f18a862 100644 --- a/src/bin/edi_logpanel.c +++ b/src/bin/edi_logpanel.c @@ -40,14 +40,14 @@ static void _print_cb(const Eina_Log_Domain *domain, EAPI void edi_logpanel_add(Evas_Object *parent) { - Elm_Code_Widget2 *widget; + Elm_Code_Widget *widget; Elm_Code *code; code = elm_code_create(); - widget = eo_add(ELM_CODE_WIDGET2_CLASS, parent); + widget = eo_add(ELM_CODE_WIDGET_CLASS, parent); eo_do(widget, - elm_code_widget2_code_set(code); - elm_code_widget2_font_size_set(_edi_cfg->font.size)); + elm_code_widget_code_set(code); + elm_code_widget_font_size_set(_edi_cfg->font.size)); 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_show(widget); From 09ac58f30edcd5fa639ad9e8f95c1f0ca5327ffc Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 26 Jan 2015 19:46:30 +0000 Subject: [PATCH 13/14] Bind up/down/left/right to cursor control. Add a veto callback that blocks the up/down hitting the focus manager. This needs to be improved so once we hit the top / bottom it will pass on --- elm_code/lib/elm_code_widget.c | 67 ++++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/elm_code/lib/elm_code_widget.c b/elm_code/lib/elm_code_widget.c index 6c83170..0e74afe 100644 --- a/elm_code/lib/elm_code_widget.c +++ b/elm_code/lib/elm_code_widget.c @@ -10,6 +10,7 @@ #include #include "elm_code_widget.eo.h" +#include "elm_code_private.h" typedef struct { @@ -288,12 +289,17 @@ static void _elm_code_widget_cursor_move_up(Elm_Code_Widget *widget) { Elm_Code_Widget_Data *pd; + Elm_Code_Line *line; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); if (pd->cursor_line > 1) pd->cursor_line--; + line = elm_code_file_line_get(pd->code->file, pd->cursor_line); + if (pd->cursor_col > (unsigned int) line->length + 1) + pd->cursor_col = line->length + 1; + _elm_code_widget_fill(pd); } @@ -301,12 +307,45 @@ static void _elm_code_widget_cursor_move_down(Elm_Code_Widget *widget) { Elm_Code_Widget_Data *pd; + Elm_Code_Line *line; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); if (pd->cursor_line < elm_code_file_lines_get(pd->code->file)) pd->cursor_line++; + line = elm_code_file_line_get(pd->code->file, pd->cursor_line); + if (pd->cursor_col > (unsigned int) line->length + 1) + pd->cursor_col = line->length + 1; + + _elm_code_widget_fill(pd); +} + +static void +_elm_code_widget_cursor_move_left(Elm_Code_Widget *widget) +{ + Elm_Code_Widget_Data *pd; + + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); + + if (pd->cursor_col > 1) + pd->cursor_col--; + + _elm_code_widget_fill(pd); +} + +static void +_elm_code_widget_cursor_move_right(Elm_Code_Widget *widget) +{ + Elm_Code_Widget_Data *pd; + Elm_Code_Line *line; + + pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); + + line = elm_code_file_line_get(pd->code->file, pd->cursor_line); + if (pd->cursor_col <= (unsigned int) line->length) + pd->cursor_col++; + _elm_code_widget_fill(pd); } @@ -320,11 +359,30 @@ _elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED, Evas_Event_Key_Down *ev = event_info; - printf("KEY %s\n", ev->key); - if (!(strcmp(ev->key, "Up"))) + if (!strcmp(ev->key, "Up")) _elm_code_widget_cursor_move_up(widget); - if (!(strcmp(ev->key, "Down"))) + else if (!strcmp(ev->key, "Down")) _elm_code_widget_cursor_move_down(widget); + else if (!strcmp(ev->key, "Left")) + _elm_code_widget_cursor_move_left(widget); + else if (!strcmp(ev->key, "Right")) + _elm_code_widget_cursor_move_right(widget); + else + INF("Unhandled key %s", ev->key); +} + +static Eina_Bool +_elm_code_widget_event_veto_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, + Evas_Object *src EINA_UNUSED, Evas_Callback_Type type, + void *event_info EINA_UNUSED) +{ + Eina_Bool veto = EINA_FALSE; + +// TODO determine if we should allow up/down to be sent to our focus manager + if (type == EVAS_CALLBACK_KEY_DOWN) + veto = EINA_TRUE; + + return veto; } EOLIAN static Eina_Bool @@ -451,9 +509,10 @@ _elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd) evas_object_event_callback_add(grid, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, pd); evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget_clicked_cb, obj); -// FIXME find why obj is not getting key_down events evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _elm_code_widget_key_down_cb, obj); + elm_object_event_callback_add(obj, _elm_code_widget_event_veto_cb, obj); + eo_do(obj, eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, pd); eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, pd)); From ba609590586e30220735477f24e5f9fb67d56b6a Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 26 Jan 2015 23:09:22 +0000 Subject: [PATCH 14/14] And document the wiget API --- elm_code/lib/elm_code_widget.eo | 39 ++++++++++++++++++++++++++++--- elm_code/lib/elm_code_widget.eo.c | 14 +++++------ elm_code/lib/elm_code_widget.eo.h | 39 ++++++++++++++++++++++++------- 3 files changed, 73 insertions(+), 19 deletions(-) diff --git a/elm_code/lib/elm_code_widget.eo b/elm_code/lib/elm_code_widget.eo index 491c436..d274c14 100644 --- a/elm_code/lib/elm_code_widget.eo +++ b/elm_code/lib/elm_code_widget.eo @@ -5,29 +5,62 @@ class Elm_Code_Widget (Elm_Box, Elm_Interface_Scrollable, properties { code { set { + /*@ + Set the underlying code object that this widget renders + + @ingroup Data */ } get { + /*@ + Get the underlying code object we are rendering + + @ingroup Data */ } values { - Elm_Code *code; + Elm_Code *code; /*@ Our underlying Elm_Code object */ } } font_size { set { + /*@ + Set the font size that this widget uses, the font will always be a system monospaced font + + @ingroup Style */ } get { + /*@ + Get the font size currently in use + + @ingroup Style */ } values { - Evas_Font_Size font_size; + Evas_Font_Size font_size; /*@ The font size of the widgget */ } } editable { set { + /*@ + Set whether this widget allows editing + + If @a editable then the widget will allow user input to manipulate + the underlying Elm_Code_File of this Elm_Code instance. + Any other Elm_Code_Widget's connected to this Elm_Code will + update to reflect the changes. + + @ingroup Features */ } get { + /*@ + Get the current editable state of this widget + + @return EINA_TRUE if the widget is editable, EINA_FALSE otherwise. + If this widget is not editable the underlying Elm_Code_File could + still be manipulated by a different widget or the filesystem. + + @ingroup Features */ } values { - Eina_Bool editable; + Eina_Bool editable; /*@ The editable state of the widget */ } } } diff --git a/elm_code/lib/elm_code_widget.eo.c b/elm_code/lib/elm_code_widget.eo.c index 67fff69..a71356c 100644 --- a/elm_code/lib/elm_code_widget.eo.c +++ b/elm_code/lib/elm_code_widget.eo.c @@ -42,12 +42,12 @@ static Eo_Op_Description _elm_code_widget_op_desc[] = { EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget_evas_object_smart_add), EO_OP_FUNC_OVERRIDE(elm_obj_widget_on_focus, _elm_code_widget_elm_widget_on_focus), EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget_elm_interface_scrollable_content_pos_set), - EO_OP_FUNC(elm_code_widget_code_set, _elm_code_widget_code_set, ""), - EO_OP_FUNC(elm_code_widget_code_get, _elm_code_widget_code_get, ""), - EO_OP_FUNC(elm_code_widget_font_size_set, _elm_code_widget_font_size_set, ""), - EO_OP_FUNC(elm_code_widget_font_size_get, _elm_code_widget_font_size_get, ""), - EO_OP_FUNC(elm_code_widget_editable_set, _elm_code_widget_editable_set, ""), - EO_OP_FUNC(elm_code_widget_editable_get, _elm_code_widget_editable_get, ""), + EO_OP_FUNC(elm_code_widget_code_set, _elm_code_widget_code_set, "Set the underlying code object that this widget renders"), + EO_OP_FUNC(elm_code_widget_code_get, _elm_code_widget_code_get, "Get the underlying code object we are rendering"), + EO_OP_FUNC(elm_code_widget_font_size_set, _elm_code_widget_font_size_set, "Set the font size that this widget uses, the font will always be a system monospaced font"), + EO_OP_FUNC(elm_code_widget_font_size_get, _elm_code_widget_font_size_get, "Get the font size currently in use"), + EO_OP_FUNC(elm_code_widget_editable_set, _elm_code_widget_editable_set, "Set whether this widget allows editing"), + EO_OP_FUNC(elm_code_widget_editable_get, _elm_code_widget_editable_get, "Get the current editable state of this widget"), EO_OP_SENTINEL }; @@ -67,4 +67,4 @@ static const Eo_Class_Description _elm_code_widget_class_desc = { NULL }; -EO_DEFINE_CLASS(elm_code_widget_class_get, &_elm_code_widget_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); +EO_DEFINE_CLASS(elm_code_widget_class_get, &_elm_code_widget_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL); \ No newline at end of file diff --git a/elm_code/lib/elm_code_widget.eo.h b/elm_code/lib/elm_code_widget.eo.h index 4449601..4ea26c8 100644 --- a/elm_code/lib/elm_code_widget.eo.h +++ b/elm_code/lib/elm_code_widget.eo.h @@ -19,16 +19,20 @@ const Eo_Class *elm_code_widget_class_get(void) EINA_CONST; /** * - * No description supplied. + * Set the underlying code object that this widget renders * - * @param[in] code No description supplied. + * @ingroup Data + * + * @param[in] code Our underlying Elm_Code object * */ EOAPI void elm_code_widget_code_set(Elm_Code *code); /** * - * No description supplied. + * Get the underlying code object we are rendering + * + * @ingroup Data * * */ @@ -36,16 +40,20 @@ EOAPI Elm_Code * elm_code_widget_code_get(void); /** * - * No description supplied. + * Set the font size that this widget uses, the font will always be a system monospaced font * - * @param[in] font_size No description supplied. + * @ingroup Style + * + * @param[in] font_size The font size of the widgget * */ EOAPI void elm_code_widget_font_size_set(Evas_Font_Size font_size); /** * - * No description supplied. + * Get the font size currently in use + * + * @ingroup Style * * */ @@ -53,16 +61,29 @@ EOAPI Evas_Font_Size elm_code_widget_font_size_get(void); /** * - * No description supplied. + * Set whether this widget allows editing * - * @param[in] editable No description supplied. + * If @a editable then the widget will allow user input to manipulate + * the underlying Elm_Code_File of this Elm_Code instance. + * Any other Elm_Code_Widget's connected to this Elm_Code will + * update to reflect the changes. + * + * @ingroup Features + * + * @param[in] editable The editable state of the widget * */ EOAPI void elm_code_widget_editable_set(Eina_Bool editable); /** * - * No description supplied. + * Get the current editable state of this widget + * + * @return EINA_TRUE if the widget is editable, EINA_FALSE otherwise. + * If this widget is not editable the underlying Elm_Code_File could + * still be manipulated by a different widget or the filesystem. + * + * @ingroup Features * * */