2013-07-20 01:51:56 -07:00
|
|
|
#include <Elementary.h>
|
|
|
|
#include <Eio.h>
|
2013-08-26 11:29:56 -07:00
|
|
|
#include "config.h"
|
2013-07-20 01:51:56 -07:00
|
|
|
#include "common.h"
|
|
|
|
|
2014-02-04 04:48:06 -08:00
|
|
|
typedef struct app_s
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
edit_data *ed;
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
Eio_Monitor *edc_monitor;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
Eina_Bool ctrl_pressed : 1;
|
2013-08-31 10:50:17 -07:00
|
|
|
Eina_Bool shift_pressed : 1;
|
2014-02-04 04:48:06 -08:00
|
|
|
} app_data;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-23 10:29:46 -07:00
|
|
|
int main(int argc, char **argv);
|
|
|
|
|
2013-08-04 09:28:47 -07:00
|
|
|
static Eina_Bool
|
2013-07-20 01:51:56 -07:00
|
|
|
edc_changed_cb(void *data, int type EINA_UNUSED, void *event)
|
|
|
|
{
|
|
|
|
Eio_Monitor_Event *ev = event;
|
|
|
|
app_data *ad = data;
|
|
|
|
|
2014-07-12 00:01:50 -07:00
|
|
|
if (ev->monitor != ad->edc_monitor) return ECORE_CALLBACK_PASS_ON;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-07-12 00:01:50 -07:00
|
|
|
if (!edit_changed_get(ad->ed)) return ECORE_CALLBACK_DONE;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-07-12 00:01:50 -07:00
|
|
|
if (strcmp(ev->filename, config_edc_path_get()))
|
|
|
|
return ECORE_CALLBACK_DONE;
|
2013-09-28 08:13:52 -07:00
|
|
|
build_edc();
|
2013-08-04 09:28:47 -07:00
|
|
|
edit_changed_set(ad->ed, EINA_FALSE);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-07-12 00:01:50 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2014-07-09 21:43:55 -07:00
|
|
|
edc_default_setup()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-07-09 21:43:55 -07:00
|
|
|
newfile_default_set();
|
2013-09-28 08:13:52 -07:00
|
|
|
build_edc();
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
main_key_up_cb(void *data, int type EINA_UNUSED, void *ev)
|
|
|
|
{
|
|
|
|
Ecore_Event_Key *event = ev;
|
|
|
|
app_data *ad = data;
|
|
|
|
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp("Control_L", event->key))
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
edit_editable_set(ad->ed, EINA_TRUE);
|
|
|
|
ad->ctrl_pressed = EINA_FALSE;
|
|
|
|
}
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp("Shift_L", event->key))
|
2013-08-31 10:50:17 -07:00
|
|
|
ad->shift_pressed = EINA_FALSE;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2013-08-28 05:55:39 -07:00
|
|
|
static void
|
2014-02-05 03:27:03 -08:00
|
|
|
auto_indentation_toggle()
|
2013-08-28 05:55:39 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
Eina_Bool toggle = !config_auto_indent_get();
|
2014-02-04 05:45:41 -08:00
|
|
|
if (toggle) stats_info_msg_update("Auto Indentation Enabled.");
|
|
|
|
else stats_info_msg_update("Auto Indentation Disabled.");
|
2014-01-29 09:45:10 -08:00
|
|
|
config_auto_indent_set(toggle);
|
2013-08-28 05:55:39 -07:00
|
|
|
}
|
|
|
|
|
2013-08-31 10:50:17 -07:00
|
|
|
static Eina_Bool
|
2014-08-08 22:29:51 -07:00
|
|
|
template_insert_patch(app_data *ad, const char *key)
|
2013-08-31 10:50:17 -07:00
|
|
|
{
|
2014-08-13 07:12:51 -07:00
|
|
|
Edje_Part_Type part_type;
|
2014-08-11 19:51:19 -07:00
|
|
|
if (config_live_edit_get())
|
|
|
|
{
|
|
|
|
stats_info_msg_update("Insertion of template code is disabled "
|
|
|
|
"while in Live Edit mode");
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-31 10:50:17 -07:00
|
|
|
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(key, "a") || !strcmp(key, "A"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_TABLE;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "b") || !strcmp(key, "B"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_TEXTBLOCK;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "e") || !strcmp(key, "E"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_EXTERNAL;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "g") || !strcmp(key, "G"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_GRADIENT;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "i") || !strcmp(key, "I"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_IMAGE;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "o") || !strcmp(key, "O"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_GROUP;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "p") || !strcmp(key, "P"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_PROXY;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "r") || !strcmp(key, "R"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_RECTANGLE;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "t") || !strcmp(key, "T"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_TEXT;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "s") || !strcmp(key, "S"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_SPACER;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "w") || !strcmp(key, "W"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_SWALLOW;
|
2014-01-31 23:22:00 -08:00
|
|
|
else if (!strcmp(key, "x") || !strcmp(key, "X"))
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_BOX;
|
2013-08-31 10:50:17 -07:00
|
|
|
else
|
2014-08-13 07:12:51 -07:00
|
|
|
part_type = EDJE_PART_TYPE_NONE;
|
2013-08-31 10:50:17 -07:00
|
|
|
|
2014-08-13 07:12:51 -07:00
|
|
|
template_part_insert(ad->ed, part_type, TEMPLATE_INSERT_DEFAULT,
|
|
|
|
REL1_X, REL1_Y, REL2_X, REL2_Y, NULL);
|
2013-08-31 10:50:17 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
|
2013-08-25 09:53:19 -07:00
|
|
|
static Eina_Bool
|
2014-01-31 23:22:00 -08:00
|
|
|
ctrl_func(app_data *ad, const char *key)
|
2013-08-25 09:53:19 -07:00
|
|
|
{
|
|
|
|
//Save
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(key, "s") || !strcmp(key, "S"))
|
2013-08-25 09:53:19 -07:00
|
|
|
{
|
|
|
|
edit_save(ad->ed);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-05-12 08:08:54 -07:00
|
|
|
//Delete Line
|
2014-03-09 10:15:31 -07:00
|
|
|
if (!strcmp(key, "d") || !strcmp(key, "D"))
|
|
|
|
{
|
|
|
|
edit_line_delete(ad->ed);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-02-21 22:24:53 -08:00
|
|
|
//Find/Replace
|
|
|
|
if (!strcmp(key, "f") || !strcmp(key, "F"))
|
|
|
|
{
|
2014-06-04 08:50:41 -07:00
|
|
|
search_open(ad->ed);
|
2014-02-21 22:24:53 -08:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-05-31 23:35:54 -07:00
|
|
|
//Goto Line
|
|
|
|
if (!strcmp(key, "l") || !strcmp(key, "L"))
|
|
|
|
{
|
|
|
|
goto_open(ad->ed);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-25 09:53:19 -07:00
|
|
|
//Part Highlight
|
2014-09-29 19:07:57 -07:00
|
|
|
if (!strcmp(key, "h") || !strcmp(key, "H"))
|
2013-08-25 09:53:19 -07:00
|
|
|
{
|
2014-03-08 05:55:48 -08:00
|
|
|
config_part_highlight_set(!config_part_highlight_get());
|
|
|
|
edit_part_highlight_toggle(ad->ed, EINA_TRUE);
|
2013-08-25 09:53:19 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-28 05:55:39 -07:00
|
|
|
//Swallow Dummy Object
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(key, "w") || !strcmp(key, "W"))
|
2013-08-25 09:53:19 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_dummy_swallow_set(!config_dummy_swallow_get());
|
2013-09-18 21:54:45 -07:00
|
|
|
view_dummy_toggle(VIEW_DATA, EINA_TRUE);
|
2013-08-25 09:53:19 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-03-08 05:55:48 -08:00
|
|
|
//Template Code
|
|
|
|
if (!strcmp(key, "t") || !strcmp(key, "T"))
|
|
|
|
{
|
2014-08-11 19:55:50 -07:00
|
|
|
if (config_live_edit_get())
|
|
|
|
{
|
|
|
|
stats_info_msg_update("Insertion of template code is disabled "
|
|
|
|
"while in Live Edit mode");
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-13 07:12:51 -07:00
|
|
|
template_insert(ad->ed, TEMPLATE_INSERT_DEFAULT);
|
2014-03-08 05:55:48 -08:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-25 09:53:19 -07:00
|
|
|
//Full Edit View
|
2014-08-10 02:33:17 -07:00
|
|
|
if (!strcmp(key, "Left"))
|
2013-08-25 09:53:19 -07:00
|
|
|
{
|
2014-08-11 04:17:31 -07:00
|
|
|
base_live_view_full_view();
|
2013-08-25 09:53:19 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-10 02:33:17 -07:00
|
|
|
//Full Live View
|
|
|
|
if (!strcmp(key, "Right"))
|
2013-08-25 09:53:19 -07:00
|
|
|
{
|
2014-08-11 04:17:31 -07:00
|
|
|
base_text_editor_full_view();
|
2013-08-25 09:53:19 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-10 02:33:17 -07:00
|
|
|
//Full Console View
|
|
|
|
if (!strcmp(key, "Up"))
|
|
|
|
{
|
2014-08-11 05:13:04 -07:00
|
|
|
base_console_full_view();
|
2014-08-10 02:33:17 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
//Full Editors View
|
|
|
|
if (!strcmp(key, "Down"))
|
|
|
|
{
|
2014-08-11 05:13:04 -07:00
|
|
|
base_editors_full_view();
|
2014-08-10 02:33:17 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-28 05:55:39 -07:00
|
|
|
//Auto Indentation
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(key, "i") || !strcmp(key, "I"))
|
2013-08-28 05:55:39 -07:00
|
|
|
{
|
2014-02-04 16:55:35 -08:00
|
|
|
auto_indentation_toggle();
|
2013-08-28 05:55:39 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-07-18 21:31:08 -07:00
|
|
|
//Auto Completion
|
|
|
|
if (!strcmp(key, "o") || !strcmp(key, "O"))
|
|
|
|
{
|
|
|
|
autocomp_toggle();
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-10 21:48:01 -07:00
|
|
|
//Live Edit
|
2014-08-13 03:38:46 -07:00
|
|
|
if (!strcmp(key, "e") || !strcmp(key, "E"))
|
2014-08-10 21:48:01 -07:00
|
|
|
{
|
2014-08-11 00:32:35 -07:00
|
|
|
live_edit_toggle();
|
2014-08-10 21:48:01 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-01 21:45:47 -07:00
|
|
|
|
2014-05-12 08:08:54 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2013-08-25 09:53:19 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static Eina_Bool
|
|
|
|
main_key_down_cb(void *data, int type EINA_UNUSED, void *ev)
|
|
|
|
{
|
|
|
|
Ecore_Event_Key *event = ev;
|
|
|
|
app_data *ad = data;
|
|
|
|
|
2014-07-18 21:31:08 -07:00
|
|
|
if (autocomp_key_event_hook(event->key)) return ECORE_CALLBACK_DONE;
|
|
|
|
|
2013-08-31 10:50:17 -07:00
|
|
|
//Shift Key
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp("Shift_L", event->key))
|
2013-08-31 10:50:17 -07:00
|
|
|
{
|
|
|
|
ad->shift_pressed = EINA_TRUE;
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ad->ctrl_pressed)
|
|
|
|
{
|
2014-08-08 22:29:51 -07:00
|
|
|
if (ad->shift_pressed) return template_insert_patch(ad, event->key);
|
2014-01-31 23:22:00 -08:00
|
|
|
else return ctrl_func(ad, event->key);
|
2013-08-31 10:50:17 -07:00
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//Main Menu
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "Escape"))
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-05-31 23:35:54 -07:00
|
|
|
if (search_is_opened() || goto_is_opened())
|
2014-03-01 20:34:22 -08:00
|
|
|
{
|
2014-05-31 23:35:54 -07:00
|
|
|
goto_close();
|
2014-03-01 20:34:22 -08:00
|
|
|
search_close();
|
|
|
|
edit_focus_set(ad->ed);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-01-29 04:56:29 -08:00
|
|
|
menu_toggle();
|
2013-07-20 01:51:56 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
|
2014-07-30 02:08:57 -07:00
|
|
|
if (menu_activated_get() > 0) return ECORE_CALLBACK_PASS_ON;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
//Control Key
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp("Control_L", event->key))
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
ad->ctrl_pressed = EINA_TRUE;
|
2013-09-07 23:34:44 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
2013-07-21 00:10:00 -07:00
|
|
|
//README
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "F1"))
|
2013-07-21 00:10:00 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_about();
|
2013-07-21 00:10:00 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-25 10:17:57 -07:00
|
|
|
//New
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "F2"))
|
2013-08-25 10:17:57 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_edc_new();
|
2013-08-25 10:17:57 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
//Save
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "F3"))
|
2013-08-25 10:17:57 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_edc_save();
|
2013-08-25 10:17:57 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-24 22:47:46 -07:00
|
|
|
//Load
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "F4"))
|
2013-08-24 22:47:46 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_edc_load();
|
2013-08-24 22:47:46 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
//Line Number
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "F5"))
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-01-29 09:45:10 -08:00
|
|
|
config_linenumber_set(!config_linenumber_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
edit_line_number_toggle(ad->ed);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-10 01:46:14 -07:00
|
|
|
//Tools
|
|
|
|
if (!strcmp(event->key, "F9"))
|
|
|
|
{
|
|
|
|
base_tools_toggle(EINA_TRUE);
|
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
|
|
|
//Console
|
2014-03-08 08:12:28 -08:00
|
|
|
if (!strcmp(event->key, "F10"))
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-08-14 02:29:53 -07:00
|
|
|
base_console_toggle();
|
2013-07-20 01:51:56 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2014-08-10 01:46:14 -07:00
|
|
|
//Statusbar
|
2014-03-08 08:05:26 -08:00
|
|
|
if (!strcmp(event->key, "F11"))
|
|
|
|
{
|
2014-08-10 01:46:14 -07:00
|
|
|
base_statusbar_toggle(EINA_TRUE);
|
2014-03-08 08:05:26 -08:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-08-25 10:17:57 -07:00
|
|
|
//Setting
|
2014-01-31 23:22:00 -08:00
|
|
|
if (!strcmp(event->key, "F12"))
|
2013-08-25 10:17:57 -07:00
|
|
|
{
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_setting();
|
2013-08-25 10:17:57 -07:00
|
|
|
return ECORE_CALLBACK_DONE;
|
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2014-01-26 08:21:02 -08:00
|
|
|
static Eina_Bool
|
|
|
|
main_mouse_wheel_cb(void *data, int type EINA_UNUSED, void *ev)
|
|
|
|
{
|
|
|
|
Ecore_Event_Mouse_Wheel *event = ev;
|
|
|
|
app_data *ad = data;
|
2014-05-12 07:44:49 -07:00
|
|
|
Evas_Coord x, y, w, h;
|
2014-01-26 08:21:02 -08:00
|
|
|
|
|
|
|
if (!ad->ctrl_pressed) return ECORE_CALLBACK_PASS_ON;
|
|
|
|
|
2014-05-12 07:44:49 -07:00
|
|
|
//View Scale
|
2014-02-04 05:20:40 -08:00
|
|
|
view_data *vd = edj_mgr_view_get(NULL);
|
2014-05-12 07:44:49 -07:00
|
|
|
Evas_Object *view = view_obj_get(vd);
|
|
|
|
evas_object_geometry_get(view, &x, &y, &w, &h);
|
2014-01-26 08:21:02 -08:00
|
|
|
|
2014-05-12 07:44:49 -07:00
|
|
|
if ((event->x >= x) && (event->x <= (x + w)) &&
|
|
|
|
(event->y >= y) && (event->y <= (y + h)))
|
|
|
|
{
|
|
|
|
double scale = config_view_scale_get();
|
|
|
|
|
|
|
|
if (event->z < 0) scale += 0.1;
|
|
|
|
else scale -= 0.1;
|
|
|
|
|
|
|
|
config_view_scale_set(scale);
|
|
|
|
scale = config_view_scale_get();
|
|
|
|
view_scale_set(vd, scale);
|
2014-01-26 08:21:02 -08:00
|
|
|
|
2014-05-12 07:44:49 -07:00
|
|
|
char buf[256];
|
|
|
|
snprintf(buf, sizeof(buf), "View Scale: %2.2fx", scale);
|
|
|
|
stats_info_msg_update(buf);
|
2014-01-28 22:42:30 -08:00
|
|
|
|
2014-05-12 07:44:49 -07:00
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
|
|
|
//Font Size
|
|
|
|
Evas_Object *editor = edit_obj_get(ad->ed);
|
|
|
|
evas_object_geometry_get(editor, &x, &y, &w, &h);
|
|
|
|
|
|
|
|
if ((event->x >= x) && (event->x <= (x + w)) &&
|
|
|
|
(event->y >= y) && (event->y <= (y + h)))
|
|
|
|
{
|
|
|
|
if (event->z < 0)
|
|
|
|
{
|
|
|
|
config_font_size_set(config_font_size_get() + 0.1f);
|
2014-05-26 07:35:57 -07:00
|
|
|
edit_font_size_update(ad->ed, EINA_TRUE, EINA_TRUE);
|
2014-05-12 07:44:49 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
config_font_size_set(config_font_size_get() - 0.1f);
|
2014-05-26 07:35:57 -07:00
|
|
|
edit_font_size_update(ad->ed, EINA_TRUE, EINA_TRUE);
|
2014-05-12 07:44:49 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
2014-01-26 08:21:02 -08:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_PASS_ON;
|
|
|
|
}
|
|
|
|
|
2013-09-19 00:49:58 -07:00
|
|
|
static void
|
2014-02-04 16:55:35 -08:00
|
|
|
edc_view_set(Eina_Stringshare *group)
|
2013-09-19 00:49:58 -07:00
|
|
|
{
|
2014-02-04 05:20:40 -08:00
|
|
|
view_data *vd = edj_mgr_view_get(group);
|
|
|
|
if (vd) edj_mgr_view_switch_to(vd);
|
2014-02-04 05:45:41 -08:00
|
|
|
else vd = edj_mgr_view_new(group);
|
2013-09-19 01:44:51 -07:00
|
|
|
|
2013-09-19 00:49:58 -07:00
|
|
|
if (!vd) return;
|
|
|
|
|
2014-02-17 21:42:30 -08:00
|
|
|
if (group) stats_edc_group_update(group);
|
2013-09-19 00:49:58 -07:00
|
|
|
}
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
static void
|
2014-02-04 16:55:35 -08:00
|
|
|
view_sync_cb(void *data EINA_UNUSED, Eina_Stringshare *part_name,
|
2013-09-18 10:05:46 -07:00
|
|
|
Eina_Stringshare *group_name)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-02-04 05:45:41 -08:00
|
|
|
if (stats_group_name_get() != group_name)
|
2014-02-04 16:55:35 -08:00
|
|
|
edc_view_set(group_name);
|
2013-09-18 21:54:45 -07:00
|
|
|
view_part_highlight_set(VIEW_DATA, part_name);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-04 05:45:41 -08:00
|
|
|
edc_edit_set(app_data *ad)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-02-04 05:45:41 -08:00
|
|
|
edit_data *ed = edit_init(base_layout_get());
|
2014-01-29 09:45:10 -08:00
|
|
|
edit_edc_read(ed, config_edc_path_get());
|
2014-08-11 04:17:31 -07:00
|
|
|
base_text_editor_set(edit_obj_get(ed));
|
2013-09-18 10:05:46 -07:00
|
|
|
edit_view_sync_cb_set(ed, view_sync_cb, ad);
|
2013-07-20 01:51:56 -07:00
|
|
|
ad->ed = ed;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-02-05 03:27:03 -08:00
|
|
|
statusbar_set()
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2014-02-04 05:45:41 -08:00
|
|
|
Evas_Object *obj = stats_init(base_layout_get());
|
2014-02-04 00:17:43 -08:00
|
|
|
elm_object_part_content_set(base_layout_get(), "elm.swallow.statusbar",
|
2014-02-04 05:45:41 -08:00
|
|
|
obj);
|
2014-03-14 02:00:47 -07:00
|
|
|
base_statusbar_toggle(EINA_FALSE);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2014-01-29 09:45:10 -08:00
|
|
|
config_update_cb(void *data)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
app_data *ad = data;
|
2014-01-29 09:45:10 -08:00
|
|
|
build_cmd_set();
|
2013-07-20 01:51:56 -07:00
|
|
|
edit_line_number_toggle(ad->ed);
|
2014-05-26 07:35:57 -07:00
|
|
|
edit_font_size_update(ad->ed, EINA_FALSE, EINA_TRUE);
|
2014-01-27 22:22:26 -08:00
|
|
|
|
2014-03-08 08:22:54 -08:00
|
|
|
base_tools_toggle(EINA_FALSE);
|
2014-03-08 08:12:28 -08:00
|
|
|
base_statusbar_toggle(EINA_FALSE);
|
2014-03-12 12:12:14 -07:00
|
|
|
edit_part_highlight_toggle(ad->ed, EINA_FALSE);
|
2013-09-18 21:54:45 -07:00
|
|
|
view_dummy_toggle(VIEW_DATA, EINA_FALSE);
|
2013-07-20 03:56:33 -07:00
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
//previous build was failed, Need to rebuild then reload the edj.
|
2014-02-04 05:20:40 -08:00
|
|
|
if (edj_mgr_reload_need_get())
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
2013-09-28 08:13:52 -07:00
|
|
|
build_edc();
|
2013-08-04 09:28:47 -07:00
|
|
|
edit_changed_set(ad->ed, EINA_FALSE);
|
2014-02-04 05:20:40 -08:00
|
|
|
edj_mgr_clear();
|
2014-02-04 16:55:35 -08:00
|
|
|
edc_view_set(stats_group_name_get());
|
2014-07-12 00:01:50 -07:00
|
|
|
eio_monitor_del(ad->edc_monitor);
|
2014-01-29 09:45:10 -08:00
|
|
|
ad->edc_monitor = eio_monitor_add(config_edc_path_get());
|
2014-07-12 00:01:50 -07:00
|
|
|
if (!ad->edc_monitor) EINA_LOG_ERR("Failed to add Eio_Monitor");
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
//If the edc is reloaded, then rebuild it!
|
|
|
|
else if (edit_changed_get(ad->ed))
|
|
|
|
{
|
2013-08-04 09:28:47 -07:00
|
|
|
edit_changed_set(ad->ed, EINA_FALSE);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
2014-01-27 22:22:26 -08:00
|
|
|
|
2014-02-04 05:20:40 -08:00
|
|
|
view_scale_set(edj_mgr_view_get(NULL), config_view_scale_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
args_dispatch(int argc, char **argv, char *edc_path, char *img_path,
|
2013-08-27 21:16:34 -07:00
|
|
|
char *snd_path, char *fnt_path, char *data_path)
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
Eina_Bool default_edc = EINA_TRUE;
|
|
|
|
|
|
|
|
//No arguments. set defaults
|
|
|
|
if (argc == 1) goto defaults;
|
|
|
|
|
|
|
|
//Help
|
|
|
|
if ((argc >=2 ) && !strcmp(argv[1], "--help"))
|
|
|
|
{
|
2013-08-27 21:16:34 -07:00
|
|
|
fprintf(stdout, "Usage: enventor [input file] [-id image path] [-sd sound path] [-fd font path] [-dd data path]\n");
|
2013-07-20 01:51:56 -07:00
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//edc path
|
2014-03-15 01:20:42 -07:00
|
|
|
if ((argc >= 2) && strstr(argv[1], ".edc"))
|
2013-07-20 01:51:56 -07:00
|
|
|
{
|
|
|
|
sprintf(edc_path, "%s", argv[1]);
|
|
|
|
default_edc = EINA_FALSE;
|
|
|
|
}
|
|
|
|
else goto defaults;
|
|
|
|
|
|
|
|
//edc image path
|
|
|
|
int cur_arg = 2;
|
|
|
|
|
|
|
|
while (cur_arg < argc)
|
|
|
|
{
|
|
|
|
if (argc > (cur_arg + 1))
|
|
|
|
{
|
|
|
|
if (!strcmp("-id", argv[cur_arg]))
|
2014-02-18 03:34:03 -08:00
|
|
|
sprintf(img_path, "%s", argv[cur_arg + 1]);
|
2013-07-20 01:51:56 -07:00
|
|
|
else if (!strcmp("-sd", argv[cur_arg]))
|
2014-02-18 03:34:03 -08:00
|
|
|
sprintf(snd_path, "%s", argv[cur_arg + 1]);
|
2013-08-27 10:26:13 -07:00
|
|
|
else if (!strcmp("-fd", argv[cur_arg]))
|
2014-02-18 03:34:03 -08:00
|
|
|
sprintf(fnt_path, "%s", argv[cur_arg + 1]);
|
2013-08-27 21:16:34 -07:00
|
|
|
else if (!strcmp("-dd", argv[cur_arg]))
|
2014-02-18 03:34:03 -08:00
|
|
|
sprintf(data_path, "%s", argv[cur_arg + 1]);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
cur_arg += 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
defaults:
|
2014-09-10 23:43:26 -07:00
|
|
|
if (default_edc) sprintf(edc_path, DEFAULT_EDC_PATH_FORMAT, getpid());
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
config_data_set(app_data *ad, int argc, char **argv)
|
|
|
|
{
|
2014-02-18 03:34:03 -08:00
|
|
|
char edc_path[PATH_MAX] = { 0, };
|
|
|
|
char img_path[PATH_MAX] = { 0, };
|
|
|
|
char snd_path[PATH_MAX] = { 0, };
|
|
|
|
char fnt_path[PATH_MAX] = { 0, };
|
|
|
|
char data_path[PATH_MAX] = { 0, };
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-08-27 21:16:34 -07:00
|
|
|
args_dispatch(argc, argv, edc_path, img_path, snd_path, fnt_path, data_path);
|
2014-01-29 09:45:10 -08:00
|
|
|
config_init(edc_path, img_path, snd_path, fnt_path, data_path);
|
|
|
|
config_update_cb_set(config_update_cb, ad);
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
elm_setup()
|
|
|
|
{
|
2014-02-17 18:47:09 -08:00
|
|
|
elm_need_efreet();
|
2013-09-23 00:57:11 -07:00
|
|
|
elm_config_profile_set("standard");
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-08-27 11:11:07 -07:00
|
|
|
/* Recover the scale since it will be reset by
|
2013-09-23 00:57:11 -07:00
|
|
|
elm_config_profile_set() */
|
|
|
|
char *scale = getenv("ELM_SCALE");
|
|
|
|
if (scale) elm_config_scale_set(atof(scale));
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-02-06 23:58:18 -08:00
|
|
|
/* Recover the current engine since it will be reset by
|
|
|
|
elm_config_profiel_set() */
|
|
|
|
char *engine = getenv("ELM_ENGINE");
|
|
|
|
if (engine && !strncmp(engine, "gl", strlen("gl")))
|
|
|
|
elm_config_preferred_engine_set("opengl_x11");
|
|
|
|
|
2014-06-01 21:13:09 -07:00
|
|
|
elm_config_focus_highlight_clip_disabled_set(EINA_FALSE);
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_config_scroll_bounce_enabled_set(EINA_FALSE);
|
|
|
|
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
2013-08-26 11:29:56 -07:00
|
|
|
elm_app_compile_bin_dir_set(PACKAGE_BIN_DIR);
|
|
|
|
elm_app_compile_data_dir_set(PACKAGE_DATA_DIR);
|
|
|
|
elm_app_compile_lib_dir_set(PACKAGE_LIB_DIR);
|
|
|
|
elm_app_info_set(main, "enventor",
|
|
|
|
"images/logo.png");
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-09-23 10:29:46 -07:00
|
|
|
snprintf(EDJE_PATH, sizeof(EDJE_PATH), "%s/themes/enventor.edj",
|
|
|
|
elm_app_data_dir_get());
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_theme_extension_add(NULL, EDJE_PATH);
|
|
|
|
}
|
|
|
|
|
2013-09-19 01:44:51 -07:00
|
|
|
static void
|
2014-02-05 03:27:03 -08:00
|
|
|
edj_mgr_set()
|
2013-09-19 01:44:51 -07:00
|
|
|
{
|
2014-02-04 05:20:40 -08:00
|
|
|
edj_mgr_init(base_layout_get());
|
2014-08-11 04:17:31 -07:00
|
|
|
base_live_view_set(edj_mgr_obj_get());
|
2013-09-19 01:44:51 -07:00
|
|
|
}
|
|
|
|
|
2014-01-29 10:17:59 -08:00
|
|
|
static void
|
2014-08-11 00:32:35 -07:00
|
|
|
tools_set(edit_data *ed)
|
2014-01-29 10:17:59 -08:00
|
|
|
{
|
2014-08-11 00:32:35 -07:00
|
|
|
Evas_Object *tools = tools_create(base_layout_get(), ed);
|
2014-03-08 08:22:54 -08:00
|
|
|
base_tools_set(tools);
|
2014-01-29 10:17:59 -08:00
|
|
|
}
|
|
|
|
|
2013-07-25 09:31:49 -07:00
|
|
|
static Eina_Bool
|
2013-07-20 01:51:56 -07:00
|
|
|
init(app_data *ad, int argc, char **argv)
|
|
|
|
{
|
2014-05-12 08:08:54 -07:00
|
|
|
elm_init(argc, argv);
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, main_key_down_cb, ad);
|
|
|
|
ecore_event_handler_add(ECORE_EVENT_KEY_UP, main_key_up_cb, ad);
|
2014-01-26 08:21:02 -08:00
|
|
|
ecore_event_handler_add(ECORE_EVENT_MOUSE_WHEEL, main_mouse_wheel_cb, ad);
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
elm_setup();
|
2014-05-12 08:08:54 -07:00
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
config_data_set(ad, argc, argv);
|
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
if (!build_init()) return EINA_FALSE;
|
2014-07-09 21:43:55 -07:00
|
|
|
if (!edc_default_setup()) return EINA_FALSE;
|
2014-02-04 00:17:43 -08:00
|
|
|
if (!base_gui_init()) return EINA_FALSE;
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-07-18 21:31:08 -07:00
|
|
|
autocomp_init(base_layout_get());
|
2014-02-04 16:55:35 -08:00
|
|
|
edj_mgr_set();
|
|
|
|
statusbar_set();
|
2014-02-04 05:45:41 -08:00
|
|
|
edc_edit_set(ad);
|
2014-02-04 16:55:35 -08:00
|
|
|
edc_view_set(stats_group_name_get());
|
2014-02-04 00:17:43 -08:00
|
|
|
menu_init(ad->ed);
|
2014-08-11 00:32:35 -07:00
|
|
|
tools_set(ad->ed);
|
|
|
|
live_edit_init(ad->ed);
|
2014-01-29 05:28:02 -08:00
|
|
|
|
2014-05-12 02:04:22 -07:00
|
|
|
base_gui_show();
|
|
|
|
|
2014-01-29 09:45:10 -08:00
|
|
|
ad->edc_monitor = eio_monitor_add(config_edc_path_get());
|
2014-07-12 00:01:50 -07:00
|
|
|
if (!ad->edc_monitor) EINA_LOG_ERR("Failed to add Eio_Monitor");
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
ecore_event_handler_add(EIO_MONITOR_FILE_MODIFIED, edc_changed_cb, ad);
|
2013-07-25 09:31:49 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
2013-07-20 01:51:56 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
term(app_data *ad)
|
|
|
|
{
|
2013-09-28 08:13:52 -07:00
|
|
|
build_term();
|
2014-01-29 08:15:33 -08:00
|
|
|
menu_term();
|
2013-07-20 01:51:56 -07:00
|
|
|
edit_term(ad->ed);
|
2014-08-11 00:32:35 -07:00
|
|
|
live_edit_term();
|
2014-02-04 05:20:40 -08:00
|
|
|
edj_mgr_term();
|
2014-02-04 05:45:41 -08:00
|
|
|
stats_term();
|
2014-02-04 00:17:43 -08:00
|
|
|
base_gui_term();
|
2014-01-29 09:45:10 -08:00
|
|
|
config_term();
|
2014-07-18 21:31:08 -07:00
|
|
|
autocomp_term();
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2014-07-18 23:07:25 -07:00
|
|
|
eio_monitor_del(ad->edc_monitor);
|
|
|
|
|
2013-07-20 01:51:56 -07:00
|
|
|
elm_shutdown();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
2013-09-12 06:14:16 -07:00
|
|
|
app_data ad;
|
|
|
|
memset(&ad, 0x00, sizeof(ad));
|
2013-07-20 01:51:56 -07:00
|
|
|
|
2013-07-25 09:31:49 -07:00
|
|
|
if (!init(&ad, argc, argv))
|
|
|
|
{
|
|
|
|
term(&ad);
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-20 01:51:56 -07:00
|
|
|
|
|
|
|
elm_run();
|
|
|
|
|
|
|
|
term(&ad);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|