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

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

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

revision 1.10 by jefbed, Fri Aug 13 19:32:51 2004 UTC revision 1.11 by jefbed, Mon Aug 16 17:27:05 2004 UTC
# Line 20  Line 20 
20  */  */
21    
22  #include "arshell.h"  #include "arshell.h"
23  #include "../bitmaps/text.xbm"  #include <ctype.h>
24    
25    void
26    arshell_select_all()
27    {
28      XmTextSetSelection(arshell.gui.widgets.work, 0,
29                         XmTextGetLastPosition(arshell.gui.widgets.work),
30                         XtLastTimestampProcessed(antiright.display));
31    }
32    
33    void
34    arshell_selection_case(int (*operation)(int))
35    {
36      char *text=XmTextGetString(arshell.gui.widgets.work);
37      XmTextPosition left, right;
38      int counter=0;
39      XmTextGetSelectionPosition(arshell.gui.widgets.work, &left, &right);
40      for(counter=left; counter <= right; counter++)
41        text[counter]=(*operation)(text[counter]);
42      XmTextSetString(arshell.gui.widgets.work, text);
43      XtFree(text);
44    }
45    void
46    arshell_lower_selection_case()
47    {
48      arshell_selection_case(&tolower);
49    }
50    void
51    arshell_upper_selection_case()
52    {
53      arshell_selection_case(&toupper);
54    }
55    
56    void
57    arshell_change_font_cb()
58    {
59      char *font_string;
60      XFontStruct *font_struct;
61    
62      font_string=antiright_pipe_read("arshell -ADF");
63      if((*font_string)!='\0')
64        {
65          font_struct=XLoadQueryFont(antiright.display, font_string);
66          if(font_struct!=NULL)
67            {
68              XmFontList font_list=XmFontListCreate(font_struct, XmSTRING_DEFAULT_CHARSET);
69              ARCLARG;
70              antiright_set(XmNfontList, (XtArgVal)font_list);
71              antiright_set_values(arshell.gui.widgets.work);
72              ARCLARG;
73              XmFontListFree(font_list);
74            }
75          else
76            {
77              antiright_system("arshell -ADm 'The entered font was not found.  ' &");
78            }
79        }
80      free(font_string);
81    }
82    
83  /* This is a simple method of printing the current file.  */  /* This is a simple method of printing the current file.  */
84  void  void
85  arshell_print_cb()  arshell_print_cb()
# Line 78  arshell_line(XmTextPosition end_position Line 137  arshell_line(XmTextPosition end_position
137    XtFree(text);    XtFree(text);
138    return(lines);    return(lines);
139  }  }
140    void
141    arshell_goto_line(unsigned int line)
142    {
143      /* Declare a counter for the number of lines counted.  */
144      int line_counter=1;
145      /* Declare a text position counter. */
146      XmTextPosition position=0;
147      char *text=XmTextGetString(arshell.gui.widgets.work);
148      unsigned int text_length=strlen(text);
149      while((position<text_length) & (line_counter<line))
150        {
151          if(text[position]=='\n')
152            line_counter++;
153          position++;
154        }
155      XtFree(text);
156      XmTextSetInsertionPosition(arshell.gui.widgets.work, position);
157    }
158    void
159    arshell_goto_line_cb()
160    {
161      char *line_string=antiright_pipe_read("arshell -ADp Line:");
162      arshell_goto_line(atoi(line_string));
163      free(line_string);  
164    }
165  int  int
166  arshell_current_line()  arshell_current_line()
167  {  {
168    return(arshell_line(XmTextGetInsertionPosition(arshell.gui.widgets.work)));    return(arshell_line(XmTextGetInsertionPosition(arshell.gui.widgets.work)+1));
169  }  }
170  int  int
171  arshell_text_lines()  arshell_text_lines()
# Line 109  void Line 193  void
193  arshell_set_work_area_arguments()  arshell_set_work_area_arguments()
194  {  {
195    ARCLARG;    ARCLARG;
   antiright_set(XmNscrollHorizontal, False);  
   antiright_set(XmNscrollVertical, True);  
196    antiright_set(XmNeditMode, XmMULTI_LINE_EDIT);    antiright_set(XmNeditMode, XmMULTI_LINE_EDIT);
   antiright_set(XmNwordWrap, True);  
197    antiright_set(XmNcolumns, 80);    antiright_set(XmNcolumns, 80);
198    antiright_set(XmNrows, 24);    antiright_set(XmNrows, 24);
199  }  }
200  void  void
201    arshell_verified_status(XmTextVerifyCallbackStruct *call_pointer)
202    {
203      char *status;
204      asprintf(&status, "Lines:%d  Current:%d",
205               arshell_text_lines(), arshell_line(call_pointer->newInsert));
206      antiright_status(status);
207      free(status);
208    }
209    void
210  arshell_modify_verify_cb(Widget widget, XtPointer client_data,  arshell_modify_verify_cb(Widget widget, XtPointer client_data,
211                           XtPointer call_data)                           XtPointer call_data)
212  {  {
   XmTextVerifyCallbackStruct *call_pointer=call_data;  
213    client_data=NULL;    client_data=NULL;
214    widget=NULL;    widget=NULL;
215    arshell_status();    arshell_verified_status(call_data);
216    }
217    void
218    arshell_motion_verify_cb(Widget widget, XtPointer client_data,
219                             XtPointer call_data)
220    {
221      client_data=NULL;
222      widget=NULL;
223      arshell_verified_status(call_data);
224  }  }
   
