elm_code: Update style and alignment of gutter
This commit is contained in:
parent
ff72fa0651
commit
c22f0d2a0a
|
@ -63,7 +63,6 @@ _elm_code_test_welcome_setup(Evas_Object *parent)
|
|||
elm_code_file_line_token_add(code->file, 1, 14, 21, ELM_CODE_TOKEN_TYPE_COMMENT);
|
||||
_append_line(code->file, "");
|
||||
_append_line(code->file, "This is a demo of elm_code's capabilities.");
|
||||
|
||||
_append_line(code->file, "*** Currently experimental ***");
|
||||
elm_code_file_line_status_set(code->file, 4, ELM_CODE_STATUS_TYPE_ERROR);
|
||||
|
||||
|
|
|
@ -26,12 +26,10 @@ typedef enum {
|
|||
ELM_CODE_TOKEN_TYPE_DEFAULT = ELM_CODE_STATUS_TYPE_COUNT,
|
||||
ELM_CODE_TOKEN_TYPE_COMMENT,
|
||||
|
||||
|
||||
ELM_CODE_TOKEN_TYPE_ADDED,
|
||||
ELM_CODE_TOKEN_TYPE_REMOVED,
|
||||
ELM_CODE_TOKEN_TYPE_CHANGED,
|
||||
|
||||
ELM_CODE_TOKEN_TYPE_CURSOR, // a pseudo type used for styling but may not be set on a cell
|
||||
ELM_CODE_TOKEN_TYPE_COUNT
|
||||
} Elm_Code_Token_Type;
|
||||
|
||||
|
|
|
@ -5,6 +5,14 @@
|
|||
#include <Elm_Code.h>
|
||||
#include "elm_code_private.h"
|
||||
|
||||
typedef enum {
|
||||
ELM_CODE_WIDGET_COLOR_GUTTER_BG = ELM_CODE_TOKEN_TYPE_COUNT,
|
||||
ELM_CODE_WIDGET_COLOR_GUTTER_FG,
|
||||
ELM_CODE_WIDGET_COLOR_CURSOR,
|
||||
|
||||
ELM_CODE_WIDGET_COLOR_COUNT
|
||||
} Elm_Code_Widget_Colors;
|
||||
|
||||
Eina_Unicode status_icons[] = {
|
||||
' ',
|
||||
'!',
|
||||
|
@ -146,22 +154,21 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Evas_Textgrid_Cell *cells, E
|
|||
length = line->length;
|
||||
evas_object_textgrid_size_get(pd->grid, &w, NULL);
|
||||
|
||||
cells[0].codepoint = status_icons[line->status];
|
||||
cells[0].bold = 1;
|
||||
cells[0].fg = ELM_CODE_TOKEN_TYPE_DEFAULT;
|
||||
cells[0].bg = line->status;
|
||||
cells[gutter-1].codepoint = status_icons[line->status];
|
||||
cells[gutter-1].bold = 1;
|
||||
cells[gutter-1].fg = ELM_CODE_WIDGET_COLOR_GUTTER_FG;
|
||||
cells[gutter-1].bg = (line->status == ELM_CODE_STATUS_TYPE_DEFAULT) ? ELM_CODE_WIDGET_COLOR_GUTTER_BG : line->status;
|
||||
|
||||
if (pd->show_line_numbers)
|
||||
{
|
||||
number = malloc(sizeof(char) * gutter);
|
||||
snprintf(number, gutter, "%d", line->number);
|
||||
snprintf(number, gutter, "%*d", gutter - 1, line->number);
|
||||
|
||||
for (g = 1; g < gutter; g++)
|
||||
for (g = 0; g < gutter - 1; g++)
|
||||
{
|
||||
// TODO style this properly
|
||||
cells[g].codepoint = (g == gutter - 1) ? '|' : *(number + g - 1);
|
||||
cells[g].fg = ELM_CODE_TOKEN_TYPE_DEFAULT;
|
||||
cells[g].bg = ELM_CODE_STATUS_TYPE_DEFAULT;
|
||||
cells[g].codepoint = *(number + g);
|
||||
cells[g].fg = ELM_CODE_WIDGET_COLOR_GUTTER_FG;
|
||||
cells[g].bg = ELM_CODE_WIDGET_COLOR_GUTTER_BG;
|
||||
}
|
||||
free(number);
|
||||
}
|
||||
|
@ -187,7 +194,7 @@ _elm_code_widget_fill_line(Elm_Code_Widget *widget, Evas_Textgrid_Cell *cells, E
|
|||
if (pd->editable && pd->focussed && pd->cursor_line == line->number)
|
||||
{
|
||||
if (pd->cursor_col + gutter - 1 < (unsigned int) w)
|
||||
cells[pd->cursor_col + gutter - 1].bg = ELM_CODE_TOKEN_TYPE_CURSOR;
|
||||
cells[pd->cursor_col + gutter - 1].bg = ELM_CODE_WIDGET_COLOR_CURSOR;
|
||||
}
|
||||
|
||||
evas_object_textgrid_update_add(pd->grid, 0, line->number - 1, w, 1);
|
||||
|
@ -623,9 +630,13 @@ _elm_code_widget_setup_palette(Evas_Object *o)
|
|||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED,
|
||||
54, 54, 255, 255);
|
||||
|
||||
// the style for a cursor - this is a special token and will be applied to the background
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CURSOR,
|
||||
// other styles that the widget uses
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_CURSOR,
|
||||
205, 205, 54, 255);
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_GUTTER_BG,
|
||||
75, 75, 75, 255);
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_WIDGET_COLOR_GUTTER_FG,
|
||||
139, 139, 139, 255);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
|
|
|
@ -29,7 +29,7 @@ elm_code_widget_text_left_gutter_width_get(Elm_Code_Widget *widget)
|
|||
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) + 1;
|
||||
width += elm_code_widget_text_line_number_width_get(widget);
|
||||
|
||||
return width;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue