Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # texts.pl |
2 | ||
3 | use vars qw/$TOP/; | |
4 | ||
5 | sub texts { | |
6 | ||
7 | # Create a top-level window that displays a basic text widget. | |
8 | ||
9 | my ($demo) = @_; | |
10 | $TOP = $MW->WidgetDemo( | |
11 | -name => $demo, | |
12 | -text => '', | |
13 | -title => 'Text Demonstration - Basic Facilities', | |
14 | -iconname => 'texts', | |
15 | ); | |
16 | ||
17 | my $t = $TOP->Scrolled(qw/Text -relief sunken -borderwidth 2 -setgrid true | |
18 | -height 30 -scrollbars e/); | |
19 | $t->pack(qw/-expand yes -fill both/); | |
20 | ||
21 | $t->insert('0.0', 'This window is a text widget. It displays one or more lines of text | |
22 | and allows you to edit the text. Here is a summary of the things you | |
23 | can do to a text widget: | |
24 | ||
25 | 1. Scrolling. Use the scrollbar to adjust the view in the text window. | |
26 | ||
27 | 2. Scanning. Press mouse button 2 in the text window and drag up or down. | |
28 | This will drag the text at high speed to allow you to scan its contents. | |
29 | ||
30 | 3. Insert text. Press mouse button 1 to set the insertion cursor, then | |
31 | type text. What you type will be added to the widget. | |
32 | ||
33 | 4. Select. Press mouse button 1 and drag to select a range of characters. | |
34 | Once you\'ve released the button, you can adjust the selection by pressing | |
35 | button 1 with the shift key down. This will reset the end of the | |
36 | selection nearest the mouse cursor and you can drag that end of the | |
37 | selection by dragging the mouse before releasing the mouse button. | |
38 | You can double-click to select whole words or triple-click to select | |
39 | whole lines. | |
40 | ||
41 | 5. Delete and replace. To delete text, select the characters you\'d like | |
42 | to delete and type Backspace or Delete. Alternatively, you can type new | |
43 | text, in which case it will replace the selected text. | |
44 | ||
45 | 6. Copy the selection. To copy the selection into this window, select | |
46 | what you want to copy (either here or in another application), then | |
47 | click button 2 to copy the selection to the point of the mouse cursor. | |
48 | ||
49 | 7. Edit. Text widgets support the standard Motif editing characters | |
50 | plus many Emacs editing characters. Backspace and Control-h erase the | |
51 | character to the left of the insertion cursor. Delete and Control-d | |
52 | erase the character to the right of the insertion cursor. Meta-backspace | |
53 | deletes the word to the left of the insertion cursor, and Meta-d deletes | |
54 | the word to the right of the insertion cursor. Control-k deletes from | |
55 | the insertion cursor to the end of the line, or it deletes the newline | |
56 | character if that is the only thing left on the line. Control-o opens | |
57 | a new line by inserting a newline character to the right of the insertion | |
58 | cursor. Control-t transposes the two characters on either side of the | |
59 | insertion cursor. | |
60 | ||
61 | 7. Resize the window. This widget has been configured with the "setGrid" | |
62 | option on, so that if you resize the window it will always resize to an | |
63 | even number of characters high and wide. Also, if you make the window | |
64 | narrow you can see that long lines automatically wrap around onto | |
65 | additional lines so that all the information is always visible.'); | |
66 | ||
67 | $t->mark(qw/set insert 0.0/); | |
68 | ||
69 | } # end texts | |
70 | ||
71 | 1; |