eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'TextView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: TextView


Inheritance:

   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

Description:


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

copyright

COPYRIGHT (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.

Class protocol:

defaults
o  defaultIcon
return the default icon if started as a topView

o  defaultMenuMessage
This message is the default yo be sent to the menuHolder to get a menu

o  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

o  defaultSelectionBackgroundColor
return the default selection background color

o  defaultSelectionForegroundColor
return the default selection foreground color

o  defaultViewBackgroundColor
return the default view background

o  lastSearchIgnoredCase

o  lastSearchWasMatch

o  st80SelectMode

o  st80SelectMode: aBoolean

o  updateStyleCache
extract values from the styleSheet and cache them in class variables

help specs
o  helpSpec
This resource specification was automatically generated
by the UIHelpTool of ST/X.

instance creation
o  on: aModel aspect: aspect change: change menu: menu initialSelection: initial
for ST-80 compatibility

o  with: someText

interface specs
o  searchDialogSpec
This resource specification was automatically generated
by the UIPainter of ST/X.

Usage example(s):

     UIPainter new openOnClass:TextView andSelector:#searchDialogSpec

startup
o  open
start an empty TextView

o  openModalOnModel: aModel
start a textView on a model; return the textView

o  openModalWith: aString
start a textView with aString as initial contents

Usage example(s):

     TextView openModalWith:'some text'
     EditTextView openModalWith:'some text'

o  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'

o  openOn: aFileName
start a textView on a file; return the textView

Usage example(s):

     TextView openOn:'../../doc/overview.doc'
     EditTextView openOn:'../../doc/overview.doc'

o  openOnModel: aModel
start a textView on a model; return the textView

o  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'

o  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

o  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'

o  setupEmpty
create a textview in a topview, with horizontal and
vertical scrollbars - a helper for #startWith: and #startOn:

o  setupForFile: aFileName
setup a textView on a file; return the textView

o  setupForModel: aModel
setup a textView on a model; return the textView

o  setupWith: aStringOrStringCollection title: aTitle
setup a textView with aStringOrStringCollection as initial contents in a topView


Instance protocol:

Compatibility-ST80
o  displaySelection: aBoolean
ST-80 compatibility: ignored here.

o  editText: someText
ST-80 compatibility: set the edited text.

o  selectAndScroll
ST-80 compatibility: ignored here.

o  selectFrom: startPos to: endPos
change the selection given two character positions.

o  selectionStartIndex
ST-80 compatibility: return the selections start character position.

o  selectionStopIndex
ST-80 compatibility: return the character position of
the character right after the selection.

accessing
o  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

o  characterPositionOfSelection
return the character index of the first character in the selection.
Returns 0 if there is no selection.

o  characterPositionOfSelectionEnd
return the character index of the last character in the selection.
Returns 0 if there is no selection.

o  contentsWasSaved
return true, if the contents was saved (by a save action),
false if not (or was modified again after the last save).

o  contentsWasSaved: aBoolean

o  defaultFileNameForFileDialog
return the default fileName to use for the save-dialog

o  defaultFileNameForFileDialog: aBaseName
define the default fileName to use for the save-dialog

o  directoryForFileDialog: aDirectory
define the default directory to use for the save-dialog

o  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.

o  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.

o  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.

o  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.

o  saveAction: something

o  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

o  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

o  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
o  contents: newContents selected: selectedBoolean
|w|

w := Workspace new open.
w contents:'Hello world' selected:true.

o  fromFile: aFileName
take contents from a named file

** This is an obsolete interface - do not use it (it may vanish in future versions) **

o  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

o  loadTextFile: aFileName
take contents from a named file

o  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.

o  setList: something
set the displayed contents (a collection of strings)
without redraw.
Redefined since changing contents implies deselect

o  setupForFile: aFileName
take contents from a named file

o  text
for ST80 compatibility

o  wordAtLine: selectLine col: selectCol do: aFiveArgBlock
find word boundaries, evaluate the block argument with those.
A helper for nextWord and selectWord functions.

accessing-look
o  selectionBackgroundColor
return the selection-background color.

o  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.

o  selectionForegroundColor
return the selection-foreground color.

o  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.

o  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
o  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
o  allowDrag: aBoolean
enable/disable dragging support

o  canDrag
returns true if dragging is enabled

o  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.

o  dropSource
returns the dropSource or nil

o  dropSource: aDropSourceOrNil
set the dropSource or nil

encoding
o  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
o  buttonMotion: buttonState x: x y: y
mouse-move while button was pressed - handle selection changes

o  buttonMultiPress: button x: x y: y
multi-mouse-click - select word under pointer

o  buttonPress: button x: x y: y
mouse-click - prepare for selection change

o  buttonRelease: button x: x y: y
mouse- button release - turn off autoScroll if any

o  doubleClickX: x y: y
double-click - select word under pointer

o  extendSelectionToX: x y: y
mouse-move while button was pressed - handle selection changes

o  extendSelectionToX: x y: y setPrimarySelection: aBoolean
mouse-move while button was pressed or shift-clicked
- handle selection changes

o  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)

