editor: Add support for moving to file start/end.
Add API to mainview/mainview panel. Also add key combination for ctrl+home and ctrl+end.
This commit is contained in:
parent
5a3e9864fa
commit
3c4d9529b9
|
@ -911,6 +911,14 @@ _smart_cb_key_down(void *data EINA_UNUSED, Evas *e EINA_UNUSED,
|
||||||
{
|
{
|
||||||
edi_mainview_goto_popup_show();
|
edi_mainview_goto_popup_show();
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(ev->key, "Home"))
|
||||||
|
{
|
||||||
|
edi_mainview_goto_start();
|
||||||
|
}
|
||||||
|
else if (!strcmp(ev->key, "End"))
|
||||||
|
{
|
||||||
|
edi_mainview_goto_end();
|
||||||
|
}
|
||||||
else if (edi_language_provider_has(editor) && !strcmp(ev->key, "space"))
|
else if (edi_language_provider_has(editor) && !strcmp(ev->key, "space"))
|
||||||
{
|
{
|
||||||
_suggest_list_load(editor);
|
_suggest_list_load(editor);
|
||||||
|
|
|
@ -410,6 +410,22 @@ edi_mainview_goto(unsigned int number)
|
||||||
edi_mainview_panel_goto(_current_panel, number);
|
edi_mainview_panel_goto(_current_panel, number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_mainview_goto_start(void)
|
||||||
|
{
|
||||||
|
if (edi_mainview_is_empty()) return;
|
||||||
|
|
||||||
|
edi_mainview_panel_goto_start(_current_panel);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_mainview_goto_end(void)
|
||||||
|
{
|
||||||
|
if (edi_mainview_is_empty()) return;
|
||||||
|
|
||||||
|
edi_mainview_panel_goto_end(_current_panel);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
edi_mainview_goto_position(unsigned int row, unsigned int col)
|
edi_mainview_goto_position(unsigned int row, unsigned int col)
|
||||||
{
|
{
|
||||||
|
|
|
@ -221,6 +221,20 @@ void edi_mainview_search();
|
||||||
*/
|
*/
|
||||||
void edi_mainview_goto(unsigned int line);
|
void edi_mainview_goto(unsigned int line);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the beginning of the file in the current view.
|
||||||
|
*
|
||||||
|
* @ingroup Content
|
||||||
|
*/
|
||||||
|
void edi_mainview_goto_start(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the end of the file in the current view.
|
||||||
|
*
|
||||||
|
* @ingroup Content
|
||||||
|
*/
|
||||||
|
void edi_mainview_goto_end(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Go to a requested line, column position in the current view's contents.
|
* Go to a requested line, column position in the current view's contents.
|
||||||
*
|
*
|
||||||
|
|
|
@ -970,6 +970,68 @@ edi_mainview_panel_goto_position(Edi_Mainview_Panel *panel, unsigned int row, un
|
||||||
elm_object_focus_set(editor->entry, EINA_TRUE);
|
elm_object_focus_set(editor->entry, EINA_TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_mainview_panel_goto_end(Edi_Mainview_Panel *panel)
|
||||||
|
{
|
||||||
|
Edi_Editor *editor;
|
||||||
|
Elm_Code *code;
|
||||||
|
Elm_Code_Line *line;
|
||||||
|
const char *ch;
|
||||||
|
unsigned int row, tabstop, length = 0;
|
||||||
|
|
||||||
|
if (!panel || !panel->current)
|
||||||
|
return;
|
||||||
|
|
||||||
|
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
code = elm_code_widget_code_get(editor->entry);
|
||||||
|
if (!code) return;
|
||||||
|
|
||||||
|
row = elm_code_file_lines_get(code->file);
|
||||||
|
if (row <= 0) return;
|
||||||
|
|
||||||
|
line = elm_code_file_line_get(code->file, row);
|
||||||
|
if (!line) return;
|
||||||
|
|
||||||
|
tabstop = elm_code_widget_tabstop_get(editor->entry);
|
||||||
|
|
||||||
|
for (ch = line->content; *ch; ch++)
|
||||||
|
{
|
||||||
|
if (*ch == '\t')
|
||||||
|
length += tabstop;
|
||||||
|
else
|
||||||
|
length++;
|
||||||
|
}
|
||||||
|
|
||||||
|
elm_code_widget_cursor_position_set(editor->entry, elm_code_file_lines_get(code->file), length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
edi_mainview_panel_goto_start(Edi_Mainview_Panel *panel)
|
||||||
|
{
|
||||||
|
Edi_Editor *editor;
|
||||||
|
Elm_Code *code;
|
||||||
|
unsigned int row;
|
||||||
|
|
||||||
|
if (!panel || !panel->current)
|
||||||
|
return;
|
||||||
|
|
||||||
|
editor = (Edi_Editor *)evas_object_data_get(panel->current->view, "editor");
|
||||||
|
if (!editor)
|
||||||
|
return;
|
||||||
|
|
||||||
|
code = elm_code_widget_code_get(editor->entry);
|
||||||
|
if (!code) return;
|
||||||
|
|
||||||
|
row = elm_code_file_lines_get(code->file);
|
||||||
|
if (row <= 0) return;
|
||||||
|
|
||||||
|
elm_code_widget_cursor_position_set(editor->entry, 1, 1);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_edi_mainview_panel_goto_popup_go_cb(void *data,
|
_edi_mainview_panel_goto_popup_go_cb(void *data,
|
||||||
Evas_Object *obj EINA_UNUSED,
|
Evas_Object *obj EINA_UNUSED,
|
||||||
|
|
|
@ -319,6 +319,24 @@ void edi_mainview_panel_goto_popup_show();
|
||||||
*/
|
*/
|
||||||
unsigned int edi_mainview_panel_item_count(Edi_Mainview_Panel *panel);
|
unsigned int edi_mainview_panel_item_count(Edi_Mainview_Panel *panel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the beginning of the file in the panel's editor view.
|
||||||
|
*
|
||||||
|
* @param panel the mainview panel context
|
||||||
|
*
|
||||||
|
* @ingroup Content
|
||||||
|
*/
|
||||||
|
void edi_mainview_panel_goto_start(Edi_Mainview_Panel *panel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Go to the end of the file in the panel's editor view.
|
||||||
|
*
|
||||||
|
* @param panel the mainview panel context
|
||||||
|
*
|
||||||
|
* @ingroup Content
|
||||||
|
*/
|
||||||
|
void edi_mainview_panel_goto_end(Edi_Mainview_Panel *panel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue