forked from enlightenment/edi
Added goto line feature, hook in ctrl-f for search (find...)
This commit is contained in:
parent
3deedfeeb8
commit
eb38d77af9
|
@ -2,7 +2,7 @@
|
|||
|
||||
* Add simple build functions
|
||||
* Create an edi_build binary for command line building
|
||||
* Added simple search function
|
||||
* Added simple search and goto line functions
|
||||
|
||||
2014-03-31 ajwillia.ms (Andy Williams)
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#define COPYRIGHT "Copyright © 2014 Andy Williams <andy@andyilliams.me> and various contributors (see AUTHORS)."
|
||||
|
||||
static Evas_Object *_edi_filepanel, *_edi_logpanel, *_edi_consolepanel;
|
||||
static Evas_Object *_edi_main_win, *_edi_new_popup;
|
||||
static Evas_Object *_edi_main_win, *_edi_new_popup, *_edi_goto_popup;
|
||||
|
||||
static Evas_Object *edi_win_setup(const char *path);
|
||||
|
||||
|
@ -182,12 +182,11 @@ _tb_new_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSE
|
|||
|
||||
popup = elm_popup_add(_edi_main_win);
|
||||
_edi_new_popup = popup;
|
||||
|
||||
// popup title
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter new file name");
|
||||
|
||||
input = elm_entry_add(popup);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
elm_object_content_set(popup, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
|
@ -254,6 +253,58 @@ _tb_search_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UN
|
|||
edi_mainview_search();
|
||||
}
|
||||
|
||||
static void
|
||||
_tb_goto_go_cb(void *data,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
int number;
|
||||
|
||||
number = atoi(elm_entry_entry_get((Evas_Object *) data));
|
||||
edi_mainview_goto(number);
|
||||
|
||||
evas_object_del(_edi_goto_popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_tb_goto_cancel_cb(void *data EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_del(_edi_goto_popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_tb_goto_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup, *input, *button;
|
||||
|
||||
elm_toolbar_item_selected_set(elm_toolbar_selected_item_get(obj), EINA_FALSE);
|
||||
|
||||
popup = elm_popup_add(_edi_main_win);
|
||||
_edi_goto_popup = popup;
|
||||
elm_object_part_text_set(popup, "title,text",
|
||||
"Enter line number");
|
||||
|
||||
input = elm_entry_add(popup);
|
||||
elm_entry_single_line_set(input, EINA_TRUE);
|
||||
elm_object_content_set(popup, input);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "cancel");
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_tb_goto_cancel_cb, NULL);
|
||||
|
||||
button = elm_button_add(popup);
|
||||
elm_object_text_set(button, "go");
|
||||
elm_object_part_content_set(popup, "button2", button);
|
||||
evas_object_smart_callback_add(button, "clicked",
|
||||
_tb_goto_go_cb, input);
|
||||
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_tb_build_cb(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
{
|
||||
|
@ -301,7 +352,8 @@ edi_toolbar_setup(Evas_Object *win)
|
|||
tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
||||
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
|
||||
|
||||
tb_it = elm_toolbar_item_append(tb, "edit-find", "Search", _tb_search_cb, NULL);
|
||||
tb_it = elm_toolbar_item_append(tb, "find", "Find", _tb_search_cb, NULL);
|
||||
tb_it = elm_toolbar_item_append(tb, "go-jump", "Goto Line", _tb_goto_cb, NULL);
|
||||
|
||||
tb_it = elm_toolbar_item_append(tb, "separator", "", NULL, NULL);
|
||||
elm_toolbar_item_separator_set(tb_it, EINA_TRUE);
|
||||
|
|
|
@ -141,6 +141,10 @@ _smart_cb_key_down(void *data, Evas *e EINA_UNUSED,
|
|||
{
|
||||
edi_mainview_save();
|
||||
}
|
||||
else if (!strcmp(ev->key, "f"))
|
||||
{
|
||||
edi_mainview_search();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -154,6 +158,7 @@ _edi_mainview_content_text_create(const char *path, Evas_Object *parent)
|
|||
txt = elm_entry_add(parent);
|
||||
elm_entry_editable_set(txt, EINA_TRUE);
|
||||
elm_entry_scrollable_set(txt, EINA_TRUE);
|
||||
elm_entry_line_wrap_set(txt, EINA_FALSE);
|
||||
elm_entry_text_style_user_push(txt, "DEFAULT='font=Monospace font_size=12'");
|
||||
elm_entry_file_set(txt, path, ELM_TEXT_FORMAT_PLAIN_UTF8);
|
||||
elm_entry_autosave_set(txt, EDI_CONTENT_AUTOSAVE);
|
||||
|
@ -172,6 +177,7 @@ _edi_mainview_content_text_create(const char *path, Evas_Object *parent)
|
|||
evas_object_key_grab(txt, "Prior", ctrl, shift | alt, 1);
|
||||
evas_object_key_grab(txt, "Next", ctrl, shift | alt, 1);
|
||||
evas_object_key_grab(txt, "s", ctrl, shift | alt, 1);
|
||||
evas_object_key_grab(txt, "f", ctrl, shift | alt, 1);
|
||||
|
||||
return txt;
|
||||
}
|
||||
|
@ -516,6 +522,31 @@ edi_mainview_search()
|
|||
edi_editor_search(txt);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
edi_mainview_goto(int line)
|
||||
{
|
||||
Evas_Object *txt;
|
||||
Elm_Object_Item *it;
|
||||
Evas_Object *tb;
|
||||
Evas_Textblock_Cursor *mcur;
|
||||
Evas_Coord x, y, w, h;
|
||||
|
||||
it = elm_naviframe_top_item_get(nf);
|
||||
txt = elm_object_item_content_get(it);
|
||||
if (!txt || line <= 0)
|
||||
return;
|
||||
|
||||
tb = elm_entry_textblock_get(txt);
|
||||
mcur = evas_object_textblock_cursor_get(tb);
|
||||
|
||||
evas_textblock_cursor_line_set(mcur, line-1);
|
||||
elm_entry_cursor_geometry_get(txt, &x, &y, &w, &h);
|
||||
elm_scroller_region_show(txt, x, y, w, h);
|
||||
elm_entry_calc_force(txt);
|
||||
|
||||
elm_object_focus_set(txt, EINA_TRUE);
|
||||
}
|
||||
|
||||
EAPI void
|
||||
edi_mainview_add(Evas_Object *parent, Evas_Object *win)
|
||||
{
|
||||
|
|
|
@ -141,6 +141,15 @@ EAPI void edi_mainview_paste();
|
|||
*/
|
||||
EAPI void edi_mainview_search();
|
||||
|
||||
/**
|
||||
* Go to a requested line in the current view's contents.
|
||||
*
|
||||
* @param line the line number (1 based) to scroll to
|
||||
*
|
||||
* @ingroup Content
|
||||
*/
|
||||
EAPI void edi_mainview_goto(int line);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue