$editorToken subcommand ?options? |
$editorToken color colorToken ?range?The range argument is a two-element list containing the start and end positions of the region. If range is not specified, the command applies to the entire text.
$editorToken delete pos1 pos2If one of the specified positions pos1 or pos2 is out of range, an error occurs.
$editorToken exec actionThe action argument is the name of a standard command to perform on the currently selected region. It is the name of a Cocoa method that is defined in the NSTextView class (or inherited from a parent class) and takes a unique nullable argument. The main methods available are given in the following table:
Alignment | alignCenter, alignJustified, alignLeft, alignRight |
Case changes | capitalizeWord, lowercaseWord, uppercaseWord |
Deletions | delete, deleteBackward, deleteForward, deleteToBeginningOfLine, deleteToBeginningOfParagraph, deleteToEndOfLine, deleteToEndOfParagraph, deleteWordBackward, deleteWordForward |
Insertions | insertBacktab, insertContainerBreak, insertLineBreak, insertNewline, insertParagraphSeparator, insertTab, insertTabIgnoringFieldEditor |
Marks | deleteToMark, selectToMark, setMark, swapWithMark |
Miscellaneous | print, showGuessPanel, startSpeaking, stopSpeaking |
Movement | moveBackward, moveDown, moveForward, moveLeft, moveRight, moveToBeginningOfDocument, moveToBeginningOfLine, moveToBeginningOfParagraph, moveToEndOfDocument, moveToEndOfLine, moveToEndOfParagraph, moveToLeftEndOfLine, moveToRightEndOfLine, moveUp, moveWordBackward, moveWordForward, moveWordLeft, moveWordRight, pageDown, pageUp |
Movement and selection | moveBackwardAndModifySelection, moveDownAndModifySelection, moveForwardAndModifySelection, moveLeftAndModifySelection, moveParagraphBackwardAndModifySelection, moveParagraphForwardAndModifySelection, moveRightAndModifySelection, moveToBeginningOfDocumentAndModifySelection, moveToBeginningOfLineAndModifySelection, moveToBeginningOfParagraphAndModifySelection, moveToEndOfDocumentAndModifySelection, moveToEndOfLineAndModifySelection, moveToEndOfParagraphAndModifySelection, moveToLeftEndOfLineAndModifySelection, moveToRightEndOfLineAndModifySelection, moveUpAndModifySelection, moveWordBackwardAndModifySelection, moveWordForwardAndModifySelection, moveWordLeftAndModifySelection, moveWordRightAndModifySelection, pageDownAndModifySelection, pageUpAndModifySelection |
Pasteboard | copy, cut, paste, pasteAsPlainText, pasteAsRichText, yank |
Scrolling | scrollLineDown, scrollLineUp, scrollPageDown, scrollPageUp, scrollToBeginningOfDocument, scrollToEndOfDocument |
Selection | centerSelectionInVisibleArea, selectAll, selectLine, selectParagraph, selectWord |
Style | outline, subscript, superscript, underline, unscript |
$editorToken get pos1 pos2If one of the specified positions pos1 or pos2 is out of range, an error occurs.
$editorToken hyper (proc|URL) ?range?The range argument is a two-element list containing the start and end positions of the region. If range is not specified, the command applies to the entire text.
$editorToken insert ?-pos num? ?--? textThe -pos option specifies the position where the text is to be inserted. If this option is not specified, the text is inserted at the current position. The command clears any existing selection before the text is inserted.
$editorToken maxPos
$editorToken pos ?num?If there is no num argument, the command returns the current position of the insertion cursor. Otherwise it sets the position to num: if num is out of range, it raises an error. To know the length of the text, see the maxPos subcommand.
$editorToken register action callbackThe callback argument is the name of a Tcl proc that will be invoked when the action is executed. Setting the callback argument to an empty string unregisters a previously declared callback for the given action (if there is no such callback, nothing happens). There are two kinds of actions explained in the next sections.
$editorToken register moveRight myProcand the proc myProc should have the following prototype:
proc myProc {token} { # instructions here }If myProc raises an error, then the default implementation of action is executed.
$editorToken register willChangeSelection mySelectionProcand the proc mySelectionProc should have the following prototype:
proc mySelectionProc {token old new} { # instructions here to compute actual selection's start and end return [list $start $end] }
$editorToken search ?options? pattern posIt supports the exact same options as the search command for document windows (with the exception of the -w option, which is not relevant here). For more information, see the [search] page.
$editorToken select start endThe start and end arguments are the starting and ending positions respectively of the region to hilite. If the positions are out of range, an error occurs. The command clears the current selection before installing the new one.
$editorToken selEndIt returns the end position of the hilited selection, or the current insertion position if no text is selected. In the case of a multiple selection, the returned value is the end of the first selected range.
$editorToken style num ?range?The range argument is a two-element list containing the start and end positions of the region. If range is not specified, the command applies to the entire text.
normal | 0 |
italic | 1 |
bold | 2 |
⌘Y
).
set root [view root Document -frame {220 250 440 360}] set edToken [view create TextView -frame {10 10 420 340} -parent $root] view show $rootThe variable $edToken contains the token of the TextView which is also the name of the command associated with this view. All the following instructions use this $edToken command.
$edToken insert "Optimus pretosius rures corrumperet ossifragi, et catelli\ imputat umbraculi. Fragilis zothecas plane neglegenter iocari\ utilitas ossifragi."Move cursor to start of text:
$edToken pos 0Search for the word ossifragi and hilite it:
set res [$edToken search ossifragi 0] $edToken select {*}$resColorize ossifragi in red:
$edToken color [colors::named red] $resConvert the word at current position to uppercase:
$edToken exec uppercaseWordFind all occurrences of ossifragi in a case-insensitive manner:
$edToken search -i 1 -all ossifragi 0Select the entire text and put it in the pasteboard:
$edToken exec selectAll $edToken exec copy