- Timestamp:
- Oct 18, 2008, 11:36:17 PM (15 years ago)
- Location:
- toilet/trunk
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/configure.ac
r2537 r2988 52 52 53 53 CUCUL="no" 54 PKG_CHECK_MODULES(C UCUL, cucul >= 0.99.beta14,54 PKG_CHECK_MODULES(CACA, caca >= 0.99.beta15, 55 55 [CUCUL="yes"], 56 56 [AC_MSG_RESULT(no) 57 AC_MSG_ERROR([you need libc ucul version 0.99.beta14or later])])57 AC_MSG_ERROR([you need libcaca version 0.99.beta15 or later])]) 58 58 59 59 AC_MSG_CHECKING([for release date]) -
toilet/trunk/doc/toilet.1.in
r1403 r2988 123 123 such as XTerm or rxvt. 124 124 .I <format> 125 is the name of the export format as recognised by libc ucul. The special125 is the name of the export format as recognised by libcaca. The special 126 126 argument 127 127 .I list -
toilet/trunk/src/Makefile.am
r2420 r2988 8 8 term.c figlet.c 9 9 toilet_CPPFLAGS = -DFONTDIR=\"$(datadir)/figlet\" 10 toilet_CFLAGS = @C UCUL_CFLAGS@11 toilet_LDADD = @C UCUL_LIBS@ @GETOPT_LIBS@ @ZLIB_LIBS@10 toilet_CFLAGS = @CACA_CFLAGS@ 11 toilet_LDADD = @CACA_LIBS@ @GETOPT_LIBS@ @ZLIB_LIBS@ 12 12 -
toilet/trunk/src/export.c
r1461 r2988 25 25 #include <stdio.h> 26 26 #include <stdlib.h> 27 #include <c ucul.h>27 #include <caca.h> 28 28 29 29 #include "toilet.h" … … 36 36 printf("Available export formats:\n"); 37 37 38 exports = c ucul_get_export_list();38 exports = caca_get_export_list(); 39 39 for(p = exports; *p; p += 2) 40 40 printf("\"%s\": %s\n", *p, *(p + 1)); … … 49 49 cx->export = format; 50 50 51 exports = c ucul_get_export_list();51 exports = caca_get_export_list(); 52 52 for(p = exports; *p; p += 2) 53 53 if(!strcmp(*p, format)) -
toilet/trunk/src/figlet.c
r2420 r2988 25 25 #include <stdlib.h> 26 26 #include <string.h> 27 #include <c ucul.h>27 #include <caca.h> 28 28 29 29 #include "toilet.h" … … 42 42 43 43 snprintf(path, 2047, "%s/%s", cx->dir, cx->font); 44 if(c ucul_canvas_set_figfont(cx->cv, path))44 if(caca_canvas_set_figfont(cx->cv, path)) 45 45 return -1; 46 46 … … 54 54 static int feed_figlet(context_t *cx, uint32_t ch, uint32_t attr) 55 55 { 56 return c ucul_put_figchar(cx->cv, ch);56 return caca_put_figchar(cx->cv, ch); 57 57 } 58 58 59 59 static int flush_figlet(context_t *cx) 60 60 { 61 int ret = c ucul_flush_figlet(cx->cv);61 int ret = caca_flush_figlet(cx->cv); 62 62 cx->torender = cx->cv; 63 cx->cv = c ucul_create_canvas(0, 0);63 cx->cv = caca_create_canvas(0, 0); 64 64 return ret; 65 65 } … … 67 67 static int end_figlet(context_t *cx) 68 68 { 69 return c ucul_canvas_set_figfont(cx->cv, NULL);69 return caca_canvas_set_figfont(cx->cv, NULL); 70 70 } 71 71 -
toilet/trunk/src/filter.c
r1831 r2988 25 25 #include <stdio.h> 26 26 #include <stdlib.h> 27 #include <c ucul.h>27 #include <caca.h> 28 28 29 29 #include "toilet.h" … … 130 130 unsigned int xmin, xmax, ymin, ymax; 131 131 132 xmin = w = c ucul_get_canvas_width(cx->torender);132 xmin = w = caca_get_canvas_width(cx->torender); 133 133 xmax = 0; 134 ymin = h = c ucul_get_canvas_height(cx->torender);134 ymin = h = caca_get_canvas_height(cx->torender); 135 135 ymax = 0; 136 136 … … 138 138 for(x = 0; x < w; x++) 139 139 { 140 unsigned long int ch = c ucul_get_char(cx->torender, x, y);140 unsigned long int ch = caca_get_char(cx->torender, x, y); 141 141 if(ch != (unsigned char)' ') 142 142 { … … 155 155 return; 156 156 157 c ucul_set_canvas_boundaries(cx->torender, xmin, ymin,157 caca_set_canvas_boundaries(cx->torender, xmin, ymin, 158 158 xmax - xmin + 1, ymax - ymin + 1); 159 159 } … … 163 163 static unsigned char const palette[] = 164 164 { 165 C UCUL_LIGHTBLUE, CUCUL_BLUE, CUCUL_LIGHTGRAY, CUCUL_DARKGRAY,165 CACA_LIGHTBLUE, CACA_BLUE, CACA_LIGHTGRAY, CACA_DARKGRAY, 166 166 }; 167 167 168 168 unsigned int x, y, w, h; 169 169 170 w = c ucul_get_canvas_width(cx->torender);171 h = c ucul_get_canvas_height(cx->torender);170 w = caca_get_canvas_width(cx->torender); 171 h = caca_get_canvas_height(cx->torender); 172 172 173 173 for(y = 0; y < h; y++) 174 174 for(x = 0; x < w; x++) 175 175 { 176 unsigned long int ch = c ucul_get_char(cx->torender, x, y);176 unsigned long int ch = caca_get_char(cx->torender, x, y); 177 177 int i; 178 178 … … 181 181 182 182 i = ((cx->lines + y + x / 8) / 2) % 4; 183 c ucul_set_color_ansi(cx->torender, palette[i], CUCUL_TRANSPARENT);184 c ucul_put_char(cx->torender, x, y, ch);183 caca_set_color_ansi(cx->torender, palette[i], CACA_TRANSPARENT); 184 caca_put_char(cx->torender, x, y, ch); 185 185 } 186 186 } … … 190 190 static unsigned char const rainbow[] = 191 191 { 192 C UCUL_LIGHTMAGENTA, CUCUL_LIGHTRED, CUCUL_YELLOW,193 C UCUL_LIGHTGREEN, CUCUL_LIGHTCYAN, CUCUL_LIGHTBLUE,192 CACA_LIGHTMAGENTA, CACA_LIGHTRED, CACA_YELLOW, 193 CACA_LIGHTGREEN, CACA_LIGHTCYAN, CACA_LIGHTBLUE, 194 194 }; 195 195 unsigned int x, y, w, h; 196 196 197 w = c ucul_get_canvas_width(cx->torender);198 h = c ucul_get_canvas_height(cx->torender);197 w = caca_get_canvas_width(cx->torender); 198 h = caca_get_canvas_height(cx->torender); 199 199 200 200 for(y = 0; y < h; y++) 201 201 for(x = 0; x < w; x++) 202 202 { 203 unsigned long int ch = c ucul_get_char(cx->torender, x, y);203 unsigned long int ch = caca_get_char(cx->torender, x, y); 204 204 if(ch != (unsigned char)' ') 205 205 { 206 c ucul_set_color_ansi(cx->torender,206 caca_set_color_ansi(cx->torender, 207 207 rainbow[(x / 2 + y + cx->lines) % 6], 208 C UCUL_TRANSPARENT);209 c ucul_put_char(cx->torender, x, y, ch);208 CACA_TRANSPARENT); 209 caca_put_char(cx->torender, x, y, ch); 210 210 } 211 211 } … … 214 214 static void filter_flip(context_t *cx) 215 215 { 216 c ucul_flip(cx->torender);216 caca_flip(cx->torender); 217 217 } 218 218 219 219 static void filter_flop(context_t *cx) 220 220 { 221 c ucul_flop(cx->torender);221 caca_flop(cx->torender); 222 222 } 223 223 224 224 static void filter_180(context_t *cx) 225 225 { 226 c ucul_rotate_180(cx->torender);226 caca_rotate_180(cx->torender); 227 227 } 228 228 229 229 static void filter_left(context_t *cx) 230 230 { 231 c ucul_rotate_left(cx->torender);231 caca_rotate_left(cx->torender); 232 232 } 233 233 234 234 static void filter_right(context_t *cx) 235 235 { 236 c ucul_rotate_right(cx->torender);237 } 238 236 caca_rotate_right(cx->torender); 237 } 238 -
toilet/trunk/src/main.c
r1461 r2988 31 31 #include <stdlib.h> 32 32 #include <string.h> 33 #include <c ucul.h>33 #include <caca.h> 34 34 35 35 #include "toilet.h" -
toilet/trunk/src/render.c
r2419 r2988 25 25 #include <string.h> 26 26 #include <stdio.h> 27 #include <c ucul.h>27 #include <caca.h> 28 28 29 29 #include "toilet.h" … … 38 38 cx->w = cx->h = 0; 39 39 cx->lines = 0; 40 cx->cv = c ucul_create_canvas(0, 0);40 cx->cv = caca_create_canvas(0, 0); 41 41 42 42 if(!strcasecmp(cx->font, "term")) … … 48 48 int render_stdin(context_t *cx) 49 49 { 50 c ucul_canvas_t *cv;50 caca_canvas_t *cv; 51 51 char *line; 52 52 int i, len; … … 55 55 len = 1024; 56 56 line = malloc(len); 57 cv = c ucul_create_canvas(0, 0);57 cv = caca_create_canvas(0, 0); 58 58 59 59 /* Read from stdin */ … … 63 63 break; 64 64 65 c ucul_set_canvas_size(cv, 0, 0);66 c ucul_import_memory(cv, line, strlen(line), "utf8");67 for(i = 0; i < c ucul_get_canvas_width(cv); i++)65 caca_set_canvas_size(cv, 0, 0); 66 caca_import_memory(cv, line, strlen(line), "utf8"); 67 for(i = 0; i < caca_get_canvas_width(cv); i++) 68 68 { 69 uint32_t ch = c ucul_get_char(cv, i, 0);70 uint32_t at = c ucul_get_attr(cv, i, 0);69 uint32_t ch = caca_get_char(cv, i, 0); 70 uint32_t at = caca_get_attr(cv, i, 0); 71 71 cx->feed(cx, ch, at); 72 if(c ucul_utf32_is_fullwidth(ch)) i++;72 if(caca_utf32_is_fullwidth(ch)) i++; 73 73 } 74 74 … … 83 83 int render_list(context_t *cx, int argc, char *argv[]) 84 84 { 85 c ucul_canvas_t *cv;85 caca_canvas_t *cv; 86 86 int i, j, len; 87 87 char *parser = NULL; 88 88 89 cv = c ucul_create_canvas(0, 0);89 cv = caca_create_canvas(0, 0); 90 90 91 91 for(j = 0; j < argc; ) … … 106 106 len = strlen(parser); 107 107 108 c ucul_set_canvas_size(cv, 0, 0);109 c ucul_import_memory(cv, parser, len, "utf8");110 for(i = 0; i < c ucul_get_canvas_width(cv); i++)108 caca_set_canvas_size(cv, 0, 0); 109 caca_import_memory(cv, parser, len, "utf8"); 110 for(i = 0; i < caca_get_canvas_width(cv); i++) 111 111 { 112 uint32_t ch = c ucul_get_char(cv, i, 0);113 uint32_t at = c ucul_get_attr(cv, i, 0);112 uint32_t ch = caca_get_char(cv, i, 0); 113 uint32_t at = caca_get_attr(cv, i, 0); 114 114 cx->feed(cx, ch, at); 115 if(c ucul_utf32_is_fullwidth(ch)) i++;115 if(caca_utf32_is_fullwidth(ch)) i++; 116 116 } 117 117 … … 130 130 render_flush(cx); 131 131 132 c ucul_free_canvas(cv);132 caca_free_canvas(cv); 133 133 134 134 return 0; … … 138 138 { 139 139 cx->end(cx); 140 c ucul_free_canvas(cx->cv);140 caca_free_canvas(cx->cv); 141 141 142 142 return 0; … … 157 157 158 158 /* Output line */ 159 buffer = c ucul_export_memory(cx->torender, cx->export, &len);159 buffer = caca_export_memory(cx->torender, cx->export, &len); 160 160 if(!buffer) 161 161 return -1; 162 162 fwrite(buffer, len, 1, stdout); 163 163 free(buffer); 164 c ucul_free_canvas(cx->torender);164 caca_free_canvas(cx->torender); 165 165 166 166 return 0; -
toilet/trunk/src/term.c
r1461 r2988 23 23 #endif 24 24 #include <stdlib.h> 25 #include <c ucul.h>25 #include <caca.h> 26 26 27 27 #include "toilet.h" … … 81 81 } 82 82 83 c ucul_set_attr(cx->cv, attr);84 c ucul_set_canvas_size(cx->cv, cx->ew, cx->eh);83 caca_set_attr(cx->cv, attr); 84 caca_set_canvas_size(cx->cv, cx->ew, cx->eh); 85 85 86 c ucul_put_char(cx->cv, cx->x, cx->y, ch);86 caca_put_char(cx->cv, cx->x, cx->y, ch); 87 87 cx->x++; 88 88 … … 93 93 { 94 94 cx->torender = cx->cv; 95 c ucul_set_canvas_size(cx->torender, cx->w, cx->h);95 caca_set_canvas_size(cx->torender, cx->w, cx->h); 96 96 97 97 cx->ew = 16; … … 99 99 cx->x = cx->y = 0; 100 100 cx->w = cx->h = 0; 101 cx->cv = c ucul_create_canvas(cx->ew, cx->eh);101 cx->cv = caca_create_canvas(cx->ew, cx->eh); 102 102 103 103 return 0; -
toilet/trunk/src/toilet.h
r1461 r2988 25 25 unsigned int term_width; 26 26 27 c ucul_canvas_t *cv;28 c ucul_canvas_t *torender;27 caca_canvas_t *cv; 28 caca_canvas_t *torender; 29 29 unsigned int w, h, ew, eh, x, y, lines; 30 30 … … 42 42 unsigned int print_direction, full_layout, codetag_count; 43 43 unsigned int glyphs; 44 c ucul_canvas_t *fontcv, *charcv;44 caca_canvas_t *fontcv, *charcv; 45 45 int *left, *right; /* Unused yet */ 46 46 unsigned int *lookup; -
toilet/trunk/tools/Makefile.am
r1468 r2988 4 4 5 5 caca2tlf_SOURCES = caca2tlf.c 6 caca2tlf_CFLAGS = @C UCUL_CFLAGS@7 caca2tlf_LDADD = @C UCUL_LIBS@6 caca2tlf_CFLAGS = @CACA_CFLAGS@ 7 caca2tlf_LDADD = @CACA_LIBS@ 8 8 -
toilet/trunk/tools/caca2tlf.c
r2415 r2988 25 25 #include <string.h> 26 26 #include <stdlib.h> 27 #include <c ucul.h>27 #include <caca.h> 28 28 29 29 enum mode { GRAY, HALFBLOCKS, QUARTERBLOCKS } mode; … … 32 32 static void add_char(unsigned long int); 33 33 34 c ucul_font_t *f;35 c ucul_canvas_t *out, *onechar;34 caca_font_t *f; 35 caca_canvas_t *out, *onechar; 36 36 uint32_t const *blocks; 37 37 uint8_t * image; … … 69 69 } 70 70 71 f = c ucul_load_font(fontname, 0);71 f = caca_load_font(fontname, 0); 72 72 73 73 if(!f) … … 78 78 } 79 79 80 w = c ucul_get_font_width(f);81 h = c ucul_get_font_height(f);80 w = caca_get_font_width(f); 81 h = caca_get_font_height(f); 82 82 iw = w * 2 + 1; 83 83 ih = h + 1; … … 101 101 } 102 102 103 blocks = c ucul_get_font_blocks(f);104 onechar = c ucul_create_canvas(0, 0);105 c ucul_set_color_ansi(onechar, CUCUL_WHITE, CUCUL_BLACK);103 blocks = caca_get_font_blocks(f); 104 onechar = caca_create_canvas(0, 0); 105 caca_set_color_ansi(onechar, CACA_WHITE, CACA_BLACK); 106 106 image = malloc(4 * iw * ih); 107 107 108 out = c ucul_create_canvas(0, 0);108 out = caca_create_canvas(0, 0); 109 109 printf("tlf2a$ %u %u %u -1 4 0 0 0\n", gh, gh - 1, fgw + 2); 110 110 … … 141 141 continue; 142 142 143 len = c ucul_utf32_to_utf8(buf, ch);143 len = caca_utf32_to_utf8(buf, ch); 144 144 buf[len] = '\0'; 145 145 printf("0x%.04lX %s\n", ch, buf); … … 148 148 } 149 149 150 c ucul_free_canvas(out);151 c ucul_free_canvas(onechar);150 caca_free_canvas(out); 151 caca_free_canvas(onechar); 152 152 free(image); 153 c ucul_free_font(f);153 caca_free_font(f); 154 154 155 155 return 0; … … 163 163 fprintf(stderr, "Available fonts:\n"); 164 164 165 fonts = c ucul_get_font_list();165 fonts = caca_get_font_list(); 166 166 for(i = 0; fonts[i]; i++) 167 167 fprintf(stderr, " \"%s\"\n", fonts[i]); … … 173 173 unsigned long int len; 174 174 unsigned int x, y, myw, mygw; 175 int full = c ucul_utf32_is_fullwidth(ch);176 177 c ucul_set_canvas_size(onechar, full ? 2 : 1, 1);178 c ucul_put_char(onechar, 0, 0, ch);179 c ucul_render_canvas(onechar, f, image, iw, ih, 4 * iw);175 int full = caca_utf32_is_fullwidth(ch); 176 177 caca_set_canvas_size(onechar, full ? 2 : 1, 1); 178 caca_put_char(onechar, 0, 0, ch); 179 caca_render_canvas(onechar, f, image, iw, ih, 4 * iw); 180 180 181 181 myw = full ? 2 * w : w; 182 182 mygw = full ? fgw : gw; 183 183 184 c ucul_set_canvas_size(out, (full ? fgw : gw) + 2, gh);184 caca_set_canvas_size(out, (full ? fgw : gw) + 2, gh); 185 185 186 186 switch(mode) … … 193 193 194 194 if(c >= 0xa0) 195 c ucul_put_str(out, x, y, "█");195 caca_put_str(out, x, y, "█"); 196 196 else if(c >= 0x80) 197 c ucul_put_str(out, x, y, "▓");197 caca_put_str(out, x, y, "▓"); 198 198 else if(c >= 0x40) 199 c ucul_put_str(out, x, y, "▒");199 caca_put_str(out, x, y, "▒"); 200 200 else if(c >= 0x20) 201 c ucul_put_str(out, x, y, "░");201 caca_put_str(out, x, y, "░"); 202 202 else 203 c ucul_put_char(out, x, y, ' ');203 caca_put_char(out, x, y, ' '); 204 204 } 205 205 break; … … 213 213 uint8_t p2 = image[4 * (x + (y * 2 + 1) * iw) + 2]; 214 214 215 c ucul_put_str(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80)]);215 caca_put_str(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80)]); 216 216 } 217 217 break; … … 231 231 uint8_t p4 = image[4 * (x * 2 + 1 + (y * 2 + 1) * iw) + 2]; 232 232 233 c ucul_put_str(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80) +233 caca_put_str(out, x, y, str[(p1 > 0x80) + 2 * (p2 > 0x80) + 234 234 4 * (p3 > 0x80) + 8 * (p4 > 0x80)]); 235 235 } … … 239 239 if(ch == ' ' || ch == 0xa0) 240 240 { 241 c ucul_draw_line(out, mygw - 1, 0, mygw - 1, gh - 1, '$');242 c ucul_draw_line(out, mygw / 2, 0, mygw / 2, gh - 1, '$');243 } 244 245 c ucul_draw_line(out, mygw, 0, mygw, gh - 1, '@');246 c ucul_put_char(out, mygw + 1, gh - 1, '@');247 248 buf = c ucul_export_memory(out, "utf8", &len);241 caca_draw_line(out, mygw - 1, 0, mygw - 1, gh - 1, '$'); 242 caca_draw_line(out, mygw / 2, 0, mygw / 2, gh - 1, '$'); 243 } 244 245 caca_draw_line(out, mygw, 0, mygw, gh - 1, '@'); 246 caca_put_char(out, mygw + 1, gh - 1, '@'); 247 248 buf = caca_export_memory(out, "utf8", &len); 249 249 fwrite(buf, len, 1, stdout); 250 250 free(buf);
Note: See TracChangeset
for help on using the changeset viewer.