Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 764 lines (628 sloc) 24.048 kb
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
1 /***********************************************************************
2 * FXRuby -- the Ruby language bindings for the FOX GUI toolkit.
b8219ec @lylejohnson Updated copyright notice for all SWIG interface files
lylejohnson authored
3 * Copyright (c) 2001-2009 by Lyle Johnson. All Rights Reserved.
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * For further information please contact the author by e-mail
a934547 @lylejohnson Replaced e-mail address "lyle@users.sourceforge.net" with
lylejohnson authored
20 * at "lyle@lylejohnson.name".
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
21 ***********************************************************************/
22
23 /// Text widget options
24 enum {
25 TEXT_READONLY = 0x00100000, /// Text is NOT editable
26 TEXT_WORDWRAP = 0x00200000, /// Wrap at word breaks
27 TEXT_OVERSTRIKE = 0x00400000, /// Overstrike mode
28 TEXT_FIXEDWRAP = 0x00800000, /// Fixed wrap columns
29 TEXT_NO_TABS = 0x01000000, /// Insert spaces for tabs
30 TEXT_AUTOINDENT = 0x02000000, /// Autoindent
31 TEXT_SHOWACTIVE = 0x04000000, /// Show active line
32 TEXT_AUTOSCROLL = 0x08000000 /// Logging mode, keeping last line visible
33 };
34
bea4cad @larskanis Strip all whitespaces on line endings
authored
35
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
36 /// Selection modes
37 enum FXTextSelectionMode {
38 SELECT_CHARS,
39 SELECT_WORDS,
40 SELECT_LINES
41 };
42
43
44 /// Highlight style entry
45 struct FXHiliteStyle {
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
46 %extend {
47 FXHiliteStyle(){
48 FXHiliteStyle *self = new FXHiliteStyle();
49 self->normalForeColor = 0;
50 self->normalBackColor = 0;
51 self->selectForeColor = 0;
52 self->selectBackColor = 0;
53 self->hiliteForeColor = 0;
54 self->hiliteBackColor = 0;
55 self->activeBackColor = 0;
56 self->style = 0;
57 return self;
58 }
59 }
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
60 FXColor normalForeColor; /// Normal text foreground color
61 FXColor normalBackColor; /// Normal text background color
62 FXColor selectForeColor; /// Selected text foreground color
63 FXColor selectBackColor; /// Selected text background color
64 FXColor hiliteForeColor; /// Highlight text foreground color
65 FXColor hiliteBackColor; /// Highlight text background color
66 FXColor activeBackColor; /// Active text background color
67 FXuint style; /// Highlight text style
68 ~FXHiliteStyle();
69 };
70
71
72 /**
73 * Text mutation callback data passed with the SEL_INSERTED,
74 * SEL_REPLACED, and SEL_DELETED messages; both old and new
75 * text is available on behalf of the undo system as well as
76 * syntax highlighting.
77 */
78 struct FXTextChange {
79 FXint pos; /// Position in buffer
80 FXint ndel; /// Number characters deleted at position
81 FXint nins; /// Number characters inserted at position
82 %extend {
83 VALUE ins() const {
84 return rb_str_new(self->ins,self->nins);
85 }
86 VALUE del() const {
87 return rb_str_new(self->del,self->ndel);
88 }
89 }
90 };
91
92 %rename("overstrike?") FXText::isOverstrike() const;
93 %rename("overstrike=") FXText::setOverstrike(FXbool);
94 %rename("numRows") FXText::getNumRows() const;
95
96 /**
97 * The text widget supports editing of multiple lines of text.
98 * An optional style table can provide text coloring based on
99 * the contents of an optional parallel style buffer, which is
100 * maintained as text is edited. In a typical scenario, the
101 * contents of the style buffer is either directly written when
102 * the text is added to the widget, or is continually modified
103 * by editing the text via syntax-based highlighting engine which
104 * colors the text based on syntactical patterns.
105 */
106 class FXText : public FXScrollArea {
107 public:
108 enum {
109 STYLE_UNDERLINE = 0x0001, /// Underline text
110 STYLE_STRIKEOUT = 0x0002, /// Strike out text
111 STYLE_BOLD = 0x0004 /// Bold text
112 };
113 public:
114 long onPaint(FXObject*,FXSelector,void* PTR_EVENT);
115 long onFocusIn(FXObject*,FXSelector,void* PTR_EVENT);
116 long onFocusOut(FXObject*,FXSelector,void* PTR_EVENT);
117 long onLeftBtnPress(FXObject*,FXSelector,void* PTR_EVENT);
118 long onLeftBtnRelease(FXObject*,FXSelector,void* PTR_EVENT);
119 long onMiddleBtnPress(FXObject*,FXSelector,void* PTR_EVENT);
120 long onMiddleBtnRelease(FXObject*,FXSelector,void* PTR_EVENT);
121 long onRightBtnPress(FXObject*,FXSelector,void* PTR_EVENT);
122 long onRightBtnRelease(FXObject*,FXSelector,void* PTR_EVENT);
123 long onUngrabbed(FXObject*,FXSelector,void* PTR_EVENT);
124 long onMotion(FXObject*,FXSelector,void* PTR_EVENT);
125 long onBeginDrag(FXObject*,FXSelector,void* PTR_EVENT);
126 long onEndDrag(FXObject*,FXSelector,void* PTR_EVENT);
127 long onDragged(FXObject*,FXSelector,void* PTR_EVENT);
128 long onDNDEnter(FXObject*,FXSelector,void* PTR_EVENT);
129 long onDNDLeave(FXObject*,FXSelector,void* PTR_EVENT);
130 long onDNDMotion(FXObject*,FXSelector,void* PTR_EVENT);
131 long onDNDDrop(FXObject*,FXSelector,void* PTR_EVENT);
132 long onDNDRequest(FXObject*,FXSelector,void* PTR_EVENT);
133 long onSelectionLost(FXObject*,FXSelector,void* PTR_EVENT);
134 long onSelectionGained(FXObject*,FXSelector,void* PTR_EVENT);
135 long onSelectionRequest(FXObject*,FXSelector,void* PTR_EVENT);
136 long onClipboardLost(FXObject*,FXSelector,void* PTR_EVENT);
137 long onClipboardGained(FXObject*,FXSelector,void* PTR_EVENT);
138 long onClipboardRequest(FXObject*,FXSelector,void* PTR_EVENT);
139 long onKeyPress(FXObject*,FXSelector,void* PTR_EVENT);
140 long onKeyRelease(FXObject*,FXSelector,void* PTR_EVENT);
141 long onBlink(FXObject*,FXSelector,void* PTR_IGNORE);
142 long onFlash(FXObject*,FXSelector,void* PTR_IGNORE);
143 long onAutoScroll(FXObject*,FXSelector,void* PTR_EVENT);
144 long onQueryHelp(FXObject*,FXSelector,void* PTR_IGNORE);
145 long onQueryTip(FXObject*,FXSelector,void* PTR_IGNORE);
146
147 // Control commands
148 long onCmdToggleEditable(FXObject*,FXSelector,void* PTR_IGNORE);
149 long onUpdToggleEditable(FXObject*,FXSelector,void* PTR_IGNORE);
150 long onCmdToggleOverstrike(FXObject*,FXSelector,void* PTR_IGNORE);
151 long onUpdToggleOverstrike(FXObject*,FXSelector,void* PTR_IGNORE);
152 long onCmdCursorRow(FXObject*,FXSelector,void* PTR_IGNORE);
153 long onUpdCursorRow(FXObject*,FXSelector,void* PTR_IGNORE);
154 long onCmdCursorColumn(FXObject*,FXSelector,void* PTR_IGNORE);
155 long onUpdCursorColumn(FXObject*,FXSelector,void* PTR_IGNORE);
156 long onUpdHaveSelection(FXObject*,FXSelector,void* PTR_IGNORE);
157 long onUpdSelectAll(FXObject*,FXSelector,void* PTR_IGNORE);
158 long onCmdSetStringValue(FXObject*,FXSelector,void* PTR_STRING);
159 long onCmdGetStringValue(FXObject*,FXSelector,void* PTR_NULL); // FIXME
160 long onCmdSearch(FXObject*,FXSelector,void* PTR_IGNORE);
161 long onCmdReplace(FXObject*,FXSelector,void* PTR_IGNORE);
162 long onCmdSearchNext(FXObject*,FXSelector,void* PTR_IGNORE);
163 long onCmdSearchSel(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
164
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
165 // Cursor movement
166 long onCmdCursorTop(FXObject*,FXSelector,void* PTR_IGNORE);
167 long onCmdCursorBottom(FXObject*,FXSelector,void* PTR_IGNORE);
168 long onCmdCursorHome(FXObject*,FXSelector,void* PTR_IGNORE);
169 long onCmdCursorEnd(FXObject*,FXSelector,void* PTR_IGNORE);
170 long onCmdCursorRight(FXObject*,FXSelector,void* PTR_IGNORE);
171 long onCmdCursorLeft(FXObject*,FXSelector,void* PTR_IGNORE);
172 long onCmdCursorUp(FXObject*,FXSelector,void* PTR_IGNORE);
173 long onCmdCursorDown(FXObject*,FXSelector,void* PTR_IGNORE);
174 long onCmdCursorWordLeft(FXObject*,FXSelector,void* PTR_IGNORE);
175 long onCmdCursorWordRight(FXObject*,FXSelector,void* PTR_IGNORE);
176 long onCmdCursorWordStart(FXObject*,FXSelector,void* PTR_IGNORE);
177 long onCmdCursorWordEnd(FXObject*,FXSelector,void* PTR_IGNORE);
178 long onCmdCursorPageDown(FXObject*,FXSelector,void* PTR_IGNORE);
179 long onCmdCursorPageUp(FXObject*,FXSelector,void* PTR_IGNORE);
180 long onCmdCursorScreenTop(FXObject*,FXSelector,void* PTR_IGNORE);
181 long onCmdCursorScreenBottom(FXObject*,FXSelector,void* PTR_IGNORE);
182 long onCmdCursorScreenCenter(FXObject*,FXSelector,void* PTR_IGNORE);
183 long onCmdCursorParHome(FXObject*,FXSelector,void* PTR_IGNORE);
184 long onCmdCursorParEnd(FXObject*,FXSelector,void* PTR_IGNORE);
185 long onCmdBlockBeg(FXObject*,FXSelector,void* PTR_IGNORE);
186 long onCmdBlockEnd(FXObject*,FXSelector,void* PTR_IGNORE);
187 long onCmdGotoMatching(FXObject*,FXSelector,void* PTR_IGNORE);
188 long onCmdGotoSelected(FXObject*,FXSelector,void* PTR_IGNORE);
189 long onCmdGotoLine(FXObject*,FXSelector,void* PTR_IGNORE);
190 long onCmdScrollUp(FXObject*,FXSelector,void* PTR_IGNORE);
191 long onCmdScrollDown(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
192
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
193 // Mark and extend
194 long onCmdMark(FXObject*,FXSelector,void* PTR_IGNORE);
195 long onCmdExtend(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
196
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
197 // Inserting
198 long onCmdOverstString(FXObject*,FXSelector,void* PTR_CHAR);
199 long onCmdInsertString(FXObject*,FXSelector,void* PTR_CSTRING);
200 long onCmdInsertNewline(FXObject*,FXSelector,void* PTR_IGNORE);
201 long onCmdInsertTab(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
202
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
203 // Manipulation Selection
204 long onCmdCutSel(FXObject*,FXSelector,void* PTR_IGNORE);
205 long onCmdCopySel(FXObject*,FXSelector,void* PTR_IGNORE);
206 long onCmdPasteSel(FXObject*,FXSelector,void* PTR_IGNORE);
207 long onCmdDeleteSel(FXObject*,FXSelector,void* PTR_IGNORE);
208 long onCmdChangeCase(FXObject*,FXSelector,void* PTR_IGNORE);
209 long onCmdShiftText(FXObject*,FXSelector,void* PTR_IGNORE);
210 long onCmdPasteMiddle(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
211
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
212 // Changing Selection
213 long onCmdSelectChar(FXObject*,FXSelector,void* PTR_IGNORE);
214 long onCmdSelectWord(FXObject*,FXSelector,void* PTR_IGNORE);
215 long onCmdSelectLine(FXObject*,FXSelector,void* PTR_IGNORE);
216 long onCmdSelectAll(FXObject*,FXSelector,void* PTR_IGNORE);
217 long onCmdSelectMatching(FXObject*,FXSelector,void* PTR_IGNORE);
218 long onCmdSelectBlock(FXObject*,FXSelector,void* PTR_IGNORE);
219 long onCmdDeselectAll(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
220
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
221 // Deletion
222 long onCmdBackspace(FXObject*,FXSelector,void* PTR_IGNORE);
223 long onCmdBackspaceWord(FXObject*,FXSelector,void* PTR_IGNORE);
224 long onCmdBackspaceBol(FXObject*,FXSelector,void* PTR_IGNORE);
225 long onCmdDelete(FXObject*,FXSelector,void* PTR_IGNORE);
226 long onCmdDeleteWord(FXObject*,FXSelector,void* PTR_IGNORE);
227 long onCmdDeleteEol(FXObject*,FXSelector,void* PTR_IGNORE);
228 long onCmdDeleteAll(FXObject*,FXSelector,void* PTR_IGNORE);
229 long onCmdDeleteLine(FXObject*,FXSelector,void* PTR_IGNORE);
bea4cad @larskanis Strip all whitespaces on line endings
authored
230
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
231 public:
232 static const FXchar textDelimiters[];
233
234 public:
bea4cad @larskanis Strip all whitespaces on line endings
authored
235
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
236 enum {
237 ID_CURSOR_TOP=FXScrollArea::ID_LAST,
238 ID_CURSOR_BOTTOM,
239 ID_CURSOR_HOME,
240 ID_CURSOR_END,
241 ID_CURSOR_RIGHT,
242 ID_CURSOR_LEFT,
243 ID_CURSOR_UP,
244 ID_CURSOR_DOWN,
245 ID_CURSOR_WORD_LEFT,
246 ID_CURSOR_WORD_RIGHT,
247 ID_CURSOR_WORD_START,
248 ID_CURSOR_WORD_END,
249 ID_CURSOR_PAGEDOWN,
250 ID_CURSOR_PAGEUP,
251 ID_CURSOR_SCRNTOP,
252 ID_CURSOR_SCRNBTM,
253 ID_CURSOR_SCRNCTR,
254 ID_CURSOR_PAR_HOME,
255 ID_CURSOR_PAR_END,
256 ID_SCROLL_UP,
257 ID_SCROLL_DOWN,
258 ID_MARK,
259 ID_EXTEND,
260 ID_OVERST_STRING,
261 ID_INSERT_STRING,
262 ID_INSERT_NEWLINE,
263 ID_INSERT_TAB,
264 ID_CUT_SEL,
265 ID_COPY_SEL,
266 ID_DELETE_SEL,
267 ID_PASTE_SEL,
268 ID_PASTE_MIDDLE,
269 ID_SELECT_CHAR,
270 ID_SELECT_WORD,
271 ID_SELECT_LINE,
272 ID_SELECT_ALL,
273 ID_SELECT_MATCHING,
274 ID_SELECT_BRACE,
275 ID_SELECT_BRACK,
276 ID_SELECT_PAREN,
277 ID_SELECT_ANG,
278 ID_DESELECT_ALL,
279 ID_BACKSPACE,
280 ID_BACKSPACE_WORD,
281 ID_BACKSPACE_BOL,
282 ID_DELETE,
283 ID_DELETE_WORD,
284 ID_DELETE_EOL,
285 ID_DELETE_ALL,
286 ID_DELETE_LINE,
287 ID_TOGGLE_EDITABLE,
288 ID_TOGGLE_OVERSTRIKE,
289 ID_CURSOR_ROW,
290 ID_CURSOR_COLUMN,
291 ID_CLEAN_INDENT,
292 ID_SHIFT_LEFT,
293 ID_SHIFT_RIGHT,
294 ID_SHIFT_TABLEFT,
295 ID_SHIFT_TABRIGHT,
296 ID_UPPER_CASE,
297 ID_LOWER_CASE,
298 ID_GOTO_MATCHING,
299 ID_GOTO_SELECTED,
300 ID_GOTO_LINE,
301 ID_SEARCH_FORW_SEL,
302 ID_SEARCH_BACK_SEL,
303 ID_SEARCH_FORW,
304 ID_SEARCH_BACK,
305 ID_SEARCH,
306 ID_REPLACE,
307 ID_LEFT_BRACE,
308 ID_LEFT_BRACK,
309 ID_LEFT_PAREN,
310 ID_LEFT_ANG,
311 ID_RIGHT_BRACE,
312 ID_RIGHT_BRACK,
313 ID_RIGHT_PAREN,
314 ID_RIGHT_ANG,
315 ID_BLINK,
316 ID_FLASH,
317 ID_LAST
318 };
319 public:
320
321 /// Construct multi-line text widget
322 %extend {
323 FXText(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=0,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=3,FXint pr=3,FXint pt=2,FXint pb=2){
324 return new FXRbText(p,tgt,sel,opts,x,y,w,h,pl,pr,pt,pb);
325 }
326 }
327
328 /// Change top margin
329 void setMarginTop(FXint pt);
330
331 /// Return top margin
332 FXint getMarginTop() const;
333
334 /// Change bottom margin
335 void setMarginBottom(FXint pb);
336
337 /// Return bottom margin
338 FXint getMarginBottom() const;
339
340 /// Change left margin
341 void setMarginLeft(FXint pl);
342
343 /// Return left margin
344 FXint getMarginLeft() const;
345
346 /// Change right margin
347 void setMarginRight(FXint pr);
348
349 /// Return right margin
350 FXint getMarginRight() const;
351
352 /// Return wrap columns
353 FXint getWrapColumns() const;
354
355 /// Set wrap columns
356 void setWrapColumns(FXint cols);
357
358 /// Return tab columns
359 FXint getTabColumns() const;
360
361 /// Change tab columns
362 void setTabColumns(FXint cols);
363
364 /// Return number of columns used for line numbers
365 FXint getBarColumns() const;
366
367 /// Change number of columns used for line numbers
368 void setBarColumns(FXint cols);
369
370 /// Return TRUE if text was modified
371 FXbool isModified() const;
372
373 /// Set modified flag
374 void setModified(FXbool mod=TRUE);
375
376 /// Set editable flag
377 void setEditable(FXbool edit=TRUE);
378
379 /// Return TRUE if text is editable
380 FXbool isEditable() const;
381
382 /// Set overstrike mode
383 void setOverstrike(FXbool over=TRUE);
384
385 /// Return TRUE if overstrike mode in effect
386 FXbool isOverstrike() const;
387
388 /// Set styled text mode
389 void setStyled(FXbool styled=TRUE);
390
391 /// Return TRUE if style buffer
392 FXbool isStyled() const;
393
394 /// Change delimiters of words
395 void setDelimiters(const FXchar* delims=textDelimiters);
bea4cad @larskanis Strip all whitespaces on line endings
authored
396
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
397 /// Return word delimiters
398 const FXchar* getDelimiters() const;
399
400 /// Change text font
401 void setFont(FXFont* fnt);
402
403 /// Return text font
404 FXFont* getFont() const;
405
406 /// Change text color
407 void setTextColor(FXColor clr);
408
409 /// Return text color
410 FXColor getTextColor() const;
411
412 /// Change selected background color
413 void setSelBackColor(FXColor clr);
414
415 /// Return selected background color
416 FXColor getSelBackColor() const;
417
418 /// Change selected text color
419 void setSelTextColor(FXColor clr);
420
421 /// Return selected text color
422 FXColor getSelTextColor() const;
423
424 /// Change highlighted text color
425 void setHiliteTextColor(FXColor clr);
426
427 /// Return highlighted text color
428 FXColor getHiliteTextColor() const;
429
430 /// Change highlighted background color
431 void setHiliteBackColor(FXColor clr);
432
433 /// Return highlighted background color
434 FXColor getHiliteBackColor() const;
435
436 /// Change active background color
437 void setActiveBackColor(FXColor clr);
438
439 /// Return active background color
440 FXColor getActiveBackColor() const;
441
442 /// Change cursor color
443 void setCursorColor(FXColor clr);
444
445 /// Return cursor color
446 FXColor getCursorColor() const;
447
448 /// Change line number color
449 void setNumberColor(FXColor clr);
450
451 /// Return line number color
452 FXColor getNumberColor() const;
453
454 /// Change bar color
455 void setBarColor(FXColor clr);
456
457 /// Return bar color
458 FXColor getBarColor() const;
459
460 /// Set help text
461 void setHelpText(const FXString& text);
462
463 /// Return help text
464 FXString getHelpText() const;
465
466 /// Set the tool tip message for this text field
467 void setTipText(const FXString& text);
468
469 /// Get the tool tip message for this text field
470 FXString getTipText() const;
471
472 /// Get character at position in text buffer
473 FXint getByte(FXint pos) const;
474
475 /// Get wide character at position pos
476 FXwchar getChar(FXint pos) const;
477
478 /// Get length of wide character at position pos
479 FXint getCharLen(FXint pos) const;
480
481 /// Get style at position in style buffer
482 FXint getStyle(FXint pos) const;
483
484 %extend {
485
486 // Extract n bytes of text from position pos
487 VALUE extractText(FXint pos,FXint n) const {
488 VALUE str;
489 FXString buffer;
490 self->extractText(buffer,pos,n);
491 str=rb_str_new(buffer.text(),n);
492 return str;
493 }
494
495 /// Extract n bytes of style info from position pos
496 VALUE extractStyle(FXint pos,FXint n) const {
497 FXString style;
498 VALUE str=Qnil;
499 if(self->isStyled()){
500 self->extractStyle(style,pos,n);
501 str=rb_str_new(style.text(),n);
502 }
503 return str;
504 }
505
506 } // end %extend
507
508 /// Return text in the widget
509 FXString getText() const;
510
511 /// Return length of buffer
512 FXint getLength() const;
513
514 /// Return number of rows in buffer
515 FXint getNumRows() const;
bea4cad @larskanis Strip all whitespaces on line endings
authored
516
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
517 /// Shift block of lines from position start up to end by given amount
518 FXint shiftText(FXint start,FXint end,FXint amount,FXbool notify=FALSE);
519
520 %extend {
521 /**
522 * Search for string in text buffer, returning the extent of
523 * the string in beg and end. The search starts from the given
524 * starting position, scans forward (SEARCH_FORWARD) or backward
525 * (SEARCH_BACKWARD), and wraps around if SEARCH_WRAP has been
526 * specified. The search type is either a plain search (SEARCH_EXACT),
527 * case insensitive search (SEARCH_IGNORECASE), or regular expression
528 * search (SEARCH_REGEX).
529 * For regular expression searches, capturing parentheses are used if
530 * npar is greater than 1; in this case, the number of entries in the
531 * beg[], end[] arrays must be npar also. If either beg or end or
532 * both are NULL, internal arrays are used.
533 * [This API is still subject to change!!]
534 */
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
535 VALUE findText(const FXString& string,FXint start=0,FXuint flags=SEARCH_FORWARD|SEARCH_WRAP|SEARCH_EXACT){
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
536 FXint* beg;
537 FXint* end;
538 VALUE ary=Qnil;
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
539 FXint ngroups=string.contains('(')+1; // FIXME: is this right?
540 if(!FXMALLOC(&beg,FXint,ngroups)){
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
541 return Qnil;
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
542 }
543 if(!FXMALLOC(&end,FXint,ngroups)){
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
544 FXFREE(&beg);
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
545 return Qnil;
546 }
547 if(self->findText(string,beg,end,start,flags,ngroups)){
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
548 ary=rb_ary_new();
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
549 rb_ary_push(ary,FXRbMakeArray(beg,ngroups));
550 rb_ary_push(ary,FXRbMakeArray(end,ngroups));
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
551 }
552 FXFREE(&beg);
553 FXFREE(&end);
554 return ary;
555 }
556 }
557
558 /// Return TRUE if position pos is selected
559 FXbool isPosSelected(FXint pos) const;
560
561 /// Return TRUE if position is fully visible
562 FXbool isPosVisible(FXint pos) const;
563
564 /// Return text position at given visible x,y coordinate
565 FXint getPosAt(FXint x,FXint y) const;
566
567 /// Count number of rows; start should be on a row start
568 FXint countRows(FXint start,FXint end) const;
569
570 /// Count number of columns; start should be on a row start
571 FXint countCols(FXint start,FXint end) const;
572
573 /// Count number of newlines
574 FXint countLines(FXint start,FXint end) const;
575
576 /// Return position of begin of line containing position pos
577 FXint lineStart(FXint pos) const;
578
579 /// Return position of end of line containing position pos
580 FXint lineEnd(FXint pos) const;
581
582 /// Return start of next line
583 FXint nextLine(FXint pos,FXint nl=1) const;
584
585 /// Return start of previous line
586 FXint prevLine(FXint pos,FXint nl=1) const;
587
588 /// Return row start
589 FXint rowStart(FXint pos) const;
590
591 /// Return row end
592 FXint rowEnd(FXint pos) const;
593
594 /// Return start of next row
595 FXint nextRow(FXint pos,FXint nr=1) const;
596
597 /// Return start of previous row
598 FXint prevRow(FXint pos,FXint nr=1) const;
599
600 /// Return end of previous word
601 FXint leftWord(FXint pos) const;
602
603 /// Return begin of next word
604 FXint rightWord(FXint pos) const;
605
606 /// Return begin of word
607 FXint wordStart(FXint pos) const;
608
609 /// Return end of word
610 FXint wordEnd(FXint pos) const;
611
612 /// Return validated utf8 character start position
613 FXint validPos(FXint pos) const;
614
615 /// Retreat to the previous valid utf8 character start
616 FXint dec(FXint pos) const;
bea4cad @larskanis Strip all whitespaces on line endings
authored
617
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
618 /// Advance to the next valid utf8 character start
619 FXint inc(FXint pos) const;
620
621 /// Make line containing pos the top line
622 void setTopLine(FXint pos);
623
624 /// Return position of top line
625 FXint getTopLine() const;
626
627 /// Make line containing pos the bottom line
628 void setBottomLine(FXint pos);
629
630 /// Return the position of the bottom line
631 FXint getBottomLine() const;
632
633 /// Make line containing pos the center line
634 void setCenterLine(FXint pos);
635
636 /// Set the anchor position
637 void setAnchorPos(FXint pos);
638
639 /// Return the anchor position
640 FXint getAnchorPos() const;
641
642 /// Set cursor row
643 void setCursorRow(FXint row,FXbool notify=FALSE);
644
645 /// Return cursor row, i.e. indent position
646 FXint getCursorRow() const;
647
648 /// Set cursor column
649 void setCursorColumn(FXint col,FXbool notify=FALSE);
650
651 /// Return cursor column
652 FXint getCursorColumn() const;
653
654 /// Return the cursor position
655 FXint getCursorPos() const;
656
657 /// Return selstartpos
658 FXint getSelStartPos() const;
659
660 /// Return selendpos
661 FXint getSelEndPos() const;
662
663 /// Select all text
664 FXbool selectAll(FXbool notify=FALSE);
665
666 /// Select len characters starting at given position pos
667 FXbool setSelection(FXint pos,FXint len,FXbool notify=FALSE);
668
669 /// Highlight len characters starting at given position pos
670 FXbool setHighlight(FXint start,FXint len);
671
672 /// Unhighlight the text
673 FXbool killHighlight();
674
675 /// Scroll text to make the given position visible
676 void makePositionVisible(FXint pos);
677
678 /// Change text widget style
679 void setTextStyle(FXuint style);
680
681 /// Return text widget style
682 FXuint getTextStyle() const;
683
684 /// Change number of visible rows
685 void setVisibleRows(FXint rows);
686
687 /// Return number of visible rows
688 FXint getVisibleRows() const;
689
690 /// Change number of visible columns
691 void setVisibleColumns(FXint cols);
692
693 /// Return number of visible columns
694 FXint getVisibleColumns() const;
695
bea4cad @larskanis Strip all whitespaces on line endings
authored
696 /**
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
697 * Change brace and parenthesis match highlighting time, in ms.
698 * A match highlight time of 0 disables brace matching.
699 */
700 void setHiliteMatchTime(FXuint t);
701
702 /**
703 * Return brace and parenthesis match highlighting time, in ms.
704 */
705 FXuint getHiliteMatchTime() const;
706
707 %extend {
708 /// Set highlight styles
709 void setHiliteStyles(VALUE styles){
710 if(self->isMemberOf(FXMETACLASS(FXRbText))){
711 FXRbText *text=dynamic_cast<FXRbText*>(self);
712 FXASSERT(text);
713 Check_Type(styles,T_ARRAY);
714 if(text->numStyles>0){
715 delete [] text->styles;
716 text->numStyles=0;
717 }
b6b1acb @lylejohnson checked in changes from the RB-1.6 branch (through r2945)
lylejohnson authored
718 text->numStyles=RARRAY_LEN(styles);
45cf7d8 @lylejohnson initial checkin of r2610 from trunk
lylejohnson authored
719 if(text->numStyles>0){
720 text->styles=new FXHiliteStyle[text->numStyles];
721 for (long i=0; i<text->numStyles; i++){
722 FXHiliteStyle* ptr;
723 SWIG_ConvertPtr(rb_ary_entry(styles,i),(void **)&ptr,SWIGTYPE_p_FXHiliteStyle,1);
724 text->styles[i]=*ptr;
725 }
726 self->setHiliteStyles(text->styles);
727 }
728 }
729 else{
730 rb_notimplement();
731 }
732 }
733
734 /// Get highlight styles
735 VALUE getHiliteStyles() const {
736 if(self->isMemberOf(FXMETACLASS(FXRbText))){
737 const FXRbText* text=dynamic_cast<const FXRbText*>(self);
738 FXASSERT(text);
739 VALUE ary=rb_ary_new();
740 for(FXint i=0; i<text->numStyles; i++){
741 rb_ary_push(ary,FXRbGetRubyObj(&(text->styles[i]),"FXHiliteStyle *"));
742 }
743 return ary;
744 }
745 else{
746 rb_notimplement();
747 return Qnil; // not reached
748 }
749 }
750 }
751
752 /// Destructor
753 virtual ~FXText();
754 };
755
756
757 DECLARE_FXOBJECT_VIRTUALS(FXText)
758 DECLARE_FXID_VIRTUALS(FXText)
759 DECLARE_FXDRAWABLE_VIRTUALS(FXText)
760 DECLARE_FXWINDOW_VIRTUALS(FXText)
761 DECLARE_FXSCROLLAREA_VIRTUALS(FXText)
762 DECLARE_FXTEXT_VIRTUALS(FXText)
763
Something went wrong with that request. Please try again.