o  lineAndColumnOfPoint: aPoint
given a point in the view (i.e. visible coordinates),
return a {line , col} pair of the correspondidng character position

o  lineAndColumnOfX: x y: y
given a point in the view (i.e. visible coordinates),
return a {line , col} pair of the correspondidng character position

o  mapped

o  quadClickX: x y: y
quadrupleClick-click - select all

o  tripleClickX: x y: y
triple-click - select line under pointer

initialization & release
o  fetchDeviceResources
fetch device colors, to avoid reallocation at redraw time

o  initStyle
setup viewStyle specifics

o  initialize
I handle menus myself

o  initializeSaveAction

menu & menu actions
o  appendTo: aFileName
append contents to a file named fileName

o  canOpenFileBrowserOnIt

o  canOpenWebBrowserOnIt

o  changeFont
pop up a fontPanel to change font

o  compareAgainst: otherText named: whatIsIt
common code for compate with file and compare with clipboard

o  compareWithClipboard
compare the selection against the clipboard contents

o  compareWithFile
compare the selection or the whole text against the contents of a file

o  copySelection
copy contents into smalltalk copybuffer

o  copySelectionBox
copy contents into the smalltalk copybuffer.
This copies it as a rectangular text area (INed/MAXed-like)

o  defaultForGotoLine
return a default value to show in the gotoLine box

o  defaultForGotoPosition
return a default value to show in the gotoPosition box

o  doPrint
print the contents on the printer

o  editMenu
return my popUpMenu

o  find
same as search - for VW compatibility

o  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.

o  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.

o  inspectBase64Decoded
decode base64 and inspect

o  openDefectInExpeccoALMOnIt
open a webBrowser and navigate to the selected defect in expeccoALM;
selection must be of the form: Dxxxxxx

o  openFileBrowserOnFileNamed: fileNameString
open a fileBrowser on the given fileNameString

o  openFileBrowserOnIt
open a fileBrowser on the selected fileName

o  openSaveDialog
Ask user for filename using a fileSelectionBox
and save contents into that file.

o  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...

o  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...

o  openWebBrowserOnIt
open a webBrowser on the selected url

o  openWorkspaceWithIt
open a workspace containing the selected text

o  replace: someText
replace the selection by someText. I am readonly, so this is a no-op here.
Subclasses may redefine me.

o  save
save contents into a file
- ask user for filename using a fileSelectionBox.

o  saveAs: fileName
save the contents into a file named fileName.
On error return false otherwise return true

o  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

o  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

o  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.

o  saveWebPageAs
save the document addressed by the selection, which should be a valid URL

o  search
search for a string - show a box to enter searchpattern
- currently no regular expressions are handled.

o  search: patternArg ignoreCase: ign forward: fwd
search for a string without matching

o  search: patternArg ignoreCase: ign match: match forward: fwd
LastSearchIgnoredCase := lastSearchIgnoredCase := ign.

