1 /* Copyright (c) 2006 by Arkkra Enterprises */
2 /* All rights reserved */
7 // Classes for Edit menu item off of main toolbar
9 #include <FL/Fl_Widget.H>
10 #include <FL/Fl_Text_Editor.H>
11 #include <FL/Fl_Text_Buffer.H>
12 #include <FL/Fl_Double_Window.H>
13 #include <FL/Fl_Input.H>
14 #include <FL/Fl_Int_Input.H>
15 #include <FL/Fl_Box.H>
16 #include <FL/Fl_Button.H>
17 #include <FL/Fl_Round_Button.H>
18 #include <FL/Fl_Check_Button.H>
19 #include <FL/Fl_Return_Button.H>
23 // Class for window that pops up for "Find" or "Replace"
25 class Find_dialog : public Fl_Double_Window {
27 friend class Edit; // so it can call FindNext()
34 static void FindNext_cb(Fl_Widget *, void * data);
35 static void Replace_cb(Fl_Widget *, void * data);
36 static void ReplaceAll_cb(Fl_Widget *, void * data);
37 static void Cancel_cb(Fl_Widget *, void * data);
38 static void Pattern_cb(Fl_Widget *, void * data);
39 static void change_cb(Fl_Widget *, void * data);
40 static void cursor_change_check(void * data);
42 // Returns current search pattern
43 const char * get_pattern(void);
45 // Tells class which edit buffer to search in
46 void set_editor(Fl_Text_Editor *);
48 // Class instance can be either a Find or a Replace.
49 // These change the personality.
51 void as_Replace(void);
53 // when not allowed to search/replace
60 void ReplaceAll(void);
67 Fl_Input * replace_with_p;
68 Fl_Button * replace_p;
69 Fl_Button * replace_all_p;
70 Fl_Check_Button * casematch_p;
72 Fl_Round_Button * up_p;
73 Fl_Round_Button * down_p;
74 Fl_Return_Button * next_p;
77 // The text editor widget we are editing
78 Fl_Text_Editor * editor_p;
80 // true if current personality is "Replace," false if "Find."
83 // Where cursor was at last check
84 int last_cursor_position;
88 // Class for window that pops up for Go To
90 class GoTo_dialog : Fl_Double_Window {
99 static void OK_cb(Fl_Widget *, void * data);
100 static void Cancel_cb(Fl_Widget *, void * data);
102 // Tells us which editor instance to use
103 void set_editor(Fl_Text_Editor * ed);
105 // Initialize contents on GoTo field to the current line number
106 void set_current_line();
114 Fl_Int_Input * linenum_p;
115 Fl_Return_Button * ok_p;
116 Fl_Button * cancel_p;
117 Fl_Text_Editor * editor_p;
121 // Class for Edit Menu from main toolbar
129 static void Undo_cb(Fl_Widget *, void * data);
130 static void Cut_cb(Fl_Widget *, void * data);
131 static void Copy_cb(Fl_Widget *, void * data);
132 static void Paste_cb(Fl_Widget *, void * data);
133 static void Delete_cb(Fl_Widget *, void * data);
134 static void Find_cb(Fl_Widget *, void * data);
135 static void FindNext_cb(Fl_Widget *, void * data);
136 static void Replace_cb(Fl_Widget *, void * data);
137 static void GoTo_cb(Fl_Widget *, void * data);
138 static void SelectAll_cb(Fl_Widget *, void * data);
139 static void modify_cb(int, int, int, int, const char *, void * data);
141 // Tells us which editor instance to use
142 void set_editor(Fl_Text_Editor * ed);
144 // true if there is something in the clipboard that can be pasted
145 bool can_paste() { return wrote_to_clipboard; }
146 void set_can_paste();
159 void SelectAll(void);
162 Fl_Text_Editor * editor_p;
163 Fl_Text_Buffer * buffer_p;
164 Find_dialog * find_p;
165 GoTo_dialog * goto_p;
167 // if wrote something to the cut/copy buffer
168 bool wrote_to_clipboard;