blob: 3f6c49e9da0f441014e1b83e28174e7cd1e12fc6 [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: Fl_Input.H 8111 2010-12-23 08:13:18Z manolo $"
3//
4// Input header file for the Fast Light Tool Kit (FLTK).
5//
6// Copyright 1998-2010 by Bill Spitzak and others.
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Library General Public
10// License as published by the Free Software Foundation; either
11// version 2 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// Library General Public License for more details.
17//
18// You should have received a copy of the GNU Library General Public
19// License along with this library; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
21// USA.
22//
23// Please report all bugs and problems on the following page:
24//
25// http://www.fltk.org/str.php
26//
27
28/* \file
29 Fl_Input widget . */
30
31#ifndef Fl_Input_H
32#define Fl_Input_H
33
34#include "Fl_Input_.H"
35
36/**
37 This is the FLTK text input widget. It displays a single line
38 of text and lets the user edit it. Normally it is drawn with an
39 inset box and a white background. The text may contain any
40 characters, and will correctly display any UTF text, using
41 ^X notation for unprintable control characters. It assumes the
42 font can draw any characters of the used scripts, which is true
43 for standard fonts under MSWindows and Mac OS X.
44 Characters can be input using the keyboard or the character palette/map.
45 Character composition is done using dead keys and/or a compose
46 key as defined by the operating system.
47 <P>
48 <TABLE WIDTH=90% BORDER=1 SUMMARY="Fl_Input keyboard and mouse bindings.">
49 <CAPTION ALIGN=TOP>Fl_Input keyboard and mouse bindings.</CAPTION>
50 <TR><TD NOWRAP="NOWRAP" WIDTH="1%">
51 <B>Mouse button 1</B>
52 </TD><TD>
53 Moves the cursor to this point.
54 Drag selects characters.
55 Double click selects words.
56 Triple click selects all line.
57 Shift+click extends the selection.
58 When you select text it is automatically copied to the selection buffer.
59 </TD></TR><TR><TD NOWRAP="NOWRAP">
60 <B>Mouse button 2</B>
61 </TD><TD>
62 Insert the selection buffer at the point clicked.
63 You can also select a region and replace it with the selection buffer
64 by selecting the region with mouse button 2.
65 </TD></TR><TR><TD NOWRAP="NOWRAP">
66 <B>Mouse button 3</B>
67 </TD><TD>
68 Currently acts like button 1.
69 </TD></TR><TR><TD NOWRAP="NOWRAP">
70 <B>Backspace</B>
71 </TD><TD>
72 Deletes one character to the left, or deletes the selected region.
73 </TD></TR><TR><TD NOWRAP="NOWRAP">
74 <B>Delete</B>
75 </TD><TD>
76 Deletes one character to the right, or deletes the selected region.
77 Combine with Shift for equivalent of ^X (copy+cut).
78 </TD></TR><TR><TD NOWRAP="NOWRAP">
79 <B>Enter</b>
80 </TD><TD>
81 May cause the callback, see when().
82 </TD></TR></TABLE>
83
84 <P>
85
86 <TABLE WIDTH="90%" BORDER="1" SUMMARY="Fl_Input platform specific keyboard bindings.">
87 <CAPTION ALIGN=TOP>Fl_Input platform specific keyboard bindings.</CAPTION>
88 <TR>
89 <TD NOWRAP="NOWRAP" WIDTH="1%"><B> Windows/Linux </B></TD>
90 <TD NOWRAP="NOWRAP" WIDTH="1%"><B> Mac </B></TD>
91 <TD NOWRAP="NOWRAP" ><B> Function </B></TD>
92
93 </TR><TR>
94 <TD NOWRAP="NOWRAP"><B> ^A </B></TD>
95 <TD NOWRAP="NOWRAP"><B> Command-A </B></TD>
96 <TD>
97 <B>Selects all text in the widget.</B>
98
99 </TD></TR><TR>
100 <TD NOWRAP="NOWRAP"><B> ^C </B></TD>
101 <TD NOWRAP="NOWRAP"><B> Command-C </B></TD>
102 <TD>
103 <B>Copy the current selection to the clipboard.</B>
104
105 </TD></TR><TR>
106 <TD NOWRAP="NOWRAP"><B> ^I </B></TD>
107 <TD NOWRAP="NOWRAP"><B> ^I </B></TD>
108 <TD>
109 <B>Insert a tab.</B>
110
111 </TD></TR><TR>
112 <TD NOWRAP="NOWRAP"><B> ^J </B></TD>
113 <TD NOWRAP="NOWRAP"><B> ^J </B></TD>
114 <TD>
115 <B>Insert a Line Feed.</B> <BR>
116 (Similar to literal 'Enter' character)
117
118 </TD></TR><TR>
119 <TD NOWRAP="NOWRAP"><B> ^L </B></TD>
120 <TD NOWRAP="NOWRAP"><B> ^L </B></TD>
121 <TD>
122 <B>Insert a Form Feed.</B>
123
124 </TD></TR><TR>
125 <TD NOWRAP="NOWRAP"><B> ^M </B></TD>
126 <TD NOWRAP="NOWRAP"><B> ^M </B></TD>
127 <TD>
128 <B>Insert a Carriage Return.</B>
129
130 </TD></TR><TR>
131 <TD NOWRAP="NOWRAP"><B> ^V,<BR>Shift-Insert </B></TD>
132 <TD NOWRAP="NOWRAP"><B> Command-V </B></TD>
133 <TD>
134 <B>Paste the clipboard.</B> <BR>
135 (Macs keyboards don't have "Insert" keys,
136 but if they did, Shift-Insert would work)
137
138 </TD></TR><TR>
139 <TD NOWRAP="NOWRAP"><B> ^X,<BR>Shift-Delete </B></TD>
140 <TD NOWRAP="NOWRAP"><B> Command-X,<BR>Shift-Delete </B></TD>
141 <TD>
142 <B>Cut.</B> <BR>
143 Copy the selection to the clipboard and delete it.
144 (If there's no selection, Shift-Delete acts like Delete)
145
146 </TD></TR><TR>
147 <TD NOWRAP="NOWRAP"><B> ^Z </B></TD>
148 <TD NOWRAP="NOWRAP"><B> Command-Z </B></TD>
149 <TD>
150 <B>Undo.</B> <BR>
151 This is a single-level undo mechanism, but all adjacent
152 deletions and insertions are concatenated into a single "undo".
153 Often this will undo a lot more than you expected.
154
155 </TD></TR><TR>
156 <TD NOWRAP="NOWRAP"><B> Shift-^Z </B></TD>
157 <TD NOWRAP="NOWRAP"><B> Shift-Command-Z </B></TD>
158 <TD>
159 <B>Redo.</B> <BR>
160 Currently same behavior as ^Z.
161 Reserved for future multilevel undo/redo.
162
163 </TD></TR><TR>
164 <TD NOWRAP="NOWRAP"><B> Arrow Keys </B></TD>
165 <TD NOWRAP="NOWRAP"><B> Arrow Keys </B></TD>
166 <TD>
167 <B>Standard cursor movement.</B> <BR>
168 Can be combined with Shift to extend selection.
169
170 </TD></TR><TR>
171 <TD NOWRAP="NOWRAP"><B> Home </B></TD>
172 <TD NOWRAP="NOWRAP"><B> Command-Up,<BR>Command-Left </B></TD>
173 <TD>
174 <B>Move to start of line.</B> <BR>
175 Can be combined with Shift to extend selection.
176
177 </TD></TR><TR>
178 <TD NOWRAP="NOWRAP"><B> End </B></TD>
179 <TD NOWRAP="NOWRAP"><B> Command-Down,<BR>Command-Right </B></TD>
180 <TD>
181 <B>Move to end of line.</B> <BR>
182 Can be combined with Shift to extend selection.
183
184 </TD></TR><TR>
185 <TD NOWRAP="NOWRAP"><B>Ctrl-Home</B></TD>
186 <TD NOWRAP="NOWRAP"><B>Command-Up,<BR>Command-PgUp,<BR>Ctrl-Left</B></TD>
187 <TD>
188 <B>Move to top of document/field.</B> <BR>
189 In single line input, moves to start of line.
190 In multiline input, moves to start of top line.
191 Can be combined with Shift to extend selection.
192
193 </TD></TR><TR>
194 <TD NOWRAP="NOWRAP"><B> Ctrl-End </B></TD>
195 <TD NOWRAP="NOWRAP"><B> Command-End,<BR>Command-PgDn,<BR>Ctrl-Right</B></TD>
196 <TD>
197 <B>Move to bottom of document/field.</B> <BR>
198 In single line input, moves to end of line.
199 In multiline input, moves to end of last line.
200 Can be combined with Shift to extend selection.
201
202 </TD></TR><TR>
203 <TD NOWRAP="NOWRAP"><B> Ctrl-Left </B></TD>
204 <TD NOWRAP="NOWRAP"><B> Alt-Left </B></TD>
205 <TD>
206 <B>Word left.</B> <BR>
207 Can be combined with Shift to extend selection.
208
209 </TD></TR><TR>
210 <TD NOWRAP="NOWRAP"><B> Ctrl-Right </B></TD>
211 <TD NOWRAP="NOWRAP"><B> Alt-Right </B></TD>
212 <TD>
213 <B>Word right.</B> <BR>
214 Can be combined with Shift to extend selection.
215
216 </TD></TR><TR>
217 <TD NOWRAP="NOWRAP"><B> Ctrl-Backspace </B></TD>
218 <TD NOWRAP="NOWRAP"><B> Alt-Backspace </B></TD>
219 <TD>
220 <B>Delete word left.</B>
221
222 </TD></TR><TR>
223 <TD NOWRAP="NOWRAP"><B> Ctrl-Delete </B></TD>
224 <TD NOWRAP="NOWRAP"><B> Alt-Delete </B></TD>
225 <TD>
226 <B>Delete word right.</B>
227
228 </TD></TR></TABLE>
229 */
230class FL_EXPORT Fl_Input : public Fl_Input_ {
231 int handle_key();
232 int shift_position(int p);
233 int shift_up_down_position(int p);
234 void handle_mouse(int keepmark=0);
235
236 // Private keyboard functions
237 int kf_lines_up(int repeat_num);
238 int kf_lines_down(int repeat_num);
239 int kf_page_up();
240 int kf_page_down();
241 int kf_insert_toggle();
242 int kf_delete_word_right();
243 int kf_delete_word_left();
244 int kf_delete_sol();
245 int kf_delete_eol();
246 int kf_delete_char_right();
247 int kf_delete_char_left();
248 int kf_move_sol();
249 int kf_move_eol();
250 int kf_clear_eol();
251 int kf_move_char_left();
252 int kf_move_char_right();
253 int kf_move_word_left();
254 int kf_move_word_right();
255 int kf_move_up_and_sol();
256 int kf_move_down_and_eol();
257 int kf_top();
258 int kf_bottom();
259 int kf_select_all();
260 int kf_undo();
261 int kf_redo();
262 int kf_copy();
263 int kf_paste();
264 int kf_copy_cut();
265
266protected:
267 void draw();
268public:
269 int handle(int);
270 Fl_Input(int,int,int,int,const char * = 0);
271};
272
273#endif
274
275//
276// End of "$Id: Fl_Input.H 8111 2010-12-23 08:13:18Z manolo $".
277//