Changeset 2426
- Timestamp:
- Jun 15, 2008, 7:01:48 PM (15 years ago)
- Location:
- neercs/trunk/src
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
neercs/trunk/src/Makefile.am
r2402 r2426 2 2 bin_PROGRAMS = neercs 3 3 4 neercs_SOURCES = neercs.h main.c screens.c term.c effects.c wm.c4 neercs_SOURCES = neercs.h grab.c main.c screens.c term.c effects.c wm.c 5 5 neercs_CFLAGS = @CACA_CFLAGS@ 6 6 neercs_LDADD = @CACA_LIBS@ @UTIL_LIBS@ -
neercs/trunk/src/main.c
r2421 r2426 43 43 struct screen_list *screen_list = NULL; 44 44 char *default_shell = NULL; 45 int i, w, h , nt, args = 0;45 int i, w, h; 46 46 int eof = 0, refresh = 1, command = 0; 47 47 48 49 nt = argc - 1;50 args = nt;51 52 if(nt == 0)53 {54 nt = 1;55 }56 57 48 default_shell = getenv("SHELL"); 58 49 59 if(default_shell == NULL && !args)50 if(default_shell == NULL && argc < 2) 60 51 { 61 52 fprintf(stderr, "Environment variable SHELL not set and no arguments given. kthxbye.\n"); … … 99 90 screen_list->pty = screen_list->prevpty = 0; 100 91 101 102 for(i = 0; i < nt; i++) 92 for(i = 0; i < argc-1; i++) 103 93 { 104 94 struct screen *tmp; 105 if(args) tmp = create_screen(w, h, argv[i + 1]); 106 else tmp = create_screen(w, h, default_shell); 95 if(argc < 2) 96 tmp = create_screen(w, h, default_shell); 97 else 98 { 99 if(!strcmp(argv[i + 1], "-P")) 100 { 101 if(i + 2 > argc) 102 { 103 fprintf(stderr, "-P needs a parameter !\n"); 104 exit(1); 105 } 106 tmp = create_screen_grab(w, h, atoi(argv[i + 2])); 107 i++; 108 } 109 else 110 tmp = create_screen(w, h, argv[i + 1]); 111 } 107 112 108 113 if(tmp) -
neercs/trunk/src/neercs.h
r2421 r2426 15 15 16 16 #include <stdint.h> 17 #include <c ucul.h>17 #include <caca.h> 18 18 19 19 … … 76 76 77 77 int create_pty(char *cmd, unsigned int w, unsigned int h, int *cpid); 78 int create_pty_grab(pid_t pid, unsigned int w, unsigned int h); 79 int grab_process(pid_t pid, int ptyfd); 78 80 79 81 long int import_term(struct screen_list *screen_list, struct screen *sc, void const *data, unsigned int size); … … 87 89 /* Screens management */ 88 90 struct screen* create_screen(int w, int h, char *command); 91 struct screen* create_screen_grab(int w, int h, int pid); 89 92 int destroy_screen(struct screen *s); 90 93 int add_screen(struct screen_list *list, struct screen *s); … … 105 108 106 109 107 108 109 110 #if 0 110 111 # define debug(f, z...) fprintf(stderr, f "\n", z) -
neercs/trunk/src/screens.c
r2422 r2426 28 28 29 29 #include "neercs.h" 30 31 struct screen* create_screen_grab(int w, int h, int pid) 32 { 33 struct screen *s = (struct screen*) malloc(sizeof(struct screen)); 34 35 s->cv = cucul_create_canvas(w, h); 36 cucul_set_color_ansi(s->cv, CUCUL_BLACK, CUCUL_BLACK); 37 cucul_clear_canvas(s->cv); 38 s->init = 0; 39 40 s->buf = NULL; 41 s->title = NULL; 42 s->total = 0; 43 s->w = w+1; 44 s->h = h+1; 45 s->bell = 0; 46 s->pid = pid; 47 48 s->fd = create_pty_grab(pid, w, h); 49 50 if(s->fd < 0) 51 { 52 cucul_free_canvas(s->cv); 53 free(s); 54 return NULL; 55 } 56 return s; 57 } 30 58 31 59 struct screen* create_screen(int w, int h, char *command) -
neercs/trunk/src/term.c
r2421 r2426 577 577 } 578 578 579 int create_pty_grab(pid_t pid, unsigned int w, unsigned int h) 580 { 581 int fdm, fds; 582 583 int ret = openpty(&fdm, &fds, NULL, NULL, NULL); 584 585 if(ret < 0) 586 { 587 fprintf(stderr, "open() error\n"); 588 return -1; 589 } 590 591 set_tty_size(0, w, h); 592 grab_process(pid, fds); 593 594 fcntl(fdm, F_SETFL, O_NDELAY); 595 return fdm; 596 } 597 579 598 int set_tty_size(int fd, unsigned int w, unsigned int h) 580 599 {
Note: See TracChangeset
for help on using the changeset viewer.