1 /* GIMP - The GNU Image Manipulation Program 2 * Copyright (C) 1995 Spencer Kimball and Peter Mattis 3 * 4 * GimpTextBuffer 5 * Copyright (C) 2010 Michael Natterer <mitch@gimp.org> 6 * 7 * This program is free software: you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 3 of the License, or 10 * (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program. If not, see <https://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef __GIMP_TEXT_BUFFER_H__ 22 #define __GIMP_TEXT_BUFFER_H__ 23 24 25 #define GIMP_TYPE_TEXT_BUFFER (gimp_text_buffer_get_type ()) 26 #define GIMP_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TEXT_BUFFER, GimpTextBuffer)) 27 #define GIMP_IS_TEXT_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TEXT_BUFFER)) 28 #define GIMP_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TEXT_BUFFER, GimpTextBufferClass)) 29 #define GIMP_IS_TEXT_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TEXT_BUFFER)) 30 31 32 typedef struct _GimpTextBufferClass GimpTextBufferClass; 33 34 struct _GimpTextBuffer 35 { 36 GtkTextBuffer parent_instance; 37 38 GtkTextTag *bold_tag; 39 GtkTextTag *italic_tag; 40 GtkTextTag *underline_tag; 41 GtkTextTag *strikethrough_tag; 42 43 GList *size_tags; 44 GList *baseline_tags; 45 GList *kerning_tags; 46 GList *font_tags; 47 GList *color_tags; 48 49 GtkTextTag *preedit_underline_tag; 50 GList *preedit_color_tags; 51 GList *preedit_bg_color_tags; 52 53 gboolean insert_tags_set; 54 GList *insert_tags; 55 GList *remove_tags; 56 57 GdkAtom markup_atom; 58 }; 59 60 struct _GimpTextBufferClass 61 { 62 GtkTextBufferClass parent_class; 63 64 void (* color_applied) (GimpTextBuffer *buffer, 65 const GimpRGB *color); 66 }; 67 68 69 GType gimp_text_buffer_get_type (void) G_GNUC_CONST; 70 71 GimpTextBuffer * gimp_text_buffer_new (void); 72 73 void gimp_text_buffer_set_text (GimpTextBuffer *buffer, 74 const gchar *text); 75 gchar * gimp_text_buffer_get_text (GimpTextBuffer *buffer); 76 77 void gimp_text_buffer_set_markup (GimpTextBuffer *buffer, 78 const gchar *markup); 79 gchar * gimp_text_buffer_get_markup (GimpTextBuffer *buffer); 80 81 gboolean gimp_text_buffer_has_markup (GimpTextBuffer *buffer); 82 83 GtkTextTag * gimp_text_buffer_get_iter_size (GimpTextBuffer *buffer, 84 const GtkTextIter *iter, 85 gint *size); 86 GtkTextTag * gimp_text_buffer_get_size_tag (GimpTextBuffer *buffer, 87 gint size); 88 void gimp_text_buffer_set_size (GimpTextBuffer *buffer, 89 const GtkTextIter *start, 90 const GtkTextIter *end, 91 gint size); 92 void gimp_text_buffer_change_size (GimpTextBuffer *buffer, 93 const GtkTextIter *start, 94 const GtkTextIter *end, 95 gint amount); 96 97 GtkTextTag * gimp_text_buffer_get_iter_baseline (GimpTextBuffer *buffer, 98 const GtkTextIter *iter, 99 gint *baseline); 100 void gimp_text_buffer_set_baseline (GimpTextBuffer *buffer, 101 const GtkTextIter *start, 102 const GtkTextIter *end, 103 gint count); 104 void gimp_text_buffer_change_baseline (GimpTextBuffer *buffer, 105 const GtkTextIter *start, 106 const GtkTextIter *end, 107 gint count); 108 109 GtkTextTag * gimp_text_buffer_get_iter_kerning (GimpTextBuffer *buffer, 110 const GtkTextIter *iter, 111 gint *kerning); 112 void gimp_text_buffer_set_kerning (GimpTextBuffer *buffer, 113 const GtkTextIter *start, 114 const GtkTextIter *end, 115 gint count); 116 void gimp_text_buffer_change_kerning (GimpTextBuffer *buffer, 117 const GtkTextIter *start, 118 const GtkTextIter *end, 119 gint count); 120 121 GtkTextTag * gimp_text_buffer_get_iter_font (GimpTextBuffer *buffer, 122 const GtkTextIter *iter, 123 gchar **font); 124 GtkTextTag * gimp_text_buffer_get_font_tag (GimpTextBuffer *buffer, 125 const gchar *font); 126 void gimp_text_buffer_set_font (GimpTextBuffer *buffer, 127 const GtkTextIter *start, 128 const GtkTextIter *end, 129 const gchar *font); 130 131 GtkTextTag * gimp_text_buffer_get_iter_color (GimpTextBuffer *buffer, 132 const GtkTextIter *iter, 133 GimpRGB *color); 134 GtkTextTag * gimp_text_buffer_get_color_tag (GimpTextBuffer *buffer, 135 const GimpRGB *color); 136 void gimp_text_buffer_set_color (GimpTextBuffer *buffer, 137 const GtkTextIter *start, 138 const GtkTextIter *end, 139 const GimpRGB *color); 140 141 GtkTextTag * gimp_text_buffer_get_preedit_color_tag (GimpTextBuffer *buffer, 142 const GimpRGB *color); 143 void gimp_text_buffer_set_preedit_color (GimpTextBuffer *buffer, 144 const GtkTextIter *start, 145 const GtkTextIter *end, 146 const GimpRGB *color); 147 GtkTextTag * gimp_text_buffer_get_preedit_bg_color_tag (GimpTextBuffer *buffer, 148 const GimpRGB *color); 149 void gimp_text_buffer_set_preedit_bg_color (GimpTextBuffer *buffer, 150 const GtkTextIter *start, 151 const GtkTextIter *end, 152 const GimpRGB *color); 153 154 const gchar * gimp_text_buffer_tag_to_name (GimpTextBuffer *buffer, 155 GtkTextTag *tag, 156 const gchar **attribute, 157 gchar **value); 158 GtkTextTag * gimp_text_buffer_name_to_tag (GimpTextBuffer *buffer, 159 const gchar *name, 160 const gchar *attribute, 161 const gchar *value); 162 163 void gimp_text_buffer_set_insert_tags (GimpTextBuffer *buffer, 164 GList *insert_tags, 165 GList *remove_tags); 166 void gimp_text_buffer_clear_insert_tags (GimpTextBuffer *buffer); 167 void gimp_text_buffer_insert (GimpTextBuffer *buffer, 168 const gchar *text); 169 170 gint gimp_text_buffer_get_iter_index (GimpTextBuffer *buffer, 171 GtkTextIter *iter, 172 gboolean layout_index); 173 void gimp_text_buffer_get_iter_at_index (GimpTextBuffer *buffer, 174 GtkTextIter *iter, 175 gint index, 176 gboolean layout_index); 177 178 gboolean gimp_text_buffer_load (GimpTextBuffer *buffer, 179 GFile *file, 180 GError **error); 181 gboolean gimp_text_buffer_save (GimpTextBuffer *buffer, 182 GFile *file, 183 gboolean selection_only, 184 GError **error); 185 186 187 #endif /* __GIMP_TEXT_BUFFER_H__ */ 188