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

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

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

revision 1.2 by jefbed, Mon Aug 16 17:27:05 2004 UTC revision 1.3 by jefbed, Tue Aug 17 20:36:22 2004 UTC
# Line 24  Line 24 
24  void  void
25  arshell_insert_file_cb()  arshell_insert_file_cb()
26  {  {
27      ARBUG;
28      
29    char *file=antiright_pipe_read("cat `arshell -ADf`");    char *file=antiright_pipe_read("cat `arshell -ADf`");
30    XmTextInsert(arshell.gui.widgets.work,    XmTextInsert(arshell.gui.widgets.work,
31                 XmTextGetInsertionPosition(arshell.gui.widgets.work),                 XmTextGetInsertionPosition(arshell.gui.widgets.work),
# Line 36  arshell_open_file_cb(Widget parent_widge Line 38  arshell_open_file_cb(Widget parent_widge
38                       XtPointer client_data,                       XtPointer client_data,
39                       XtPointer call_data)                       XtPointer call_data)
40  {  {
41      ARBUG;
42      
43    char *label;    char *label;
44    XmString motif_string;    XmString motif_string;
45    ARCLARG;    ARCLARG;
# Line 54  arshell_open_file_cb(Widget parent_widge Line 58  arshell_open_file_cb(Widget parent_widge
58  void  void
59  arshell_open_file()  arshell_open_file()
60  {  {
61      ARBUG;
62      
63    char *command_string;    char *command_string;
64    char *buffer;    char *buffer;
65    asprintf(&command_string, "cat %s", arshell.edit.filename);    asprintf(&command_string, "cat %s", arshell.edit.filename);
# Line 80  arshell_file_select_ok_cb(Widget widget, Line 86  arshell_file_select_ok_cb(Widget widget,
86                            XtPointer client_data,                            XtPointer client_data,
87                            XtPointer call_data)                            XtPointer call_data)
88  {  {
89      ARBUG;
90    XmFileSelectionBoxCallbackStruct *call_pointer=call_data;    XmFileSelectionBoxCallbackStruct *call_pointer=call_data;
91    char *c_string;    char *c_string;
92    
93    if(arshell.flags.file_open)    if(arshell.flags.file_open)
94      {      {
95          ARBUG;
96        arshell_save_work_area();        arshell_save_work_area();
97      }      }
98    c_string=antiright_c_string(call_pointer->value);    c_string=antiright_c_string(call_pointer->value);
# Line 93  arshell_file_select_ok_cb(Widget widget, Line 101  arshell_file_select_ok_cb(Widget widget,
101    XtDestroyWidget(widget);    XtDestroyWidget(widget);
102    if(arshell.flags.saving)    if(arshell.flags.saving)
103      {      {
104          ARBUG;
105        arshell.flags.file_open=True;        arshell.flags.file_open=True;
106        arshell_save_work_area();        arshell_save_work_area();
107        arshell.flags.saving=False;        arshell.flags.saving=False;
108      }      }
109    if(arshell.flags.opening)    if(arshell.flags.opening)
110      {      {
111          ARBUG;
112        arshell.flags.file_open=True;        arshell.flags.file_open=True;
113        arshell_open_file();        arshell_open_file();
114        arshell.flags.opening=False;        arshell.flags.opening=False;
# Line 109  arshell_file_select_ok_cb(Widget widget, Line 119  arshell_file_select_ok_cb(Widget widget,
119  void  void
120  arshell_select_filename()  arshell_select_filename()
121  {  {
122      ARBUG;
123    Widget file_selection_widget;    Widget file_selection_widget;
124    ARCLARG;    ARCLARG;
125    antiright_set(XmNtitle, (XtArgVal)"File Selector");    antiright_set(XmNtitle, (XtArgVal)"File Selector");
# Line 128  arshell_select_filename() Line 139  arshell_select_filename()
139  void  void
140  arshell_put_text_into_file(FILE *file)  arshell_put_text_into_file(FILE *file)
141  {  {
142      ARBUG;
143    char *text_string;    char *text_string;
144    assert(arshell.gui.widgets.work != NULL);    assert(arshell.gui.widgets.work != NULL);
145    text_string=XmTextGetString(arshell.gui.widgets.work);    text_string=XmTextGetString(arshell.gui.widgets.work);
# Line 137  arshell_put_text_into_file(FILE *file) Line 149  arshell_put_text_into_file(FILE *file)
149  void  void
150  arshell_open_file_for_writing(FILE **file_pointer)  arshell_open_file_for_writing(FILE **file_pointer)
151  {  {
152      ARBUG;
153    (*file_pointer)=fopen(arshell.edit.filename, "w");    (*file_pointer)=fopen(arshell.edit.filename, "w");
154    if((*file_pointer)==NULL)    if((*file_pointer)==NULL)
155      {      {
# Line 147  arshell_open_file_for_writing(FILE **fil Line 160  arshell_open_file_for_writing(FILE **fil
160  void  void
161  arshell_save_work_area()  arshell_save_work_area()
162  {  {
163      ARBUG;
164    FILE* file_pointer;    FILE* file_pointer;
165    arshell.flags.saving=True;    arshell.flags.saving=True;
166    if(arshell.flags.file_open==False)    if(arshell.flags.file_open==False)
167      {      {
168          ARBUG;
169        arshell_select_filename();        arshell_select_filename();
170      }      }
171    else    else
172      {      {
173          ARBUG;
174        arshell_open_file_for_writing(&file_pointer);        arshell_open_file_for_writing(&file_pointer);
175        arshell_put_text_into_file(file_pointer);        arshell_put_text_into_file(file_pointer);
176        fclose(file_pointer);        fclose(file_pointer);
177        arshell_get_rid_of_modified_status();        arshell_get_rid_of_modified_status();
178        antiright_set_title(arshell.edit.filename);        antiright_set_title(arshell.edit.filename);
179      }      }
180      arshell.flags.saving=False;
181  }  }
182    
183  void  void
184  arshell_save_as_cb()  arshell_save_as_cb()
185  {  {
186      ARBUG;
187      arshell.flags.saving=True;
188    arshell_select_filename();    arshell_select_filename();
   arshell_save_work_area();  
189  }  }
190    
191  void  void
192  arshell_open_cb()  arshell_open_cb()
193  {  {
194      ARBUG;
195    arshell.flags.opening=True;    arshell.flags.opening=True;
196      arshell.flags.saving=False;
197    arshell_select_filename();    arshell_select_filename();
198  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

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