home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tk42r2x.zip / TclTk / lib / tk4.2 / demos / text.tcl < prev    next >
Text File  |  1999-07-27  |  3KB  |  73 lines

  1. # text.tcl --
  2. #
  3. # This demonstration script creates a text widget that describes
  4. # the basic editing functions.
  5. #
  6. # SCCS: @(#) text.tcl 1.5 96/02/16 10:49:07
  7.  
  8. set w .text
  9. catch {destroy $w}
  10. toplevel $w
  11. wm title $w "Text Demonstration - Basic Facilities"
  12. wm iconname $w "text"
  13. positionWindow $w
  14.  
  15. frame $w.buttons
  16. pack $w.buttons -side bottom -fill x -pady 2m
  17. button $w.buttons.dismiss -text Dismiss -command "destroy $w"
  18. button $w.buttons.code -text "See Code" -command "showCode $w"
  19. pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
  20.  
  21. text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" -setgrid 1 \
  22.     -height 30
  23. scrollbar $w.scroll -command "$w.text yview"
  24. pack $w.scroll -side right -fill y
  25. pack $w.text -expand yes -fill both
  26. $w.text insert 0.0 \
  27. {This window is a text widget.  It displays one or more lines of text
  28. and allows you to edit the text.  Here is a summary of the things you
  29. can do to a text widget:
  30.  
  31. 1. Scrolling. Use the scrollbar to adjust the view in the text window.
  32.  
  33. 2. Scanning. Press mouse button 2 in the text window and drag up or down.
  34. This will drag the text at high speed to allow you to scan its contents.
  35.  
  36. 3. Insert text. Press mouse button 1 to set the insertion cursor, then
  37. type text.  What you type will be added to the widget.
  38.  
  39. 4. Select. Press mouse button 1 and drag to select a range of characters.
  40. Once you've released the button, you can adjust the selection by pressing
  41. button 1 with the shift key down.  This will reset the end of the
  42. selection nearest the mouse cursor and you can drag that end of the
  43. selection by dragging the mouse before releasing the mouse button.
  44. You can double-click to select whole words or triple-click to select
  45. whole lines.
  46.  
  47. 5. Delete and replace. To delete text, select the characters you'd like
  48. to delete and type Backspace or Delete.  Alternatively, you can type new
  49. text, in which case it will replace the selected text.
  50.  
  51. 6. Copy the selection. To copy the selection into this window, select
  52. what you want to copy (either here or in another application), then
  53. click button 2 to copy the selection to the point of the mouse cursor.
  54.  
  55. 7. Edit.  Text widgets support the standard Motif editing characters
  56. plus many Emacs editing characters.  Backspace and Control-h erase the
  57. character to the left of the insertion cursor.  Delete and Control-d
  58. erase the character to the right of the insertion cursor.  Meta-backspace
  59. deletes the word to the left of the insertion cursor, and Meta-d deletes
  60. the word to the right of the insertion cursor.  Control-k deletes from
  61. the insertion cursor to the end of the line, or it deletes the newline
  62. character if that is the only thing left on the line.  Control-o opens
  63. a new line by inserting a newline character to the right of the insertion
  64. cursor.  Control-t transposes the two characters on either side of the
  65. insertion cursor.
  66.  
  67. 7. Resize the window.  This widget has been configured with the "setGrid"
  68. option on, so that if you resize the window it will always resize to an
  69. even number of characters high and wide.  Also, if you make the window
  70. narrow you can see that long lines automatically wrap around onto
  71. additional lines so that all the information is always visible.}
  72. $w.text mark set insert 0.0
  73.