225  void  void
226  arshell_create_text_work_area()  arshell_create_text_work_area()
227  {  {
# Line 138  arshell_create_text_work_area() Line 234  arshell_create_text_work_area()
234    XtAddCallback(arshell.gui.widgets.work, XmNvalueChangedCallback,    XtAddCallback(arshell.gui.widgets.work, XmNvalueChangedCallback,
235                  arshell_value_changed_cb, NULL);                  arshell_value_changed_cb, NULL);
236    XtAddCallback(arshell.gui.widgets.work, XmNmodifyVerifyCallback,    XtAddCallback(arshell.gui.widgets.work, XmNmodifyVerifyCallback,
237                  arshell_modify_verify_cb, NULL);                  arshell_modify_verify_cb, NULL);
238      XtAddCallback(arshell.gui.widgets.work, XmNmotionVerifyCallback,
239                    arshell_motion_verify_cb, NULL);
240    arshell_setup_work_menubar();    arshell_setup_work_menubar();
241    antiright_set_icon(text_bits);    {
242        char *icon;
243        asprintf(&icon, "%s/handtoface.xpm", ICONDIR);
244        antiright_set_bitmap_from_file(antiright.parent_widget, icon);
245        free(icon);
246      }
247  }  }
248    
249  void  void
# Line 173  void Line 276  void
276  arshell_set_work_area_from_stdin()  arshell_set_work_area_from_stdin()
277  {  {
278    char buffer[BUFSIZ];    char buffer[BUFSIZ];
279    assert(arshell.gui.widgets.work != NULL);    if(arshell.gui.widgets.work==NULL)
280        arshell_create_text_work_area();
281    while(fgets(buffer, BUFSIZ, stdin) != NULL)    while(fgets(buffer, BUFSIZ, stdin) != NULL)
282      XmTextInsert(arshell.gui.widgets.work,      XmTextInsert(arshell.gui.widgets.work,
283                   XmTextGetInsertionPosition(arshell.gui.widgets.work), buffer);                   XmTextGetInsertionPosition(arshell.gui.widgets.work), buffer);
284    XmTextSetInsertionPosition(arshell.gui.widgets.work, 0);    XmTextSetInsertionPosition(arshell.gui.widgets.work, 0);
285      arshell_status();
286  }  }
287  void  void
288  arshell_create_default_text_entry(Widget widget_row_widget,  arshell_create_default_text_entry(Widget widget_row_widget,

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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