Merging in master

This commit is contained in:
Andy Williams 2014-10-23 21:24:20 +01:00
commit 84414c6e1b
7 changed files with 80 additions and 28 deletions

View File

@ -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

View File

@ -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");

View File

@ -24,17 +24,17 @@
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_STRING = "<color=#ff5a35>";
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_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_BACKGROUND = "+<backing_color=#000000>";
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>";
@ -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;
@ -496,9 +496,12 @@ _clang_load_errors(const char *path, 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. */
@ -517,14 +520,27 @@ _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
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;
@ -573,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;
@ -588,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);
@ -606,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;
}

View File

@ -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);

View File

@ -8,6 +8,7 @@
#include "edi_private.h"
#include <stdlib.h>
#include <sys/wait.h>
#define _EDI_WELCOME_PROJECT_NEW_TABLE_WIDTH 4
@ -129,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];
@ -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);
}

View File

@ -2,6 +2,7 @@
# define EDI_H_
#include <Elementary.h>
#include <Eina.h>
#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.

View File

@ -2,6 +2,10 @@
# include "config.h"
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#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 *