Changeset 1385 for toilet/trunk
- Timestamp:
- Nov 13, 2006, 2:02:05 AM (14 years ago)
- Location:
- toilet/trunk/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/figlet.c
r1376 r1385 33 33 #define EXT_GLYPHS (STD_GLYPHS + 7) 34 34 35 static int feed_figlet(context_t *, uint32_t );35 static int feed_figlet(context_t *, uint32_t, uint32_t); 36 36 static int flush_figlet(context_t *); 37 37 static int end_figlet(context_t *); … … 51 51 } 52 52 53 static int feed_figlet(context_t *cx, uint32_t ch )53 static int feed_figlet(context_t *cx, uint32_t ch, uint32_t attr) 54 54 { 55 55 unsigned int c, w, h, x, y; … … 91 91 cx->h = cx->y + h; 92 92 93 if(attr) 94 cucul_set_attr(cx->cv, attr); 93 95 cucul_set_canvas_size(cx->cv, cx->w, cx->h); 94 96 … … 97 99 for(x = 0; x < w; x++) 98 100 { 99 uint32_t tmp = cucul_get_char(cx->image, x, y + c * cx->height); 100 cucul_put_char(cx->cv, cx->x + x, cx->y + y, tmp); 101 uint32_t tmpch = cucul_get_char(cx->image, x, y + c * cx->height); 102 //uint32_t tmpat = cucul_get_attr(cx->image, x, y + c * cx->height); 103 /* FIXME: this could be changed to cucul_put_attr() when the 104 * function is fixed in libcucul */ 105 //cucul_set_attr(cx->cv, tmpat); 106 cucul_put_char(cx->cv, cx->x + x, cx->y + y, tmpch); 107 //cucul_put_attr(cx->cv, cx->x + x, cx->y + y, tmpat); 101 108 } 102 109 -
toilet/trunk/src/render.c
r1376 r1385 47 47 int render_stdin(context_t *cx) 48 48 { 49 char buf[10]; 50 unsigned int i = 0, len; 51 uint32_t ch; 49 cucul_canvas_t *cv; 50 char *line; 51 unsigned int i, len; 52 53 /* FIXME: we can't read longer lines */ 54 len = 1024; 55 line = malloc(len); 56 cv = cucul_create_canvas(0, 0); 52 57 53 58 /* Read from stdin */ 54 59 while(!feof(stdin)) 55 60 { 56 buf[i++] = getchar();57 buf[i] = '\0';61 if(!fgets(line, len, stdin)) 62 break; 58 63 59 ch = cucul_utf8_to_utf32(buf, &len); 64 cucul_set_canvas_size(cv, 0, 0); 65 cucul_import_memory(cv, line, strlen(line), "utf8"); 66 for(i = 0; i < cucul_get_canvas_width(cv); i++) 67 { 68 uint32_t ch = cucul_get_char(cv, i, 0); 69 uint32_t at = cucul_get_attr(cv, i, 0); 70 cx->feed(cx, ch, at); 71 if(cucul_utf32_is_fullwidth(ch)) i++; 72 } 60 73 61 if(!len)62 continue;74 render_flush(cx); 75 } 63 76 64 cx->feed(cx, ch); 65 i = 0; 66 67 if(ch == '\n') 68 render_flush(cx); 69 } 77 free(line); 70 78 71 79 return 0; … … 74 82 int render_list(context_t *cx, unsigned int argc, char *argv[]) 75 83 { 76 unsigned int i, j; 84 cucul_canvas_t *cv; 85 unsigned int i, j, len; 86 char *parser = NULL; 77 87 78 for(i = 0; i < argc; i++) 88 cv = cucul_create_canvas(0, 0); 89 90 for(j = 0; j < argc; ) 79 91 { 80 /* Read from commandline */ 81 unsigned int len; 92 char *cr; 82 93 83 if(i) 84 cx->feed(cx, ' '); 94 if(!parser) 95 { 96 if(j) 97 cx->feed(cx, ' ', 0); 98 parser = argv[j]; 99 } 85 100 86 for(j = 0; argv[i][j];) 101 cr = strchr(parser, '\n'); 102 if(cr) 103 len = (cr - parser) + 1; 104 else 105 len = strlen(parser); 106 107 cucul_set_canvas_size(cv, 0, 0); 108 cucul_import_memory(cv, parser, len, "utf8"); 109 for(i = 0; i < cucul_get_canvas_width(cv); i++) 87 110 { 88 cx->feed(cx, cucul_utf8_to_utf32(argv[i] + j, &len)); 89 j += len; 111 uint32_t ch = cucul_get_char(cv, i, 0); 112 uint32_t at = cucul_get_attr(cv, i, 0); 113 cx->feed(cx, ch, at); 114 if(cucul_utf32_is_fullwidth(ch)) i++; 115 } 116 117 if(cr) 118 { 119 parser += len; 120 render_flush(cx); 121 } 122 else 123 { 124 parser = NULL; 125 j++; 90 126 } 91 127 } -
toilet/trunk/src/term.c
r1376 r1385 27 27 #include "render.h" 28 28 29 static int feed_tiny(context_t *, uint32_t );29 static int feed_tiny(context_t *, uint32_t, uint32_t); 30 30 static int flush_tiny(context_t *); 31 31 static int end_tiny(context_t *); … … 43 43 } 44 44 45 static int feed_tiny(context_t *cx, uint32_t ch )45 static int feed_tiny(context_t *cx, uint32_t ch, uint32_t attr) 46 46 { 47 47 switch(ch) … … 80 80 } 81 81 82 cucul_set_attr(cx->cv, attr); 82 83 cucul_set_canvas_size(cx->cv, cx->ew, cx->eh); 83 84 -
toilet/trunk/src/toilet.h
r1243 r1385 29 29 30 30 /* Render methods */ 31 int (*feed)(struct toilet_context *, uint32_t );31 int (*feed)(struct toilet_context *, uint32_t, uint32_t); 32 32 int (*flush)(struct toilet_context *); 33 33 int (*end)(struct toilet_context *);
Note: See TracChangeset
for help on using the changeset viewer.