Adding some initial concept of status flags for a line and default enum to start working on color pallette in our widget. Load enough colors to provide these statuses and hook into the EDI log panel implementation

This commit is contained in:
Andy Williams 2014-11-05 00:01:28 +00:00
parent 80373debf7
commit 87d360b43f
4 changed files with 45 additions and 12 deletions

View File

@ -3,6 +3,21 @@
#include <Eina.h>
typedef enum {
ELM_CODE_STATUS_TYPE_DEFAULT = 0,
ELM_CODE_STATUS_TYPE_ERROR,
ELM_CODE_STATUS_TYPE_COUNT
} Elm_Code_Status_Type;
typedef enum {
ELM_CODE_TOKEN_TYPE_DEFAULT = ELM_CODE_STATUS_TYPE_COUNT,
ELM_CODE_TOKEN_TYPE_COUNT
} Elm_Code_Token_Type;
#include "elm_code_file.h"
#ifdef __cplusplus

View File

@ -15,6 +15,7 @@ static Elm_Code_Line *_elm_code_blank_create(int line)
if (!ecl) return NULL;
ecl->number = line;
ecl->status = ELM_CODE_STATUS_TYPE_DEFAULT;
return ecl;
}
@ -120,12 +121,16 @@ EAPI void elm_code_file_line_append(Elm_Code_File *file, const char *line)
_elm_code_file_line_append_data(file, line, strlen(line), row+1);
}
EAPI char *elm_code_file_line_content_get(Elm_Code_File *file, int number)
EAPI Elm_Code_Line *elm_code_file_line_get(Elm_Code_File *file, unsigned int number)
{
return eina_list_nth(file->lines, number - 1);
}
EAPI char *elm_code_file_line_content_get(Elm_Code_File *file, unsigned int number)
{
Elm_Code_Line *line;
line = eina_list_nth(file->lines, number - 1);
printf("N %d\n", number);
line = elm_code_file_line_get(file, number);
if (!line)
return NULL;

View File

@ -3,6 +3,8 @@
#include <Eina.h>
#include "elm_code_common.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -17,6 +19,8 @@ typedef struct _Elm_Code_Line
char *content;
unsigned int number;
Elm_Code_Status_Type status;
} Elm_Code_Line;
typedef struct _Elm_Code_File
@ -64,7 +68,9 @@ EAPI unsigned int elm_code_file_lines_get(Elm_Code_File *file);
EAPI void elm_code_file_line_append(Elm_Code_File *file, const char *line);
EAPI char *elm_code_file_line_content_get(Elm_Code_File *file, int line);
EAPI Elm_Code_Line *elm_code_file_line_get(Elm_Code_File *file, unsigned int line);
EAPI char *elm_code_file_line_content_get(Elm_Code_File *file, unsigned int line);
/**
* @}

View File

@ -10,8 +10,9 @@
EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code)
{
Elm_Code_Line *line;
Evas_Textgrid_Cell *cells;
const char *line, *chr;
const char *content, *chr;
unsigned int length;
int w, h, cw, ch;
unsigned int x, y;
@ -24,17 +25,18 @@ EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code)
for (y = 1; y <= elm_code_file_lines_get(code->file); y++)
{
line = elm_code_file_line_content_get(code->file, y);
chr = line;
line = elm_code_file_line_get(code->file, y);
content = elm_code_file_line_content_get(code->file, y);
chr = content;
cells = evas_object_textgrid_cellrow_get(o, y - 1);
length = strlen(line);
length = strlen(content);
for (x = 0; x < (unsigned int) w && x < length; x++)
{
cells[x].codepoint = *chr;
cells[x].bg = 0;
cells[x].fg = 1;
cells[x].bg = line->status;
cells[x].fg = ELM_CODE_TOKEN_TYPE_DEFAULT;
chr++;
}
@ -59,9 +61,14 @@ EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code)
evas_object_textgrid_font_set(o, "Mono", 10 * elm_config_scale_get());
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, 0,
// setup status colors
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT,
54, 54, 54, 255);
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, 1,
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_ERROR,
205, 54, 54, 255);
// setup token colors
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_DEFAULT,
205, 205, 205, 255);
evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, code);