Annotation of micropolis/src/tk/library/demos/mkBasic.tcl, revision 1.1.1.1

1.1       root        1: # mkBasic w
                      2: #
                      3: # Create a top-level window that displays a basic text widget.
                      4: #
                      5: # Arguments:
                      6: #    w -       Name to use for new top-level window.
                      7: 
                      8: proc mkBasic {{w .basic}} {
                      9:     catch {destroy $w}
                     10:     toplevel $w
                     11:     dpos $w
                     12:     wm title $w "Text Demonstration - Basic Facilities"
                     13:     wm iconname $w "Text Basics"
                     14:     button $w.ok -text OK -command "destroy $w"
                     15:     text $w.t -relief raised -bd 2 -yscrollcommand "$w.s set" -setgrid true
                     16:     scrollbar $w.s -relief flat -command "$w.t yview"
                     17:     pack append $w $w.ok {bottom fillx} $w.s {right filly} $w.t {expand fill}
                     18:     $w.t insert 0.0 {\
                     19: This window is a text widget.  It displays one or more lines of text
                     20: and allows you to edit the text.  Here is a summary of the things you
                     21: can do to a text widget:
                     22: 
                     23: 1. Scrolling. Use the scrollbar to adjust the view in the text window.
                     24: 
                     25: 2. Scanning. Press mouse button 2 in the text window and drag up or down.
                     26: This will drag the text at high speed to allow you to scan its contents.
                     27: 
                     28: 3. Insert text. Press mouse button 1 to set the insertion cursor, then
                     29: type text.  What you type will be added to the widget.  You can backspace
                     30: over what you've typed using either the backspace key, the delete key,
                     31: or Control+h.
                     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. To delete text, select the characters you'd like to delete
                     42: and type Control+d.
                     43: 
                     44: 6. Copy the selection. To copy the selection either from this window
                     45: or from any other window or application, select what you want, click
                     46: button 1 to set the insertion cursor, then type Control+v to copy the
                     47: selection to the point of the insertion cursor.
                     48: 
                     49: 7. Resize the window.  This widget has been configured with the "setGrid"
                     50: option on, so that if you resize the window it will always resize to an
                     51: even number of characters high and wide.  Also, if you make the window
                     52: narrow you can see that long lines automatically wrap around onto
                     53: additional lines so that all the information is always visible.
                     54: 
                     55: When you're finished with this demonstration, press the "OK" button
                     56: below.}
                     57:     $w.t mark set insert 0.0
                     58:     bind $w <Any-Enter> "focus $w.t"
                     59: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.