| 1 |
/* Copyright (C) 2008, 2009 Vincent Penquerc'h. |
| 2 |
This file is part of the Kate codec library. |
| 3 |
Written by Vincent Penquerc'h. |
| 4 |
|
| 5 |
Use, distribution and reproduction of this library is governed |
| 6 |
by a BSD style source license included with this source in the |
| 7 |
file 'COPYING'. Please read these terms before distributing. */ |
| 8 |
|
| 9 |
|
| 10 |
#ifndef KATE_kate_h_GUARD |
| 11 |
#define KATE_kate_h_GUARD |
| 12 |
|
| 13 |
/** \file kate.h |
| 14 |
The libkate public API. |
| 15 |
*/ |
| 16 |
|
| 17 |
#include "kate/kate_config.h" |
| 18 |
|
| 19 |
/** \name API version */ |
| 20 |
/** @{ */ |
| 21 |
#define KATE_VERSION_MAJOR @VERSION_MAJOR@ /**< major version number of the libkate API */ |
| 22 |
#define KATE_VERSION_MINOR @VERSION_MINOR@ /**< minor version number of the libkate API */ |
| 23 |
#define KATE_VERSION_PATCH @VERSION_PATCH@ /**< patch version number of the libkate API */ |
| 24 |
/** @} */ |
| 25 |
|
| 26 |
/** \name Bitstream version */ |
| 27 |
/** @{ */ |
| 28 |
#define KATE_BITSTREAM_VERSION_MAJOR 0 /**< major version number of the highest bitstream version this version of libkate supports */ |
| 29 |
#define KATE_BITSTREAM_VERSION_MINOR 7 /**< minor version number of the highest bitstream version this version of libkate supports */ |
| 30 |
/** @} */ |
| 31 |
|
| 32 |
/** defines the character encoding used by text */ |
| 33 |
typedef enum { |
| 34 |
kate_utf8 /**< utf-8 variable length byte encoding, see RFC 3629 */ |
| 35 |
} kate_text_encoding; |
| 36 |
|
| 37 |
/** defines the type of markup in a text */ |
| 38 |
typedef enum { |
| 39 |
kate_markup_none, /**< the text should not be interpreted for markup */ |
| 40 |
kate_markup_simple /**< the text should be interpreted for simple markup */ |
| 41 |
} kate_markup_type; |
| 42 |
|
| 43 |
/** defines how to interpret spatial dimension values */ |
| 44 |
typedef enum { |
| 45 |
kate_pixel, /**< dimensions are in pixels */ |
| 46 |
kate_percentage, /**< dimensions are in percentage of total size */ |
| 47 |
kate_millionths /**< dimensions are in millionths of total size */ |
| 48 |
} kate_space_metric; |
| 49 |
|
| 50 |
struct kate_meta; |
| 51 |
typedef struct kate_meta kate_meta; |
| 52 |
|
| 53 |
/** defines an area where to draw */ |
| 54 |
typedef struct kate_region { |
| 55 |
kate_space_metric metric; /**< how to interpret the xywh values */ |
| 56 |
int x; /**< origin of the region */ |
| 57 |
int y; /**< origin of the region */ |
| 58 |
int w; /**< size of the region */ |
| 59 |
int h; /**< size of the region */ |
| 60 |
int style; /**< default style to apply to text in this region */ |
| 61 |
unsigned int clip:1; /**< text/images will be clipped to the region */ |
| 62 |
unsigned int pad0:31; |
| 63 |
kate_meta *meta; |
| 64 |
kate_uintptr_t pad1[5]; |
| 65 |
} kate_region; |
| 66 |
|
| 67 |
/** defines an RGBA color */ |
| 68 |
typedef struct kate_color { |
| 69 |
unsigned char r; /**< red component, 0 (black) to 255 (full intensity) */ |
| 70 |
unsigned char g; /**< green component, 0 (black) to 255 (full intensity) */ |
| 71 |
unsigned char b; /**< blue component, 0 (black) to 255 (full intensity) */ |
| 72 |
unsigned char a; /**< alpha component, 0 (fully transparent) to 255 (fully opaque) */ |
| 73 |
} kate_color; |
| 74 |
|
| 75 |
/** defines how to wrap text if necessary */ |
| 76 |
typedef enum { |
| 77 |
kate_wrap_word, /**< allow wrapping at word boundaries */ |
| 78 |
kate_wrap_none /**< forbid wrapping */ |
| 79 |
} kate_wrap_mode; |
| 80 |
|
| 81 |
/** defines a style to display text */ |
| 82 |
typedef struct kate_style { |
| 83 |
kate_float halign; /**< horizontal alignment, -1 for left, +1 for right, other values inter/extrapolate */ |
| 84 |
kate_float valign; /**< horizontal alignment, -1 for top, +1 for bottom, other values inter/extrapolate */ |
| 85 |
|
| 86 |
kate_color text_color; /**< RGBA color of the text */ |
| 87 |
kate_color background_color; /**< background RGBA color of the whole region, regardless of what extent any text has */ |
| 88 |
kate_color draw_color; /**< RGBA color for drawn shapes */ |
| 89 |
|
| 90 |
kate_space_metric font_metric; /**< whether font size are in pixels, percentage, etc */ |
| 91 |
kate_float font_width; /**< horizontal size of the glyphs */ |
| 92 |
kate_float font_height; /**< vertical size of the glyphs */ |
| 93 |
|
| 94 |
kate_space_metric margin_metric; /**< how to interpret margin values */ |
| 95 |
kate_float left_margin; /**< size of left margin */ |
| 96 |
kate_float top_margin; /**< size of top margin */ |
| 97 |
kate_float right_margin; /**< size of right margin */ |
| 98 |
kate_float bottom_margin; /**< size of bottom margin */ |
| 99 |
|
| 100 |
unsigned int bold:1; /**< display text in bold */ |
| 101 |
unsigned int italics:1; /**< display text in italics */ |
| 102 |
unsigned int underline:1; /**< display underlined text */ |
| 103 |
unsigned int strike:1; /**< display striked text */ |
| 104 |
unsigned int justify:1; /**< display justified text */ |
| 105 |
unsigned int wrap_mode:2; /**< how to wrap text if necessary */ |
| 106 |
unsigned int pad0:25; |
| 107 |
|
| 108 |
kate_const char *font; /**< name of the font to use */ |
| 109 |
|
| 110 |
kate_meta *meta; |
| 111 |
|
| 112 |
kate_uintptr_t pad1[8]; |
| 113 |
} kate_style; |
| 114 |
|
| 115 |
/** defines a type of curve */ |
| 116 |
typedef enum kate_curve_type { |
| 117 |
kate_curve_none, /**< no curve */ |
| 118 |
kate_curve_static, /**< a single point */ |
| 119 |
kate_curve_linear, /**< linear interpolation of line segments */ |
| 120 |
kate_curve_catmull_rom_spline, /**< Catmull-Rom spline, goes through each point (even the first and last) */ |
| 121 |
kate_curve_bezier_cubic_spline, /**< Bezier cubic spline, goes through the first and last points, but not others */ |
| 122 |
kate_curve_bspline /**< Cubic uniform B-spline with 3-multiplicity end knots (goes through each point) */ |
| 123 |
} kate_curve_type; |
| 124 |
|
| 125 |
/** defines a curve */ |
| 126 |
typedef struct kate_curve { |
| 127 |
kate_curve_type type; /**< type of the curve */ |
| 128 |
size_t npts; /**< number of points in this curve */ |
| 129 |
kate_float *pts; /**< point coordinates for this curve (2D: npts*2 values) */ |
| 130 |
kate_uintptr_t pad[5]; |
| 131 |
} kate_curve; |
| 132 |
|
| 133 |
/** defines a way to transform a curve point */ |
| 134 |
typedef enum kate_motion_mapping { |
| 135 |
/* these can be used for a x/y position mapping */ |
| 136 |
kate_motion_mapping_none, /**< motion maps to itself */ |
| 137 |
kate_motion_mapping_frame, /**< 0x0 at top left of frame, 1x1 at bottom right of frame */ |
| 138 |
kate_motion_mapping_window, /**< 0x0 at top left of window, 1x1 at bottom right of window */ |
| 139 |
kate_motion_mapping_region, /**< 0x0 at top left of region, 1x1 at bottom right of region */ |
| 140 |
kate_motion_mapping_event_duration, /**< 0-1 map to 0 to the duration of the event (to be used with time) */ |
| 141 |
kate_motion_mapping_bitmap_size, /**< 0x0 at top left of bitmap, 1x1 at bottom right of bitmap */ |
| 142 |
|
| 143 |
#if 0 |
| 144 |
text is useful, find a way to readd it easily |
| 145 |
kate_motion_mapping_text, /**< 0x0 at top left of text, 1x1 at bottom right of text */ |
| 146 |
#endif |
| 147 |
|
| 148 |
/* more mapping may be added in future versions */ |
| 149 |
|
| 150 |
kate_motion_mapping_user=128 /**< 128 to 255 for user specific mappings */ |
| 151 |
} kate_motion_mapping; |
| 152 |
|
| 153 |
/** defines what uses a motion can have */ |
| 154 |
typedef enum kate_motion_semantics { |
| 155 |
kate_motion_semantics_time, /**< controls the flow of time - 1D */ |
| 156 |
kate_motion_semantics_z, /**< controls the "depth" of the plane - 1D */ |
| 157 |
kate_motion_semantics_region_position, /**< controls the region position */ |
| 158 |
kate_motion_semantics_region_size, /**< controls the region size */ |
| 159 |
kate_motion_semantics_text_alignment_int, /**< controls internal text alignment */ |
| 160 |
kate_motion_semantics_text_alignment_ext, /**< controls external text alignment */ |
| 161 |
kate_motion_semantics_text_position, /**< controls the text position */ |
| 162 |
kate_motion_semantics_text_size, /**< controls the text size */ |
| 163 |
kate_motion_semantics_marker1_position, /**< controls the position of a point */ |
| 164 |
kate_motion_semantics_marker2_position, /**< controls the position of a point */ |
| 165 |
kate_motion_semantics_marker3_position, /**< controls the position of a point */ |
| 166 |
kate_motion_semantics_marker4_position, /**< controls the position of a point */ |
| 167 |
kate_motion_semantics_glyph_pointer_1, /**< controls a pointer to a particular glyph in the text */ |
| 168 |
kate_motion_semantics_glyph_pointer_2, /**< controls a pointer to a particular glyph in the text */ |
| 169 |
kate_motion_semantics_glyph_pointer_3, /**< controls a pointer to a particular glyph in the text */ |
| 170 |
kate_motion_semantics_glyph_pointer_4, /**< controls a pointer to a particular glyph in the text */ |
| 171 |
kate_motion_semantics_text_color_rg, /**< controls the red and green components of the text color */ |
| 172 |
kate_motion_semantics_text_color_ba, /**< controls the blue and alpha components of the text color */ |
| 173 |
kate_motion_semantics_background_color_rg, /**< controls the red and green components of the background color */ |
| 174 |
kate_motion_semantics_background_color_ba, /**< controls the blue and alpha components of the background color */ |
| 175 |
kate_motion_semantics_draw_color_rg, /**< controls the red and green components of the draw color */ |
| 176 |
kate_motion_semantics_draw_color_ba, /**< controls the blue and alpha components of the draw color */ |
| 177 |
kate_motion_semantics_style_morph, /**< controls morphing between style and secondary style */ |
| 178 |
kate_motion_semantics_text_path, /**< controls the path on which text is drawn */ |
| 179 |
kate_motion_semantics_text_path_section, /**< controls the section of the path on which text is drawn */ |
| 180 |
kate_motion_semantics_draw, /**< controls drawing */ |
| 181 |
kate_motion_semantics_text_visible_section, /**< controls the section of the text which is visible */ |
| 182 |
kate_motion_semantics_horizontal_margins, /**< controls the size of the left and right margins */ |
| 183 |
kate_motion_semantics_vertical_margins, /**< controls the size of the top and bottom margins */ |
| 184 |
kate_motion_semantics_bitmap_position, /**< controls the position of the background image */ |
| 185 |
kate_motion_semantics_bitmap_size, /**< controls the size of the background image */ |
| 186 |
kate_motion_semantics_marker1_bitmap, /**< controls the bitmap of the image used for marker 1 */ |
| 187 |
kate_motion_semantics_marker2_bitmap, /**< controls the bitmap of the image used for marker 2 */ |
| 188 |
kate_motion_semantics_marker3_bitmap, /**< controls the bitmap of the image used for marker 3 */ |
| 189 |
kate_motion_semantics_marker4_bitmap, /**< controls the bitmap of the image used for marker 4 */ |
| 190 |
kate_motion_semantics_glyph_pointer_1_bitmap, /**< controls the bitmap of the image used for glyph pointer 1 */ |
| 191 |
kate_motion_semantics_glyph_pointer_2_bitmap, /**< controls the bitmap of the image used for glyph pointer 2 */ |
| 192 |
kate_motion_semantics_glyph_pointer_3_bitmap, /**< controls the bitmap of the image used for glyph pointer 3 */ |
| 193 |
kate_motion_semantics_glyph_pointer_4_bitmap, /**< controls the bitmap of the image used for glyph pointer 4 */ |
| 194 |
kate_motion_semantics_draw_width, /**< controls the width of the drawn line */ |
| 195 |
|
| 196 |
/* more semantics may be added in future versions */ |
| 197 |
|
| 198 |
kate_motion_semantics_user = 128 /**< 128 to 255 for user specific semantics */ |
| 199 |
} kate_motion_semantics; |
| 200 |
|
| 201 |
/** defines a motion - well, try to find a better explanation */ |
| 202 |
typedef struct kate_motion { |
| 203 |
size_t ncurves; /**< number of curves in this motion */ |
| 204 |
kate_curve **curves; /**< the list of curves in this motion */ |
| 205 |
kate_float *durations; /**< the durations of each curve */ |
| 206 |
kate_motion_mapping x_mapping; /**< how to remap the x coordinate of the points */ |
| 207 |
kate_motion_mapping y_mapping; /**< how to remap the y coordinate of the points */ |
| 208 |
kate_motion_semantics semantics; /**< what use this motion has */ |
| 209 |
unsigned int periodic:1; /**< if true, repeats periodically (loops) */ |
| 210 |
unsigned int pad0:31; |
| 211 |
kate_meta *meta; |
| 212 |
kate_uintptr_t pad1[4]; |
| 213 |
} kate_motion; |
| 214 |
|
| 215 |
/** defines the direction in which glyphs within a text are drawn */ |
| 216 |
typedef enum kate_text_directionality { |
| 217 |
kate_l2r_t2b, /**< left to right, top to bottom: eg, English */ |
| 218 |
kate_r2l_t2b, /**< right to left, top to bottom: eg, Arabic */ |
| 219 |
kate_t2b_r2l, /**< top to bottom, right to left: eg, Japanese */ |
| 220 |
kate_t2b_l2r /**< top to bottom, left to right: eg, Sometimes Japanese */ |
| 221 |
} kate_text_directionality; |
| 222 |
|
| 223 |
/** defines colors to correspond to a bitmap's pixels */ |
| 224 |
typedef struct kate_palette { |
| 225 |
size_t ncolors; /**< number of colors in this palette */ |
| 226 |
kate_color *colors; /**< the list of colors in this palette */ |
| 227 |
kate_meta *meta; |
| 228 |
kate_uintptr_t pad[1]; |
| 229 |
} kate_palette; |
| 230 |
|
| 231 |
/** defines a particular type of bitmap */ |
| 232 |
typedef enum kate_bitmap_type { |
| 233 |
kate_bitmap_type_paletted, /**< paletted bitmap */ |
| 234 |
kate_bitmap_type_png /**< a PNG bitmap */ |
| 235 |
} kate_bitmap_type; |
| 236 |
|
| 237 |
/** defines a paletted image */ |
| 238 |
typedef struct kate_bitmap { |
| 239 |
size_t width; /**< width in pixels */ |
| 240 |
size_t height; /**< height in pixels */ |
| 241 |
unsigned char bpp; /**< bits per pixel, from 1 to 8, or 0 for a raw PNG bitmap */ |
| 242 |
kate_bitmap_type type; /**< the type of this bitmap */ |
| 243 |
unsigned char pad0[1]; |
| 244 |
unsigned char internal; |
| 245 |
int palette; /**< index of the default palette to use */ |
| 246 |
unsigned char *pixels; /**< pixels, rows first, one byte per pixel regardless of bpp */ |
| 247 |
size_t size; /**< for raw bitmaps, number of bytes in pixels */ |
| 248 |
int x_offset; /**< the horizontal offset to the logical origin of the bitmap */ |
| 249 |
int y_offset; /**< the vertical offset to the logical origin of the bitmap */ |
| 250 |
kate_meta *meta; |
| 251 |
kate_uintptr_t pad1[14]; |
| 252 |
} kate_bitmap; |
| 253 |
|
| 254 |
/** defines a set of images to map to a range of Unicode code points */ |
| 255 |
typedef struct kate_font_range { |
| 256 |
int first_code_point; /**< first code point in this range */ |
| 257 |
int last_code_point; /**< last code point in this range */ |
| 258 |
int first_bitmap; /**< index of the bitmap the first code point maps to */ |
| 259 |
kate_uintptr_t pad[5]; |
| 260 |
} kate_font_range; |
| 261 |
|
| 262 |
/** defines a set of ranges to define a font mapping */ |
| 263 |
typedef struct kate_font_mapping { |
| 264 |
size_t nranges; /**< the number of ranges in this mapping */ |
| 265 |
kate_font_range **ranges; /**< the list of ranges in this mapping */ |
| 266 |
kate_uintptr_t pad[6]; |
| 267 |
} kate_font_mapping; |
| 268 |
|
| 269 |
/** |
| 270 |
Information about a Kate bitstream. |
| 271 |
On encoding, this information will be filled by the encoder. |
| 272 |
On decoding, it will be extracted from the stream headers. |
| 273 |
*/ |
| 274 |
typedef struct kate_info { |
| 275 |
unsigned char bitstream_version_major; /**< the version of the bitstream being read or written */ |
| 276 |
unsigned char bitstream_version_minor; /**< the version of the bitstream being read or written */ |
| 277 |
unsigned char pad0[2]; |
| 278 |
|
| 279 |
kate_text_encoding text_encoding; /**< the default text encoding (utf-8 only for now) */ |
| 280 |
kate_text_directionality text_directionality; /**< the default text directionality (left to right, etc) */ |
| 281 |
|
| 282 |
unsigned char num_headers; /**< number of header packets in the bitstream */ |
| 283 |
unsigned char granule_shift; /**< how many low granpos bits are used for the offset */ |
| 284 |
unsigned char pad1[2]; |
| 285 |
|
| 286 |
kate_uint32_t gps_numerator; /**< granules per second numerator */ |
| 287 |
kate_uint32_t gps_denominator; /**< granules per second denominator */ |
| 288 |
|
| 289 |
kate_const char *language; /**< based on RFC 3066, 15 character + terminating zero max */ |
| 290 |
|
| 291 |
kate_const char *category; /**< freeform for now, 15 characters + terminating zero max */ |
| 292 |
|
| 293 |
size_t nregions; /**< the number of predefined regions */ |
| 294 |
kate_const kate_region *kate_const *regions; /**< the list of predefined regions */ |
| 295 |
|
| 296 |
size_t nstyles; /**< the number of predefined styles */ |
| 297 |
kate_const kate_style *kate_const *styles; /**< the list of predefined styles */ |
| 298 |
|
| 299 |
size_t ncurves; /**< the number of predefined curves */ |
| 300 |
kate_const kate_curve *kate_const *curves; /**< the list of predefined curves */ |
| 301 |
|
| 302 |
size_t nmotions; /**< the number of predefined motions */ |
| 303 |
kate_const kate_motion *kate_const *motions; /**< the list of predefined motions */ |
| 304 |
|
| 305 |
size_t npalettes; /**< the number of predefined palettes */ |
| 306 |
kate_const kate_palette *kate_const *palettes; /**< the list of predefined palettes */ |
| 307 |
|
| 308 |
size_t nbitmaps; /**< the number of predefined bitmaps */ |
| 309 |
kate_const kate_bitmap *kate_const *bitmaps; /**< the list of predefined bitmaps */ |
| 310 |
|
| 311 |
size_t nfont_ranges; /**< the number of predefined font ranges */ |
| 312 |
kate_const kate_font_range *kate_const *font_ranges; /**< the list of predefined font ranges */ |
| 313 |
|
| 314 |
size_t nfont_mappings; /**< the number of predefined font mappings */ |
| 315 |
kate_const kate_font_mapping *kate_const *font_mappings; /**< the list of predefined font mappings */ |
| 316 |
|
| 317 |
kate_markup_type text_markup_type; /**< how to interpret any markup found in the text */ |
| 318 |
|
| 319 |
size_t original_canvas_width; /**< width of the canvas this stream was authored for */ |
| 320 |
size_t original_canvas_height; /**< height of the canvas this stream was authored for */ |
| 321 |
|
| 322 |
kate_uintptr_t pad2[11]; |
| 323 |
|
| 324 |
/* internal */ |
| 325 |
int remove_markup; |
| 326 |
int no_limits; |
| 327 |
int probe; |
| 328 |
|
| 329 |
kate_uintptr_t pad3[13]; |
| 330 |
} kate_info; |
| 331 |
|
| 332 |
struct kate_encode_state; /* internal */ |
| 333 |
struct kate_decode_state; /* internal */ |
| 334 |
|
| 335 |
/** top level information about a Kate bitstream */ |
| 336 |
typedef struct kate_state { |
| 337 |
kate_const kate_info *ki; /**< the kate_info associated with this state */ |
| 338 |
|
| 339 |
/* internal */ |
| 340 |
kate_const struct kate_encode_state *kes; |
| 341 |
kate_const struct kate_decode_state *kds; |
| 342 |
|
| 343 |
kate_uintptr_t pad[5]; |
| 344 |
} kate_state; |
| 345 |
|
| 346 |
/** Vorbis comments - this is the same as Vorbis and Theora comments */ |
| 347 |
typedef struct kate_comment { |
| 348 |
char **user_comments; /**< the list of comments, in the form "tag=value" */ |
| 349 |
int *comment_lengths; /**< the lengths of the comment strings in bytes */ |
| 350 |
int comments; /**< the number of comments in the list */ |
| 351 |
char *vendor; /**< vendor string, null terminated */ |
| 352 |
} kate_comment; |
| 353 |
|
| 354 |
/** |
| 355 |
This is an event passed to the user. |
| 356 |
A kate_tracker may be used to track animation changes to this event. |
| 357 |
*/ |
| 358 |
typedef struct kate_event { |
| 359 |
kate_int64_t start; /**< the time at offset rate at which this event starts */ |
| 360 |
kate_int64_t duration; /**< the duration in granules */ |
| 361 |
kate_int64_t backlink; /**< the relative offset in granules since the start of the earliest still active event (positive or zero) */ |
| 362 |
|
| 363 |
kate_float start_time; /**< the time at which this event starts */ |
| 364 |
kate_float end_time; /**< the time at which this event ends */ |
| 365 |
|
| 366 |
kate_int32_t id; /**< unique id to identify this event */ |
| 367 |
|
| 368 |
kate_text_encoding text_encoding; /**< character encoding for the text in this event */ |
| 369 |
kate_text_directionality text_directionality; /**< directionality of the text in this event */ |
| 370 |
kate_const char *language; /**< language of the text in this event (may be NULL if no override) */ |
| 371 |
kate_const char *text; /**< the event text (may be NULL if none) */ |
| 372 |
size_t len; /**< length in bytes of the text */ |
| 373 |
size_t len0; /**< length in bytes of the text, including terminating zero(s) */ |
| 374 |
|
| 375 |
size_t nmotions; /**< number of attached motions (may be zero) */ |
| 376 |
kate_const kate_motion *kate_const *motions; /**< the list of attached motions (may be NULL if none) */ |
| 377 |
|
| 378 |
kate_const kate_region *region; /**< region to display in (may be NULL for no particular region) */ |
| 379 |
kate_const kate_style *style; /**< style to display text (may be NULL for no particular style) */ |
| 380 |
kate_const kate_style *secondary_style; /**< secondary style to display text (may be NULL for no particular style) */ |
| 381 |
kate_const kate_font_mapping *font_mapping; /**< font mapping to use for the text (may be NULL for no particular mapping) */ |
| 382 |
kate_const kate_palette *palette; /**< palette to use as background (may be NULL for none) */ |
| 383 |
kate_const kate_bitmap *bitmap; /**< bitmap to use as background (may be NULL for none) */ |
| 384 |
|
| 385 |
kate_markup_type text_markup_type; /**< how to interpret any markup found in the text */ |
| 386 |
|
| 387 |
size_t nbitmaps; /**< number of attached bitmaps (may be zero) */ |
| 388 |
kate_const kate_bitmap *kate_const *bitmaps; /**< the list of attached bitmaps (may be NULL if none) */ |
| 389 |
|
| 390 |
kate_meta *meta; |
| 391 |
|
| 392 |
kate_uintptr_t pad0[5]; |
| 393 |
|
| 394 |
/* internal */ |
| 395 |
const kate_info *ki; |
| 396 |
size_t trackers; |
| 397 |
|
| 398 |
kate_uintptr_t pad1[10]; |
| 399 |
} kate_event; |
| 400 |
|
| 401 |
struct kate_tracker_internal; /* internal */ |
| 402 |
|
| 403 |
/** this keeps track of changes during an event's lifetime */ |
| 404 |
typedef struct kate_tracker { |
| 405 |
const kate_info *ki; /**< the kate_info associated with this tracker */ |
| 406 |
kate_const kate_event *event; /**< the event being tracked */ |
| 407 |
kate_float t; /**< the current time at which the tracker interpolates */ |
| 408 |
|
| 409 |
struct { |
| 410 |
unsigned int region:1; /**< if set, the tracker has region information */ |
| 411 |
unsigned int text_alignment_int:1; /**< if set, the tracker has internal text alignment information */ |
| 412 |
unsigned int text_alignment_ext:1; /**< if set, the tracker has external text alignment information */ |
| 413 |
unsigned int text_pos:1; /**< if set, the tracker has text position information */ |
| 414 |
unsigned int text_size:1; /**< if set, the tracker has text size information */ |
| 415 |
unsigned int marker_pos:4; /**< if set, the tracker has marker position information */ |
| 416 |
unsigned int text_color:1; /**< if set, the tracker has text color information */ |
| 417 |
unsigned int background_color:1; /**< if set, the tracker has background color information */ |
| 418 |
unsigned int draw_color:1; /**< if set, the tracker has draw color information */ |
| 419 |
unsigned int glyph_pointer:4; /**< if set, the tracker has glyph pointer information */ |
| 420 |
unsigned int path:1; /**< if set, the tracker has text path information */ |
| 421 |
unsigned int draw:1; /**< if set, the tracker has draw information */ |
| 422 |
unsigned int visible_section:1; /**< if set, the tracker has visible section information */ |
| 423 |
unsigned int z:1; /**< if set, the tracker has z (depth) information */ |
| 424 |
unsigned int hmargins:1; /**< if set, the tracker has horizontal margin information */ |
| 425 |
unsigned int vmargins:1; /**< if set, the tracker has vertical margin information */ |
| 426 |
unsigned int bitmap_pos:1; /**< if set, the tracker has bitmap position information */ |
| 427 |
unsigned int bitmap_size:1; /**< if set, the tracker has bitmap size information */ |
| 428 |
unsigned int marker_bitmap:4; /**< if set, the tracker has bitmap information for the marker bitmap */ |
| 429 |
unsigned int glyph_pointer_bitmap:4; /**< if set, the tracker has bitmap information for the glyph pointer bitmap */ |
| 430 |
unsigned int draw_width:1; /**< if set, the tracker has draw line width information */ |
| 431 |
/* 33 bits */ |
| 432 |
unsigned int pad0:31; |
| 433 |
/* 64 bits */ |
| 434 |
} has; /**< bitfield describing what information the tracker has */ |
| 435 |
|
| 436 |
int window_w; /**< the window width */ |
| 437 |
int window_h; /**< the window height */ |
| 438 |
int frame_x; /**< the video frame origin in the window */ |
| 439 |
int frame_y; /**< the video frame origin in the window */ |
| 440 |
int frame_w; /**< the video frame width */ |
| 441 |
int frame_h; /**< the video frame height */ |
| 442 |
|
| 443 |
/* has.region */ |
| 444 |
kate_float region_x; /**< the region horizontal position in pixels */ |
| 445 |
kate_float region_y; /**< the region vertical position in pixels */ |
| 446 |
kate_float region_w; /**< the region width in pixels */ |
| 447 |
kate_float region_h; /**< the region height in pixels */ |
| 448 |
|
| 449 |
/* has.text_alignment (int/ext) */ |
| 450 |
kate_float text_halign; /**< the horizontal text alignment (-1 for left, 1 for right, etc) */ |
| 451 |
kate_float text_valign; /**< the vertical text alignment (-1 for top, 1 for bottom, etc) */ |
| 452 |
|
| 453 |
/* has.text_pos */ |
| 454 |
kate_float text_x; /**< the horizontal text position */ |
| 455 |
kate_float text_y; /**< the vertical text position */ |
| 456 |
|
| 457 |
/* has.text_size */ |
| 458 |
kate_float text_size_x; /**< the horizontal text size (eg, width) */ |
| 459 |
kate_float text_size_y; /**< the vertical text size (eg, height) */ |
| 460 |
|
| 461 |
/* has.marker_pos&(1<<n) */ |
| 462 |
kate_float marker_x[4]; /**< the horizontal position of each marker */ |
| 463 |
kate_float marker_y[4]; /**< the vertical position of each marker */ |
| 464 |
|
| 465 |
/* has.text_color */ |
| 466 |
kate_color text_color; /**< the text color */ |
| 467 |
|
| 468 |
/* has.background_color */ |
| 469 |
kate_color background_color; /**< the background color */ |
| 470 |
|
| 471 |
/* has.draw_color */ |
| 472 |
kate_color draw_color; /**< the draw color */ |
| 473 |
|
| 474 |
/* has.glyph_pointer&(1<<n) */ |
| 475 |
kate_float glyph_pointer[4]; /**< the glyph index of each glyph pointer */ |
| 476 |
kate_float glyph_height[4]; /**< the height associated with each glyph pointer in pixels */ |
| 477 |
|
| 478 |
/* has.path */ |
| 479 |
kate_float path_start; /**< the starting point of the current path part */ |
| 480 |
kate_float path_end; /**< the end point of the current path part */ |
| 481 |
|
| 482 |
/* has.draw */ |
| 483 |
kate_float draw_x; /**< the current horizontal position of the drawn shape */ |
| 484 |
kate_float draw_y; /**< the current vertical position of the drawn shape */ |
| 485 |
|
| 486 |
/* has.visible_section */ |
| 487 |
kate_float visible_x; /**< the glyph index of the first visible glyph */ |
| 488 |
kate_float visible_y; /**< the glyph index of the last visible glyph */ |
| 489 |
|
| 490 |
/* has.z */ |
| 491 |
kate_float z; /**< the depth of this event's text */ |
| 492 |
|
| 493 |
/* has.hmargins */ |
| 494 |
kate_float left_margin; /**< the size of the left margin */ |
| 495 |
kate_float right_margin; /**< the size of the right margin */ |
| 496 |
|
| 497 |
/* has.vmargins */ |
| 498 |
kate_float top_margin; /**< the size of the top margin */ |
| 499 |
kate_float bottom_margin; /**< the size of the bottom margin */ |
| 500 |
|
| 501 |
/* has.bitmap_pos */ |
| 502 |
kate_float bitmap_x; /**< the horizontal bitmap position */ |
| 503 |
kate_float bitmap_y; /**< the vertical bitmap position */ |
| 504 |
|
| 505 |
/* has.bitmap_size */ |
| 506 |
kate_float bitmap_size_x; /**< the horizontal bitmap size (eg, width) */ |
| 507 |
kate_float bitmap_size_y; /**< the vertical bitmap size (eg, height) */ |
| 508 |
|
| 509 |
/* has.marker_bitmap&(1<<n) */ |
| 510 |
const kate_bitmap *marker_bitmap[4]; /**< index of the bitmap for the marker bitmap */ |
| 511 |
|
| 512 |
/* has.glyph_pointer_bitmap&(1<<n) */ |
| 513 |
const kate_bitmap *glyph_pointer_bitmap[4]; /**< index of the bitmap for the glyph pointer bitmap */ |
| 514 |
|
| 515 |
/* has.draw_width */ |
| 516 |
kate_float draw_width; /**< width of the drawn line */ |
| 517 |
|
| 518 |
/* internal */ |
| 519 |
struct kate_tracker_internal *internal; |
| 520 |
|
| 521 |
kate_uintptr_t pad[19]; |
| 522 |
|
| 523 |
} kate_tracker; |
| 524 |
|
| 525 |
/** a kate packet raw data */ |
| 526 |
typedef struct kate_packet { |
| 527 |
size_t nbytes; /**< the number of bytes in this packet */ |
| 528 |
void *data; /**< pointer to the data in this packet */ |
| 529 |
} kate_packet; |
| 530 |
|
| 531 |
#ifdef __cplusplus |
| 532 |
extern "C" { |
| 533 |
#endif |
| 534 |
|
| 535 |
/** \defgroup version Version information */ |
| 536 |
extern int kate_get_version(void); |
| 537 |
extern const char *kate_get_version_string(void); |
| 538 |
extern int kate_get_bitstream_version(void); |
| 539 |
extern const char *kate_get_bitstream_version_string(void); |
| 540 |
|
| 541 |
/** \defgroup info kate_info access */ |
| 542 |
extern int kate_info_init(kate_info *ki); |
| 543 |
extern int kate_info_set_granule_encoding(kate_info *ki,kate_float resolution,kate_float max_length,kate_float max_event_lifetime); |
| 544 |
extern int kate_info_set_language(kate_info *ki,const char *language); |
| 545 |
extern int kate_info_set_text_directionality(kate_info *ki,kate_text_directionality text_directionality); |
| 546 |
extern int kate_info_set_markup_type(kate_info *ki,kate_markup_type text_markup_type); |
| 547 |
extern int kate_info_set_category(kate_info *ki,const char *category); |
| 548 |
extern int kate_info_set_original_canvas_size(kate_info *ki,size_t width,size_t height); |
| 549 |
extern int kate_info_add_region(kate_info *ki,kate_region *kr); |
| 550 |
extern int kate_info_add_style(kate_info *ki,kate_style *ks); |
| 551 |
extern int kate_info_add_curve(kate_info *ki,kate_curve *kc); |
| 552 |
extern int kate_info_add_motion(kate_info *ki,kate_motion *km); |
| 553 |
extern int kate_info_add_palette(kate_info *ki,kate_palette *kp); |
| 554 |
extern int kate_info_add_bitmap(kate_info *ki,kate_bitmap *kb); |
| 555 |
extern int kate_info_add_font_range(kate_info *ki,kate_font_range *kfr); |
| 556 |
extern int kate_info_add_font_mapping(kate_info *ki,kate_font_mapping *kfm); |
| 557 |
extern int kate_info_matches_language(const kate_info *ki,const char *language); |
| 558 |
extern int kate_info_remove_markup(kate_info *ki,int flag); |
| 559 |
extern int kate_info_no_limits(kate_info *ki,int flag); |
| 560 |
extern int kate_info_clear(kate_info *ki); |
| 561 |
|
| 562 |
/** \defgroup granule Granule calculations */ |
| 563 |
extern int kate_granule_shift(const kate_info *ki); |
| 564 |
extern int kate_granule_split_time(const kate_info *ki,kate_int64_t granulepos,kate_float *base,kate_float *offset); |
| 565 |
extern kate_float kate_granule_time(const kate_info *ki,kate_int64_t granulepos); |
| 566 |
extern kate_int64_t kate_duration_granule(const kate_info *ki,kate_float duration); |
| 567 |
extern kate_float kate_granule_duration(const kate_info *ki,kate_int64_t duration); |
| 568 |
|
| 569 |
/** \defgroup misc misc */ |
| 570 |
extern int kate_clear(kate_state *k); |
| 571 |
extern int kate_motion_get_point(const kate_motion *km,kate_float duration,kate_float t,kate_float *x,kate_float *y); |
| 572 |
extern int kate_curve_get_point(const kate_curve *kc,kate_float t,kate_float *x,kate_float *y); |
| 573 |
extern int kate_region_init(kate_region *kr); |
| 574 |
extern int kate_style_init(kate_style *ks); |
| 575 |
extern int kate_palette_init(kate_palette *kp); |
| 576 |
extern int kate_bitmap_init(kate_bitmap *kb); |
| 577 |
extern int kate_bitmap_init_new(kate_bitmap *kb); |
| 578 |
extern int kate_curve_init(kate_curve *kc); |
| 579 |
extern int kate_motion_init(kate_motion *km); |
| 580 |
|
| 581 |
/** \defgroup text Text manipulation */ |
| 582 |
extern int kate_text_get_character(kate_text_encoding text_encoding,const char ** const text,size_t *len0); |
| 583 |
extern int kate_text_set_character(kate_text_encoding text_encoding,int c,char ** const text,size_t *len0); |
| 584 |
extern int kate_text_remove_markup(kate_text_encoding text_encoding,char *text,size_t *len0); |
| 585 |
extern int kate_text_validate(kate_text_encoding text_encoding,const char *text,size_t len0); |
| 586 |
|
| 587 |
/** \defgroup comments kate_comment access */ |
| 588 |
extern int kate_comment_init(kate_comment *kc); |
| 589 |
extern int kate_comment_clear(kate_comment *kc); |
| 590 |
extern int kate_comment_add(kate_comment *kc,const char *comment); |
| 591 |
extern int kate_comment_add_length(kate_comment *kc,const char *comment,size_t len); |
| 592 |
extern int kate_comment_add_tag(kate_comment *kc,const char *tag,const char *value); |
| 593 |
extern const char *kate_comment_query(const kate_comment *kc,const char *tag,int count); |
| 594 |
extern int kate_comment_query_count(const kate_comment *kc,const char *tag); |
| 595 |
|
| 596 |
/** \defgroup encoding Encoding */ |
| 597 |
extern int kate_encode_init(kate_state *k,kate_info *ki); |
| 598 |
extern int kate_encode_headers(kate_state *k,kate_comment *kc,kate_packet *kp); |
| 599 |
extern int kate_encode_text(kate_state *k,kate_float start_time,kate_float stop_time,const char *text,size_t sz,kate_packet *kp); /* text is not null terminated */ |
| 600 |
extern int kate_encode_text_raw_times(kate_state *k,kate_int64_t start_time,kate_int64_t stop_time,const char *text,size_t sz,kate_packet *kp); /* text is not null terminated */ |
| 601 |
extern int kate_encode_keepalive(kate_state *k,kate_float t,kate_packet *kp); |
| 602 |
extern int kate_encode_keepalive_raw_times(kate_state *k,kate_int64_t t,kate_packet *kp); |
| 603 |
extern int kate_encode_repeat(kate_state *k,kate_float t,kate_float threshold,kate_packet *kp); |
| 604 |
extern int kate_encode_repeat_raw_times(kate_state *k,kate_int64_t t,kate_int64_t threshold,kate_packet *kp); |
| 605 |
extern int kate_encode_finish(kate_state *k,kate_float t,kate_packet *kp); /* t may be negative to use the end granule of the last event */ |
| 606 |
extern int kate_encode_finish_raw_times(kate_state *k,kate_int64_t t,kate_packet *kp); /* t may be negative to use the end granule of the last event */ |
| 607 |
extern int kate_encode_set_id(kate_state *k,kate_int32_t id); |
| 608 |
extern int kate_encode_set_language(kate_state *k,const char *language); /* language can be NULL */ |
| 609 |
extern int kate_encode_set_text_encoding(kate_state *k,kate_text_encoding text_encoding); |
| 610 |
extern int kate_encode_set_text_directionality(kate_state *k,kate_text_directionality text_directionality); |
| 611 |
extern int kate_encode_set_region_index(kate_state *k,size_t region); |
| 612 |
extern int kate_encode_set_region(kate_state *k,const kate_region *kr); |
| 613 |
extern int kate_encode_set_style_index(kate_state *k,size_t style); |
| 614 |
extern int kate_encode_set_style(kate_state *k,const kate_style *ks); |
| 615 |
extern int kate_encode_set_secondary_style_index(kate_state *k,size_t style); |
| 616 |
extern int kate_encode_set_secondary_style(kate_state *k,const kate_style *ks); |
| 617 |
extern int kate_encode_set_font_mapping_index(kate_state *k,size_t font_mapping); |
| 618 |
extern int kate_encode_add_motion(kate_state *k,kate_motion *km,int destroy); |
| 619 |
extern int kate_encode_add_motion_index(kate_state *k,size_t motion); |
| 620 |
extern int kate_encode_set_palette_index(kate_state *k,size_t palette); |
| 621 |
extern int kate_encode_set_palette(kate_state *k,const kate_palette *kp); |
| 622 |
extern int kate_encode_set_bitmap_index(kate_state *k,size_t bitmap); |
| 623 |
extern int kate_encode_set_bitmap(kate_state *k,const kate_bitmap *kb); |
| 624 |
extern int kate_encode_add_bitmap(kate_state *k,const kate_bitmap *kb); |
| 625 |
extern int kate_encode_add_bitmap_index(kate_state *k,size_t bitmap); |
| 626 |
extern int kate_encode_set_markup_type(kate_state *k,int markup_type); |
| 627 |
extern int kate_encode_merge_meta(kate_state *k,kate_meta *meta); |
| 628 |
extern int kate_encode_add_meta(kate_state *k,const kate_meta *meta); |
| 629 |
extern kate_int64_t kate_encode_get_granule(const kate_state *k); |
| 630 |
|
| 631 |
/** \defgroup decoding Decoding */ |
| 632 |
extern int kate_decode_is_idheader(const kate_packet *kp); |
| 633 |
extern int kate_decode_init(kate_state *k,kate_info *ki); |
| 634 |
extern int kate_decode_headerin(kate_info *ki,kate_comment *kc,kate_packet *kp); |
| 635 |
extern int kate_decode_packetin(kate_state *k,kate_packet *kp); |
| 636 |
extern int kate_decode_eventout(kate_state *k,kate_const kate_event **ev); /* event can be NULL */ |
| 637 |
extern int kate_decode_seek(kate_state *k); |
| 638 |
|
| 639 |
/** \defgroup tracker Tracker */ |
| 640 |
extern int kate_tracker_init(kate_tracker *kin,const kate_info *ki,kate_const kate_event *ev); |
| 641 |
extern int kate_tracker_clear(kate_tracker *kin); |
| 642 |
extern int kate_tracker_update(kate_tracker *kin,kate_float t,int window_w,int window_h,int frame_x,int frame_y,int frame_w,int frame_h); |
| 643 |
extern int kate_tracker_morph_styles(kate_style *style,kate_float t,const kate_style *from,const kate_style *to); |
| 644 |
extern int kate_tracker_get_text_path_position(kate_tracker *kin,size_t glyph,int *x,int *y); |
| 645 |
extern int kate_tracker_update_property_at_duration(const kate_tracker *kin,kate_float duration,kate_float t,kate_motion_semantics semantics,kate_float *x,kate_float *y); |
| 646 |
extern int kate_tracker_remap(const kate_tracker *kin,kate_motion_mapping x_mapping,kate_motion_mapping y_mapping,kate_float *x,kate_float *y); |
| 647 |
|
| 648 |
/** \defgroup font Font */ |
| 649 |
extern int kate_font_get_index_from_code_point(const kate_font_mapping *kfm,int c); |
| 650 |
|
| 651 |
/** \defgroup high High level API */ |
| 652 |
extern int kate_high_decode_init(kate_state *k); |
| 653 |
extern int kate_high_decode_packetin(kate_state *k,kate_packet *kp,kate_const kate_event **ev); |
| 654 |
extern int kate_high_decode_clear(kate_state *k); |
| 655 |
extern const kate_comment *kate_high_decode_get_comments(kate_state *k); |
| 656 |
|
| 657 |
/** \defgroup packet kate_packet */ |
| 658 |
extern int kate_packet_wrap(kate_packet *kp,size_t nbytes,const void *data); |
| 659 |
extern int kate_packet_init(kate_packet *kp,size_t nbytes,const void *data); |
| 660 |
extern int kate_packet_clear(kate_packet *kp); |
| 661 |
|
| 662 |
/** \defgroup metadata Meta data */ |
| 663 |
extern int kate_meta_create(kate_meta **km); |
| 664 |
extern int kate_meta_destroy(kate_meta *km); |
| 665 |
extern int kate_meta_add(kate_meta *km,const char *tag,const char *value,size_t len); |
| 666 |
extern int kate_meta_add_string(kate_meta *km,const char *tag,const char *value); |
| 667 |
extern int kate_meta_query_tag_count(const kate_meta *km,const char *tag); |
| 668 |
extern int kate_meta_query_tag(const kate_meta *km,const char *tag,unsigned int idx,const char **value,size_t *len); |
| 669 |
extern int kate_meta_remove_tag(kate_meta *km,const char *tag,unsigned int idx); |
| 670 |
extern int kate_meta_query_count(const kate_meta *km); |
| 671 |
extern int kate_meta_query(const kate_meta *km,unsigned int idx,const char **tag,const char **value,size_t *len); |
| 672 |
extern int kate_meta_remove(kate_meta *km,unsigned int idx); |
| 673 |
extern int kate_meta_merge(kate_meta *km,kate_meta *km2); |
| 674 |
|
| 675 |
#ifdef __cplusplus |
| 676 |
} |
| 677 |
#endif |
| 678 |
|
| 679 |
/** \name Error codes */ |
| 680 |
/** @{ */ |
| 681 |
#define KATE_E_NOT_FOUND (-1) /**< whatever was requested was not found */ |
| 682 |
#define KATE_E_INVALID_PARAMETER (-2) /**< a bogus parameter was passed (usually NULL) */ |
| 683 |
#define KATE_E_OUT_OF_MEMORY (-3) /**< we're running out of cheese, bring some more */ |
| 684 |
#define KATE_E_BAD_GRANULE (-4) /**< decreasing granule */ |
| 685 |
#define KATE_E_INIT (-5) /**< initializing twice, using an uninitialized state, etc */ |
| 686 |
#define KATE_E_BAD_PACKET (-6) /**< packet contains invalid data */ |
| 687 |
#define KATE_E_TEXT (-7) /**< invalid/truncated character/sequence, etc */ |
| 688 |
#define KATE_E_LIMIT (-8) /**< a limit was exceeded (eg, string too long, pixel value above bpp, etc) */ |
| 689 |
#define KATE_E_VERSION (-9) /**< we do not understand that bitstream version */ |
| 690 |
#define KATE_E_NOT_KATE (-10) /**< the packet is not a Kate packet */ |
| 691 |
#define KATE_E_BAD_TAG (-11) /**< a tag does not comply with the Vorbis comment rules */ |
| 692 |
#define KATE_E_IMPL (-12) /**< the requested feature is not implemented */ |
| 693 |
/** @} */ |
| 694 |
|
| 695 |
#endif |
| 696 |
|