PEG Markdown Highlight
|
00001 /* PEG Markdown Highlight 00002 * Copyright 2011-2012 Ali Rantakari -- http://hasseg.org 00003 * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info). 00004 * 00005 * pmh_styleparser.h 00006 * 00007 * Public interface of a parser for custom syntax highlighting stylesheets. 00008 */ 00009 00014 #include "pmh_definitions.h" 00015 #include <stdbool.h> 00016 00022 typedef struct 00023 { 00024 int red; 00025 int green; 00026 int blue; 00027 int alpha; 00028 } pmh_attr_argb_color; 00029 00031 typedef struct 00032 { 00033 bool italic; 00034 bool bold; 00035 bool underlined; 00036 } pmh_attr_font_styles; 00037 00039 typedef struct 00040 { 00041 int size_pt; 00042 bool is_relative; 00044 } pmh_attr_font_size; 00045 00047 typedef enum 00048 { 00049 pmh_attr_type_foreground_color, 00050 pmh_attr_type_background_color, 00051 pmh_attr_type_caret_color, 00052 pmh_attr_type_font_size_pt, 00053 pmh_attr_type_font_family, 00054 pmh_attr_type_font_style, 00055 pmh_attr_type_other 00056 } pmh_attr_type; 00057 00066 typedef union 00067 { 00068 pmh_attr_argb_color *argb_color; 00069 pmh_attr_font_styles *font_styles; 00070 pmh_attr_font_size *font_size; 00071 char *font_family; 00072 char *string; 00075 } pmh_attr_value; 00076 00078 typedef struct pmh_style_attribute 00079 { 00080 pmh_element_type lang_element_type; 00082 pmh_attr_type type; 00083 char *name; 00087 pmh_attr_value *value; 00088 struct pmh_style_attribute *next; 00089 } pmh_style_attribute; 00090 00092 typedef struct 00093 { 00095 pmh_style_attribute *editor_styles; 00096 00099 pmh_style_attribute *editor_current_line_styles; 00100 00102 pmh_style_attribute *editor_selection_styles; 00103 00105 pmh_style_attribute **element_styles; 00106 } pmh_style_collection; 00107 00108 00130 pmh_style_collection *pmh_parse_styles(char *input, 00131 void(*error_callback)(char*,int,void*), 00132 void *error_callback_context); 00133 00141 void pmh_free_style_collection(pmh_style_collection *collection); 00142 00143 00144 char *pmh_attr_name_from_type(pmh_attr_type type); 00145 00146 pmh_attr_type pmh_attr_type_from_name(char *name); 00147