o  searchUsingSpec: aSearchSpec
LastSearchIgnoredCase := lastSearchIgnoredCase := ign.

o  searchVariableVisible
search variable option in searchbox visible?
(only true for codeview2's textview)

o  searchVariableWithSyntaxElement: syntaxElementForVariable forward: fwd
this only works for CodeView2::TextView, which supports syntaxElements.
Finds the next occurrence of a syntax element (typically, a variable)

o  syntaxElementForSelectedVariable
for a better search; ignored here, but redefined in CodeView2

o  syntaxElementForVariableUnderCursor
for a better search; ignored here, but redefined in CodeView2

native widget support
o  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
o  currentSelectionBgColor

o  currentSelectionFgColor

o  fileOutContentsOn: aStream
save contents on a stream, replacing leading spaces by tab-characters.

o  fileOutContentsOn: aStream compressTabs: compressTabs
save contents on a stream. If compressTabs is true,
leading spaces will be replaced by tab-characters in the output.

o  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.

o  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 ...

o  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

o  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.

o  isClosingParenthesis: ch
return true if the given character is an closing parenthesis character,
as specified in the current parenthesisSpecification

o  isOpeningParenthesis: ch
return true if the given character is an opening parenthesis character,
as specified in the current parenthesisSpecification

o  rememberSearchPattern: pattern
move to top or addFirst

o  removeTrailingWhitespace

o  resetVariablesBeforeNewSearch
clear the autosearch action, when the first pattern is searched for

o  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

o  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.

o  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.

o  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

o  stopScrollSelect
stop auto scroll; deinstall timed-block

o  textChanged
(comment from inherited method)
ignored here

o  widthForScrollBetween: firstLine and: lastLine
return the width in pixels for a scroll between firstLine and lastLine

queries
o  hasSearchActionSelection
Here we fake the use of typeOfSelection which is really in EditTextView

o  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
o  clearMarginOfVisibleLine: visLine with: color
if there is a margin, clear it - a helper for selection drawing

o  drawSelectedFromVisibleLine: startVisLineNr to: endVisLineNr

o  drawVisibleLineSelected: visLineNr

o  drawVisibleLineSelected: visLineNr col: col

o  drawVisibleLineSelected: visLineNr from: selectionStartCol

o  drawVisibleLineSelected: visLineNr from: startCol to: endCol

o  redrawFromVisibleLine: startVisLineNr to: endVisLineNr
redraw a visible line range

o  redrawVisibleLine: visLineNr
redraw visible line lineNr

o  redrawVisibleLine: visLine col: col
redraw single character at col in visible line lineNr.

o  redrawVisibleLine: visLine from: startCol
redraw visible line lineNr from startCol to end of line

o  redrawVisibleLine: visLine from: startCol to: endCol
redraw visible line lineNr from startCol to endCol

searching
o  clearSearchAction

o  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.

o  searchAction

o  searchAction: aSearcherOrSearchBlock

o  searchAgainInSameDirection
search again in the same direction and -if found- position cursor

o  searchBwd
search backward (for the same thing again)
If found, position cursor

o  searchBwd: pattern
do a backward search

o  searchBwd: pattern ifAbsent: aBlock
do a backward search

o  searchBwd: pattern ignoreCase: ign
do a backward search

o  searchBwd: pattern ignoreCase: ign ifAbsent: aBlock
do a backward search

o  searchBwd: pattern ignoreCase: ign match: match
do a backward search.
match pattern functionality is not yet available for backward search

o  searchBwdUsingSpec: searchSpec
do a backward search

o  searchBwdUsingSpec: searchSpec ifAbsent: aBlock
do a backward search

o  searchForAndSelectMatchingParenthesisFromLine: startLine col: startCol
select characters enclosed by matching parenthesis if one is under startLine/Col

o  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.

o  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.

o  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.

o  searchFwd
search forward for the same pattern or selection again

o  searchFwd: pattern
do a forward search

o  searchFwd: pattern ifAbsent: aBlock
do a forward search

o  searchFwd: pattern ignoreCase: ign
do a forward search

o  searchFwd: pattern ignoreCase: ign ifAbsent: aBlock
do a forward search

o  searchFwd: pattern ignoreCase: ign match: match
do a forward search

o  searchFwd: pattern ignoreCase: ign match: match ifAbsent: aBlock
do a forward search

o  searchFwd: pattern ignoreCase: ign match: match startingAtLine: startLine col: startCol ifAbsent: aBlock
do a forward search

o  searchFwdUsingSpec: searchSpec
do a forward search

o  searchFwdUsingSpec: searchSpec ifAbsent: aBlock
do a forward search

o  searchFwdUsingSpec: searchSpec startingAtLine: startLine col: startCol ifAbsent: aBlock
do a forward search

o  searchPattern
return the last search pattern

o  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)

