r618: Undo items are only pushed if some time has passed since the last push.
[cinelerra_cv.git] / guicast / test.C
blob2f90b30734f985a7838f88f8f0f30ed9b2acec5a
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         };
114         int close_event()
115         {
116                 set_done(0);
117                 return 1;
118         };
120         int keypress_event()
121         {
122                 switch(get_keypress())
123                 {
124                         case UP:
125                                 current_cursor += 1;
126                                 if(current_cursor >= XC_num_glyphs) current_cursor = 0;
127                                 break;
128                         
129                         case DOWN:
130                                 current_cursor -= 1;
131                                 if(current_cursor <= 0) current_cursor = XC_num_glyphs - 1;
132                                 break;
133                 }
134                 printf("%d\n", current_cursor);
135                 set_x_cursor(current_cursor);
136         }
137         
138         int current_cursor;
141 int main(int argc, char *argv[])
143         new BC_Signals;
144         TestWindow window;
145         int angles[] = { 180, 0 };
146         float values[] = { 1, 0 };
148         window.add_tool(new BC_Pan(10, 
149                 120, 
150                 100, 
151                 1, 
152                 2, 
153                 angles, 
154                 -1, 
155                 -1,
156                 values));
157         window.add_tool(new BC_TextBox(10, 10, 200, 5, _("Mary Egbert\nhad a little lamb.")));
158         BC_Title *title;
159         window.add_tool(title = new BC_Title(10, 210, _("Hello world")));
160         title->update("xyz");
161         window.show_window();
163 sleep(2);
164         title->update("abc");
166         window.run_window();
168 //      thread_fork();