/[antiright]/antiright/src/arshell/arguments.c
ViewVC logotype

Diff of /antiright/src/arshell/arguments.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by jefbed, Sat Jul 23 17:10:09 2005 UTC revision 1.24 by jefbed, Sun Jul 31 16:19:50 2005 UTC
# Line 23  Line 23 
23  #include "arshell.h"  #include "arshell.h"
24    
25  void  void
26  arshell_add_lower_button()  arshell_add_lower_button ()
27  {  {
28    Widget button;    Widget button;
29    arshell_row_layout();    arshell_row_layout ();
30    assert(arshell.gui.layout.row_widget);    assert (arshell.gui.layout.row_widget);
31    button=antiright_panel_button(arshell.gui.layout.row_widget, "Lower",    button = antiright_panel_button (arshell.gui.layout.row_widget, "Lower",
32                            arshell_lower_mainwindow_cb, NULL);                                     arshell_lower_mainwindow_cb, NULL);
33    antiright_set_tooltip(button, "Lower the panel.");    antiright_set_tooltip (button, "Lower the panel.");
34  }  }
35    
36  void  void
37  arshell_handle_graph_arguments(int *counter_int, char **argv)  arshell_handle_graph_arguments (int *counter_int, char **argv)
38  {  {
39    switch(argv[(*counter_int)][3])    switch (argv[(*counter_int)][3])
40      {      {
41      case 'e': /* Graph an equation, using the output of the passed      case 'e':                   /* Graph an equation, using the output of the passed
42                   program.  */                                     program.  */
43        (*counter_int)++;        (*counter_int)++;
44        antiright_graph_equation(argv[(*counter_int)]);        antiright_graph_equation (argv[(*counter_int)]);
45        break;        break;
46      case 's': /* Display a number system output by the passed      case 's':                   /* Display a number system output by the passed
47                   program.  */                                     program.  */
48        (*counter_int)++;        (*counter_int)++;
49        antiright_graph_system(argv[(*counter_int)]);        antiright_graph_system (argv[(*counter_int)]);
50        break;        break;
51      case 'l': /* Draw a line.  */      case 'l':                   /* Draw a line.  */
52        (*counter_int)++;        (*counter_int)++;
53        antiright_graph_line(atoi(argv[(*counter_int)]),        antiright_graph_line (atoi (argv[(*counter_int)]),
54                             atoi(argv[(*counter_int)+1]),                              atoi (argv[(*counter_int) + 1]),
55                             atoi(argv[(*counter_int)+2]),                              atoi (argv[(*counter_int) + 2]),
56                             atoi(argv[(*counter_int)+3]));                              atoi (argv[(*counter_int) + 3]));
57        (*counter_int)+=3;        (*counter_int) += 3;
58        break;        break;
59      case 'p': /* Plot a point.  */      case 'p':                   /* Plot a point.  */
60        (*counter_int)++;        (*counter_int)++;
61        antiright_graph_point(atoi(argv[(*counter_int)]),        antiright_graph_point (atoi (argv[(*counter_int)]),
62                              atoi(argv[(*counter_int)+1]));                               atoi (argv[(*counter_int) + 1]));
63        (*counter_int)++;        (*counter_int)++;
64          
65        break;        break;
66      case 'r': /* Graph a rectangle.  */      case 'r':                   /* Graph a rectangle.  */
67        (*counter_int)++;        (*counter_int)++;
68        antiright_graph_rect(atoi(argv[(*counter_int)]),        antiright_graph_rect (atoi (argv[(*counter_int)]),
69                             atoi(argv[(*counter_int)+1]),                              atoi (argv[(*counter_int) + 1]),
70                             atoi(argv[(*counter_int)+2]),                              atoi (argv[(*counter_int) + 2]),
71                             atoi(argv[(*counter_int)+3]));                              atoi (argv[(*counter_int) + 3]));
72        (*counter_int)+=3;        (*counter_int) += 3;
73        break;        break;
74      }      }
75  }  }
76    
77  void  void
78  arshell_handle_construction_arguments(int *counter_int, char **argv)  arshell_handle_construction_arguments (int *counter_int, char **argv)
79  {  {
80    switch(argv[(*counter_int)][2])    switch (argv[(*counter_int)][2])
81      {      {
82      case 'b': /* Add a bitmap button.  */      case 'b':                   /* Add a bitmap button.  */
83        arshell_add_bitmap_button(counter_int, argv);        arshell_add_bitmap_button (counter_int, argv);
84        break;        break;
85      case 'C': /* Add a color selector.  */      case 'C':                   /* Add a color selector.  */
86        arshell_color_widget(arshell.gui.widgets.row);        arshell_color_widget (arshell.gui.widgets.row);
87        break;        break;
88      case 'c': /* Add a clockload applet.  */      case 'c':                   /* Add a clockload applet.  */
89        arshell_clockload_applet(arshell.gui.widgets.row);        arshell_clockload_applet (arshell.gui.widgets.row);
90        break;        break;
91      case 'D': /* Add a dialog.  */      case 'D':                   /* Add a dialog.  */
92        arshell_handle_dialog_arguments(counter_int, argv);        arshell_handle_dialog_arguments (counter_int, argv);
93        break;        break;
94      case 'g': /* Add a graphing widget.  */      case 'g':                   /* Add a graphing widget.  */
95        arshell_handle_graph_arguments(counter_int, argv);        arshell_handle_graph_arguments (counter_int, argv);
96        arshell.use_graph=True;        arshell.use_graph = True;
97        break;        break;
98      case 'i': /* Add an icon without a label.  */      case 'i':                   /* Add an icon without a label.  */
99        arshell_add_icon_button(counter_int, argv);        arshell_add_icon_button (counter_int, argv);
100        break;        break;
101      case 'L': /* Add a Lower button.  */      case 'L':                   /* Add a Lower button.  */
102        arshell_add_lower_button();        arshell_add_lower_button ();
103        break;        break;
104      case 'l': /* Add a label.  */      case 'l':                   /* Add a label.  */
105        (*counter_int)++;        (*counter_int)++;
106        ARCLARG;        ARCLARG;
107        antiright_label(arshell.gui.widgets.row, argv[(*counter_int)]);        antiright_label (arshell.gui.widgets.row, argv[(*counter_int)]);
108        break;        break;
109      case 'm':      case 'm':
110        arshell_handle_menubar_sub_arguments(counter_int, argv);        arshell_handle_menubar_sub_arguments (counter_int, argv);
111        break;        break;
112      case 's': /* Create a status area.  */      case 's':                   /* Create a status area.  */
113        antiright_create_status_bar(arshell.gui.widgets.mainwindow);        antiright_create_status_bar (arshell.gui.widgets.mainwindow);
114        break;        break;
115      case 't': /* Add a text field.  */      case 't':                   /* Add a text field.  */
116        (*counter_int)++;        (*counter_int)++;
117        arshell_create_default_text_entry(arshell.gui.widgets.row,        arshell_create_default_text_entry (arshell.gui.widgets.row,
118                                          counter_int, argv);                                           counter_int, argv);
119        break;        break;
120      case 'w': /* Add a work area scrolled text.  */      case 'w':                   /* Add a work area scrolled text.  */
121        arshell_create_text_work_area();        arshell_create_text_work_area ();
122        break;        break;
123      }      }
124  }  }
125    
126  void  void
127  arshell_handle_long_options(int *counter_int, char **argv)  arshell_handle_long_options (int *counter_int, char **argv)
128  {  {
129    int length=strlen(argv[(*counter_int)]), counter;    int length = strlen (argv[(*counter_int)]), counter;
130    char *option=(char*)xmalloc(length-1);    char *option = (char *) xmalloc (length - 1);
131    for(counter=2; counter <= length; counter++)    for (counter = 2; counter <= length; counter++)
132      {      {
133        option[counter-2]=argv[(*counter_int)][counter];        option[counter - 2] = argv[(*counter_int)][counter];
134      }      }
135    
136  #ifdef DEBUG  #ifdef DEBUG
137    printf("LENGTH:%d;COUNTER:%d;OPTION:%s\n", length, counter, option);    printf ("LENGTH:%d;COUNTER:%d;OPTION:%s\n", length, counter, option);
138    fflush(stdout);    fflush (stdout);
139    length-=2;    length -= 2;
140  #endif /* DEBUG  */  #endif /* DEBUG  */
141    
142    if(!strncmp(option, "help", length))    if (!strncmp (option, "help", length))
143      {      {
144        arshell_usage();        arshell_usage ();
145      }      }
146    if(!strncmp(option, "fifo", length))    if (!strncmp (option, "fifo", length))
147      {      {
148        (*counter_int)++;        (*counter_int)++;
149        antiright_fifo_server(argv[(*counter_int)], argv[(*counter_int)+1]);        antiright_fifo_server (argv[(*counter_int)], argv[(*counter_int) + 1]);
150        (*counter_int)++;        (*counter_int)++;
151      }      }
152    if(!strncmp(option, "test", length))    if (!strncmp (option, "test", length))
153      {      {
154        puts("TESTING");        puts ("TESTING");
155        antiright_pipe_write("cut -d ' ' -f 2", "num 1 2 3");        antiright_pipe_write ("cut -d ' ' -f 2", "num 1 2 3");
156        puts("TESTING");        puts ("TESTING");
157        exit(0);        exit (0);
158      }      }
159  }  }
160    
161  void  void
162  arshell_process_options(int *counter_int, char **argv)  arshell_process_options (int *counter_int, char **argv)
163  {  {
164    /* The code for the case statements should be clear as to    /* The code for the case statements should be clear as to
165       its action and fully indirected through extraction.  */       its action and fully indirected through extraction.  */
166    switch (argv[(*counter_int)][1])    switch (argv[(*counter_int)][1])
167      {      {
168      case 'A': /* This section adds a widget.  */      case 'A':                   /* This section adds a widget.  */
169        arshell_handle_construction_arguments(counter_int, argv);        arshell_handle_construction_arguments (counter_int, argv);
170          
171        break;        break;
172      case 'E': /* Exit when a button is pressed.  */      case 'E':                   /* Exit when a button is pressed.  */
173        arshell.flags.exit_on_action=True;        arshell.flags.exit_on_action = True;
174        break;        break;
175        /* The following only works if you have the yetanotherclib        /* The following only works if you have the yetanotherclib
176           library.  */           library.  */
177  #ifdef HAVE_YACLIB  #ifdef HAVE_YACLIB
178      case 'f': /* Load an arshell interface definition file.  */      case 'f':                   /* Load an arshell interface definition file.  */
179        (*counter_int)++;        (*counter_int)++;
180        arshell_parse_interface_file(argv[(*counter_int)]);        arshell_parse_interface_file (argv[(*counter_int)]);
181        break;        break;
182  #endif /* HAVE_YACLIB  */  #endif /* HAVE_YACLIB  */
183      case 'l': /* Start up lowered.  */      case 'l':                   /* Start up lowered.  */
184        arshell.flags.lowered=True;        arshell.flags.lowered = True;
185        break;        break;
186      case 'p': /* Input pipe operations.  */      case 'p':                   /* Input pipe operations.  */
187        arshell_set_work_area_from_stdin();        arshell_set_work_area_from_stdin ();
188        break;        break;
189      case 'r':      case 'r':
190        arshell_set_rows(counter_int, argv);        arshell_set_rows (counter_int, argv);
191        break;        break;
192      case 'T':      case 'T':
193        arshell.flags.force_tooltips=False;        arshell.flags.force_tooltips = False;
194        break;          break;
195      case 't':      case 't':
196        arshell.flags.force_tooltips=True;        arshell.flags.force_tooltips = True;
197        break;        break;
198      case 'U':      case 'U':
199        arshell_handle_updating_argument(counter_int, argv);        arshell_handle_updating_argument (counter_int, argv);
200        break;        break;
201      case 'W':      case 'W':
202        arshell_set_window_title_and_work_filename(counter_int, argv);        arshell_set_window_title_and_work_filename (counter_int, argv);
203        break;        break;
204      case '-':      case '-':
205        arshell_handle_long_options(counter_int, argv);        arshell_handle_long_options (counter_int, argv);
206        break;        break;
207      default:      default:
208        arshell_usage();        arshell_usage ();
209        break;        break;
210      }      }
211  }  }
212  void  void
213  arshell_process_non_option_arguments(int *counter_int, char **argv)  arshell_process_non_option_arguments (int *counter_int, char **argv)
214  {  {
215    arshell_row_layout();    arshell_row_layout ();
216    arshell_optioned_button(arshell.gui.layout.row_widget,    arshell_optioned_button (arshell.gui.layout.row_widget,
217                            arshell_system_cb, argv[(*counter_int)]);                             arshell_system_cb, argv[(*counter_int)]);
218  }  }
219    
220    
221  void  void
222  arshell_handle_command_line_arguments(int* argc, char** argv)  arshell_handle_command_line_arguments (int *argc, char **argv)
223  {  {
224    int  counter_int;    int counter_int;
225    arshell_initialize_layout_values();    arshell_initialize_layout_values ();
226    for(counter_int=1; counter_int < (*argc); counter_int++)    for (counter_int = 1; counter_int < (*argc); counter_int++)
227    {      {
228      if(argv[counter_int][0] == '-')        if (argv[counter_int][0] == '-')
229        {          {
230          arshell_process_options(&counter_int, argv);            arshell_process_options (&counter_int, argv);
231        }          }
232      else        else
233        {          {
234          arshell_process_non_option_arguments(&counter_int, argv);            arshell_process_non_option_arguments (&counter_int, argv);
235        }          }
236    }        }
237      
238  }  }

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26