| 1 |
/* Copyright (C) 2008 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 |
#ifdef HAVE_CONFIG_H |
| 11 |
#include "config.h" |
| 12 |
#endif |
| 13 |
#ifdef HAVE_UNISTD_H |
| 14 |
#include <unistd.h> |
| 15 |
#endif |
| 16 |
#include <stdarg.h> |
| 17 |
#include <stdio.h> |
| 18 |
#ifdef HAVE_STDLIB_H |
| 19 |
#include <stdlib.h> |
| 20 |
#endif |
| 21 |
#include <errno.h> |
| 22 |
#ifdef HAVE_STRING_H |
| 23 |
#include <string.h> |
| 24 |
#endif |
| 25 |
#include <ogg/ogg.h> |
| 26 |
#include "kate/oggkate.h" |
| 27 |
#include "kate_internal.h" |
| 28 |
#include "kutil.h" |
| 29 |
|
| 30 |
const char *halign2text(kate_float d) |
| 31 |
{ |
| 32 |
static char tmp[32]; |
| 33 |
if (d==0.0) return "hcenter"; |
| 34 |
if (d==1.0) return "hright"; |
| 35 |
if (d==-1.0) return "hleft"; |
| 36 |
snprintf(tmp,sizeof(tmp),"halign %.16g",d); |
| 37 |
tmp[sizeof(tmp)-1]=0; |
| 38 |
return tmp; |
| 39 |
} |
| 40 |
|
| 41 |
const char *valign2text(kate_float d) |
| 42 |
{ |
| 43 |
static char tmp[32]; |
| 44 |
if (d==0.0) return "vcenter"; |
| 45 |
if (d==-1.0) return "vtop"; |
| 46 |
if (d==1.0) return "vbottom"; |
| 47 |
snprintf(tmp,sizeof(tmp),"valign %.16g",d); |
| 48 |
tmp[sizeof(tmp)-1]=0; |
| 49 |
return tmp; |
| 50 |
} |
| 51 |
|
| 52 |
const char *metric2text(kate_space_metric d) |
| 53 |
{ |
| 54 |
switch (d) { |
| 55 |
case kate_pixel: return "pixel"; |
| 56 |
case kate_percentage: return "percent"; |
| 57 |
case kate_millionths: return "millionths"; |
| 58 |
default: return "invalid"; |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
const char *metric2suffix(kate_space_metric d) |
| 63 |
{ |
| 64 |
switch (d) { |
| 65 |
case kate_pixel: return ""; |
| 66 |
case kate_percentage: return "%"; |
| 67 |
case kate_millionths: return "m"; |
| 68 |
default: return "invalid"; |
| 69 |
} |
| 70 |
} |
| 71 |
|
| 72 |
const char *curve2text(kate_curve_type d) |
| 73 |
{ |
| 74 |
switch (d) { |
| 75 |
case kate_curve_none: return "none"; |
| 76 |
case kate_curve_static: return "static"; |
| 77 |
case kate_curve_linear: return "linear"; |
| 78 |
case kate_curve_catmull_rom_spline: return "catmull_rom"; |
| 79 |
case kate_curve_bezier_cubic_spline: return "bezier_cubic"; |
| 80 |
case kate_curve_bspline: return "bspline"; |
| 81 |
} |
| 82 |
return "invalid"; |
| 83 |
} |
| 84 |
|
| 85 |
const char *semantics2text(kate_motion_semantics d) |
| 86 |
{ |
| 87 |
static char tmp[32]; |
| 88 |
switch (d) { |
| 89 |
case kate_motion_semantics_time: return "time"; |
| 90 |
case kate_motion_semantics_region_position: return "region position"; |
| 91 |
case kate_motion_semantics_region_size: return "region size"; |
| 92 |
case kate_motion_semantics_text_alignment_ext: return "external text alignment"; |
| 93 |
case kate_motion_semantics_text_alignment_int: return "internal text alignment"; |
| 94 |
case kate_motion_semantics_text_position: return "text position"; |
| 95 |
case kate_motion_semantics_text_size: return "text size"; |
| 96 |
case kate_motion_semantics_marker1_position: return "marker 1 position"; |
| 97 |
case kate_motion_semantics_marker2_position: return "marker 2 position"; |
| 98 |
case kate_motion_semantics_marker3_position: return "marker 3 position"; |
| 99 |
case kate_motion_semantics_marker4_position: return "marker 4 position"; |
| 100 |
case kate_motion_semantics_glyph_pointer_1: return "glyph pointer 1"; |
| 101 |
case kate_motion_semantics_glyph_pointer_2: return "glyph pointer 2"; |
| 102 |
case kate_motion_semantics_glyph_pointer_3: return "glyph pointer 3"; |
| 103 |
case kate_motion_semantics_glyph_pointer_4: return "glyph pointer 4"; |
| 104 |
case kate_motion_semantics_text_color_rg: return "text color rg"; |
| 105 |
case kate_motion_semantics_text_color_ba: return "text color ba"; |
| 106 |
case kate_motion_semantics_background_color_rg: return "background color rg"; |
| 107 |
case kate_motion_semantics_background_color_ba: return "background color ba"; |
| 108 |
case kate_motion_semantics_draw_color_rg: return "draw color rg"; |
| 109 |
case kate_motion_semantics_draw_color_ba: return "draw color ba"; |
| 110 |
case kate_motion_semantics_style_morph: return "style morph"; |
| 111 |
case kate_motion_semantics_text_path: return "text path"; |
| 112 |
case kate_motion_semantics_text_path_section: return "text path section"; |
| 113 |
case kate_motion_semantics_draw: return "draw"; |
| 114 |
case kate_motion_semantics_text_visible_section: return "visible section"; |
| 115 |
case kate_motion_semantics_z: return "z"; |
| 116 |
case kate_motion_semantics_horizontal_margins: return "horizontal margins"; |
| 117 |
case kate_motion_semantics_vertical_margins: return "vertical margins"; |
| 118 |
case kate_motion_semantics_bitmap_position: return "bitmap position"; |
| 119 |
case kate_motion_semantics_bitmap_size: return "bitmap size"; |
| 120 |
case kate_motion_semantics_marker1_bitmap: return "marker 1 bitmap"; |
| 121 |
case kate_motion_semantics_marker2_bitmap: return "marker 2 bitmap"; |
| 122 |
case kate_motion_semantics_marker3_bitmap: return "marker 3 bitmap"; |
| 123 |
case kate_motion_semantics_marker4_bitmap: return "marker 4 bitmap"; |
| 124 |
case kate_motion_semantics_glyph_pointer_1_bitmap: return "glyph pointer 1 bitmap"; |
| 125 |
case kate_motion_semantics_glyph_pointer_2_bitmap: return "glyph pointer 2 bitmap"; |
| 126 |
case kate_motion_semantics_glyph_pointer_3_bitmap: return "glyph pointer 3 bitmap"; |
| 127 |
case kate_motion_semantics_glyph_pointer_4_bitmap: return "glyph pointer 4 bitmap"; |
| 128 |
case kate_motion_semantics_draw_width: return "draw width"; |
| 129 |
default: snprintf(tmp,sizeof(tmp),"user %u",d); return tmp; |
| 130 |
} |
| 131 |
return "invalid"; |
| 132 |
} |
| 133 |
|
| 134 |
const char *mapping2text(kate_motion_mapping d) |
| 135 |
{ |
| 136 |
static char tmp[32]; |
| 137 |
switch (d) { |
| 138 |
case kate_motion_mapping_none: return "none"; |
| 139 |
case kate_motion_mapping_frame: return "frame"; |
| 140 |
case kate_motion_mapping_region: return "region"; |
| 141 |
case kate_motion_mapping_event_duration: return "event duration"; |
| 142 |
case kate_motion_mapping_bitmap_size: return "bitmap size"; |
| 143 |
default: snprintf(tmp,sizeof(tmp),"user %u",d); return tmp; |
| 144 |
} |
| 145 |
return "invalid"; |
| 146 |
} |
| 147 |
|
| 148 |
const char *directionality2text(kate_text_directionality d) |
| 149 |
{ |
| 150 |
switch (d) { |
| 151 |
case kate_l2r_t2b: return "l2r_t2b"; |
| 152 |
case kate_r2l_t2b: return "r2l_t2b"; |
| 153 |
case kate_t2b_r2l: return "t2b_r2l"; |
| 154 |
case kate_t2b_l2r: return "t2b_l2r"; |
| 155 |
} |
| 156 |
return "invalid"; |
| 157 |
} |
| 158 |
|
| 159 |
const char *wrap2text(kate_wrap_mode w) |
| 160 |
{ |
| 161 |
switch (w) { |
| 162 |
case kate_wrap_word: return "word"; |
| 163 |
case kate_wrap_none: return "none"; |
| 164 |
} |
| 165 |
return "invalid"; |
| 166 |
} |
| 167 |
|
| 168 |
const char *encoding2text(kate_text_encoding text_encoding) |
| 169 |
{ |
| 170 |
switch (text_encoding) { |
| 171 |
case kate_utf8: return "UTF-8"; |
| 172 |
default: return "unknown"; |
| 173 |
} |
| 174 |
} |
| 175 |
|