o  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)

o  setSearchPattern
set the searchpattern from the selection if there is one

o  setSearchPattern: aStringOrNil
set the searchpattern for future searches

o  setSearchPattern: aString ignoreCase: aBoolean
set the searchpattern and caseIgnore for future searches

o  setSearchPattern: aString ignoreCase: ignoreCaseBoolean match: matchBoolean
set the searchpattern and caseIgnore for future searches

o  setSearchPatternWithMatchEscapes: match
set the searchpattern from the selection if there is one

o  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) **

o  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) **

o  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)

o  startPositionForSearchBackward

o  startPositionForSearchBackwardBasedOnSelection

o  startPositionForSearchForward

o  startPositionForSearchForwardBasedOnSelection

selections
o  changeTypeOfSelectionTo: newType
ignored here - but redefined in subclasses which
differentiate between pasted- and user-selections

o  expandSelectionDown
self redrawLine:l.

o  expandSelectionLeft

o  expandSelectionRight

o  expandSelectionUp
self redrawLine:l.

o  hasSelection
return true, if there is a text selection

o  hasSelectionForCopy
return true, if there is a selection which can be copied
(the same as #hasSelection, except for editfields in password-mode)

o  hasSelectionWithinSingleLine
return true, if there is a selection and it is within a line

o  hasSingleFullLineSelected

o  isInSelection: line col: aColNr
returns true, if the line, and column is in the selection

o  makeSelectionVisible
scroll to make the selection visible

o  selectAll
select the whole text

o  selectFromCharacterPosition: pos1
compute line/col from the character position and select the text up to the end

o  selectFromCharacterPosition: pos1 to: pos2
compute line/col from character positions and select the text

o  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

o  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

o  selectLine: selectLine
select one line and redraw it

o  selectLineAtY: y
select the line at given y-(view-)coordinate

o  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).

o  selectMatchingParenthesisFromX: x y: y
undo scroll operation ...

o  selectWordAtLine: line col: col
select the word at given line/col

o  selectWordAtX: x y: y
select the word at given x/y-(view-)coordinate

o  selectedInterval
return the selection-boundaries as interval

o  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.

o  selectionAsString
return the selection as a String (i.e. without emphasis)

o  selectionChanged
can be redefined for notification or special actions.
If you do, do not forget to do a super selectionChanged

o  selectionEndCol
the last columnNr of the selection (or nil)

o  selectionEndLine
the last lineNr of the selection (or nil)

o  selectionStartCol
the first columnNr of the selection (or nil)

o  selectionStartLine
the first lineNr of the selection (or nil)

o  setPrimarySelection
can be redefined for notification or special actions

o  st80SelectMode
st80 selectmode behaves slightly different

o  st80SelectMode: aBoolean
st80 selectmode behaves slightly different

o  unselect
unselect - if there was a selection redraw that area

o  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).

o  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.

o  withSelectionForeground: hilightFg background: hilightBg do: aBlock
evaluate aBlock while the selection is shown highlighted with colors passed as args.

testing
o  isTextView
I am showing text


Private classes:

    ParenthesesMatcher

Examples:


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.


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Thu, 21 Nov 2024 14:18:14 GMT