#define EDITOR_STYLE_HEADING6 "heading6"
#define EDITOR_STYLE_QUOTE "quote"
#define EDITOR_STYLE_CODE_BLOCK "code_block"
+#define EDITOR_STYLE_LIST0 "list0"
#define EDITOR_STYLE_EMPHASIS "emphasis"
#define EDITOR_STYLE_STRONG "strong"
#define EDITOR_STYLE_CODE "code"
UiBool editor_set_style(UiText *text, const char *style, UiBool enabled);
void editor_set_paragraph_style(UiText *text, const char *style);
+void editor_insert_list(UiText *text, UiBool oredered);
#if GTK_MAJOR_VERSION >= 4
GtkWidget* editor_gtk4_workaround(UiObject *obj, UiWidgetArgs args, void *userdata);
cxMapPut(markdown_tags, EDITOR_STYLE_HEADING5, &((MDTag){"##### ", NULL}));
cxMapPut(markdown_tags, EDITOR_STYLE_HEADING6, &((MDTag){"###### ", NULL}));
cxMapPut(markdown_tags, EDITOR_STYLE_CODE_BLOCK, &((MDTag){" ", NULL}));
+ cxMapPut(markdown_tags, EDITOR_STYLE_LIST0, &((MDTag){" - ", NULL}));
cxMapPut(markdown_tags, EDITOR_STYLE_STRONG, &((MDTag){"**", "**"}));
cxMapPut(markdown_tags, EDITOR_STYLE_EMPHASIS, &((MDTag){"*", "*"}));
cxMapPut(markdown_tags, EDITOR_STYLE_CODE, &((MDTag){"`", "`"}));
}
+static void tagstyle_list0(MDActiveStyles *style, GtkTextTag *tag) {
+
+}
+
void init_tagtable(GtkTextTagTable *table) {
printf("init_tagtable\n");
GtkTextTag *tag;
g_object_set(tag, "foreground", "blue", NULL);
g_object_set_data(G_OBJECT(tag), "set_style", (void*)tagstyle_link);
gtk_text_tag_table_add(table, tag);
+
+ tag = gtk_text_tag_new(EDITOR_STYLE_LIST0);
+ g_object_set(tag, "left-margin", 60, "right-margin", 60, "ident", 60, NULL);
+ g_object_set_data(G_OBJECT(tag), "set_style", (void*)tagstyle_list0);
+ gtk_text_tag_table_add(table, tag);
}
/*
gtk_text_iter_forward_line(&pos);
}
}
+
+void editor_insert_list(UiText *text, UiBool oredered) {
+ GtkTextBuffer *buffer = text->data1;
+ NoteEditor *editor = g_object_get_data(text->obj, "editor");
+
+ GtkTextMark *cursor = gtk_text_buffer_get_insert(buffer);
+ if(!cursor) {
+ fprintf(stderr, "Error: no insert mark\n");
+ return;
+ }
+ GtkTextIter start, end;
+ gtk_text_buffer_get_iter_at_mark(buffer, &end, cursor);
+
+ GtkTextMark *start_mark = gtk_text_buffer_create_mark(buffer, NULL, &end, TRUE);
+
+ gtk_text_buffer_insert(buffer, &end, "•", -1);
+ gtk_text_buffer_get_iter_at_mark(buffer, &start, start_mark);
+
+ gtk_text_buffer_apply_tag_by_name(buffer, EDITOR_STYLE_LIST0, &start, &end);
+
+ gtk_text_buffer_delete_mark(buffer, start_mark);
+}
ui_togglebutton(obj, .icon = "format-text-italic", .varname = "note_textnote_emphasis", .onchange = action_textnote_style_emphasis);
ui_togglebutton(obj, .icon = "format-text-underline", .varname = "note_textnote_underline", .onchange = action_textnote_style_underline);
ui_togglebutton(obj, .label = "code", .varname = "note_textnote_code", .onchange = action_textnote_style_code);
- ui_button(obj, .icon = "view-list-bullet");
+ ui_button(obj, .icon = "view-list-bullet", .onclick = action_textnote_insertlist);
ui_button(obj, .icon = "view-list-ordered");
ui_button(obj, .icon = "insert-image");
ui_button(obj, .icon = "insert-link");
note_set_paragraph_type(notebook->current_note->model, event->intval);
}
}
+
+void action_textnote_insertlist(UiEvent *event, void *userdata) {
+ if(event->set) {
+ return;
+ }
+ MainWindow *window = event->window;
+ NotebookModel *notebook = window->current_notebook;
+ if(notebook && notebook->current_note && notebook->current_note->model) {
+ note_insert_list(notebook->current_note->model, FALSE);
+ }
+}