📄 text.tcl
字号:
# text.tcl --## This demonstration script creates a text widget that describes# the basic editing functions.## RCS: @(#) $Id: text.tcl,v 1.2 1998/09/14 18:23:30 stanton Exp $if {![info exists widgetDemo]} { error "This script should be run from the \"widget\" demo."}set w .textcatch {destroy $w}toplevel $wwm title $w "Text Demonstration - Basic Facilities"wm iconname $w "text"positionWindow $wframe $w.buttonspack $w.buttons -side bottom -fill x -pady 2mbutton $w.buttons.dismiss -text Dismiss -command "destroy $w"button $w.buttons.code -text "See Code" -command "showCode $w"pack $w.buttons.dismiss $w.buttons.code -side left -expand 1text $w.text -relief sunken -bd 2 -yscrollcommand "$w.scroll set" -setgrid 1 \ -height 30scrollbar $w.scroll -command "$w.text yview"pack $w.scroll -side right -fill ypack $w.text -expand yes -fill both$w.text insert 0.0 \{This window is a text widget. It displays one or more lines of textand allows you to edit the text. Here is a summary of the things youcan do to a text widget:1. Scrolling. Use the scrollbar to adjust the view in the text window.2. Scanning. Press mouse button 2 in the text window and drag up or down.This will drag the text at high speed to allow you to scan its contents.3. Insert text. Press mouse button 1 to set the insertion cursor, thentype text. What you type will be added to the widget.4. Select. Press mouse button 1 and drag to select a range of characters.Once you've released the button, you can adjust the selection by pressingbutton 1 with the shift key down. This will reset the end of theselection nearest the mouse cursor and you can drag that end of theselection by dragging the mouse before releasing the mouse button.You can double-click to select whole words or triple-click to selectwhole lines.5. Delete and replace. To delete text, select the characters you'd liketo delete and type Backspace or Delete. Alternatively, you can type newtext, in which case it will replace the selected text.6. Copy the selection. To copy the selection into this window, selectwhat you want to copy (either here or in another application), thenclick button 2 to copy the selection to the point of the mouse cursor.7. Edit. Text widgets support the standard Motif editing charactersplus many Emacs editing characters. Backspace and Control-h erase thecharacter to the left of the insertion cursor. Delete and Control-derase the character to the right of the insertion cursor. Meta-backspacedeletes the word to the left of the insertion cursor, and Meta-d deletesthe word to the right of the insertion cursor. Control-k deletes fromthe insertion cursor to the end of the line, or it deletes the newlinecharacter if that is the only thing left on the line. Control-o opensa new line by inserting a newline character to the right of the insertioncursor. Control-t transposes the two characters on either side of theinsertion cursor.7. Resize the window. This widget has been configured with the "setGrid"option on, so that if you resize the window it will always resize to aneven number of characters high and wide. Also, if you make the windownarrow you can see that long lines automatically wrap around ontoadditional lines so that all the information is always visible.}$w.text mark set insert 0.0
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -