forked from enlightenment/edi
clang: save errors and display if clicked
Using a gutter click in elm_code to print to console for now
This commit is contained in:
parent
bf53022adb
commit
4f8ece09cf
|
@ -12,6 +12,8 @@ elm_code_line_free(Elm_Code_Line *line)
|
|||
if (!line)
|
||||
return;
|
||||
|
||||
if (line->status_text)
|
||||
free((char *)line->status_text);
|
||||
if (line->modified)
|
||||
free(line->modified);
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ typedef struct _Elm_Code_Line
|
|||
Eina_List *tokens;
|
||||
|
||||
void *data;
|
||||
const char *status_text;
|
||||
} Elm_Code_Line;
|
||||
|
||||
EAPI void elm_code_line_free(Elm_Code_Line *line);
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include <Elm_Code.h>
|
||||
#include "Elm_Code.h"
|
||||
#include "elm_code_private.h"
|
||||
|
||||
typedef enum {
|
||||
|
@ -543,11 +543,12 @@ _elm_code_widget_cursor_move(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
|
|||
static Eina_Bool
|
||||
_elm_code_widget_position_at_coordinates_get(Elm_Code_Widget *widget, Elm_Code_Widget_Data *pd,
|
||||
Evas_Coord x, Evas_Coord y,
|
||||
unsigned int *row, unsigned int *col)
|
||||
unsigned int *row, int *col)
|
||||
{
|
||||
Elm_Code_Line *line;
|
||||
Evas_Coord ox, oy, sx, sy;
|
||||
int cw, ch;
|
||||
unsigned int number;
|
||||
|
||||
evas_object_geometry_get(widget, &ox, &oy, NULL, NULL);
|
||||
elm_scroller_region_get(pd->scroller, &sx, &sy, NULL, NULL);
|
||||
|
@ -555,53 +556,62 @@ _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);
|
||||
number = ((double) y / ch) + 1;
|
||||
if (col)
|
||||
*col = ((double) x / cw) - elm_code_widget_text_left_gutter_width_get(widget) + 1;
|
||||
if (row)
|
||||
*row = ((double) y / ch) + 1;
|
||||
*row = number;
|
||||
|
||||
line = elm_code_file_line_get(pd->code->file, *row);
|
||||
line = elm_code_file_line_get(pd->code->file, number);
|
||||
return !!line;
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_clicked_editable_cb(Elm_Code_Widget *widget, Evas_Coord x, Evas_Coord y)
|
||||
_elm_code_widget_clicked_gutter_cb(Elm_Code_Widget *widget, unsigned int row)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
unsigned int row, col;
|
||||
Eina_Bool hasline;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
hasline = _elm_code_widget_position_at_coordinates_get(widget, pd, x, y, &row, &col);
|
||||
if (!hasline)
|
||||
line = elm_code_file_line_get(pd->code->file, row);
|
||||
if (!line)
|
||||
return;
|
||||
|
||||
eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET_EVENT_LINE_GUTTER_CLICKED, line));
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_clicked_editable_cb(Elm_Code_Widget *widget, unsigned int row, unsigned int col)
|
||||
{
|
||||
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, row);
|
||||
if (col > (unsigned int) line->unicode_length + 1)
|
||||
if (!line)
|
||||
return;
|
||||
|
||||
if (col > line->unicode_length + 1)
|
||||
col = line->unicode_length + 1;
|
||||
else if (col == 0)
|
||||
else if (col <= 0)
|
||||
col = 1;
|
||||
|
||||
_elm_code_widget_cursor_move(widget, pd, col, row, EINA_FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
_elm_code_widget_clicked_readonly_cb(Elm_Code_Widget *widget, Evas_Coord x, Evas_Coord y)
|
||||
_elm_code_widget_clicked_readonly_cb(Elm_Code_Widget *widget, unsigned int row)
|
||||
{
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Elm_Code_Line *line;
|
||||
unsigned int row;
|
||||
Eina_Bool hasline;
|
||||
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
||||
hasline = _elm_code_widget_position_at_coordinates_get(widget, pd, x, y, &row, NULL);
|
||||
if (!hasline)
|
||||
line = elm_code_file_line_get(pd->code->file, row);
|
||||
if (!line)
|
||||
return;
|
||||
|
||||
line = elm_code_file_line_get(pd->code->file, row);
|
||||
eo_do(widget, eo_event_callback_call(ELM_CODE_WIDGET_EVENT_LINE_CLICKED, line));
|
||||
}
|
||||
|
||||
|
@ -612,7 +622,8 @@ _elm_code_widget_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj
|
|||
Elm_Code_Widget *widget;
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Evas_Event_Mouse_Down *event;
|
||||
unsigned int row, col;
|
||||
unsigned int row;
|
||||
int col;
|
||||
|
||||
widget = (Elm_Code_Widget *)data;
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
@ -623,6 +634,7 @@ _elm_code_widget_mouse_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj
|
|||
return;
|
||||
|
||||
_elm_code_widget_position_at_coordinates_get(widget, pd, event->canvas.x, event->canvas.y, &row, &col);
|
||||
if (col > 0)
|
||||
elm_code_widget_selection_start(widget, row, col);
|
||||
}
|
||||
|
||||
|
@ -633,7 +645,8 @@ _elm_code_widget_mouse_move_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj
|
|||
Elm_Code_Widget *widget;
|
||||
Elm_Code_Widget_Data *pd;
|
||||
Evas_Event_Mouse_Move *event;
|
||||
unsigned int row, col;
|
||||
unsigned int row;
|
||||
int col;
|
||||
|
||||
widget = (Elm_Code_Widget *)data;
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
@ -655,6 +668,9 @@ _elm_code_widget_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E
|
|||
Elm_Code_Widget_Data *pd;
|
||||
Evas_Event_Mouse_Up *event;
|
||||
Evas_Coord x, y;
|
||||
unsigned int row;
|
||||
int col;
|
||||
Eina_Bool hasline;
|
||||
|
||||
widget = (Elm_Code_Widget *)data;
|
||||
pd = eo_data_scope_get(widget, ELM_CODE_WIDGET_CLASS);
|
||||
|
@ -671,10 +687,16 @@ _elm_code_widget_mouse_up_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj E
|
|||
|
||||
x = event->canvas.x;
|
||||
y = event->canvas.y;
|
||||
if (pd->editable)
|
||||
_elm_code_widget_clicked_editable_cb(widget, x, y);
|
||||
hasline = _elm_code_widget_position_at_coordinates_get(widget, pd, x, y, &row, &col);
|
||||
if (!hasline)
|
||||
return;
|
||||
|
||||
if (col <= 0)
|
||||
_elm_code_widget_clicked_gutter_cb(widget, row);
|
||||
else if (pd->editable)
|
||||
_elm_code_widget_clicked_editable_cb(widget, row, (unsigned int) col);
|
||||
else
|
||||
_elm_code_widget_clicked_readonly_cb(widget, x, y);
|
||||
_elm_code_widget_clicked_readonly_cb(widget, row);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -179,6 +179,7 @@ class Elm_Code_Widget (Elm_Layout, Elm_Interface_Atspi_Text)
|
|||
}
|
||||
events {
|
||||
line,clicked;
|
||||
line,gutter,clicked;
|
||||
cursor,changed;
|
||||
changed,user;
|
||||
selection,changed;
|
||||
|
|
|
@ -286,7 +286,8 @@ _edi_range_color_set(Edi_Editor *editor, Edi_Range range, Elm_Code_Token_Type ty
|
|||
}
|
||||
|
||||
static void
|
||||
_edi_line_status_set(Edi_Editor *editor, unsigned int number, Elm_Code_Status_Type status)
|
||||
_edi_line_status_set(Edi_Editor *editor, unsigned int number, Elm_Code_Status_Type status,
|
||||
const char *text)
|
||||
{
|
||||
Elm_Code *code;
|
||||
Elm_Code_Line *line;
|
||||
|
@ -298,6 +299,8 @@ _edi_line_status_set(Edi_Editor *editor, unsigned int number, Elm_Code_Status_Ty
|
|||
ecore_thread_main_loop_begin();
|
||||
|
||||
elm_code_line_status_set(line, status);
|
||||
if (text)
|
||||
line->status_text = strdup(text);
|
||||
|
||||
eo_do(editor->entry,
|
||||
elm_code_widget_line_refresh(line));
|
||||
|
@ -491,14 +494,9 @@ _clang_load_errors(const char *path EINA_UNUSED, Edi_Editor *editor)
|
|||
status = ELM_CODE_STATUS_TYPE_FATAL;
|
||||
break;
|
||||
}
|
||||
|
||||
_edi_line_status_set(editor, line, status);
|
||||
|
||||
# if CLANG_DEBUG
|
||||
CXString str = clang_formatDiagnostic(diag, clang_defaultDiagnosticDisplayOptions());
|
||||
printf("DEBUG: Diag:%s\n", clang_getCString(str));
|
||||
CXString str = clang_getDiagnosticSpelling(diag);
|
||||
_edi_line_status_set(editor, line, status, clang_getCString(str));
|
||||
clang_disposeString(str);
|
||||
# endif
|
||||
|
||||
clang_disposeDiagnostic(diag);
|
||||
}
|
||||
|
@ -572,6 +570,18 @@ _unfocused_cb(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
edi_editor_save(editor);
|
||||
}
|
||||
|
||||
static void
|
||||
_gutter_clicked_cb(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Elm_Code_Line *line;
|
||||
|
||||
line = (Elm_Code_Line *)event_info;
|
||||
|
||||
if (line->status_text)
|
||||
printf("CLANG %s\n", line->status_text);
|
||||
}
|
||||
|
||||
static void
|
||||
_edi_editor_parse_file_cb(Elm_Code_File *file EINA_UNUSED, void *data)
|
||||
{
|
||||
|
@ -644,6 +654,7 @@ edi_editor_add(Evas_Object *parent, Edi_Mainview_Item *item)
|
|||
evas_object_event_callback_add(widget, EVAS_CALLBACK_KEY_DOWN,
|
||||
_smart_cb_key_down, editor);
|
||||
evas_object_smart_callback_add(widget, "changed,user", _changed_cb, editor);
|
||||
evas_object_smart_callback_add(widget, "line,gutter,clicked", _gutter_clicked_cb, editor);
|
||||
/*
|
||||
evas_object_smart_callback_add(txt, "undo,request", _undo_cb, editor);
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue