From 16ca047e64766a24d64e61ab4a0b298275669760 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Fri, 17 Oct 2014 23:43:15 +0100 Subject: [PATCH 1/9] Disable a broken test for now - we're focussing on testing elm_code at the moment --- src/tests/Makefile.am | 1 - src/tests/edi_suite.c | 1 - src/tests/{edi_test_console.c => edi_test_console.c-old} | 0 3 files changed, 2 deletions(-) rename src/tests/{edi_test_console.c => edi_test_console.c-old} (100%) diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am index d18854e..2b2a7f2 100644 --- a/src/tests/Makefile.am +++ b/src/tests/Makefile.am @@ -5,7 +5,6 @@ check_PROGRAMS = edi_suite edi_suite_SOURCES = \ edi_test_path.c \ -edi_test_console.c \ edi_suite.c edi_suite_CPPFLAGS = -I$(top_builddir)/src/lib/ -I$(top_builddir)/src/bin/ \ diff --git a/src/tests/edi_suite.c b/src/tests/edi_suite.c index b168ba7..f57bf16 100644 --- a/src/tests/edi_suite.c +++ b/src/tests/edi_suite.c @@ -14,7 +14,6 @@ static const struct { void (*build)(TCase *tc); } tests[] = { { "basic", edi_test_basic }, - { "console", edi_test_console }, { "path", edi_test_path } }; diff --git a/src/tests/edi_test_console.c b/src/tests/edi_test_console.c-old similarity index 100% rename from src/tests/edi_test_console.c rename to src/tests/edi_test_console.c-old From 5402a5921f0ae1acc46d6a33243971f20d1304ab Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Mon, 20 Oct 2014 23:20:14 +0100 Subject: [PATCH 2/9] Using the +/- format application to remove bold etc where used. This requires a patch from herdsman to evas to work effectively --- src/bin/editor/edi_editor.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index 61736a9..1e3139e 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -32,7 +32,7 @@ static Edi_Color EDI_COLOR_CLASS = "+ color=#72AAD4 font_weight=Bold"; static Edi_Color EDI_COLOR_FUNCTION = "+ color=#72AAD4 font_weight=Bold"; static Edi_Color EDI_COLOR_PARAM = "+ color=#ffffff"; static Edi_Color EDI_COLOR_KEYWORD = "+ color=#ff9900 font_weight=Bold"; -static Edi_Color EDI_COLOR_PREPROCESSOR = "+ color=#00B000 font_weight=Bold"; +static Edi_Color EDI_COLOR_PREPROCESSOR = "+ color=#00B000"; static Edi_Color EDI_COLOR_BACKGROUND = "+ backing_color=#000000"; static Edi_Color EDI_COLOR_SEVIRITY_IGNORED = "+ backing_color=#000000"; @@ -280,13 +280,19 @@ _edi_editor_statusbar_add(Evas_Object *panel, Edi_Editor *editor, Edi_Mainview_I static void _edi_range_color_set(Edi_Editor *editor, Edi_Range range, Edi_Color color) { + char *format; + format = strdup(color); + evas_textblock_cursor_line_set(_format_cursor, range.start.line - 1); evas_textblock_cursor_pos_set(_format_cursor, evas_textblock_cursor_pos_get(_format_cursor) + range.start.col - 1); - evas_textblock_cursor_format_prepend(_format_cursor, color); + evas_textblock_cursor_format_prepend(_format_cursor, format); + format[0] = '-'; evas_textblock_cursor_line_set(_format_cursor, range.end.line - 1); evas_textblock_cursor_pos_set(_format_cursor, evas_textblock_cursor_pos_get(_format_cursor) + range.end.col - 1); - evas_textblock_cursor_format_append(_format_cursor, EDI_COLOR_FOREGROUND); + evas_textblock_cursor_format_append(_format_cursor, format); + + free(format); } static void From 76675f629801c394a7052c3436d150c089e70ca6 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Tue, 21 Oct 2014 14:26:01 +0100 Subject: [PATCH 3/9] Use the recommended formatting for colour, avoid font weight right now as it doesn't stack properly --- src/bin/editor/edi_editor.c | 40 ++++++++++++++++--------------------- 1 file changed, 17 insertions(+), 23 deletions(-) diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index 1e3139e..19e3016 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -22,22 +22,22 @@ #define Edi_Color const char * -static Edi_Color EDI_COLOR_FOREGROUND = "+ color=#ffffff"; -static Edi_Color EDI_COLOR_COMMENT = "+ color=#3399ff"; -static Edi_Color EDI_COLOR_STRING = "+ color=#ff3a35"; -static Edi_Color EDI_COLOR_NUMBER = "+ color=#D4D42A font_weight=Bold"; -static Edi_Color EDI_COLOR_BRACE = "+ color=#656565"; -static Edi_Color EDI_COLOR_TYPE = "+ color=#3399ff"; -static Edi_Color EDI_COLOR_CLASS = "+ color=#72AAD4 font_weight=Bold"; -static Edi_Color EDI_COLOR_FUNCTION = "+ color=#72AAD4 font_weight=Bold"; -static Edi_Color EDI_COLOR_PARAM = "+ color=#ffffff"; -static Edi_Color EDI_COLOR_KEYWORD = "+ color=#ff9900 font_weight=Bold"; -static Edi_Color EDI_COLOR_PREPROCESSOR = "+ color=#00B000"; +static Edi_Color EDI_COLOR_FOREGROUND = ""; +static Edi_Color EDI_COLOR_COMMENT = ""; +static Edi_Color EDI_COLOR_STRING = ""; +static Edi_Color EDI_COLOR_NUMBER = "";// font_weight=Bold"; +static Edi_Color EDI_COLOR_BRACE = ""; +static Edi_Color EDI_COLOR_TYPE = ""; +static Edi_Color EDI_COLOR_CLASS = "";// font_weight=Bold"; +static Edi_Color EDI_COLOR_FUNCTION = "";// font_weight=Bold"; +static Edi_Color EDI_COLOR_PARAM = ""; +static Edi_Color EDI_COLOR_KEYWORD = "";// font_weight=Bold"; +static Edi_Color EDI_COLOR_PREPROCESSOR = ""; -static Edi_Color EDI_COLOR_BACKGROUND = "+ backing_color=#000000"; -static Edi_Color EDI_COLOR_SEVIRITY_IGNORED = "+ backing_color=#000000"; -static Edi_Color EDI_COLOR_SEVIRITY_NOTE = "+ backing_color=#ff9900"; -static Edi_Color EDI_COLOR_SEVIRITY_WARNING = "+ backing_color=#ff9900"; +static Edi_Color EDI_COLOR_BACKGROUND = "+"; +static Edi_Color EDI_COLOR_SEVIRITY_IGNORED = ""; +static Edi_Color EDI_COLOR_SEVIRITY_NOTE = ""; +static Edi_Color EDI_COLOR_SEVIRITY_WARNING = ""; typedef struct { @@ -280,19 +280,13 @@ _edi_editor_statusbar_add(Evas_Object *panel, Edi_Editor *editor, Edi_Mainview_I static void _edi_range_color_set(Edi_Editor *editor, Edi_Range range, Edi_Color color) { - char *format; - format = strdup(color); - evas_textblock_cursor_line_set(_format_cursor, range.start.line - 1); evas_textblock_cursor_pos_set(_format_cursor, evas_textblock_cursor_pos_get(_format_cursor) + range.start.col - 1); - evas_textblock_cursor_format_prepend(_format_cursor, format); + evas_textblock_cursor_format_prepend(_format_cursor, color); - format[0] = '-'; evas_textblock_cursor_line_set(_format_cursor, range.end.line - 1); evas_textblock_cursor_pos_set(_format_cursor, evas_textblock_cursor_pos_get(_format_cursor) + range.end.col - 1); - evas_textblock_cursor_format_append(_format_cursor, format); - - free(format); + evas_textblock_cursor_format_append(_format_cursor, ""); } static void From d671a68877b80becabb8c63c7adf47f999e415f2 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Wed, 22 Oct 2014 21:08:24 +0200 Subject: [PATCH 4/9] use waitpid() instead of wait() --- src/bin/welcome/edi_welcome.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bin/welcome/edi_welcome.c b/src/bin/welcome/edi_welcome.c index e356da6..47ad865 100644 --- a/src/bin/welcome/edi_welcome.c +++ b/src/bin/welcome/edi_welcome.c @@ -8,6 +8,7 @@ #include "edi_private.h" #include +#include #define _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH 4 @@ -151,7 +152,7 @@ _edi_welcome_project_new_create_cb(void *data, Evas_Object *obj EINA_UNUSED, voi execlp(script, script, fullpath, name, user, email, url, NULL); exit(0); } - wait(pid); + waitpid(pid, NULL, 0); _edi_welcome_project_open(fullpath); } From 8fadf1098758189dbf0e467f53c06763add58d08 Mon Sep 17 00:00:00 2001 From: Boris Faure Date: Wed, 22 Oct 2014 21:08:57 +0200 Subject: [PATCH 5/9] fix some compiler warnings --- src/bin/editor/edi_editor.c | 10 ++++++---- src/bin/mainview/edi_mainview.c | 10 +++++----- src/bin/welcome/edi_welcome.c | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index 19e3016..cc8bb84 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -24,13 +24,13 @@ static Edi_Color EDI_COLOR_FOREGROUND = ""; static Edi_Color EDI_COLOR_COMMENT = ""; -static Edi_Color EDI_COLOR_STRING = ""; +//static Edi_Color EDI_COLOR_STRING = ""; static Edi_Color EDI_COLOR_NUMBER = "";// font_weight=Bold"; static Edi_Color EDI_COLOR_BRACE = ""; static Edi_Color EDI_COLOR_TYPE = ""; static Edi_Color EDI_COLOR_CLASS = "";// font_weight=Bold"; static Edi_Color EDI_COLOR_FUNCTION = "";// font_weight=Bold"; -static Edi_Color EDI_COLOR_PARAM = ""; +//static Edi_Color EDI_COLOR_PARAM = ""; static Edi_Color EDI_COLOR_KEYWORD = "";// font_weight=Bold"; static Edi_Color EDI_COLOR_PREPROCESSOR = ""; @@ -278,7 +278,7 @@ _edi_editor_statusbar_add(Evas_Object *panel, Edi_Editor *editor, Edi_Mainview_I #if HAVE_LIBCLANG static void -_edi_range_color_set(Edi_Editor *editor, Edi_Range range, Edi_Color color) +_edi_range_color_set(Edi_Editor *editor EINA_UNUSED, Edi_Range range, Edi_Color color) { evas_textblock_cursor_line_set(_format_cursor, range.start.line - 1); evas_textblock_cursor_pos_set(_format_cursor, evas_textblock_cursor_pos_get(_format_cursor) + range.start.col - 1); @@ -447,7 +447,7 @@ _clang_load_highlighting(const char *path, Edi_Editor *editor) } static void -_clang_load_errors(const char *path, Edi_Editor *editor) +_clang_load_errors(const char *path EINA_UNUSED, Edi_Editor *editor) { unsigned n = clang_getNumDiagnostics(editor->tx_unit); unsigned i = 0; @@ -517,12 +517,14 @@ _edi_clang_setup(const char *path, Edi_Editor *editor) evas_textblock_cursor_free(_format_cursor); } +/* static void _edi_clang_dispose(Edi_Editor *editor) { clang_disposeTranslationUnit(editor->tx_unit); clang_disposeIndex(editor->idx); } +*/ #endif EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item) diff --git a/src/bin/mainview/edi_mainview.c b/src/bin/mainview/edi_mainview.c index ceb6c0a..f673bf7 100644 --- a/src/bin/mainview/edi_mainview.c +++ b/src/bin/mainview/edi_mainview.c @@ -188,7 +188,7 @@ _edi_mainview_item_tab_add(Edi_Path_Options *options, const char *mime) it = elm_naviframe_item_simple_push(nf, content); elm_naviframe_item_style_set(it, "overlap"); - tab = elm_toolbar_item_append(tb, NULL, basename(options->path), _promote, it); + tab = elm_toolbar_item_append(tb, NULL, basename((char*)options->path), _promote, it); item->view = it; item->tab = tab; elm_toolbar_item_selected_set(tab, EINA_TRUE); @@ -214,7 +214,7 @@ _edi_mainview_win_title_get(const char *path) { char *winname, *filename; - filename = basename(path); + filename = basename((char*)path); winname = malloc((8 + strlen(filename)) * sizeof(char)); snprintf(winname, 8 + strlen(filename), "Edi :: %s", filename); @@ -552,7 +552,7 @@ edi_mainview_goto(int line) Evas_Object *content; Elm_Object_Item *it; Edi_Editor *editor; - Evas_Object *tb; + Evas_Object *_tb; Evas_Textblock_Cursor *mcur; Evas_Coord x, y, w, h; @@ -562,8 +562,8 @@ edi_mainview_goto(int line) if (!content || line <= 0) return; - tb = elm_entry_textblock_get(editor->entry); - mcur = evas_object_textblock_cursor_get(tb); + _tb = elm_entry_textblock_get(editor->entry); + mcur = evas_object_textblock_cursor_get(_tb); evas_textblock_cursor_line_set(mcur, line-1); elm_entry_cursor_geometry_get(editor->entry, &x, &y, &w, &h); diff --git a/src/bin/welcome/edi_welcome.c b/src/bin/welcome/edi_welcome.c index 47ad865..f031c29 100644 --- a/src/bin/welcome/edi_welcome.c +++ b/src/bin/welcome/edi_welcome.c @@ -130,7 +130,7 @@ _edi_welcome_project_new_input_row_add(const char *text, const char *placeholder } static void -_edi_welcome_project_new_create_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) +_edi_welcome_project_new_create_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED) { const char *path, *name, *user, *email, *url; char script[PATH_MAX], fullpath[PATH_MAX]; From 50b9cd16f7ce1cbb287a366f9b5a5853860ef3b0 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 22 Oct 2014 22:03:39 +0100 Subject: [PATCH 6/9] Fix building out of tree --- data/extra/Makefile.am | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/extra/Makefile.am b/data/extra/Makefile.am index 9a8b3e7..9a54868 100644 --- a/data/extra/Makefile.am +++ b/data/extra/Makefile.am @@ -4,7 +4,7 @@ skeletondir = $(datadir)/$(PACKAGE)/ skeleton_DATA = install-data-hook: - tar -xf skeleton.tar.gz -C $(skeletondir) + tar -xf $(srcdir)/skeleton.tar.gz -C $(skeletondir) uninstall-local: rm -rf $(skeletondir)/skeleton From 95958caa310c1d223f0d0fb5e23bee39cbab0307 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 22 Oct 2014 22:41:23 +0100 Subject: [PATCH 7/9] Warn if the passed parameter is not a valid project location. Currently EDI can only open existing directories or create them - no single file mode --- src/bin/edi_main.c | 8 ++++++-- src/lib/Edi.h | 6 +++++- src/lib/edi.c | 29 ++++++++++++++++++++++++++++- 3 files changed, 39 insertions(+), 4 deletions(-) diff --git a/src/bin/edi_main.c b/src/bin/edi_main.c index cc2d59f..1912797 100644 --- a/src/bin/edi_main.c +++ b/src/bin/edi_main.c @@ -386,7 +386,11 @@ edi_open(const char *path) Evas_Object *win, *vbx, *content, *tb; const char *winname; - edi_project_set(path); + if (!edi_project_set(path)) + { + fprintf(stderr, "Project path must be a directory\n"); + return NULL; + } elm_need_ethumb(); elm_need_efreet(); @@ -481,7 +485,7 @@ elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) if (args < argc) { - project_path = realpath(argv[args], NULL); + project_path = argv[args]; } elm_app_info_set(elm_main, "edi", "images/edi.png"); diff --git a/src/lib/Edi.h b/src/lib/Edi.h index c533995..aff9918 100644 --- a/src/lib/Edi.h +++ b/src/lib/Edi.h @@ -2,6 +2,7 @@ # define EDI_H_ #include +#include #ifdef EAPI # undef EAPI @@ -98,12 +99,15 @@ EAPI int edi_shutdown(void); * @{ * * Set the current edi project that is loaded. + * Any directory is deemed a valid project. * * @param path The path to the current project being loaded. + * @return EINA_TRUE if the path represented a valid project, + * EINA_FALSE otherwise * * @ingroup Main */ -EAPI void edi_project_set(const char *path); +EAPI Eina_Bool edi_project_set(const char *path); /** * Get the current edi project that is loaded. diff --git a/src/lib/edi.c b/src/lib/edi.c index 7d667ed..8950a49 100644 --- a/src/lib/edi.c +++ b/src/lib/edi.c @@ -2,6 +2,10 @@ # include "config.h" #endif +#include +#include +#include + #include "Edi.h" #include "edi_private.h" @@ -58,13 +62,36 @@ edi_shutdown(void) return _edi_init; } -EAPI void +static Eina_Bool +_edi_path_isdir(const char *path) +{ + struct stat buf; + + if (!path) + return EINA_FALSE; + + stat(path, &buf); + return S_ISDIR(buf.st_mode); +} + +EAPI Eina_Bool edi_project_set(const char *path) { + char *real = NULL; + + real = realpath(real, NULL); + if (!_edi_path_isdir(path)) + { + free(real); + return EINA_FALSE; + } + if (_edi_project_path) eina_stringshare_del(_edi_project_path); _edi_project_path = eina_stringshare_add(path); + free(real); + return EINA_TRUE; } EAPI const char * From f7336e9276f9c16648a27fb8dda2c6f6e462c836 Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Wed, 22 Oct 2014 22:43:32 +0100 Subject: [PATCH 8/9] fix syntax mistake after changing markup type --- src/bin/editor/edi_editor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index cc8bb84..cdec582 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -34,7 +34,7 @@ static Edi_Color EDI_COLOR_FUNCTION = "";// font_weight=Bold"; static Edi_Color EDI_COLOR_KEYWORD = "";// font_weight=Bold"; static Edi_Color EDI_COLOR_PREPROCESSOR = ""; -static Edi_Color EDI_COLOR_BACKGROUND = "+"; +static Edi_Color EDI_COLOR_BACKGROUND = ""; static Edi_Color EDI_COLOR_SEVIRITY_IGNORED = ""; static Edi_Color EDI_COLOR_SEVIRITY_NOTE = ""; static Edi_Color EDI_COLOR_SEVIRITY_WARNING = ""; From 863a4a47a22771e147ed41b73a0964a00325ccda Mon Sep 17 00:00:00 2001 From: Andy Williams Date: Thu, 23 Oct 2014 21:14:46 +0100 Subject: [PATCH 9/9] Update the syntax highlighting to work after text set - thanks a lot to herdsman for the initial patch --- src/bin/editor/edi_editor.c | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/src/bin/editor/edi_editor.c b/src/bin/editor/edi_editor.c index cdec582..4ab6155 100644 --- a/src/bin/editor/edi_editor.c +++ b/src/bin/editor/edi_editor.c @@ -496,9 +496,12 @@ _clang_load_errors(const char *path EINA_UNUSED, Edi_Editor *editor) } static void -_edi_clang_setup(const char *path, Edi_Editor *editor) +_edi_clang_setup(Edi_Editor *editor) { Evas_Object *textblock; + const char *path; + + elm_entry_file_get(editor->entry, &path, NULL); /* Clang */ /* FIXME: index should probably be global. */ @@ -527,6 +530,17 @@ _edi_clang_dispose(Edi_Editor *editor) */ #endif +static void +_text_set_done(void *data, Evas_Object *obj EINA_UNUSED, void *source EINA_UNUSED) +{ + Edi_Editor *editor = (Edi_Editor *) data; + +#if HAVE_LIBCLANG + _edi_clang_setup(editor); +#endif + +} + EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item) { Evas_Object *txt, *lines, *vbox, *box, *searchbar, *statusbar; @@ -575,12 +589,6 @@ EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item) elm_entry_scrollable_set(txt, EINA_TRUE); elm_entry_line_wrap_set(txt, EINA_FALSE); elm_entry_text_style_user_push(txt, EDITOR_FONT); - elm_entry_file_set(txt, item->path, ELM_TEXT_FORMAT_PLAIN_UTF8); - elm_entry_autosave_set(txt, EDI_CONTENT_AUTOSAVE); - evas_object_size_hint_weight_set(txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_align_set(txt, EVAS_HINT_FILL, EVAS_HINT_FILL); - evas_object_show(txt); - elm_box_pack_end(box, txt); editor = calloc(1, sizeof(*editor)); editor->entry = txt; @@ -590,6 +598,16 @@ EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item) evas_object_smart_callback_add(txt, "changed,user", _changed_cb, editor); evas_object_smart_callback_add(txt, "scroll", _scroll_cb, editor); evas_object_smart_callback_add(txt, "undo,request", _undo_cb, editor); + evas_object_smart_callback_add(txt, "text,set,done", _text_set_done, editor); + + elm_entry_file_set(txt, item->path, ELM_TEXT_FORMAT_PLAIN_UTF8); + + elm_entry_autosave_set(txt, EDI_CONTENT_AUTOSAVE); + evas_object_size_hint_weight_set(txt, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(txt, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(txt); + elm_box_pack_end(box, txt); + edi_editor_search_add(searchbar, editor); _edi_editor_statusbar_add(statusbar, editor, item); @@ -608,9 +626,5 @@ EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item) evas_object_data_set(vbox, "editor", editor); _update_lines(editor); -#if HAVE_LIBCLANG - _edi_clang_setup(item->path, editor); -#endif - return vbox; }