Changeset 2445
- Timestamp:
- Jun 16, 2008, 4:33:19 PM (15 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/Makefile.am
r2444 r2445 7 7 endif 8 8 9 neercs_SOURCES = neercs.h $(grab_c) mygetopt.c main.c screens.c term.c effects.c wm.c9 neercs_SOURCES = neercs.h $(grab_c) mygetopt.c recurrent.c main.c screens.c term.c effects.c wm.c 10 10 neercs_CFLAGS = @CACA_CFLAGS@ 11 11 neercs_LDADD = @CACA_LIBS@ @UTIL_LIBS@ -
neercs/trunk/src/effects.c
r2421 r2445 209 209 cucul_printf(cv, x, y++, "See http://libcaca.zoy.org/wiki/neercs for more informations"); 210 210 } 211 212 213 214 215 #define DELAY 500000.0f 216 217 int close_screen_recurrent(struct screen_list* screen_list, struct recurrent* rec, void *user, long long unsigned int t) 218 { 219 long long unsigned int delta = t - rec->start_time; 220 221 screen_list->dont_update_coords = 1; 222 rec->kill_me = 0; 223 if(delta>=DELAY) 224 { 225 rec->kill_me = 1; 226 remove_screen(screen_list, screen_list->pty, 1); 227 screen_list->pty = screen_list->prevpty; 228 screen_list->prevpty = 0; 229 screen_list->dont_update_coords = 0; 230 } 231 else 232 { 233 float r = 1 - ((DELAY - (DELAY - delta)) / DELAY); 234 cucul_canvas_t *old, *new; 235 struct screen *s = screen_list->screen[screen_list->pty]; 236 int w = s->orig_w * r; 237 int h = s->orig_h * r; 238 239 240 old = s->cv; 241 new = cucul_create_canvas(w, h); 242 cucul_blit(new, 0, 0, old, NULL); 243 s->cv = new; 244 cucul_free_canvas(old); 245 set_tty_size(s->fd, w, h); 246 247 s->w = w; 248 s->h = h; 249 250 s->x = 251 (s->orig_x * r) + 252 ((s->orig_w/2) - s->w/2); 253 s->y = 254 (s->orig_y * r) + 255 ((s->orig_h/2) - s->h/2); 256 257 } 258 259 return 1; 260 } -
neercs/trunk/src/main.c
r2444 r2445 25 25 #include <sys/types.h> 26 26 #include <sys/wait.h> 27 #include <sys/time.h> 28 #include <time.h> 27 29 28 30 #if defined HAVE_PTY_H … … 68 70 static caca_display_t *dp; 69 71 struct screen_list *screen_list = NULL; 72 struct recurrent_list *recurrent_list = NULL; 70 73 char *default_shell = NULL; 71 74 int i, w, h, args, s=0; … … 117 120 screen_list->in_bell = 0; 118 121 screen_list->pty = screen_list->prevpty = 0; 122 screen_list->dont_update_coords = 0; 123 124 recurrent_list = (struct recurrent_list*) malloc(sizeof(struct recurrent_list)); 125 recurrent_list->recurrent = (struct recurrent**) malloc(sizeof(struct recurrent*)); 126 if(!recurrent_list->recurrent) 127 { 128 fprintf(stderr, "Can't allocate memory at %s:%d\n", __FUNCTION__, __LINE__); 129 return -1; 130 } 131 recurrent_list->count = 0; 119 132 120 133 for(;;) … … 172 185 update_windows_props(cv, screen_list); 173 186 caca_refresh_display(dp); 174 175 187 176 188 for(;;) … … 239 251 break; 240 252 case 0x0b: //CACA_KEY_CTRL_K: 241 remove_screen(screen_list, screen_list->pty, 1); 242 screen_list->pty = screen_list->prevpty; 243 screen_list->prevpty = 0; 253 add_recurrent(recurrent_list, close_screen_recurrent, cv); 244 254 refresh = 1; 245 255 break; … … 283 293 } 284 294 295 /* Recurrent functions */ 296 for(i=0; i<recurrent_list->count; i++) 297 { 298 if(recurrent_list->recurrent[i]->function) 299 { 300 refresh |= recurrent_list->recurrent[i]->function(screen_list, 301 recurrent_list->recurrent[i], 302 recurrent_list->recurrent[i]->user, 303 get_ms()); 304 } 305 } 306 /* Delete recurrent functions */ 307 for(i=0; i<recurrent_list->count; i++) 308 { 309 if(recurrent_list->recurrent[i]->kill_me) 310 { 311 remove_recurrent(recurrent_list, i); 312 i = 0; 313 } 314 } 315 285 316 /* Resfresh screen */ 286 317 if(refresh || screen_list->in_bell) … … 306 337 destroy_screen(screen_list->screen[i]); 307 338 } 339 308 340 free(screen_list->screen); 309 341 free(screen_list); 310 342 311 343 344 for(i=0; i<recurrent_list->count; i++) 345 { 346 remove_recurrent(recurrent_list, i); 347 i = 0; 348 } 349 350 free(recurrent_list->recurrent); 351 free(recurrent_list); 352 353 312 354 return 0; 313 355 } 356 357 358 359 long long get_ms(void) 360 { 361 struct timeval tv; 362 gettimeofday(&tv, NULL); 363 364 365 return (tv.tv_sec*(1000000) + tv.tv_usec); 366 } -
neercs/trunk/src/neercs.h
r2444 r2445 27 27 }; 28 28 29 29 30 struct screen 30 31 { … … 52 53 int x, y; 53 54 int w, h; 55 56 int orig_x, orig_y; 57 int orig_w, orig_h; 58 54 59 }; 55 60 … … 58 63 int wm_type; 59 64 int in_bell; 65 int dont_update_coords; 60 66 /* Add-ons*/ 61 67 int mini; … … 63 69 int help; 64 70 65 66 71 int pty, prevpty; 67 72 int count; 68 73 int width, height; 69 74 struct screen **screen; 75 }; 76 77 78 struct recurrent 79 { 80 int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t); 81 void *user; 82 long long unsigned int start_time; 83 int kill_me; 84 }; 85 86 struct recurrent_list 87 { 88 int count; 89 struct recurrent **recurrent; 70 90 }; 71 91 … … 88 108 struct screen_list *screen_list); 89 109 int update_screens_contents(struct screen_list* screen_list); 110 long long get_ms(void); 111 90 112 91 113 /* Screens management */ … … 110 132 void draw_status(cucul_canvas_t *cv, struct screen_list *screen_list); 111 133 void draw_help(cucul_canvas_t *cv, struct screen_list *screen_list); 134 int close_screen_recurrent(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t); 135 136 137 /* Recurrents */ 138 int add_recurrent(struct recurrent_list *list, 139 int (*function)(struct screen_list*, struct recurrent* rec, void *user, long long unsigned int t), 140 void *user); 141 int remove_recurrent(struct recurrent_list *list, int n); 112 142 113 143 -
neercs/trunk/src/screens.c
r2438 r2445 78 78 s->scroll = 0; 79 79 s->fd = create_pty(command, w, h, &s->pid); 80 81 s->orig_w = s->w; 82 s->orig_h = s->h; 83 s->orig_x = s->x; 84 s->orig_y = s->y; 85 80 86 81 87 if(s->fd < 0) … … 180 186 screen_list->height = cucul_get_canvas_height(cv) - (screen_list->mini*6); 181 187 182 update_windows_props(cv, screen_list); 188 if(!screen_list->dont_update_coords) 189 update_windows_props(cv, screen_list); 183 190 184 191 if(screen_list->screen[screen_list->pty]->title) … … 199 206 screen_list->screen[i]->y, 200 207 screen_list->screen[i]->cv, NULL); 208 201 209 cucul_draw_cp437_box(cv, 202 210 screen_list->screen[i]->x - 1, -
neercs/trunk/src/term.c
r2444 r2445 618 618 for(i = 0; i < screen_list->count; i++) 619 619 { 620 if(screen_list->screen[i]->total )620 if(screen_list->screen[i]->total && !screen_list->dont_update_coords) 621 621 { 622 622 unsigned long int bytes; -
neercs/trunk/src/wm.c
r2421 r2445 40 40 cucul_free_canvas(old); 41 41 set_tty_size(s->fd, w, h); 42 43 s->orig_w = s->w; 44 s->orig_h = s->h; 45 s->orig_x = s->x; 46 s->orig_y = s->y; 42 47 } 43 48
Note: See TracChangeset
for help on using the changeset viewer.