|
Class: TextView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListView
|
+--TextView
|
+--EditTextView
- Package:
- stx:libwidg
- Category:
- Views-Text
- Version:
- rev:
1.546
date: 2024/04/09 12:33:23
- user: stefan
- file: TextView.st directory: libwidg
- module: stx stc-classLibrary: libwidg
a view for readOnly text - this class adds selections to a simple list.
The text is not editable and there is no cursor.
Use TextViews for readonly text, EditTextView for editable text.
Please read the historic notice in the ListView class.
[Instance variables:]
selectionStartLine <Number> the line of the selection start (or nil)
selectionStartCol <Number> the col of the selection start
selectionEndLine <Number> the line of the selection end
selectionEndCol <Number> the col of the selection end
clickStartLine <Number> temporary - remember where select operation started
clickStartCol <Number> temporary
clickLine <Number> temporary
clickCol <Number> temporary
clickCount <Number> temporary
expandingTop <Boolean> temporary - for expandSelection
selectionFgColor <Color> color used to draw selections
selectionBgColor <Color> color used to draw selections
selectStyle <Symbol> how words are selected
directoryForFileDialog <nil|pathName> directory where save dialog should start
contentsWasSaved <Boolean> set to true, whenever saved in a file
externalEncoding <Symbol|nil> external encoding, used when text is saved to
a file. Usually something like
#jis7, #euc, #sjis etc.
(currently only passed down from the
fileBrowser)
dropSource <DropSource> drag operation descriptor or nil (dragging disabled)
dragIsActive <Boolean> true, drag operation is activated
searchAction <Block> an autosearch action; typically set by the browser.
Will be used as default when searchFwd/searchBwd is
pressed. If the searchPattern is changed, no autosearch
action will be executed.
searchBarActionBlock <Block> search action block for embedded search
panel. Used as second chance for searchFwd/bwd
[class variables:]
ST80Selections <Boolean> enables ST80 style doubleclick behavior
(right after opening parenthesis, right before
closing parenthesis, at begin of a line
at begin of text)
[StyleSheet parameters:]
textView.background defaults to viewBackground
textView.ViewFont defaults to textFont
text.st80Selections st80 behavior (click on char after parent or quote)
text.selectionForegroundColor defaults to textBackgroundColor
text.selectionBackgroundColor defaults to textForegroundColor
text.alternativeSelectionForegroundColor pasted text (i.e. paste will not replace)
defaults to selectionForegroundColor
text.alternativeSelectionBackgroundColor pasted text (i.e. paste will not replace)
defaults to selectionBackgroundColor
copyrightCOPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
defaults
-
defaultIcon
-
return the default icon if started as a topView
-
defaultMenuMessage
-
This message is the default yo be sent to the menuHolder to get a menu
-
defaultParenthesisSpecification
-
this is used for parenthesis matching and
to skip over nested structures and comments.
It returns a dictionary with opening, closing parentheses,
ignore characters (inside which those are to be ignored),
and EOL comment characters.
The default returned here is actually the Smalltalk language
parenthesisSpecification
-
defaultSelectionBackgroundColor
-
return the default selection background color
-
defaultSelectionForegroundColor
-
return the default selection foreground color
-
defaultViewBackgroundColor
-
return the default view background
-
lastSearchIgnoredCase
-
-
lastSearchWasMatch
-
-
st80SelectMode
-
-
st80SelectMode: aBoolean
-
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
help specs
-
helpSpec
-
This resource specification was automatically generated
by the UIHelpTool of ST/X.
instance creation
-
on: aModel aspect: aspect change: change menu: menu initialSelection: initial
-
for ST-80 compatibility
-
with: someText
-
interface specs
-
searchDialogSpec
-
This resource specification was automatically generated
by the UIPainter of ST/X.
Usage example(s):
UIPainter new openOnClass:TextView andSelector:#searchDialogSpec
|
startup
-
open
-
start an empty TextView
-
openModalOnModel: aModel
-
start a textView on a model; return the textView
-
openModalWith: aString
-
start a textView with aString as initial contents
Usage example(s):
TextView openModalWith:'some text'
EditTextView openModalWith:'some text'
|
-
openModalWith: aString title: aTitle
-
start a textView with aString as initial contents. Return the textView.
Usage example(s):
TextView openModalWith:'some text' title:'testing'
EditTextView openModalWith:'some text' title:'testing'
|
-
openOn: aFileName
-
start a textView on a file; return the textView
Usage example(s):
TextView openOn:'../../doc/overview.doc'
EditTextView openOn:'../../doc/overview.doc'
|
-
openOnModel: aModel
-
start a textView on a model; return the textView
-
openWith: aStringOrStringCollection
-
start a textView with aStringOrStringCollection as initial contents
Usage example(s):
TextView openWith:'some text'
EditTextView openWith:'some text'
Workspace openWith:'some text'
|
-
openWith: aStringOrStringCollection selected: selectedBoolean
-
start a textView with aStringOrStringCollection as initial (optionally selected) contents.
Return the textView.
Usage example(s):
TextView openWith:'some text' selected:true
EditTextView openWith:'some text' selected:false
|
-
openWith: aStringOrStringCollection title: aTitle
-
start a textView with aStringOrStringCollection as initial contents. Return the textView.
Usage example(s):
TextView openWith:'some text' title:'testing'
EditTextView openWith:'some text' title:'testing'
|
-
setupEmpty
-
create a textview in a topview, with horizontal and
vertical scrollbars - a helper for #startWith: and #startOn:
-
setupForFile: aFileName
-
setup a textView on a file; return the textView
-
setupForModel: aModel
-
setup a textView on a model; return the textView
-
setupWith: aStringOrStringCollection title: aTitle
-
setup a textView with aStringOrStringCollection as initial contents in a topView
Compatibility-ST80
-
displaySelection: aBoolean
-
ST-80 compatibility: ignored here.
-
editText: someText
-
ST-80 compatibility: set the edited text.
-
selectAndScroll
-
ST-80 compatibility: ignored here.
-
selectFrom: startPos to: endPos
-
change the selection given two character positions.
-
selectionStartIndex
-
ST-80 compatibility: return the selections start character position.
-
selectionStopIndex
-
ST-80 compatibility: return the character position of
the character right after the selection.
accessing
-
actionAt: aPoint
-
(comment from inherited method)
if aPoint is over a clickable (anchor-) link, return its action.
Otherwise, return nil.
The action will be something responding to #value;
i.e. a block or Explainer::ActionWithInfo or similar
-
characterPositionOfSelection
-
return the character index of the first character in the selection.
Returns 0 if there is no selection.
-
characterPositionOfSelectionEnd
-
return the character index of the last character in the selection.
Returns 0 if there is no selection.
-
contentsWasSaved
-
return true, if the contents was saved (by a save action),
false if not (or was modified again after the last save).
-
contentsWasSaved: aBoolean
-
-
defaultFileNameForFileDialog
-
return the default fileName to use for the save-dialog
-
defaultFileNameForFileDialog: aBaseName
-
define the default fileName to use for the save-dialog
-
directoryForFileDialog: aDirectory
-
define the default directory to use for the save-dialog
-
externalEncoding
-
return the encoding used when the contents is saved via the 'save / save as' dialog.
This is (currently only) passed down from the fileBrowser,
and required when utf8/japanese/chinese/korean text is edited.
(encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
Notice: this only affects the external representation of the text.
-
externalEncoding: encodingSymOrNil
-
define how the contents should be encoded when saved
via the 'save / save as' dialog.
This is (currently only) passed down from the fileBrowser,
and required when utf8/japanese/chinese/korean text is edited.
(encoding is something like #utf8 #'iso8859-5' #euc, #sjis, #jis7, #gb, #big5 or #ksc).
Notice: this only affects the external representation of the text.
-
parenthesisSpecification
-
return the dictionary which specifies which characters are opening, which are closing
and which are ignored characters w.r.t. parenthesis matching.
See the classes initialize method for a useful value.
-
parenthesisSpecification: aDictionary
-
set the dictionary which specifies which characters are opening, which are closing
and which are ignored characters w.r.t. parenthesis matching.
See the classes initialize method for a useful value.
-
saveAction: something
-
-
searchBarActionBlock
-
if set, that action is invoked for a search operations;
invoked for search/searchnext/searchPrev functions,
passing two args: how and the codeView itself
how is one of #search, #forward, #backward
-
searchBarActionBlock: aBlock
-
if set, that action is invoked for a search operations;
invoked for search/searchnext/searchPrev functions,
passing two args: how and the codeView itself
how is one of #search, #forward, #backward
-
textView
-
added to allow sending textView in any context where either
a TextView or a CodeView2 can be encountered.
Sigh - all of this because CodeView2 wraps a textView, and does not forward
all messages.
Thus, the codeView2 framework always sends codeView2 textView doSomething
accessing-contents
-
contents: newContents selected: selectedBoolean
-
|w|
w := Workspace new open.
w contents:'Hello world' selected:true.
-
fromFile: aFileName
-
take contents from a named file
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
list: aCollection expandTabs: expand scanForNonStrings: scan includesNonStrings: nonStringsIfNoScan redraw: doRedraw
-
set the displayed contents (a collection of strings) with redraw.
Redefined since changing the contents implies deselect
-
loadTextFile: aFileName
-
take contents from a named file
-
setContents: something
-
set the contents (either a string or a collection of strings).
Does not change the position (i.e. does not scroll)
and (tries to) keep the selection.
-
setList: something
-
set the displayed contents (a collection of strings)
without redraw.
Redefined since changing contents implies deselect
-
setupForFile: aFileName
-
take contents from a named file
-
text
-
for ST80 compatibility
-
wordAtLine: selectLine col: selectCol do: aFiveArgBlock
-
find word boundaries, evaluate the block argument with those.
A helper for nextWord and selectWord functions.
accessing-look
-
selectionBackgroundColor
-
return the selection-background color.
-
selectionBackgroundColor: aColor
-
set the selection-background color.
The default is defined by the styleSheet;
typically black-on-green for color displays and white-on-black for b&w displays.
-
selectionForegroundColor
-
return the selection-foreground color.
-
selectionForegroundColor: aColor
-
set the selection-foreground color.
The default is defined by the styleSheet;
typically black-on-green for color displays and white-on-black for b&w displays.
-
selectionForegroundColor: color1 backgroundColor: color2
-
set both the selection-foreground and cursor background colors.
The default is defined by the styleSheet;
typically black-on-green for color displays and white-on-black for b&w displays.
accessing-mvc
-
on: aModel aspect: aspectSym list: listSym change: changeSym menu: menuSym initialSelection: initial
-
set all of model, aspect, listMessage, changeSymbol, menuSymbol
and selection. Added for ST-80 compatibility
drag & drop
-
allowDrag: aBoolean
-
enable/disable dragging support
-
canDrag
-
returns true if dragging is enabled
-
collectionOfDragObjects
-
returns collection of dragable objects assigned to selection
Here, by default, a collection of text-dragObjects is generated;
however, if a dragObjectConverter is defined, that one gets a chance
to convert as appropriate.
-
dropSource
-
returns the dropSource or nil
-
dropSource: aDropSourceOrNil
-
set the dropSource or nil
encoding
-
validateFontEncodingFor: newEncoding ask: ask
-
if required, query user if he/she wants to change to another font,
which is able to display text encoded as specified by newEncoding
event handling
-
buttonMotion: buttonState x: x y: y
-
mouse-move while button was pressed - handle selection changes
-
buttonMultiPress: button x: x y: y
-
multi-mouse-click - select word under pointer
-
buttonPress: button x: x y: y
-
mouse-click - prepare for selection change
-
buttonRelease: button x: x y: y
-
mouse- button release - turn off autoScroll if any
-
doubleClickX: x y: y
-
double-click - select word under pointer
-
extendSelectionToX: x y: y
-
mouse-move while button was pressed - handle selection changes
-
extendSelectionToX: x y: y setPrimarySelection: aBoolean
-
mouse-move while button was pressed or shift-clicked
- handle selection changes
-
keyPress: key x: x y: y
-
handle some keyboard input (there is not much to be done here)
Usage example(s):
shift-Fn defines a key-sequence
Fn pastes that sequence
cmd-Fn performs a 'doIt' on the sequence (Workspaces only)
(see EditTextView>>keyPress:x:y and Workspace>>keyPress:x:y)
|
-
lineAndColumnOfPoint: aPoint
-
given a point in the view (i.e. visible coordinates),
return a {line , col} pair of the correspondidng character position
-
lineAndColumnOfX: x y: y
-
given a point in the view (i.e. visible coordinates),
return a {line , col} pair of the correspondidng character position
-
mapped
-
-
quadClickX: x y: y
-
quadrupleClick-click - select all
-
tripleClickX: x y: y
-
triple-click - select line under pointer
initialization & release
-
fetchDeviceResources
-
fetch device colors, to avoid reallocation at redraw time
-
initStyle
-
setup viewStyle specifics
-
initialize
-
I handle menus myself
-
initializeSaveAction
-
menu & menu actions
-
appendTo: aFileName
-
append contents to a file named fileName
-
canOpenFileBrowserOnIt
-
-
canOpenWebBrowserOnIt
-
-
changeFont
-
pop up a fontPanel to change font
-
compareAgainst: otherText named: whatIsIt
-
common code for compate with file and compare with clipboard
-
compareWithClipboard
-
compare the selection against the clipboard contents
-
compareWithFile
-
compare the selection or the whole text against the contents of a file
-
copySelection
-
copy contents into smalltalk copybuffer
-
copySelectionBox
-
copy contents into the smalltalk copybuffer.
This copies it as a rectangular text area (INed/MAXed-like)
-
defaultForGotoLine
-
return a default value to show in the gotoLine box
-
defaultForGotoPosition
-
return a default value to show in the gotoPosition box
-
doPrint
-
print the contents on the printer
-
editMenu
-
return my popUpMenu
-
find
-
same as search - for VW compatibility
-
gotoLine
-
show a box to enter lineNumber for positioning;
The entered number may be prefixed by a + or -;
in this case, the linenumber is taken relative to the current position.
-
gotoPosition
-
show a box to enter a position for positioning;
The entered number may be prefixed by a + or -;
in this case, the positin is taken relative to the current position.
-
inspectBase64Decoded
-
decode base64 and inspect
-
openDefectInExpeccoALMOnIt
-
open a webBrowser and navigate to the selected defect in expeccoALM;
selection must be of the form: Dxxxxxx
-
openFileBrowserOnFileNamed: fileNameString
-
open a fileBrowser on the given fileNameString
-
openFileBrowserOnIt
-
open a fileBrowser on the selected fileName
-
openSaveDialog
-
Ask user for filename using a fileSelectionBox
and save contents into that file.
-
openSearchBoxAndSearch
-
search for a string - show a box to enter searchpattern.
TODO: this started as an ad-hoc box, which is manually constructed.
Over time, it got more and more functions, so a separate appModel class
would now be appropriate...
-
openSearchBoxAndSearchWithReplaceChecked: replaceChecked
-
search for a string - show a box to enter searchpattern and replace options.
If replaceChecked is true, the 'replace' checkbox and 'replace to end' are
initially checked, and the focus is on the replace field.
TODO: this started as an ad-hoc box, which is manually constructed.
Over time, it got more and more functions, so a separate appModel class
would now be appropriate...
-
openWebBrowserOnIt
-
open a webBrowser on the selected url
-
openWorkspaceWithIt
-
open a workspace containing the selected text
-
replace: someText
-
replace the selection by someText. I am readonly, so this is a no-op here.
Subclasses may redefine me.
-
save
-
save contents into a file
- ask user for filename using a fileSelectionBox.
-
saveAs: fileName
-
save the contents into a file named fileName.
On error return false otherwise return true
-
saveAs: aFilename doAppend: doAppend
-
save the contents into a file named fileName;
if doAppend is true, the view's contents is appended to the existing
contents - otherwise, it overwrites any previous file contents.
On error or cancel return false otherwise return true
-
saveAs: aFilename doAppend: doAppend compressTabs: compressTabs
-
save the contents into a file named fileName;
if doAppend is true, the view's contents is appended to the existing
contents - otherwise, it overwrites any previous file contents.
On error return false otherwise return true
-
saveAs: aFilename doAppend: doAppend compressTabs: compressTabs eolMode: eolMode
-
save the contents into a file named fileName;
if doAppend is true, the view's contents is appended to the existing
contents - otherwise, it overwrites any previous file contents.
eolMode is one of #cr, #nl or #crlf.
On error return false otherwise return true.
-
saveWebPageAs
-
save the document addressed by the selection, which should be a valid URL
-
search
-
search for a string - show a box to enter searchpattern
- currently no regular expressions are handled.
-
search: patternArg ignoreCase: ign forward: fwd
-
search for a string without matching
-
search: patternArg ignoreCase: ign match: match forward: fwd
-
LastSearchIgnoredCase := lastSearchIgnoredCase := ign.
-
searchUsingSpec: aSearchSpec
-
LastSearchIgnoredCase := lastSearchIgnoredCase := ign.
-
searchVariableVisible
-
search variable option in searchbox visible?
(only true for codeview2's textview)
-
searchVariableWithSyntaxElement: syntaxElementForVariable forward: fwd
-
this only works for CodeView2::TextView, which supports syntaxElements.
Finds the next occurrence of a syntax element (typically, a variable)
-
syntaxElementForSelectedVariable
-
for a better search; ignored here, but redefined in CodeView2
-
syntaxElementForVariableUnderCursor
-
for a better search; ignored here, but redefined in CodeView2
native widget support
-
nativeWindowType
-
return a symbol describing my native window type
(may be used internally by the device as a native window creation hint,
if the device supports native windows)
private
-
currentSelectionBgColor
-
-
currentSelectionFgColor
-
-
fileOutContentsOn: aStream
-
save contents on a stream, replacing leading spaces by tab-characters.
-
fileOutContentsOn: aStream compressTabs: compressTabs
-
save contents on a stream. If compressTabs is true,
leading spaces will be replaced by tab-characters in the output.
-
fileOutContentsOn: aStream compressTabs: compressTabs encoding: encodingSymOrNil
-
save contents on a stream. If compressTabs is true,
leading spaces will be replaced by tab-characters in the output.
-
getFontParameters
-
get some info of the used font. They are cached since we use them often ..
This is redefined here, to use the font's maxHeight/maxAscent for
line separation. This is required, to allow for proper handling of
national characters, such as A-diaresis ...
-
highlightLineSpacing
-
true if the spacing between lines is to be drawn with selected color,
false if it remains white.
false for selection in list views; true for edit/text views
-
isBeginOfIgnoredBlock: ch
-
answer true, if the charcter is the start of a comment or string constant,
as specified in the current parenthesisSpecification.
Used to skip paranetheses inside comments, strings etc.
-
isClosingParenthesis: ch
-
return true if the given character is an closing parenthesis character,
as specified in the current parenthesisSpecification
-
isOpeningParenthesis: ch
-
return true if the given character is an opening parenthesis character,
as specified in the current parenthesisSpecification
-
rememberSearchPattern: pattern
-
move to top or addFirst
-
removeTrailingWhitespace
-
-
resetVariablesBeforeNewSearch
-
clear the autosearch action, when the first pattern is searched for
-
scrollSelectDown
-
auto scroll downwards while selecting
(i.e. when the mouse is down, and moved out of the window to the bottom)
scroll and reinstall timed-block.
Adjust the selectionStartLine
-
scrollSelectLeft
-
auto scroll to the left while selecting
(i.e. when the mouse is down, and moved out of the window to the left)
scroll and reinstall timed-block.
Adjust the selectionStartColumn.
-
scrollSelectRight
-
auto scroll to the right while selecting
(i.e. when the mouse is down, and moved out of the window to the right)
scroll and reinstall timed-block.
Adjust the selectionEndColumn.
-
scrollSelectUp
-
auto scroll upwards while selecting
(i.e. when the mouse is down, and moved out of the window to the top)
scroll and reinstall timed-block.
Adjust the selectionStartLine
-
stopScrollSelect
-
stop auto scroll; deinstall timed-block
-
textChanged
-
(comment from inherited method)
ignored here
-
widthForScrollBetween: firstLine and: lastLine
-
return the width in pixels for a scroll between firstLine and lastLine
queries
-
hasSearchActionSelection
-
Here we fake the use of typeOfSelection which is really in EditTextView
-
specClass
-
returns my spec class (for UI editor)
Usage example(s):
redefined, since the name of my specClass is nonStandard (i.e. not TextViewSpec)
|
redrawing
-
clearMarginOfVisibleLine: visLine with: color
-
if there is a margin, clear it - a helper for selection drawing
-
drawSelectedFromVisibleLine: startVisLineNr to: endVisLineNr
-
-
drawVisibleLineSelected: visLineNr
-
-
drawVisibleLineSelected: visLineNr col: col
-
-
drawVisibleLineSelected: visLineNr from: selectionStartCol
-
-
drawVisibleLineSelected: visLineNr from: startCol to: endCol
-
-
redrawFromVisibleLine: startVisLineNr to: endVisLineNr
-
redraw a visible line range
-
redrawVisibleLine: visLineNr
-
redraw visible line lineNr
-
redrawVisibleLine: visLine col: col
-
redraw single character at col in visible line lineNr.
-
redrawVisibleLine: visLine from: startCol
-
redraw visible line lineNr from startCol to end of line
-
redrawVisibleLine: visLine from: startCol to: endCol
-
redraw visible line lineNr from startCol to endCol
searching
-
clearSearchAction
-
-
scanFor: aCharacter fromLine: startLine col: startCol forward: forward ifFound: foundBlock ifNotFound: notFoundBlock
-
search for a character in the direction given by forward.
Performs foundBlock with line/col as argument if found, notFoundBlock if not.
-
searchAction
-
-
searchAction: aSearcherOrSearchBlock
-
-
searchAgainInSameDirection
-
search again in the same direction and -if found- position cursor
-
searchBwd
-
search backward (for the same thing again)
If found, position cursor
-
searchBwd: pattern
-
do a backward search
-
searchBwd: pattern ifAbsent: aBlock
-
do a backward search
-
searchBwd: pattern ignoreCase: ign
-
do a backward search
-
searchBwd: pattern ignoreCase: ign ifAbsent: aBlock
-
do a backward search
-
searchBwd: pattern ignoreCase: ign match: match
-
do a backward search.
match pattern functionality is not yet available for backward search
-
searchBwdUsingSpec: searchSpec
-
do a backward search
-
searchBwdUsingSpec: searchSpec ifAbsent: aBlock
-
do a backward search
-
searchForAndSelectMatchingParenthesisFromLine: startLine col: startCol
-
select characters enclosed by matching parenthesis if one is under startLine/Col
-
searchForMatchingParenthesisFromLine: startLine col: startCol ifFound: foundBlock ifNotFound: notFoundBlock onError: failBlock
-
search for a matching parenthesis; start search with character at startLine/startCol.
Search for the corresponding character is done forward if it's an opening,
backwards if it's a closing parenthesis.
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
If there is a nesting error, evaluate failBlock.
-
searchForMatchingParenthesisFromLine: startLine col: startCol ifFound: foundBlock ifNotFound: notFoundBlock onError: failBlock ignoring: ignoreSet
-
search for a matching parenthesis; start search with character at startLine/startCol.
Search for the corresponding character is done forward if it's an opening,
backwards if it's a closing parenthesis.
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
If there is a nesting error, evaluate failBlock.
-
searchForMatchingParenthesisFromLine: startLine col: startCol ifFound: foundBlock ifNotFound: notFoundBlock onError: failBlock openingCharacters: openingCharacters closingCharacters: closingCharacters ignoredCharacters: ignoreSet specialEOLComment: eolCommentSequence
-
search for a matching parenthesis;
start the search with the character at startLine/startCol.
Search for the corresponding character is done forward if it's an opening,
backwards if it's a closing parenthesis.
Evaluate foundBlock with line/col as argument if found, notFoundBlock if not.
If there is a nesting error, evaluate failBlock.
-
searchFwd
-
search forward for the same pattern or selection again
-
searchFwd: pattern
-
do a forward search
-
searchFwd: pattern ifAbsent: aBlock
-
do a forward search
-
searchFwd: pattern ignoreCase: ign
-
do a forward search
-
searchFwd: pattern ignoreCase: ign ifAbsent: aBlock
-
do a forward search
-
searchFwd: pattern ignoreCase: ign match: match
-
do a forward search
-
searchFwd: pattern ignoreCase: ign match: match ifAbsent: aBlock
-
do a forward search
-
searchFwd: pattern ignoreCase: ign match: match startingAtLine: startLine col: startCol ifAbsent: aBlock
-
do a forward search
-
searchFwdUsingSpec: searchSpec
-
do a forward search
-
searchFwdUsingSpec: searchSpec ifAbsent: aBlock
-
do a forward search
-
searchFwdUsingSpec: searchSpec startingAtLine: startLine col: startCol ifAbsent: aBlock
-
do a forward search
-
searchPattern
-
return the last search pattern
-
searchUsingSearchAction: direction
-
search using a searchaction which has been given by someone else.
Typically, this is the embedding browser, which has provided an action for
a language aware search (as opposed to a naive string search)
-
searchUsingSearchAction: direction ifAbsent: notFoundAction
-
search using a searchaction which has been given by someone else.
Typically, this is the embedding browser, which has provided an action for
a language aware search (as opposed to a naive string search)
-
setSearchPattern
-
set the searchpattern from the selection if there is one
-
setSearchPattern: aStringOrNil
-
set the searchpattern for future searches
-
setSearchPattern: aString ignoreCase: aBoolean
-
set the searchpattern and caseIgnore for future searches
-
setSearchPattern: aString ignoreCase: ignoreCaseBoolean match: matchBoolean
-
set the searchpattern and caseIgnore for future searches
-
setSearchPatternWithMatchEscapes: match
-
set the searchpattern from the selection if there is one
-
showMatch: pattern atLine: line col: col
-
after a search, highlight the matched pattern.
The code below needs a rewrite to take care of match-characters
(for now, it only highlights simple patterns and '*string*' correctly)
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
showMatch: pattern isMatch: isMatch atLine: line col: col
-
after a search, highlight the matched pattern.
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
showMatch: pattern isMatch: isMatch atLine: line col: col endCol: encColOrNil
-
after a search, highlight the matched pattern.
The code below needs a rewrite to take care of match-characters
(for now, it only highlights simple patterns and '*string*' correctly)
-
startPositionForSearchBackward
-
-
startPositionForSearchBackwardBasedOnSelection
-
-
startPositionForSearchForward
-
-
startPositionForSearchForwardBasedOnSelection
-
selections
-
changeTypeOfSelectionTo: newType
-
ignored here - but redefined in subclasses which
differentiate between pasted- and user-selections
-
expandSelectionDown
-
self redrawLine:l.
-
expandSelectionLeft
-
-
expandSelectionRight
-
-
expandSelectionUp
-
self redrawLine:l.
-
hasSelection
-
return true, if there is a text selection
-
hasSelectionForCopy
-
return true, if there is a selection which can be copied
(the same as #hasSelection, except for editfields in password-mode)
-
hasSelectionWithinSingleLine
-
return true, if there is a selection and it is within a line
-
hasSingleFullLineSelected
-
-
isInSelection: line col: aColNr
-
returns true, if the line, and column is in the selection
-
makeSelectionVisible
-
scroll to make the selection visible
-
selectAll
-
select the whole text
-
selectFromCharacterPosition: pos1
-
compute line/col from the character position and select the text up to the end
-
selectFromCharacterPosition: pos1 to: pos2
-
compute line/col from character positions and select the text
-
selectFromLine: startLine col: startCol toLine: endLine col: endCol
-
select a piece of text and redraw that area
Usage example(s):
|v|
v := TextView extent:300@300.
v contents:('smalltalk.rc' asFilename contentsOfEntireFile).
v openAndWaitUntilVisible.
Delay waitForSeconds:1.
v selectFromLine:2 col:2 toLine:10 col:15
|
-
selectFromLine: startLine toLine: endLine
-
select a piece of text and redraw that area
Usage example(s):
|v|
v := TextView extent:300@300.
v contents:('smalltalk.rc' asFilename contentsOfEntireFile).
v openAndWaitUntilVisible.
Delay waitForSeconds:1.
v selectFromLine:2 toLine:10
|
-
selectLine: selectLine
-
select one line and redraw it
-
selectLineAtY: y
-
select the line at given y-(view-)coordinate
-
selectLineWhereCharacterPosition: pos
-
select the line, where characterPosition pos is living.
The argument pos starts at 1 from the start of the text
and counts characters (i.e. can be used to convert from
character position within a string to line-position in view).
-
selectMatchingParenthesisFromX: x y: y
-
undo scroll operation ...
-
selectWordAtLine: line col: col
-
select the word at given line/col
-
selectWordAtX: x y: y
-
select the word at given x/y-(view-)coordinate
-
selectedInterval
-
return the selection-boundaries as interval
-
selection
-
return the selection as a collection of (line-)strings.
If the selection ends in a full line, the last entry in the returned
collection will be an empty string.
-
selectionAsString
-
return the selection as a String (i.e. without emphasis)
-
selectionChanged
-
can be redefined for notification or special actions.
If you do, do not forget to do a super selectionChanged
-
selectionEndCol
-
the last columnNr of the selection (or nil)
-
selectionEndLine
-
the last lineNr of the selection (or nil)
-
selectionStartCol
-
the first columnNr of the selection (or nil)
-
selectionStartLine
-
the first lineNr of the selection (or nil)
-
setPrimarySelection
-
can be redefined for notification or special actions
-
st80SelectMode
-
st80 selectmode behaves slightly different
-
st80SelectMode: aBoolean
-
st80 selectmode behaves slightly different
-
unselect
-
unselect - if there was a selection redraw that area
-
unselectWithoutRedraw
-
forget selection but do not redraw the selection area
- can be done when the selected area is redrawn anyway or
known to be invisible (however, redraw knows about that anyway).
-
validateNewSelection
-
make certain that the selection is valid.
This is a dummy here, but subclasses (like single-line editFields)
may redefine it to limit the selection to a single line, or whatever.
-
withSelectionForeground: hilightFg background: hilightBg do: aBlock
-
evaluate aBlock while the selection is shown highlighted with colors passed as args.
testing
-
isTextView
-
I am showing text
ParenthesesMatcher
although textViews (and instances of subclasses) are mostly used
as components (in the fileBrowser, the browser, the launcher etc.),
they may also be opened as a textEditor. Notice, that usually,
instances of one of my subclasses (EditTextView, TextCollector, Workspace)
are actually used.
open a (readonly) textView on some information text:
TextView
openWith:'read this
and that,
and also this'
title:'demonstration'
|
the same, but open it modal:
TextView
openModalWith:'read this first'
title:'demonstration'
|
open it modal (but editable) on some text:
(must accept before closing)
This is somewhat kludgy - when closed, the view has already
nilled its link to the model. Therefore, the accept must be
done 'manually' below.
However, usually an applicationModel is installed as the
editor-topViews application. This would get a closeRequest,
where it could handle things.
|m textView|
m := 'read this first' asValue.
textView := EditTextView openModalOnModel:m.
textView modified ifTrue:[
(self confirm:'text was not accepted - do it now ?')
ifTrue:[
m value:textView contents
]
].
Transcript showCR:m value.
|
open a textEditor on some file:
EditTextView openOn:'Makefile'
|
configuring the TextView to NOT expand tabs and scan for special lines
(to avoid reading all lines, when usig a virtualArray)
|a m|
a := VirtualArray new
setSize:100000000;
generator:[:lNr | Transcript show:'called for '; showCR:lNr.
'this is line: ',lNr printString ].
m := a asValue.
(ScrollableView forView:TextView new)
expandTabsWhenUpdating:false;
checkLineEndConventionWhenUpdating:false;
model:m;
open; inspect.
|
|