r663: This commit was generated by cvs2svn to compensate for changes in r662,
[cinelerra_cv.git] / guicast / test.C
blobec1a48dfc9af4f8c82fee02cb45b6471834ee885
1 #include "bcsignals.h"
2 #include "guicast.h"
3 #include "keys.h"
4 #include "language.h"
5 #include "vframe.h"
6 #include <ctype.h>
7 #include <math.h>
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include <sys/types.h>
12 #include <sys/wait.h>
13 #include <unistd.h>
16 #define MAX_ARGS 32
17 #define BCTEXTLEN 1024
20 void thread_fork()
22         int filedes[2];
23         int pid;
24         char *command_line = "ls -l -s -S -r";
25         char *arguments[MAX_ARGS];
26         char path[BCTEXTLEN];
27         int total_arguments;
28         FILE *stdin_fd;
29         int pipe_stdin = 0;
30         char *path_ptr;
31         char *ptr = command_line;
32         char *argument_ptr;
33         char argument[BCTEXTLEN];
36         path_ptr = path;
37         while(*ptr != ' ' && *ptr != 0)
38         {
39                 *path_ptr++ = *ptr++;
40         }
41         *path_ptr = 0;
43         arguments[total_arguments] = new char[strlen(path) + 1];
44         strcpy(arguments[total_arguments], path);
45 printf("%s\n", arguments[total_arguments]);
46         total_arguments++;
47         arguments[total_arguments] = 0;
49         while(*ptr != 0)
50         {
51                 ptr++;
52                 argument_ptr = argument;
53                 while(*ptr != ' ' && *ptr != 0)
54                 {
55                         *argument_ptr++ = *ptr++;
56                 }
57                 *argument_ptr = 0;
58 printf("%s\n", argument);
60                 arguments[total_arguments] = new char[strlen(argument) + 1];
61                 strcpy(arguments[total_arguments], argument);
62                 total_arguments++;
63                 arguments[total_arguments] = 0;
64         }
66         pipe(filedes);
67         stdin_fd = fdopen(filedes[1], "w");
68         
69         int new_pid = fork();
70         
71         if(new_pid == 0)
72         {
73                 dup2(filedes[0], fileno(stdin));
74                 execvp(path, arguments);
75                 perror("execvp");
76         }
77         else
78         {
79                 pid = new_pid;
80                 int return_value;
81                 if(waitpid(pid, &return_value, WUNTRACED) == -1)
82                 {
83                         perror("waitpid");
84                 }
85                 close(filedes[0]);
86                 close(filedes[1]);
87                 fclose(stdin_fd);
88                 printf("Finished.\n");
89         }
90         
91         
92         
93         
97 class TestWindow : public BC_Window
99 public:
100         TestWindow() : BC_Window("test", 
101                                 0,
102                                 0,
103                                 320, 
104                                 240,
105                                 -1,
106                                 -1,
107                                 0,
108                                 0,
109                                 1)
110         {
111                 current_cursor = 0;
112                 test_keypress = 1;
113         };
115         int close_event()
116         {
117                 set_done(0);
118                 return 1;
119         };
121         int keypress_event()
122         {
123                 switch(get_keypress())
124                 {
125                         case UP:
126                                 current_cursor += 1;
127                                 if(current_cursor >= XC_num_glyphs) current_cursor = 0;
128                                 break;
129                         
130                         case DOWN:
131                                 current_cursor -= 1;
132                                 if(current_cursor <= 0) current_cursor = XC_num_glyphs - 1;
133                                 break;
134                 }
135                 printf("%d\n", current_cursor);
136                 set_x_cursor(current_cursor);
137         }
138         
139         int current_cursor;
142 int main(int argc, char *argv[])
144         new BC_Signals;
145         TestWindow window;
146         int angles[] = { 180, 0 };
147         float values[] = { 1, 0 };
149         window.add_tool(new BC_Pan(10, 
150                 120, 
151                 100, 
152                 1, 
153                 2, 
154                 angles, 
155                 -1, 
156                 -1,
157                 values));
158         window.add_tool(new BC_TextBox(10, 10, 200, 5, _("Mary Egbert\nhad a little lamb.")));
159         BC_Title *title;
160         window.add_tool(title = new BC_Title(10, 210, _("Hello world")));
161         title->update("xyz");
162         window.show_window();
164 sleep(2);
165         title->update("abc");
167         window.run_window();
169 //      thread_fork();