panel: Fix mainview_goto_end()

Andy already added some of these APIs :)
This commit is contained in:
Alastair Poole 2020-04-29 10:29:50 +01:00
parent ecfbe9c608
commit 876101cf95
1 changed files with 2 additions and 16 deletions

View File

@ -976,8 +976,7 @@ edi_mainview_panel_goto_end(Edi_Mainview_Panel *panel)
Edi_Editor *editor; Edi_Editor *editor;
Elm_Code *code; Elm_Code *code;
Elm_Code_Line *line; Elm_Code_Line *line;
const char *ch; unsigned int row, length;
unsigned int row, tabstop, length = 0;
if (!panel || !panel->current) if (!panel || !panel->current)
return; return;
@ -989,26 +988,13 @@ edi_mainview_panel_goto_end(Edi_Mainview_Panel *panel)
code = elm_code_widget_code_get(editor->entry); code = elm_code_widget_code_get(editor->entry);
if (!code) return; if (!code) return;
tabstop = elm_code_widget_tabstop_get(editor->entry);
row = elm_code_file_lines_get(code->file); row = elm_code_file_lines_get(code->file);
if (row <= 0) return; if (row <= 0) return;
line = elm_code_file_line_get(code->file, row); line = elm_code_file_line_get(code->file, row);
if (!line) return; if (!line) return;
if (line->content) length = elm_code_widget_line_text_column_width_get(editor->entry, line) + 1;
{
for (ch = line->content; *ch; ch++)
{
if (*ch == '\t')
length += tabstop;
else
length++;
}
}
else
length = line->length;
elm_code_widget_cursor_position_set(editor->entry, elm_code_file_lines_get(code->file), length); elm_code_widget_cursor_position_set(editor->entry, elm_code_file_lines_get(code->file), length);
} }