Changeset 1241 for toilet/trunk/src/mono9.c
- Timestamp:
- Oct 26, 2006, 3:07:58 PM (16 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
toilet/trunk/src/mono9.c
r1240 r1241 27 27 #include "render.h" 28 28 29 static int feed_tiny(context_t *, uint32_t);30 static int end_tiny(context_t *);31 32 29 static int feed_big(context_t *, uint32_t); 30 static int flush_big(context_t *); 33 31 static int end_big(context_t *); 34 35 int init_tiny(context_t *cx)36 {37 cx->ew = 16;38 cx->eh = 2;39 cx->x = cx->y = 0;40 cx->w = cx->h = 0;41 cx->cv = cucul_create_canvas(cx->ew, cx->eh);42 43 cx->feed = feed_tiny;44 cx->end = end_tiny;45 46 return 0;47 }48 49 static int feed_tiny(context_t *cx, uint32_t ch)50 {51 switch(ch)52 {53 case (uint32_t)'\r':54 return 0;55 case (uint32_t)'\n':56 cx->x = 0;57 cx->y++;58 return 0;59 case (uint32_t)'\t':60 cx->x = (cx->x & ~7) + 8;61 return 0;62 }63 64 /* Check whether we reached the end of the screen */65 if(cx->x && cx->x + 1 > cx->term_width)66 {67 cx->x = 0;68 cx->y++;69 }70 71 /* Check whether the current canvas is large enough */72 if(cx->x + 1 > cx->w)73 {74 cx->w = cx->x + 1 < cx->term_width ? cx->x + 1 : cx->term_width;75 if(cx->w > cx->ew)76 cx->ew = cx->ew + cx->ew / 2;77 }78 79 if(cx->y + 1 > cx->h)80 {81 cx->h = cx->y + 1;82 if(cx->h > cx->eh)83 cx->eh = cx->eh + cx->eh / 2;84 }85 86 cucul_set_canvas_size(cx->cv, cx->ew, cx->eh);87 88 cucul_putchar(cx->cv, cx->x, cx->y, ch);89 cx->x++;90 91 return 0;92 }93 94 static int end_tiny(context_t *cx)95 {96 cucul_set_canvas_size(cx->cv, cx->w, cx->h);97 98 return 0;99 }100 32 101 33 int init_big(context_t *cx) … … 115 47 116 48 cx->feed = feed_big; 49 cx->flush = flush_big; 117 50 cx->end = end_big; 118 51 … … 180 113 } 181 114 115 static int flush_big(context_t *cx) 116 { 117 cx->torender = cx->cv; 118 cucul_set_canvas_size(cx->torender, cx->w, cx->h); 119 120 cx->x = cx->y = 0; 121 cx->w = cx->h = 0; 122 cx->cv = cucul_create_canvas(1, 1); 123 124 return 0; 125 } 126 182 127 static int end_big(context_t *cx) 183 128 { 184 129 cucul_free_canvas(cx->onechar); 130 cucul_free_canvas(cx->cv); 185 131 free(cx->buf); 186 132 cucul_free_font(cx->f);
Note: See TracChangeset
for help on using the changeset viewer.