forked from enlightenment/edi
Merge in the new elm_code widget.
This provides the new eo API and handles focus and a cursor now too!
This commit is contained in:
commit
66b79dd0e2
10
configure.ac
10
configure.ac
|
@ -84,6 +84,14 @@ EFL_CHECK_DOXYGEN([build_doc="yes"], [build_doc="no"])
|
|||
|
||||
# Check edje_cc
|
||||
EFL_WITH_BIN([edje], [edje-cc], [edje_cc])
|
||||
EFL_WITH_BIN([eolian], [eolian-gen], [eolian_gen])
|
||||
# Force the helper to try external eolian generators
|
||||
AM_CONDITIONAL([HAVE_EOLIAN_GEN], [true])
|
||||
|
||||
# Needs to be moved into a macro, and also, needs a way to automatically fetch
|
||||
# from all the dependencies using the Requires.
|
||||
DEPS_EOLIAN_FLAGS=`${PKG_CONFIG} --variable=eolian_flags eo evas edje ecore efl`
|
||||
AC_SUBST([DEPS_EOLIAN_FLAGS])
|
||||
|
||||
# Checks for library functions.
|
||||
AC_CHECK_FUNCS([setlocale])
|
||||
|
@ -127,6 +135,8 @@ echo " CFLAGS.................: $CFLAGS"
|
|||
echo " edje_cc................: ${edje_cc}"
|
||||
echo " highlighting (libclang): ${build_clang}"
|
||||
echo
|
||||
echo "eolian_gen...............: ${eolian_gen}"
|
||||
echo
|
||||
echo "Building documentation...: ${build_doc}"
|
||||
echo "Building tests...........: ${have_tests}"
|
||||
echo "Generate coverage .......: ${have_lcov}"
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "gettext.h"
|
||||
|
||||
#include <Elm_Code.h>
|
||||
#include "elm_code_widget.eo.h"
|
||||
|
||||
#include "elm_code_test_private.h"
|
||||
|
||||
|
@ -47,12 +48,15 @@ static Evas_Object *
|
|||
_elm_code_test_welcome_setup(Evas_Object *parent)
|
||||
{
|
||||
Elm_Code *code;
|
||||
Evas_Object *widget;
|
||||
Elm_Code_Widget *widget;
|
||||
|
||||
code = elm_code_create();
|
||||
widget = elm_code_widget_add(parent, code);
|
||||
elm_code_widget_font_size_set(widget, 14);
|
||||
eo_do(widget,eo_event_callback_add(&ELM_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code));
|
||||
widget = eo_add(ELM_CODE_WIDGET_CLASS, parent);
|
||||
eo_do(widget,
|
||||
elm_code_widget_code_set(code);
|
||||
elm_code_widget_font_size_set(14);
|
||||
elm_code_widget_editable_set(EINA_TRUE);
|
||||
eo_event_callback_add(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, _elm_code_test_line_cb, code));
|
||||
|
||||
_append_line(code->file, "Hello World, Elm Code!");
|
||||
elm_code_file_line_token_add(code->file, 1, 14, 21, ELM_CODE_TOKEN_TYPE_COMMENT);
|
||||
|
@ -88,8 +92,7 @@ _elm_code_test_diff_setup(Evas_Object *parent)
|
|||
static Evas_Object *
|
||||
elm_code_test_win_setup(void)
|
||||
{
|
||||
Evas_Object *win;
|
||||
Evas_Object *vbox;
|
||||
Evas_Object *win,*vbox;
|
||||
|
||||
win = elm_win_util_standard_add("main", "Elm_Code Test");
|
||||
if (!win) return NULL;
|
||||
|
@ -100,15 +103,11 @@ elm_code_test_win_setup(void)
|
|||
elm_box_homogeneous_set(vbox, EINA_TRUE);
|
||||
evas_object_show(vbox);
|
||||
|
||||
elm_win_focus_highlight_enabled_set(win, EINA_TRUE);
|
||||
evas_object_smart_callback_add(win, "delete,request", _elm_code_test_win_del, NULL);
|
||||
|
||||
elm_box_pack_end(vbox, _elm_code_test_welcome_setup(vbox));
|
||||
|
||||
elm_box_pack_end(vbox, _elm_code_test_diff_setup(vbox));
|
||||
|
||||
elm_win_resize_object_add(win, vbox);
|
||||
|
||||
evas_object_smart_callback_add(win, "delete,request", _elm_code_test_win_del, NULL);
|
||||
evas_object_resize(win, 380 * elm_config_scale_get(), 240 * elm_config_scale_get());
|
||||
evas_object_show(win);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include "elm_code_common.h"
|
||||
#include "elm_code_file.h"
|
||||
#include "elm_code_parse.h"
|
||||
#include "elm_code_widget.h"
|
||||
#include "elm_code_widget.eo.h"
|
||||
#include "elm_code_diff_widget.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -3,6 +3,7 @@ MAINTAINERCLEANFILES = Makefile.in
|
|||
AM_CPPFLAGS = \
|
||||
-I$(top_srcdir)/elm_code/lib \
|
||||
-DEFL_BETA_API_SUPPORT \
|
||||
-DEFL_EO_API_SUPPORT \
|
||||
@EFL_CFLAGS@ \
|
||||
-DEFL_ELM_CODE_BUILD
|
||||
|
||||
|
@ -11,7 +12,7 @@ lib_LTLIBRARIES = libelm_code.la
|
|||
includes_HEADERS = \
|
||||
elm_code_file.h \
|
||||
elm_code_parse.h \
|
||||
elm_code_widget.h \
|
||||
elm_code_widget.eo.h \
|
||||
elm_code_diff_widget.h \
|
||||
Elm_Code.h
|
||||
includesdir = $(includedir)/edi-@VMAJ@
|
||||
|
@ -23,5 +24,6 @@ elm_code_widget.c \
|
|||
elm_code_diff_widget.c \
|
||||
elm_code.c \
|
||||
elm_code_private.h
|
||||
|
||||
libelm_code_la_LIBADD = @EFL_LIBS@ -lm
|
||||
libelm_code_la_LDFLAGS = -no-undefined @EFL_LTLIBRARY_FLAGS@
|
||||
|
|
|
@ -105,7 +105,7 @@ EAPI void
|
|||
elm_code_callback_fire(Elm_Code *code, const Eo_Event_Description *signal, void *data)
|
||||
{
|
||||
Eina_List *item;
|
||||
Evas_Object *widget;
|
||||
Eo *widget;
|
||||
|
||||
EINA_LIST_FOREACH(code->widgets, item, widget)
|
||||
{
|
||||
|
|
|
@ -31,6 +31,7 @@ typedef enum {
|
|||
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;
|
||||
|
||||
|
|
|
@ -80,7 +80,8 @@ static void _elm_code_diff_widget_parse_diff(Elm_Code_File *diff, Elm_Code_File
|
|||
EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
|
||||
{
|
||||
Elm_Code *wcode1, *wcode2;
|
||||
Evas_Object *widget_left, *widget_right, *hbox;
|
||||
Elm_Code_Widget *widget_left, *widget_right;
|
||||
Evas_Object *hbox;
|
||||
|
||||
hbox = elm_panes_add(parent);
|
||||
evas_object_size_hint_weight_set(hbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
|
@ -90,7 +91,9 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
|
|||
|
||||
// left side of diff
|
||||
wcode1 = elm_code_create();
|
||||
widget_left = elm_code_widget_add(parent, wcode1);
|
||||
widget_left = eo_add(ELM_CODE_WIDGET_CLASS, parent);
|
||||
eo_do(widget_left,
|
||||
elm_code_widget_code_set(wcode1));
|
||||
|
||||
evas_object_size_hint_weight_set(widget_left, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(widget_left, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
@ -100,7 +103,9 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
|
|||
|
||||
// right side of diff
|
||||
wcode2 = elm_code_create();
|
||||
widget_right = elm_code_widget_add(parent, wcode2);
|
||||
widget_right = eo_add(ELM_CODE_WIDGET_CLASS, parent);
|
||||
eo_do(widget_right,
|
||||
elm_code_widget_code_set(wcode2));
|
||||
|
||||
evas_object_size_hint_weight_set(widget_right, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(widget_right, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
@ -114,11 +119,11 @@ EAPI Evas_Object *elm_code_diff_widget_add(Evas_Object *parent, Elm_Code *code)
|
|||
|
||||
EAPI void elm_code_diff_widget_font_size_set(Evas_Object *widget, int size)
|
||||
{
|
||||
Evas_Object *child;
|
||||
Elm_Code_Widget *child;
|
||||
|
||||
child = evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_LEFT);
|
||||
elm_code_widget_font_size_set(child, size);
|
||||
child = evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_RIGHT);
|
||||
elm_code_widget_font_size_set(child, size);
|
||||
child = (Elm_Code_Widget *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_LEFT);
|
||||
eo_do(child, elm_code_widget_font_size_set(size));
|
||||
child = (Elm_Code_Widget *) evas_object_data_get(widget, ELM_CODE_DIFF_WIDGET_RIGHT);
|
||||
eo_do(child, elm_code_widget_font_size_set(size));
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,25 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "Elm_Code.h"
|
||||
#include <Eo.h>
|
||||
#include <Evas.h>
|
||||
#include <Elementary.h>
|
||||
#define ELM_INTERNAL_API_ARGESFSDFEFC
|
||||
#include <elm_widget.h>
|
||||
|
||||
#include <Elm_Code.h>
|
||||
#include "elm_code_widget.eo.h"
|
||||
#include "elm_code_private.h"
|
||||
|
||||
EAPI const Eo_Event_Description ELM_CODE_WIDGET_EVENT_LINE_CLICKED =
|
||||
EO_EVENT_DESCRIPTION("line,clicked", "");
|
||||
typedef struct
|
||||
{
|
||||
Elm_Code *code;
|
||||
Evas_Object *grid;
|
||||
|
||||
Evas_Font_Size font_size;
|
||||
unsigned int cursor_line, cursor_col;
|
||||
Eina_Bool editable, focussed;
|
||||
} Elm_Code_Widget_Data;
|
||||
|
||||
Eina_Unicode status_icons[] = {
|
||||
' ',
|
||||
|
@ -23,19 +36,38 @@ Eina_Unicode status_icons[] = {
|
|||
0
|
||||
};
|
||||
|
||||
static Eina_Bool _elm_code_widget_resize(Evas_Object *o)
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_eo_base_constructor(Eo *obj, Elm_Code_Widget_Data *pd EINA_UNUSED)
|
||||
{
|
||||
eo_do_super(obj, ELM_CODE_WIDGET_CLASS, eo_constructor());
|
||||
|
||||
pd->cursor_line = 1;
|
||||
pd->cursor_col = 1;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_class_constructor(Eo_Class *klass EINA_UNUSED)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_elm_code_widget_resize(Evas_Object *o)
|
||||
{
|
||||
int w, h, cw, ch;
|
||||
|
||||
evas_object_geometry_get(o, NULL, NULL, &w, &h);
|
||||
evas_object_textgrid_cell_size_get(o, &cw, &ch);
|
||||
|
||||
evas_object_textgrid_size_set(o, ceil(((double) w) / cw),
|
||||
ceil(((double) h) / ch));
|
||||
|
||||
return h > 0 && w > 0;
|
||||
}
|
||||
|
||||
static void _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start, int end, Elm_Code_Token_Type type)
|
||||
static void
|
||||
_elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int count, int start, int end, Elm_Code_Token_Type type)
|
||||
{
|
||||
int x;
|
||||
|
||||
|
@ -45,7 +77,8 @@ static void _elm_code_widget_fill_line_token(Evas_Textgrid_Cell *cells, int coun
|
|||
}
|
||||
}
|
||||
|
||||
EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, int count, Elm_Code_Line *line)
|
||||
static void
|
||||
_elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, unsigned int count, Elm_Code_Line *line)
|
||||
{
|
||||
Eina_List *item;
|
||||
Elm_Code_Token *token;
|
||||
|
@ -68,17 +101,18 @@ EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, int count,
|
|||
_elm_code_widget_fill_line_token(cells, count, start, length, ELM_CODE_TOKEN_TYPE_DEFAULT);
|
||||
}
|
||||
|
||||
static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells, Elm_Code_Line *line)
|
||||
static void
|
||||
_elm_code_widget_fill_line(Elm_Code_Widget_Data *pd, Evas_Textgrid_Cell *cells, Elm_Code_Line *line)
|
||||
{
|
||||
char *chr;
|
||||
unsigned int length, x;
|
||||
int w;
|
||||
|
||||
if (!_elm_code_widget_resize(o))
|
||||
if (!_elm_code_widget_resize(pd->grid))
|
||||
return;
|
||||
|
||||
length = line->length;
|
||||
evas_object_textgrid_size_get(o, &w, NULL);
|
||||
evas_object_textgrid_size_get(pd->grid, &w, NULL);
|
||||
|
||||
cells[0].codepoint = status_icons[line->status];
|
||||
cells[0].bold = 1;
|
||||
|
@ -102,112 +136,319 @@ static void _elm_code_widget_fill_line(Evas_Object *o, Evas_Textgrid_Cell *cells
|
|||
cells[x].bg = line->status;
|
||||
}
|
||||
|
||||
elm_code_widget_fill_line_tokens(cells, w, line);
|
||||
_elm_code_widget_fill_line_tokens(cells, w, line);
|
||||
if (pd->editable && pd->focussed && pd->cursor_line == line->number)
|
||||
{
|
||||
if (pd->cursor_col < (unsigned int) w)
|
||||
cells[pd->cursor_col].bg = ELM_CODE_TOKEN_TYPE_CURSOR;
|
||||
}
|
||||
|
||||
evas_object_textgrid_update_add(o, 0, line->number - 1, w, 1);
|
||||
evas_object_textgrid_update_add(pd->grid, 0, line->number - 1, w, 1);
|
||||
}
|
||||
|
||||
EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code)
|
||||
static void
|
||||
_elm_code_widget_fill(Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
Elm_Code_Line *line;
|
||||
Evas_Textgrid_Cell *cells;
|
||||
int w, h;
|
||||
unsigned int y;
|
||||
|
||||
if (!_elm_code_widget_resize(o))
|
||||
if (!_elm_code_widget_resize(pd->grid))
|
||||
return;
|
||||
evas_object_textgrid_size_get(o, &w, &h);
|
||||
evas_object_textgrid_size_get(pd->grid, &w, &h);
|
||||
|
||||
for (y = 1; y <= (unsigned int) h && y <= elm_code_file_lines_get(code->file); y++)
|
||||
for (y = 1; y <= (unsigned int) h && y <= elm_code_file_lines_get(pd->code->file); y++)
|
||||
{
|
||||
line = elm_code_file_line_get(code->file, y);
|
||||
line = elm_code_file_line_get(pd->code->file, y);
|
||||
|
||||
cells = evas_object_textgrid_cellrow_get(o, y - 1);
|
||||
_elm_code_widget_fill_line(o, cells, line);
|
||||
cells = evas_object_textgrid_cellrow_get(pd->grid, y - 1);
|
||||
_elm_code_widget_fill_line(pd, cells, line);
|
||||
}
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_elm_code_widget_line_cb(void *data EINA_UNUSED, Eo *obj,
|
||||
_elm_code_widget_line_cb(void *data, Eo *obj EINA_UNUSED,
|
||||
const Eo_Event_Description *desc EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Elm_Code_Widget_Data *widget;
|
||||
Elm_Code_Line *line;
|
||||
Evas_Object *o;
|
||||
int h;
|
||||
|
||||
Evas_Textgrid_Cell *cells;
|
||||
|
||||
widget = (Elm_Code_Widget_Data *)data;
|
||||
line = (Elm_Code_Line *)event_info;
|
||||
o = (Evas_Object *)obj;
|
||||
|
||||
evas_object_textgrid_size_get(o, NULL, &h);
|
||||
evas_object_textgrid_size_get(widget->grid, NULL, &h);
|
||||
|
||||
if (line->number > (unsigned int) h)
|
||||
return EINA_TRUE;
|
||||
|
||||
cells = evas_object_textgrid_cellrow_get(o, line->number - 1);
|
||||
_elm_code_widget_fill_line(o, cells, line);
|
||||
cells = evas_object_textgrid_cellrow_get(widget->grid, line->number - 1);
|
||||
_elm_code_widget_fill_line(widget, cells, line);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
_elm_code_widget_file_cb(void *data, Eo *obj, const Eo_Event_Description *desc EINA_UNUSED,
|
||||
_elm_code_widget_file_cb(void *data, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *o;
|
||||
Elm_Code *code;
|
||||
Elm_Code_Widget_Data *widget;
|
||||
|
||||
code = (Elm_Code *)data;
|
||||
o = (Evas_Object *)obj;
|
||||
widget = (Elm_Code_Widget_Data *)data;
|
||||
|
||||
elm_code_widget_fill(o, code);
|
||||
_elm_code_widget_fill(widget);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
||||
_elm_code_widget_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Elm_Code *code;
|
||||
Elm_Code_Widget_Data *widget;
|
||||
|
||||
code = (Elm_Code *)data;
|
||||
widget = (Elm_Code_Widget_Data *)data;
|
||||
|
||||
elm_code_widget_fill(obj, code);
|
||||
_elm_code_widget_fill(widget);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
||||
void *event_info)
|
||||
_elm_code_widget_clicked_editable_cb(Elm_Code_Widget *widget, Evas_Coord x, Evas_Coord y)
|
||||
{
|
||||
Elm_Code *code;
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
int cw, ch;
|
||||
unsigned int row, col;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
evas_object_textgrid_cell_size_get(pd->grid, &cw, &ch);
|
||||
col = ((double) x / cw) + 2;
|
||||
row = ((double) y / ch) + 1;
|
||||
|
||||
line = elm_code_file_line_get(pd->code->file, row);
|
||||
if (line)
|
||||
{
|
||||
pd->cursor_line = row;
|
||||
|
||||
if (col <= (unsigned int) line->length + 2)
|
||||
pd->cursor_col = col - 2;
|
||||
else
|
||||
pd->cursor_col = line->length + 1;
|
||||
}
|
||||
if (pd->cursor_col == 0)
|
||||
pd->cursor_col = 1;
|
||||
|
||||
_elm_code_widget_fill(pd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_clicked_readonly_cb(Elm_Code_Widget *widget, Evas_Coord y)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
Evas_Event_Mouse_Up *event;
|
||||
Evas_Coord y;
|
||||
int ch;
|
||||
unsigned int row;
|
||||
|
||||
code = (Elm_Code *)data;
|
||||
event = (Evas_Event_Mouse_Up *)event_info;
|
||||
y = event->canvas.y;
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
evas_object_textgrid_cell_size_get(obj, NULL, &ch);
|
||||
evas_object_textgrid_cell_size_get(pd->grid, NULL, &ch);
|
||||
row = ((double) y / ch) + 1;
|
||||
|
||||
line = elm_code_file_line_get(code->file, row);
|
||||
line = elm_code_file_line_get(pd->code->file, row);
|
||||
if (line)
|
||||
elm_code_callback_fire(code, &ELM_CODE_WIDGET_EVENT_LINE_CLICKED, line);
|
||||
eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, line));
|
||||
}
|
||||
|
||||
EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code)
|
||||
static void
|
||||
_elm_code_widget_clicked_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Evas_Object *o;
|
||||
Elm_Code_Widget *widget;
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Evas_Event_Mouse_Up *event;
|
||||
Evas_Coord x, y;
|
||||
|
||||
o = evas_object_textgrid_add(parent);
|
||||
widget = (Elm_Code_Widget *)data;
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
event = (Evas_Event_Mouse_Up *)event_info;
|
||||
|
||||
elm_code_widget_font_size_set(o, 10);
|
||||
x = event->canvas.x;
|
||||
y = event->canvas.y;
|
||||
|
||||
if (pd->editable)
|
||||
_elm_code_widget_clicked_editable_cb(widget, x, y);
|
||||
else
|
||||
_elm_code_widget_clicked_readonly_cb(widget, y);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_cursor_move_up(Elm_Code_Widget *widget)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
if (pd->cursor_line > 1)
|
||||
pd->cursor_line--;
|
||||
|
||||
line = elm_code_file_line_get(pd->code->file, pd->cursor_line);
|
||||
if (pd->cursor_col > (unsigned int) line->length + 1)
|
||||
pd->cursor_col = line->length + 1;
|
||||
|
||||
_elm_code_widget_fill(pd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_cursor_move_down(Elm_Code_Widget *widget)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
if (pd->cursor_line < elm_code_file_lines_get(pd->code->file))
|
||||
pd->cursor_line++;
|
||||
|
||||
line = elm_code_file_line_get(pd->code->file, pd->cursor_line);
|
||||
if (pd->cursor_col > (unsigned int) line->length + 1)
|
||||
pd->cursor_col = line->length + 1;
|
||||
|
||||
_elm_code_widget_fill(pd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_cursor_move_left(Elm_Code_Widget *widget)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
if (pd->cursor_col > 1)
|
||||
pd->cursor_col--;
|
||||
|
||||
_elm_code_widget_fill(pd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_cursor_move_right(Elm_Code_Widget *widget)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
line = elm_code_file_line_get(pd->code->file, pd->cursor_line);
|
||||
if (pd->cursor_col <= (unsigned int) line->length)
|
||||
pd->cursor_col++;
|
||||
|
||||
_elm_code_widget_fill(pd);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_key_down_cb(void *data, Evas *evas EINA_UNUSED,
|
||||
Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Elm_Code_Widget *widget;
|
||||
|
||||
widget = (Elm_Code_Widget *)data;
|
||||
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
|
||||
if (!strcmp(ev->key, "Up"))
|
||||
_elm_code_widget_cursor_move_up(widget);
|
||||
else if (!strcmp(ev->key, "Down"))
|
||||
_elm_code_widget_cursor_move_down(widget);
|
||||
else if (!strcmp(ev->key, "Left"))
|
||||
_elm_code_widget_cursor_move_left(widget);
|
||||
else if (!strcmp(ev->key, "Right"))
|
||||
_elm_code_widget_cursor_move_right(widget);
|
||||
else
|
||||
INF("Unhandled key %s", ev->key);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_elm_code_widget_event_veto_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
Evas_Object *src EINA_UNUSED, Evas_Callback_Type type,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Eina_Bool veto = EINA_FALSE;
|
||||
|
||||
// TODO determine if we should allow up/down to be sent to our focus manager
|
||||
if (type == EVAS_CALLBACK_KEY_DOWN)
|
||||
veto = EINA_TRUE;
|
||||
|
||||
return veto;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_code_widget_elm_widget_on_focus(Eo *obj, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
Eina_Bool int_ret = EINA_FALSE;
|
||||
eo_do_super(obj, ELM_CODE_WIDGET_CLASS, int_ret = elm_obj_widget_on_focus());
|
||||
if (!int_ret) return EINA_TRUE;
|
||||
|
||||
pd->focussed = elm_widget_focus_get(obj);
|
||||
|
||||
_elm_code_widget_fill(pd);
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_elm_interface_scrollable_content_pos_set(Eo *obj EINA_UNUSED,
|
||||
Elm_Code_Widget_Data *pd EINA_UNUSED,
|
||||
Evas_Coord x, Evas_Coord y,
|
||||
Eina_Bool sig EINA_UNUSED)
|
||||
{
|
||||
printf("scroll to %d, %d\n", x, y);
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_font_size_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Evas_Font_Size font_size)
|
||||
{
|
||||
evas_object_textgrid_font_set(pd->grid, "Mono", font_size * elm_config_scale_get());
|
||||
pd->font_size = font_size;
|
||||
}
|
||||
|
||||
EOLIAN static Evas_Font_Size
|
||||
_elm_code_widget_font_size_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
return pd->font_size;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_code_set(Eo *obj, Elm_Code_Widget_Data *pd EINA_UNUSED, Elm_Code *code)
|
||||
{
|
||||
pd->code = code;
|
||||
|
||||
code->widgets = eina_list_append(code->widgets, obj);
|
||||
}
|
||||
|
||||
EOLIAN static Elm_Code *
|
||||
_elm_code_widget_code_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
return pd->code;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_elm_code_widget_editable_set(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd, Eina_Bool editable)
|
||||
{
|
||||
pd->editable = editable;
|
||||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_elm_code_widget_editable_get(Eo *obj EINA_UNUSED, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
return pd->editable;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_setup_palette(Evas_Object *o)
|
||||
{
|
||||
// setup status colors
|
||||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_STATUS_TYPE_DEFAULT,
|
||||
36, 36, 36, 255);
|
||||
|
@ -239,18 +480,44 @@ EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code)
|
|||
evas_object_textgrid_palette_set(o, EVAS_TEXTGRID_PALETTE_STANDARD, ELM_CODE_TOKEN_TYPE_CHANGED,
|
||||
54, 54, 255, 255);
|
||||
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, code);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget_clicked_cb, code);
|
||||
|
||||
eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, code));
|
||||
eo_do(o,eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, code));
|
||||
|
||||
code->widgets = eina_list_append(code->widgets, o);
|
||||
return o;
|
||||
// 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,
|
||||
205, 205, 54, 255);
|
||||
}
|
||||
|
||||
EAPI void elm_code_widget_font_size_set(Evas_Object *widget, int size)
|
||||
EOLIAN static void
|
||||
_elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd)
|
||||
{
|
||||
evas_object_textgrid_font_set(widget, "Mono", size * elm_config_scale_get());
|
||||
Evas_Object *grid, *scroller;
|
||||
|
||||
eo_do_super(obj, ELM_CODE_WIDGET_CLASS, evas_obj_smart_add());
|
||||
elm_object_focus_allow_set(obj, EINA_TRUE);
|
||||
|
||||
scroller = elm_scroller_add(obj);
|
||||
evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(scroller);
|
||||
elm_box_pack_end(obj, scroller);
|
||||
|
||||
grid = evas_object_textgrid_add(obj);
|
||||
evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(grid);
|
||||
elm_object_content_set(scroller, grid);
|
||||
pd->grid = grid;
|
||||
_elm_code_widget_setup_palette(grid);
|
||||
|
||||
evas_object_event_callback_add(grid, EVAS_CALLBACK_RESIZE, _elm_code_widget_resize_cb, pd);
|
||||
evas_object_event_callback_add(grid, EVAS_CALLBACK_MOUSE_UP, _elm_code_widget_clicked_cb, obj);
|
||||
evas_object_event_callback_add(obj, EVAS_CALLBACK_KEY_DOWN, _elm_code_widget_key_down_cb, obj);
|
||||
|
||||
elm_object_event_callback_add(obj, _elm_code_widget_event_veto_cb, obj);
|
||||
|
||||
eo_do(obj,
|
||||
eo_event_callback_add(&ELM_CODE_EVENT_LINE_SET_DONE, _elm_code_widget_line_cb, pd);
|
||||
eo_event_callback_add(&ELM_CODE_EVENT_FILE_LOAD_DONE, _elm_code_widget_file_cb, pd));
|
||||
|
||||
_elm_code_widget_font_size_set(obj, pd, 10);
|
||||
}
|
||||
|
||||
#include "elm_code_widget.eo.c"
|
||||
|
|
|
@ -0,0 +1,80 @@
|
|||
class Elm_Code_Widget (Elm_Box, Elm_Interface_Scrollable,
|
||||
Elm_Interface_Atspi_Text)
|
||||
{
|
||||
eo_prefix: elm_code_widget;
|
||||
properties {
|
||||
code {
|
||||
set {
|
||||
/*@
|
||||
Set the underlying code object that this widget renders
|
||||
|
||||
@ingroup Data */
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Get the underlying code object we are rendering
|
||||
|
||||
@ingroup Data */
|
||||
}
|
||||
values {
|
||||
Elm_Code *code; /*@ Our underlying Elm_Code object */
|
||||
}
|
||||
}
|
||||
font_size {
|
||||
set {
|
||||
/*@
|
||||
Set the font size that this widget uses, the font will always be a system monospaced font
|
||||
|
||||
@ingroup Style */
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Get the font size currently in use
|
||||
|
||||
@ingroup Style */
|
||||
}
|
||||
values {
|
||||
Evas_Font_Size font_size; /*@ The font size of the widgget */
|
||||
}
|
||||
}
|
||||
editable {
|
||||
set {
|
||||
/*@
|
||||
Set whether this widget allows editing
|
||||
|
||||
If @a editable then the widget will allow user input to manipulate
|
||||
the underlying Elm_Code_File of this Elm_Code instance.
|
||||
Any other Elm_Code_Widget's connected to this Elm_Code will
|
||||
update to reflect the changes.
|
||||
|
||||
@ingroup Features */
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Get the current editable state of this widget
|
||||
|
||||
@return EINA_TRUE if the widget is editable, EINA_FALSE otherwise.
|
||||
If this widget is not editable the underlying Elm_Code_File could
|
||||
still be manipulated by a different widget or the filesystem.
|
||||
|
||||
@ingroup Features */
|
||||
}
|
||||
values {
|
||||
Eina_Bool editable; /*@ The editable state of the widget */
|
||||
}
|
||||
}
|
||||
}
|
||||
methods {
|
||||
}
|
||||
implements {
|
||||
class.constructor;
|
||||
Eo.Base.constructor;
|
||||
Evas.Object_Smart.add;
|
||||
Elm_Widget.on_focus;
|
||||
Elm_Interface_Scrollable.content_pos_set;
|
||||
}
|
||||
events {
|
||||
line,clicked;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
EOAPI const Eo_Event_Description _ELM_CODE_WIDGET_EVENT_LINE_CLICKED =
|
||||
EO_EVENT_DESCRIPTION("line,clicked", "");
|
||||
|
||||
void _elm_code_widget_code_set(Eo *obj, Elm_Code_Widget_Data *pd, Elm_Code *code);
|
||||
|
||||
EOAPI EO_VOID_FUNC_BODYV(elm_code_widget_code_set, EO_FUNC_CALL(code), Elm_Code *code);
|
||||
|
||||
Elm_Code * _elm_code_widget_code_get(Eo *obj, Elm_Code_Widget_Data *pd);
|
||||
|
||||
EOAPI EO_FUNC_BODY(elm_code_widget_code_get, Elm_Code *, 0);
|
||||
|
||||
void _elm_code_widget_font_size_set(Eo *obj, Elm_Code_Widget_Data *pd, Evas_Font_Size font_size);
|
||||
|
||||
EOAPI EO_VOID_FUNC_BODYV(elm_code_widget_font_size_set, EO_FUNC_CALL(font_size), Evas_Font_Size font_size);
|
||||
|
||||
Evas_Font_Size _elm_code_widget_font_size_get(Eo *obj, Elm_Code_Widget_Data *pd);
|
||||
|
||||
EOAPI EO_FUNC_BODY(elm_code_widget_font_size_get, Evas_Font_Size, 0);
|
||||
|
||||
void _elm_code_widget_editable_set(Eo *obj, Elm_Code_Widget_Data *pd, Eina_Bool editable);
|
||||
|
||||
EOAPI EO_VOID_FUNC_BODYV(elm_code_widget_editable_set, EO_FUNC_CALL(editable), Eina_Bool editable);
|
||||
|
||||
Eina_Bool _elm_code_widget_editable_get(Eo *obj, Elm_Code_Widget_Data *pd);
|
||||
|
||||
EOAPI EO_FUNC_BODY(elm_code_widget_editable_get, Eina_Bool, 0);
|
||||
|
||||
void _elm_code_widget_eo_base_constructor(Eo *obj, Elm_Code_Widget_Data *pd);
|
||||
|
||||
|
||||
void _elm_code_widget_evas_object_smart_add(Eo *obj, Elm_Code_Widget_Data *pd);
|
||||
|
||||
|
||||
Eina_Bool _elm_code_widget_elm_widget_on_focus(Eo *obj, Elm_Code_Widget_Data *pd);
|
||||
|
||||
|
||||
void _elm_code_widget_elm_interface_scrollable_content_pos_set(Eo *obj, Elm_Code_Widget_Data *pd, Evas_Coord x, Evas_Coord y, Eina_Bool sig);
|
||||
|
||||
|
||||
static Eo_Op_Description _elm_code_widget_op_desc[] = {
|
||||
EO_OP_FUNC_OVERRIDE(eo_constructor, _elm_code_widget_eo_base_constructor),
|
||||
EO_OP_FUNC_OVERRIDE(evas_obj_smart_add, _elm_code_widget_evas_object_smart_add),
|
||||
EO_OP_FUNC_OVERRIDE(elm_obj_widget_on_focus, _elm_code_widget_elm_widget_on_focus),
|
||||
EO_OP_FUNC_OVERRIDE(elm_interface_scrollable_content_pos_set, _elm_code_widget_elm_interface_scrollable_content_pos_set),
|
||||
EO_OP_FUNC(elm_code_widget_code_set, _elm_code_widget_code_set, "Set the underlying code object that this widget renders"),
|
||||
EO_OP_FUNC(elm_code_widget_code_get, _elm_code_widget_code_get, "Get the underlying code object we are rendering"),
|
||||
EO_OP_FUNC(elm_code_widget_font_size_set, _elm_code_widget_font_size_set, "Set the font size that this widget uses, the font will always be a system monospaced font"),
|
||||
EO_OP_FUNC(elm_code_widget_font_size_get, _elm_code_widget_font_size_get, "Get the font size currently in use"),
|
||||
EO_OP_FUNC(elm_code_widget_editable_set, _elm_code_widget_editable_set, "Set whether this widget allows editing"),
|
||||
EO_OP_FUNC(elm_code_widget_editable_get, _elm_code_widget_editable_get, "Get the current editable state of this widget"),
|
||||
EO_OP_SENTINEL
|
||||
};
|
||||
|
||||
static const Eo_Event_Description *_elm_code_widget_event_desc[] = {
|
||||
ELM_CODE_WIDGET_EVENT_LINE_CLICKED,
|
||||
NULL
|
||||
};
|
||||
|
||||
static const Eo_Class_Description _elm_code_widget_class_desc = {
|
||||
EO_VERSION,
|
||||
"Elm_Code_Widget",
|
||||
EO_CLASS_TYPE_REGULAR,
|
||||
EO_CLASS_DESCRIPTION_OPS(_elm_code_widget_op_desc),
|
||||
_elm_code_widget_event_desc,
|
||||
sizeof(Elm_Code_Widget_Data),
|
||||
_elm_code_widget_class_constructor,
|
||||
NULL
|
||||
};
|
||||
|
||||
EO_DEFINE_CLASS(elm_code_widget_class_get, &_elm_code_widget_class_desc, ELM_BOX_CLASS, ELM_INTERFACE_SCROLLABLE_MIXIN, ELM_INTERFACE_ATSPI_TEXT_INTERFACE, NULL);
|
|
@ -0,0 +1,99 @@
|
|||
#ifndef _ELM_CODE_WIDGET_EO_H_
|
||||
#define _ELM_CODE_WIDGET_EO_H_
|
||||
|
||||
#ifndef _ELM_CODE_WIDGET_EO_CLASS_TYPE
|
||||
#define _ELM_CODE_WIDGET_EO_CLASS_TYPE
|
||||
|
||||
typedef Eo Elm_Code_Widget;
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _ELM_CODE_WIDGET_EO_TYPES
|
||||
#define _ELM_CODE_WIDGET_EO_TYPES
|
||||
|
||||
|
||||
#endif
|
||||
#define ELM_CODE_WIDGET_CLASS elm_code_widget_class_get()
|
||||
|
||||
const Eo_Class *elm_code_widget_class_get(void) EINA_CONST;
|
||||
|
||||
/**
|
||||
*
|
||||
* Set the underlying code object that this widget renders
|
||||
*
|
||||
* @ingroup Data
|
||||
*
|
||||
* @param[in] code Our underlying Elm_Code object
|
||||
*
|
||||
*/
|
||||
EOAPI void elm_code_widget_code_set(Elm_Code *code);
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the underlying code object we are rendering
|
||||
*
|
||||
* @ingroup Data
|
||||
*
|
||||
*
|
||||
*/
|
||||
EOAPI Elm_Code * elm_code_widget_code_get(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* Set the font size that this widget uses, the font will always be a system monospaced font
|
||||
*
|
||||
* @ingroup Style
|
||||
*
|
||||
* @param[in] font_size The font size of the widgget
|
||||
*
|
||||
*/
|
||||
EOAPI void elm_code_widget_font_size_set(Evas_Font_Size font_size);
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the font size currently in use
|
||||
*
|
||||
* @ingroup Style
|
||||
*
|
||||
*
|
||||
*/
|
||||
EOAPI Evas_Font_Size elm_code_widget_font_size_get(void);
|
||||
|
||||
/**
|
||||
*
|
||||
* Set whether this widget allows editing
|
||||
*
|
||||
* If @a editable then the widget will allow user input to manipulate
|
||||
* the underlying Elm_Code_File of this Elm_Code instance.
|
||||
* Any other Elm_Code_Widget's connected to this Elm_Code will
|
||||
* update to reflect the changes.
|
||||
*
|
||||
* @ingroup Features
|
||||
*
|
||||
* @param[in] editable The editable state of the widget
|
||||
*
|
||||
*/
|
||||
EOAPI void elm_code_widget_editable_set(Eina_Bool editable);
|
||||
|
||||
/**
|
||||
*
|
||||
* Get the current editable state of this widget
|
||||
*
|
||||
* @return EINA_TRUE if the widget is editable, EINA_FALSE otherwise.
|
||||
* If this widget is not editable the underlying Elm_Code_File could
|
||||
* still be manipulated by a different widget or the filesystem.
|
||||
*
|
||||
* @ingroup Features
|
||||
*
|
||||
*
|
||||
*/
|
||||
EOAPI Eina_Bool elm_code_widget_editable_get(void);
|
||||
|
||||
EOAPI extern const Eo_Event_Description _ELM_CODE_WIDGET_EVENT_LINE_CLICKED;
|
||||
|
||||
/**
|
||||
* No description
|
||||
*/
|
||||
#define ELM_CODE_WIDGET_EVENT_LINE_CLICKED (&(_ELM_CODE_WIDGET_EVENT_LINE_CLICKED))
|
||||
|
||||
#endif
|
|
@ -1,41 +0,0 @@
|
|||
#ifndef ELM_CODE_WIDGET_H_
|
||||
# define ELM_CODE_WIDGET_H_
|
||||
|
||||
EAPI extern const Eo_Event_Description ELM_CODE_WIDGET_EVENT_LINE_CLICKED;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @file
|
||||
* @brief These routines are used for rendering instances of Elm Code.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief UI Loading functions.
|
||||
* @defgroup Init Creating a widget to render an Elm Code backend
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* Functions for UI loading.
|
||||
*
|
||||
*/
|
||||
|
||||
EAPI Evas_Object *elm_code_widget_add(Evas_Object *parent, Elm_Code *code);
|
||||
|
||||
EAPI void elm_code_widget_font_size_set(Evas_Object *widget, int size);
|
||||
|
||||
EAPI void elm_code_widget_fill(Evas_Object *o, Elm_Code *code);
|
||||
|
||||
EAPI void elm_code_widget_fill_line_tokens(Evas_Textgrid_Cell *cells, int count, Elm_Code_Line *line);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* ELM_CODE_WIDGET_H_ */
|
|
@ -0,0 +1,8 @@
|
|||
#!/bin/sh
|
||||
cd `dirname $0`
|
||||
|
||||
INCLUDE="-I /usr/local/share/eolian/include/eo-1 -I /usr/local/share/eolian/include/elementary-1 -I /usr/local/share/eolian/include/evas-1 -I /usr/local/share/eolian/include/efl-1"
|
||||
|
||||
eolian_gen $INCLUDE --gh --eo -o elm_code_widget.eo.h elm_code_widget.eo
|
||||
eolian_gen $INCLUDE --gc --eo -o elm_code_widget.eo.c elm_code_widget.eo
|
||||
eolian_gen $INCLUDE --gi --eo -o elm_code_widget.c elm_code_widget.eo
|
|
@ -12,6 +12,8 @@ elm_code_test_widget.c \
|
|||
elm_code_suite.c
|
||||
|
||||
elm_code_suite_CPPFLAGS = -I$(top_builddir)/elm_code/lib/ \
|
||||
-DEFL_BETA_API_SUPPORT \
|
||||
-DEFL_EO_API_SUPPORT \
|
||||
-DPACKAGE_TESTS_DIR=\"$(top_srcdir)/elm_code/tests/\" \
|
||||
-DPACKAGE_BUILD_DIR=\"`pwd`/$(top_builddir)/elm_code/tests/\" \
|
||||
-DEFL_BETA_API_SUPPORT \
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
#include "elm_code_suite.h"
|
||||
|
||||
#include "elm_code_widget.c"
|
||||
|
||||
static void _assert_cell_type(Evas_Textgrid_Cell cell, Elm_Code_Token_Type type, int id)
|
||||
{
|
||||
ck_assert_msg(cell.fg == type, "Wrong type for cell %d", id);
|
||||
|
@ -27,7 +29,7 @@ START_TEST (elm_code_widget_token_render_simple_test)
|
|||
elm_code_file_line_token_add(file, 1, 6+1, 17+1, ELM_CODE_TOKEN_TYPE_COMMENT);
|
||||
elm_code_file_line_token_add(file, 1, 21+1, 22+1, ELM_CODE_TOKEN_TYPE_COMMENT);
|
||||
|
||||
elm_code_widget_fill_line_tokens(cells, length+1, line);
|
||||
_elm_code_widget_fill_line_tokens(cells, length+1, line);
|
||||
_assert_cell_type(cells[1], ELM_CODE_TOKEN_TYPE_DEFAULT, 1);
|
||||
_assert_cell_type(cells[4], ELM_CODE_TOKEN_TYPE_DEFAULT, 4);
|
||||
_assert_cell_type(cells[6], ELM_CODE_TOKEN_TYPE_DEFAULT, 6);
|
||||
|
|
|
@ -336,13 +336,15 @@ EAPI void edi_consolepanel_add(Evas_Object *parent)
|
|||
EAPI void edi_testpanel_add(Evas_Object *parent)
|
||||
{
|
||||
Elm_Code *code;
|
||||
Evas_Object *widget;
|
||||
Elm_Code_Widget *widget;
|
||||
|
||||
code = elm_code_create();
|
||||
_edi_test_code = code;
|
||||
|
||||
widget = elm_code_widget_add(parent, code);
|
||||
elm_code_widget_font_size_set(widget, _edi_cfg->font.size);
|
||||
widget = eo_add(ELM_CODE_WIDGET_CLASS, parent);
|
||||
eo_do(widget,
|
||||
elm_code_widget_code_set(code);
|
||||
elm_code_widget_font_size_set(_edi_cfg->font.size));
|
||||
|
||||
evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
|
|
@ -40,12 +40,14 @@ static void _print_cb(const Eina_Log_Domain *domain,
|
|||
|
||||
EAPI void edi_logpanel_add(Evas_Object *parent)
|
||||
{
|
||||
Evas_Object *widget;
|
||||
Elm_Code_Widget *widget;
|
||||
Elm_Code *code;
|
||||
|
||||
code = elm_code_create();
|
||||
widget = elm_code_widget_add(parent, code);
|
||||
elm_code_widget_font_size_set(widget, _edi_cfg->font.size);
|
||||
widget = eo_add(ELM_CODE_WIDGET_CLASS, parent);
|
||||
eo_do(widget,
|
||||
elm_code_widget_code_set(code);
|
||||
elm_code_widget_font_size_set(_edi_cfg->font.size));
|
||||
evas_object_size_hint_weight_set(widget, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(widget, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_show(widget);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include "edi_suite.h"
|
||||
|
||||
// Add some no-op methods here so linking works without having to import the whole UI!
|
||||
EAPI Evas_Object *edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
|
||||
EAPI Evas_Object *_edi_editor_add(Evas_Object *parent EINA_UNUSED, Edi_Mainview_Item *item EINA_UNUSED)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue