diff --git a/elm_code/src/lib/Elm_Code.h b/elm_code/src/lib/Elm_Code.h index 0df6bff..83d8d27 100644 --- a/elm_code/src/lib/Elm_Code.h +++ b/elm_code/src/lib/Elm_Code.h @@ -39,7 +39,6 @@ #include "elm_code_file.h" #include "elm_code_parse.h" #include "widget/elm_code_widget.eo.h" -#include "widget/elm_code_widget_text.h" #include "widget/elm_code_widget_selection.h" #include "elm_code_diff_widget.h" diff --git a/elm_code/src/lib/Makefile.am b/elm_code/src/lib/Makefile.am index e849f65..8d674f0 100644 --- a/elm_code/src/lib/Makefile.am +++ b/elm_code/src/lib/Makefile.am @@ -24,7 +24,6 @@ elm_code_text.h \ elm_code_file.h \ elm_code_parse.h \ widget/elm_code_widget.eo.h \ -widget/elm_code_widget_text.h \ widget/elm_code_widget_selection.h \ elm_code_diff_widget.h \ Elm_Code.h @@ -35,7 +34,6 @@ elm_code_line.c \ elm_code_text.c \ elm_code_file.c \ elm_code_parse.c \ -widget/elm_code_widget_text.c \ widget/elm_code_widget_tooltip.c \ widget/elm_code_widget_selection.c \ widget/elm_code_widget.c \ diff --git a/elm_code/src/lib/widget/elm_code_widget.c b/elm_code/src/lib/widget/elm_code_widget.c index b664516..fef9729 100644 --- a/elm_code/src/lib/widget/elm_code_widget.c +++ b/elm_code/src/lib/widget/elm_code_widget.c @@ -99,7 +99,7 @@ _elm_code_widget_resize(Elm_Code_Widget *widget) Elm_Code_Widget_Data *pd; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); - gutter = elm_code_widget_text_left_gutter_width_get(widget); + eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get()); if (!pd->code) return; @@ -170,7 +170,7 @@ _elm_code_widget_fill_line_tokens(Elm_Code_Widget *widget, Evas_Textgrid_Cell *c unsigned int token_start_col, token_end_col; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); - offset = elm_code_widget_text_left_gutter_width_get(widget); + eo_do(widget, offset = elm_code_widget_text_left_gutter_width_get()); start = offset; length = elm_code_line_text_column_width(line, pd->tabstop) + offset; @@ -203,7 +203,7 @@ _elm_code_widget_fill_gutter(Elm_Code_Widget *widget, Evas_Textgrid_Cell *cells, Elm_Code_Widget_Data *pd; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); - gutter = elm_code_widget_text_left_gutter_width_get(widget); + eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get()); evas_object_textgrid_size_get(pd->grid, &w, NULL); @@ -318,7 +318,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Elm_Code_Line *line) Elm_Code_Widget_Data *pd; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); - gutter = elm_code_widget_text_left_gutter_width_get(widget); + eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get()); evas_object_textgrid_size_get(pd->grid, &w, NULL); cells = evas_object_textgrid_cellrow_get(pd->grid, line->number - 1); @@ -371,7 +371,7 @@ _elm_code_widget_empty_line(Elm_Code_Widget *widget, unsigned int number) Elm_Code_Widget_Data *pd; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); - gutter = elm_code_widget_text_left_gutter_width_get(widget); + eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get()); evas_object_textgrid_size_get(pd->grid, &w, NULL); cells = evas_object_textgrid_cellrow_get(pd->grid, number - 1); @@ -524,13 +524,15 @@ _elm_code_widget_cursor_ensure_visible(Elm_Code_Widget *widget) Evas_Coord viewx, viewy, vieww, viewh, cellw, cellh; Evas_Coord curx, cury; Elm_Code_Widget_Data *pd; + int gutter; pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); elm_scroller_region_get(pd->scroller, &viewx, &viewy, &vieww, &viewh); evas_object_textgrid_cell_size_get(pd->grid, &cellw, &cellh); - curx = (pd->cursor_col + elm_code_widget_text_left_gutter_width_get(widget) - 1) * cellw; + eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get()); + curx = (pd->cursor_col + gutter - 1) * cellw; cury = (pd->cursor_line - 1) * cellh; if (curx >= viewx && cury >= viewy && curx + cellw <= viewx + vieww && cury + cellh <= viewy + viewh) @@ -574,7 +576,7 @@ _elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_W { Elm_Code_Line *line; Evas_Coord ox, oy, sx, sy; - int cw, ch; + int cw, ch, gutter; unsigned int number; evas_object_geometry_get(widget, &ox, &oy, NULL, NULL); @@ -583,9 +585,10 @@ _elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_W y = y + sy - oy; evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch); + eo_do(widget, gutter = elm_code_widget_text_left_gutter_width_get()); number = ((double) y / ch) + 1; if (col) - *col = ((double) x / cw) - elm_code_widget_text_left_gutter_width_get(widget) + 1; + *col = ((double) x / cw) - gutter + 1; if (row) *row = number; @@ -1393,4 +1396,5 @@ _elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd) _elm_code_widget_font_size_set(obj, pd, 10); } +#include "elm_code_widget_text.c" #include "elm_code_widget.eo.c" diff --git a/elm_code/src/lib/widget/elm_code_widget.eo b/elm_code/src/lib/widget/elm_code_widget.eo index ae7fdcf..38f1dbe 100644 --- a/elm_code/src/lib/widget/elm_code_widget.eo +++ b/elm_code/src/lib/widget/elm_code_widget.eo @@ -191,7 +191,15 @@ class Elm_Code_Widget (Elm_Layout, Elm_Interface_Atspi_Text) params { Elm_Code_Line *line; /*@ @in The line to test for visibility. */ } - return: bool (visible); /*@ true if the line specified is currently visible within the scroll region. */ + return: bool; /*@ true if the line specified is currently visible within the scroll region. */ + } + + /* text functions */ + text_left_gutter_width_get { + return: int; /*@ the current column width of the gutter for the widget. */ + } + text_line_number_width_get { + return: int; /*@ the column width required to represent the number of lines in the widget. */ } } implements { diff --git a/elm_code/src/lib/widget/elm_code_widget_text.c b/elm_code/src/lib/widget/elm_code_widget_text.c index c50ebce..696fc30 100644 --- a/elm_code/src/lib/widget/elm_code_widget_text.c +++ b/elm_code/src/lib/widget/elm_code_widget_text.c @@ -6,13 +6,11 @@ #include "elm_code_widget_private.h" -EAPI int -elm_code_widget_text_line_number_width_get(Elm_Code_Widget *widget) +static int +_elm_code_widget_text_line_number_width_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd) { - Elm_Code_Widget_Data *pd; int max; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); max = elm_code_file_lines_get(pd->code->file); if (max < 1) max = 1; @@ -20,19 +18,18 @@ elm_code_widget_text_line_number_width_get(Elm_Code_Widget *widget) return floor(log10(max)) + 1; } -EAPI int -elm_code_widget_text_left_gutter_width_get(Elm_Code_Widget *widget) +static int +_elm_code_widget_text_left_gutter_width_get(Eo *obj, Elm_Code_Widget_Data *pd) { - Elm_Code_Widget_Data *pd; + Elm_Code_Widget *widget; int width = 1; // the status icon, for now + widget = obj; if (!widget) return width; - pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS); - if (pd->show_line_numbers) - width += elm_code_widget_text_line_number_width_get(widget); + width += _elm_code_widget_text_line_number_width_get(widget, pd); return width; } diff --git a/elm_code/src/lib/widget/elm_code_widget_text.h b/elm_code/src/lib/widget/elm_code_widget_text.h deleted file mode 100644 index 5ac983e..0000000 --- a/elm_code/src/lib/widget/elm_code_widget_text.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef ELM_CODE_WIDGET_TEXT_H_ -# define ELM_CODE_WIDGET_TEXT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Text layout handling functions. - * @defgroup Managing the complexities of layout out text in an Elm_Code_Widget - * - * @{ - * - * Functions for text layout handling - * - */ - -EAPI int elm_code_widget_text_left_gutter_width_get(Elm_Code_Widget *widget); - -EAPI int elm_code_widget_text_line_number_width_get(Elm_Code_Widget *widget); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif /* ELM_CODE_WIDGET_TEXT_H_ */