|
|
Class: ListView
Object
|
+--GraphicsContext
|
+--DeviceGraphicsContext
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--View
|
+--ListView
|
+--SelectionInListView
|
+--TextView
- Package:
- stx:libwidg
- Category:
- Views-Text
- Version:
- rev:
1.340
date: 2009/11/04 11:26:05
- user: cg
- file: ListView.st directory: libwidg
- module: stx stc-classLibrary: libwidg
- Author:
- Claus Gittinger
a View for (string-)lists.
This class can only passively display collections of strings-
selections, editing, cursors etc. must be done in subclasses.
see SelectionInListView, TextView etc.
This code currently handles only fixed-height fonts correctly -
should be rewritten in some places ...
It can only scroll by full lines vertically (i.e. setting firstLineShown to ~~ 1)
which should be changed to have this behavior optionally for smooth scroll.
The text is internally kept in the list instance variable, and is supposed to consist
of a collection (Ordered- or StringCollection) of line entries.
Typically, individual entries are either strings or nil (for empty lines).
However, any object which supports the displayOn: and widthIn: protocol can be
used - see MultipleColumnListEntry as an example.
Therefore, ListView (and all subclasses) are prepared to handle non-string entries
(especially: attributed Text).
The internal version of the text has tabulators expanded to blanks - when text is exchanged
with an external medium (i.e. reading/writing files), these are expanded/compressed assuming
a tab-setting of 8. This is done independent of the users tab setting, which is used
while the text is edited. Thus, even if the tab setting is multiple of 4's, tabs are
written in multiples of 8 when the text is saved. Since this is the default on all ascii
terminals and printers, this assures that the text looks correctly indented when finally printed.
Notice:
ListView is one of the oldest widget classes in the current system and
definitely requires some rewrite:
Due to historic reasons (ListView implemented scrolling before the general
scrolling code in View was added), this one does scrolling different from all other
views. The general scrolling code (in View) uses the transformation for transparent scrolling.
Here, the transformation is not used, instead it is done again, by keeping the firstLineShown
(i.e. vertical offset) and leftOffset (horizontal offset).
The most annoying consequence of this is, that scrolling is done by lines here,
while its done in pixels in the View class. Thus, be careful, when changing things
(better: dont touch it ;-)
Also, all controller functionality is completely performed by the listView
(and subclasses) itself. It is still possible, to define and set a specialized
controller, though. I.e. if you like to change the input behavior, define
a corresponding controller class and intersect the keyXXX/buttonXXX messages
there.
This will be totally rewritten ... so dont depend on the internals; especially the scrolling
code will be totally removed here and the inherited functionality be used in the next version.
[Instance variables:]
list <aCollection> the text strings, a collection of lines.
Nils may be used for empty lines.
firstLineShown <Number> the index of the 1st visible line (1 ..)
leftOffset <Number> left offset for horizontal scroll
nFullLinesShown <Number> the number of unclipped lines in visible area
(internal; updated on size changes)
nLinesShown <Number> the number of lines in visible area, incl. partial
(internal; updated on size changes)
fgColor <Color> color to draw characters
bgColor <Color> the background
partialLines <Boolean> allow last line to be partial displayed
leftMargin <Number> margin at left in pixels
topMargin <Number> margin at top in pixels
textStartLeft <Number> margin + leftMargin (internal)
textStartTop <Number> margin + topMargin (internal)
innerWidth <Number> width - margins (internal)
tabPositions <aCollection> tab stops (cols)
fontHeight <Number> font height in pixels (internal)
fontAscent <Number> font ascent in pixels (internal)
fontIsFixed <Boolean> true if its a fixed font (internal)
fontWidth <Number> width of space (internal)
lineSpacing <Number> pixels between lines
lastSearchPattern <String> last pattern for searching
(kept to provide a default for next search)
lastSearchIgnoredCase <Boolean> last search ignored case
(kept to provide a default for next search)
wordCheck <Block> rule used for check for word boundaries in word select
The default rule is to return true for alphaNumeric characters.
(can be changed to allow for underscore and other
characters to be treated as alphaCharacters)
autoScrollBlock <Block> block installed as timeoutBlock when doing an
autoScroll (internal)
autoScrollDeltaT computed scroll time delta in seconds (internal)
includesNonStrings cached flag if any non-strings are in list
widthOfWidestLine cached width of widest line
listMsg if view has a model and listMsg is non-nil,
this is sent to the model to aquired a new contents
whenever a change of the aspect (aspectMsg) occurs.
viewOrigin the current origin
backgroundAlreadyClearedColor internal; speedup by avoiding
multiple fills when drawing
internal lines
scrollWhenUpdating
<Symbol> defines how the view is scrolled if the
model changes its value by some outside activity
(i.e. not by user input).
Can be one of:
#keep / nil -> stay unchanged
#endOfText -> scroll to the end
#beginOfText -> scroll to the top
The default is #beginOfText (i.e. scroll to top).
[StyleSheet parameters:]
textForegroundColor defaults to Black
textBackgroundColor defaults to White
textFont defaults to defaultFont
textTabPositions defaults to #(1 9 17 25 ...)
TextView
EditTextView
defaults
-
defaultTabPositions
-
return an array containing the styleSheets default tab positions
-
defaultTabPositions: aVector
-
set the array containing the styleSheets tab positions
-
tab4Positions
-
return an array containing tab positions for 4-col tabs
-
tab8Positions
-
return an array containing tab positions for 8-col tabs
-
updateStyleCache
-
extract values from the styleSheet and cache them in class variables
-
userDefaultTabPositions
-
return an array containing the users default tab positions
-
userDefaultTabPositions: aVector
-
set the array containing the users tab positions
accessing
-
innerHeight
-
return the number of pixels visible of the contents
- redefined since ListView adds another margin to start the text
somewhat to indented from the 3D border.
-
wordCheckBlock: aBlock
-
set the word-check block - this block is called with a character argument,
when the end/beginning of a word is searched.
It should return true, if the character belongs to the word.
The default block is set in #initialize, and returns true for alphanumeric
(national) characters.
Applications may change it to include underlines, dollars or other characters.
(a C/C++ editor would include underlines ...)
accessing-behavior
-
lineEndCRLF
-
-
scrollWhenUpdating
-
return the scroll behavior, when I get a new text
(via the model or the #contents/#list)
Possible returnValues are:
#keep / nil -> no change
#endOfText -> scroll to the end
#beginOfText -> scroll to the top
The default is #keep.
This may be useful for fields which get new values assigned from
the program (i.e. not from the user)
-
scrollWhenUpdating: aSymbolOrNil
-
define how to scroll, when I get a new text
(via the model or the #contents/#list)
Allowed arguments are:
#keep / nil -> no change
#endOfText -> scroll to the end
#beginOfText -> scroll to the top
The default is #keep.
This may be useful for fields which get new values assigned from
the program (i.e. not from the user)
accessing-contents
-
add: aString
-
add a line and redisplay
-
add: aString beforeIndex: index
-
add a line and redisplay
-
addAll: aCollectionOfLines beforeIndex: index
-
add a bunch of lines and redisplay
-
at: lineNr
-
retrieve a line; return nil if beyond end-of-text.
this allows textViews to be used like collections in some places.
-
at: index put: aString
-
change a line and redisplay
-
characterAtCharacterPosition: charPos
-
return the character at a 1-based character position.
Return a space character if nothing is there
(i.e. beyond the end of the line or below the last line)
-
characterAtLine: lineNr col: colNr
-
return the character at physical line/col.
The lineNr and colNr arguments start at 1, for the top-left cgaracter.
Return a space character if nothing is there
(i.e. beyond the end of the line or below the last line)
-
contents
-
return the contents as a string
-
contents: something
-
set the contents (either a String or a Collection of strings)
also scroll to top. See #setContents:, which does not scroll.
If the argument is a string, it is converted
to a collection of line-strings here.
-
from: from to: to do: aBlock
-
evaluate aBlock on some of my lines
-
grow: n
-
grow our list
-
lineAtY: y
-
return the lineNr for a given y-(view-)coordinate
-
list
-
return the contents as a collection of strings.
This returns the views internal list - modifying it may confuse
the listView.
-
list: aCollection
-
set the contents (a collection of strings or list entries)
and scroll as specified in scrollWhenUpdating (default:top-left).
See also #setList:, which does not scroll.
Tabs are expanded (to spaces).
The passed list is scanned for nonStrings
(remembered to optimize later redraws).
-
list: aCollection expandTabs: expand
-
set the contents (a collection of strings)
and scroll as specified in scrollWhenUpdating (default:top-left).
If expand is true, tabs are expanded (to spaces).
The passed list is scanned for nonStrings (remembered to optimize
later redraws).
-
list: aCollection expandTabs: expand scanForNonStrings: scan
-
set the contents (a collection of strings)
and scroll as specified in scrollWhenUpdating (default:top-left).
If expand is true, tabs are expanded (to spaces).
If scan is true, scan the passed list for nonStrings; otherwise,
assume that it does contain non-strings
(remembered to optimize later redraws).
-
list: aCollection expandTabs: expand scanForNonStrings: scan includesNonStrings: nonStrings
-
set the contents (a collection of strings)
and scroll as specified in scrollWhenUpdating (default:top-left).
If expand is true, tabs are expanded (to spaces).
If scan is true, scan the passed list for nonStrings;
otherwise, take the information from the nonStrings arg.
(the nonStrings information is remembered to optimize later redraws & height computations).
-
listAt: lineNr
-
given a lineNumber, return the corresponding string
This is used for accessing; i.e. for non-string entries, this
returns the corresponding string.
-
removeFromIndex: startLineNr toIndex: endLineNr
-
delete some lines
-
removeIndex: lineNr
-
delete a line, redraw the view
-
removeIndexWithoutRedraw: lineNr
-
delete a line, given its lineNr - no redraw;
return true, if something was really deleted (so sender knows,
if a redraw is needed)
-
replaceFrom: startLineNr to: endLineNr with: aCollection startingAt: replStartIndex
-
replace some lines
-
setContents: something
-
set the contents (either a string or a Collection of strings)
dont change position (i.e. do not scroll).
This can be used to update a self-changing list
(for example: a file list being shown, without disturbing user too much).
Compare with #contents:, which scrolls to top.
-
setList: aCollection
-
set the contents (a collection of strings);
do not change position (i.e. do not scroll).
This can be used to update a self-changing list
(for example: a file list being shown, without disturbing user too much)
-
setList: aCollection expandTabs: expandTabs
-
set the contents (a collection of strings);
do not change position (i.e. do not scroll).
This can be used to update a self-changing list
(for example: a file list being shown, without disturbing the user too much)
-
setList: aCollection expandTabs: expandTabs redraw: doRedraw
-
set the contents (a collection of strings);
do not change position (i.e. do not scroll).
This can be used to update a self-changing list
(for example: a file list being shown, without disturbing the user too much)
-
size
-
return the size (i.e. number of lines)
this allows textViews to be used like collections in some places.
-
stringAtLine: lineNr from: col1 to: col2
-
return the substring starting at physical line/col1, up-to and
including col2.
The lineNr and colNr arguments start at 1, for the top-left character.
Fills the string with space characters at the right.
(i.e. beyond the end of the line or below the last line)
-
textFromCharacterPosition: charPos1 to: charPos2
-
return some text as a collection of (line-)strings.
-
textFromLine: startLine col: startCol toLine: endLine col: endCol
-
return some text as a collection of (line-)strings.
-
withoutRedrawAt: index put: aString
-
change a line without redisplay and WITHOUT any sizeChange notifications.
Somewhat dangerous, since scrollBars will not be informed about contents-changes.
Use only if multiple lines are to be changed, and a sizeChanged is invoked by some other
means at the end.
accessing-look
-
backgroundColor
-
return the background color
-
backgroundColor: aColor
-
set the background color of the contents
-
font: aFont
-
set the font for all shown text.
Redraws everything.
CAVEAT: with the addition of Text objects,
this method is going to be obsoleted by a textStyle
method, which allows specific control over
normalFont/boldFont/italicFont parameters.
-
fontHeight: pixels
-
set the lines height - thats the number of pixels,
by which lines are vertically separated.
-
foregroundColor
-
return the foreground color
-
foregroundColor: aColor
-
set the foreground color
-
foregroundColor: color1 backgroundColor: color2
-
set both foreground and background colors
-
innerHorizontalMargin
-
return the margin between the left border and the 1st col
-
innerVerticalMargin
-
return the margin between the top border and the 1st line
-
leftMargin
-
return the margin to left of 1st col
-
leftMargin: aNumber
-
set the margin between the left border and the 1st col
-
level: aNumber
-
set the 3D level - caught here to update text-position variables
(which avoids many computations later)
-
lineSpacing: pixels
-
set the lineSpacing - thats an additional number of pixels,
by which lines are vertically separated.
-
partialLines: aBoolean
-
allow/disallow display of a last partial line
-
topMargin: aNumber
-
set the margin between the top border and the 1st line
-
viewBackground: aColor
-
accessing-mvc
-
addModelInterfaceTo: aDictionary
-
see comment in View>>modelInterface
-
listMessage
-
return the listMsg selector;
if non-nil, this is the message sent to the model (if any) to aquire
a new text upon change of the aspect.
This defaults to the aspect-selector.
-
listMessage: aSymbol
-
ST-80 compatibility: set the listMsg selector;
if non-nil, this will be sent to the model (if any) to aquire a
new text upon change of the aspect.
This defaults to the aspect-selector.
-
model: aModel
-
define the receivers model, from which the text is
to be aquired via list- or aspect-messages, whenever its aspect
changes.
-
on: aModel aspect: aspectSymbol
-
ST-80 compatibility
-
on: aModel aspect: aspectSymbol change: changeSymbol
-
ST-80 compatibility
-
on: aModel aspect: aspectSymbol change: changeSymbol list: listSymbol menu: menuSymbol
-
ST-80 compatibility
-
on: aModel aspect: aspectSymbol change: changeSymbol menu: menuSymbol
-
ST-80 compatibility
-
on: aModel aspect: aspectSymbol list: listSymbol menu: menuSymbol
-
ST-80 compatibility
-
on: aModel aspect: aspectSymbol menu: menuSymbol
-
ST-80 compatibility
change & update
-
update: something with: aParameter from: changedObject
-
drawing
-
drawFromVisibleLine: startVisLineNr to: endVisLineNr with: fg and: bg
-
draw a visible line range in fg/bg
-
drawLine: line atX: x inVisible: visLineNr with: fg and: bg
-
draw a given string at visible lines position with
given x position in fg/bg. Clears the whole line before drawing the string.
Low level entry; not meant for public use.
-
drawLine: line fromX: x inVisible: visLineNr with: fg and: bg
-
draw a given string at visible lines position with
given x position in fg/bg. Clears partial line before drawing the string.
Low level entry; not meant for public use.
-
drawLine: lineStringArg inVisible: visLineNr col: col with: fg and: bg
-
draw single character at col index of visible line in fg/bg
-
drawLine: lineStringArg inVisible: visLineNr from: startCol to: endColOrNil with: fg and: bg
-
draw part of a visible line in fg/bg
-
drawLine: lineString inVisible: visLineNr from: startCol with: fg and: bg
-
draw right part of a visible line from startCol to end of line in fg/bg
-
drawLine: line inVisible: visLineNr with: fg and: bg
-
draw a given string at visible lines position in fg/bg
-
drawVisibleLine: visLineNr col: col with: fg and: bg
-
draw single character at col index of visible line in fg/bg
-
drawVisibleLine: visLineNr from: startCol to: endCol with: fg and: bg
-
draw part of a visible line in fg/bg
-
drawVisibleLine: visLineNr from: startCol with: fg and: bg
-
draw right part of a visible line from startCol to end of line in fg/bg
-
drawVisibleLine: visLineNr with: fg and: bg
-
draw a visible line in fg/bg
-
fillRectangleX: x y: y width: w height: h
-
fill rectangle; checks whether the rectangle already is filled with
the current paint (#redrawX:y:w:h).
-
invalidateLine: line
-
invalidate the area of a single line.
This arranges for that line to be redrawn asynchronously (later).
If multiple such invalidations arrive, those areas may be lumped
together for a block update.
The update takes place when the windowGroup process gets a chance to
process expose events.
event handling
-
contentsChanged
-
contents changed - move origin up if possible
-
keyPress: key x: x y: y
-
a key was pressed - handle page-keys here
-
mapped
-
-
mouseWheelZoom: amount
-
CTRL-wheel action
-
redrawX: x y: y width: w height: h
-
a region must be redrawn
-
sizeChanged: how
-
size changed - move origin up if possible
-
unmap
-
initialization
-
create
-
-
defaultControllerClass
-
-
fetchDeviceResources
-
fetch device colors, to avoid reallocation at redraw time
-
initStyle
-
setup viewStyle specifics
-
initialize
-
-
initializeWordCheckAction
-
-
realize
-
-
recreate
-
recreate after a snapin or a migration
private
-
absoluteLineToVisibleLine: absLineNr
-
given an absolute line (1..) return visible linenr or nil
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
checkForExistingLine: lineNr
-
check if a line for lineNr exists; if not, expand text
-
colOfX: x inVisibleLine: visLineNr
-
given a visible lineNr and x-coordinate, return colNr
-
computeNumberOfLinesShown
-
recompute the number of visible lines
-
convertRTF: aList
-
** This is an obsolete interface - do not use it (it may vanish in future versions) **
-
getFontParameters
-
get some info of the used font. They are cached since we use them often ..
The code below uses the fonts average height parameters - these
are not OK for some oversized national characters (such as A-dieresis).
Therefore, this method should be redefined in views which will be used
with national characters (i.e. editTextViews).
-
getListFromModel
-
ask my model (if any) for the text via the listMsg.
If there is no listMessage, try aspect for backward compatibility.
-
getListFromModelScroll: aBoolean
-
ask my model (if any) for the text via the listMsg.
If there is no listMessage, try aspect for backward compatibility.
Scrolling is suppressed here
-
line: line withoutEmphasis: emphasisToRemove
-
-
listAt: lineNr from: startCol
-
return right substring from startCol to end of a line
-
listAt: lineNr from: startCol to: endCol
-
return substring from startCol to endCol of a line
-
listAt: lineNr to: endCol
-
return left substring from start to endCol of a line
-
listLineIsVisible: listLineNr
-
return true, if a particular line is visible
-
listLineToVisibleLine: listLineNr
-
given a list line (1..) return visible linenr or nil
-
recomputeWidthOfWidestLineFor: aString
-
-
suppressEmphasisInSelection
-
selection is shown with original emphasis
-
textChanged
-
ignored here
-
visibleAt: visibleLineNr
-
return what is visible at line (numbers start at 1).
This is used for redrawing; i.e. for non-string entries, this
returns the original.
-
visibleLineOfY: y
-
given a y-coordinate, return the visible lineNr
- works for fix-height fonts only
-
visibleLineToAbsoluteLine: visibleLineNr
-
given a visible line (1..) return absolut linenr
-
visibleLineToListLine: visibleLineNr
-
given a visible line (1..) return linenr in list or nil
(this one returns nil if the given visibleLineNr is one of the
separators)
-
visibleStringFrom: aString
-
-
widthForScrollBetween: firstLine and: lastLine
-
return the width in pixels for a scroll between firstLine and lastLine.
- used to optimize scrolling, by limiting the scrolled area.
Subclasses with selections or other additional visible stuff should redefine
this method.
-
widthOfLineString: entry
-
return the width of an entry
-
widthOfWidestLineBetween: firstLine and: lastLine
-
return the width in pixels of the widest line in a range
- used to optimize scrolling, by limiting the scrolled area
-
withoutAnyColorEmphasis: line
-
-
withoutBackgroundColorEmphasis: line
-
-
withoutColorEmphasis: line
-
-
withoutColorEmphasis: line ifFg: fg andBg: bg
-
remove lines color emphasis, to enforce color.
-
xOfCol: col inVisibleLine: visLineNr
-
given a visible line- and colNr, return the x-coordinate in view
-
yOfLine: lineNr
-
given a physical lineNr, return y-coordinate in view
- works for fix-height fonts only
-
yOfVisibleLine: visLineNr
-
given a visible lineNr, return y-coordinate in view
- works for fix-height fonts only
-
yVisibleToLineNr: yVisible
-
queries
-
characterPositionOfLine: lineNr col: col
-
given a line/col position, return the character index within the contents-string,
- used with Compilers error-positioning, which is based on character positions
of the contents-string.
-
colOfCharacterPosition: charPos
-
given a character index within the contents-string,
return the column number where the character is
- used to find line to hilight from Compilers error-position
-
currentLine
-
the current line (for relative gotos);
since listViews have no cursor, the first shown line is returned here.
Redefined in editTextView, to return the cursors line.
-
firstLineShown
-
return the index of the first (possibly partial) visible line
-
heightForLines: numberOfLines
-
return the height of the receiver, if numberOfLines are to be displayed
-
heightOfContents
-
return the height of the contents in pixels
- used for scrollbar interface
-
lastLineShown
-
return the index of the last (possibly partial) visible line
-
leftIndentOfLine: lineNr
-
return the number of spaces at the left in line, lineNr.
returns 0 for empty lines.
-
lengthOfLongestLine
-
return the length (in characters) of the longest line
-
lengthOfLongestLineBetween: firstLine and: lastLine
-
return the length (in characters) of the longest line in a line-range
-
lineIsFullyVisible: line
-
is line fully visible?
-
lineIsVisible: line
-
is line visible?
-
lineOfCharacterPosition: charPos
-
given a character index within the contents-string,
return the lineNumber where the character is
- used to find line to hilight from Compilers error-position
-
numberOfLines
-
return the number of lines the text has
-
preferredExtentForLines: numLines cols: numCols
-
-
widthOfContents
-
return the width of the contents in pixels
- used for scrollbar interface
-
widthOfLine: lineNr
-
return the width of a line in pixels
-
xOriginOfContents
-
return the horizontal origin of the contents in pixels
- used for scrollbar interface
-
yOriginOfContents
-
return the vertical origin of the contents in pixels
- used for scrollbar interface
redrawing
-
flash
-
show contents in reverse colors for a moment - to wakeup the user :-)
-
redraw
-
redraw complete view
-
redrawFromLine: lineNr
-
redraw starting at linrNr
-
redrawFromLine: startLine col: startCol toLine: endLine col: endCol
-
-
redrawFromLine: start to: end
-
redraw lines from start to end
-
redrawFromVisibleLine: startVisLineNr to: endVisLineNr
-
redraw a visible line range
-
redrawInverted
-
show contents in reverse colors
-
redrawLine: lineNr
-
redraw a list line
-
redrawLine: lineNr col: col
-
redraw a single character
-
redrawLine: lineNr from: startCol
-
redraw a list line from startCol to end of line
-
redrawLine: lineNr from: startCol to: endCol
-
redraw a list line from startCol to endCol
-
redrawVisibleLine: visLineNr
-
redraw a visible line
-
redrawVisibleLine: visLineNr col: col
-
redraw single character at col index of visible line
-
redrawVisibleLine: visLineNr from: startCol
-
redraw right part of a visible line from startCol to end of line
-
redrawVisibleLine: visLineNr from: startCol to: endCol
-
redraw part of a visible line
scrolling
-
gotoLine: aLineNumber
-
position to line aLineNumber; this may be redefined
in subclasses (for example to move the cursor also)
-
halfPageDown
-
scroll down half a page
-
halfPageUp
-
scroll up half a page
-
horizontalScrollStep
-
return the amount to scroll when stepping up/down.
Here, the scrolling unit is characters.
-
makeColVisible: aCol inLine: aLineNr
-
if column aCol is not visible, scroll horizontal to make it visible
-
makeLineVisible: aListLineNr
-
if aListLineNr is not visible, scroll to make it visible.
Numbering starts with 1 for the very first line of the text.
-
makeVisible: someString
-
if nescessary, scroll to make the (first)
line containing someString visible.
-
needScrollToMakeLine: aListLineNr
-
return true, if a scroll is needd to make a line visible.
Numbering starts with 1 for the very first line of the text.
-
needScrollToMakeLineVisible: aListLineNr
-
return true, if a scroll is needd to make a line visible.
Numbering starts with 1 for the very first line of the text.
-
pageDown
-
change origin to display next page
-
pageUp
-
change origin to display previous page
-
scrollDown: nLines
-
change origin to scroll down some lines (towards the bottom of the text)
-
scrollDownPixels: pix
-
change origin to scroll down some pixels
(towards the bottom of the text)
THIS WILL VANISH!
-
scrollHorizontalTo: aPixelOffset
-
change origin to make aPixelOffset be the left col
-
scrollLeft: nPixel
-
change origin to scroll left some cols
-
scrollRight: nPixel
-
change origin to scroll right some cols
-
scrollSelectDown
-
just a template - I do not know anything about selections
** This method raises an error - it must be redefined in concrete classes **
-
scrollSelectUp
-
just a template - I do not know anything about selections
** This method raises an error - it must be redefined in concrete classes **
-
scrollToBottom
-
change origin to show end of text
-
scrollToCol: aColNr
-
change origin to make aColNr be the left col
-
scrollToLeft
-
change origin to start (left) of text
-
scrollToLine: aLineNr
-
change origin to make aLineNr be the top line
-
scrollToPercent: percentOrigin
-
scroll to a position given in percent of total
-
scrollToTop
-
change origin to start of text
-
scrollUp: nLines
-
change origin to scroll up some lines (towards the top of the text)
-
scrollUpPixels: pix
-
change origin to scroll up some pixels
(towards the top of the text)
THIS WILL VANISH!
-
scrollVerticalToPercent: percent
-
scroll to a position given in percent of total
-
startAutoScrollDown: yDistance
-
setup for auto-scroll down (when button-press-moving below view)
- timeDelta for scroll is computed from distance
-
startAutoScrollHorizontal: xDistance scrollSelector: scrollSelector
-
setup for auto-scroll left/right (when button-press-moving to the right of the view)
- timeDelta for scroll is computed from distance
-
startAutoScrollLeft: xDistance
-
setup for auto-scroll up (when button-press-moving to the left of the view)
- timeDelta for scroll is computed from distance
-
startAutoScrollRight: xDistance
-
setup for auto-scroll down (when button-press-moving to the right of the view)
- timeDelta for scroll is computed from distance
-
startAutoScrollUp: yDistance
-
setup for auto-scroll up (when button-press-moving below view)
- timeDelta for scroll is computed from distance
-
startAutoScrollVertical: yDistance scrollSelector: scrollSelector
-
setup for auto-scroll up (when button-press-moving below view)
- timeDelta for scroll is computed from distance
-
stopAutoScroll
-
stop any auto-scroll
-
verticalScrollStep
-
return the amount to scroll when stepping up/down.
Here, the scrolling unit is lines.
-
viewOrigin
-
return the viewOrigin; thats the coordinate of the contents
which is shown topLeft in the view
(i.e. the origin of the visible part of the contents).
scrolling-basic
-
additionalMarginForHorizontalScroll
-
return the number of pixels by which we may scroll more than the actual
width of the document would allow.
This is redefined by editable textViews, to allo for the cursor
to be visible if it is positioned right behind the longest line of text.
The default returned here is the width of a blank (to beautify italic text)
-
scrollTo: anOrigin redraw: doRedraw
-
change origin to have newOrigin be visible at the top-left.
The argument defines the integer device coordinates of the new top-left
point.
searching
-
findBeginOfWordAtLine: selectLine col: selectCol
-
return the col of first character of the word at given line/col.
If the character under the initial col is a space character, return
the first col of the blank-block.
-
findEndOfWordAtLine: selectLine col: selectCol
-
return the col of last character of the word at given line/col.
If the character under the initial col is a space character, return
the last col of the blank-block.
Return 0 if we should wrap to next line (for spaces)
-
searchBackwardFor: pattern ignoreCase: ignCase startingAtLine: startLine col: startCol ifFound: block1 ifAbsent: block2
-
search for a pattern, if found evaluate block1 with row/col as arguments, if not
found evaluate block2.
Sorry, but pattern is no regular expression pattern (yet)
-
searchBackwardFor: pattern startingAtLine: startLine col: startCol ifFound: block1 ifAbsent: block2
-
search for a pattern, if found evaluate block1 with row/col as arguments, if not
found evaluate block2.
Sorry, but pattern is no regular expression pattern (yet)
-
searchForwardFor: pattern ignoreCase: ignCase match: match startingAtLine: startLine col: startCol ifFound: block1 ifAbsent: block2
-
search for a pattern, if found evaluate block1 with row/col as arguments, if not
found evaluate block2.
-
searchForwardFor: pattern ignoreCase: ignCase startingAtLine: startLine col: startCol ifFound: block1 ifAbsent: block2
-
search for a pattern, if found evaluate block1 with row/col as arguments, if not
found evaluate block2.
-
searchForwardFor: pattern startingAtLine: startLine col: startCol ifFound: block1 ifAbsent: block2
-
search for a pattern, if found evaluate block1 with row/col as arguments, if not
found evaluate block2.
-
standardWordCheck: char
-
tabulators
-
expandTabs
-
go through whole text expanding tabs into spaces.
This is meant to be called for text being imported from a file.
Therefore, 8-col tabs are assumed - independent of any private tab setting.
-
nextTabAfter: colNr
-
return the next tab position after col
-
nextTabAfter: colNr in: tabPositions
-
return the next tab position after col.
The second arg, tabPositions is a collection of tabStops.
-
prevTabBefore: colNr
-
return the prev tab position before col
-
setTab4
-
set 4-character tab stops
-
setTab8
-
set 8-character tab stops
-
setTabPositions: aVector
-
set tab stops
-
withTabs: line
-
Assuming an 8-character tab,
compress multiple leading spaces to tabs, return a new line string
or the original line, if no tabs where created.
good idea, to make this one a primitive, since its called
many times when a big text is saved to a file.
-
withTabs: tabulatorTable expand: line
-
expand tabs into spaces, return a new line string,
or original line, if no tabs are included.
good idea, to make this one a primitive, since it is called
many times if a big text is read from a file.
-
withTabsExpanded: line
-
expand tabs into spaces, return a new line string,
or original line, if no tabs are included.
good idea, to make this one a primitive
HighlightArea
ListViews alone are rarely used - its mostly an abstract superclass
for TextView, EditTextView and SelectionInListView.
anyway, here are a few examples:
basic simple setup:
|top l|
top := StandardSystemView new.
top extent:100@200.
l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
l list:#('one' 'two' 'three').
top open
|
specifying textMargins (these have NOTHING to do with the viewInset):
|top l|
top := StandardSystemView new.
top extent:100@200.
l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
l list:#('one' 'two' 'three').
l topMargin:10.
l leftMargin:20.
top open
|
globally set the fg/bg colors:
|top l|
top := StandardSystemView new.
top extent:100@200.
l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
l list:#('one' 'two' 'three').
l foregroundColor:(Color white).
l backgroundColor:(Color blue).
top open
|
non-string (text) entries:
|top list l|
top := StandardSystemView new.
top extent:100@200.
l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
list := #('all' 'of' 'your' 'preferred' 'colors')
with:#(red green blue 'orange' cyan)
collect:[:s :clr |
Text string:s
emphasis:(Array with:#bold
with:(#color->(Color name:clr))) ].
l list:list.
top open
|
generic non-string entries:
(notice: ColoredListEntry is obsoleted by Text)
|top list l|
top := StandardSystemView new.
top extent:100@200.
l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
list := #('all' 'of' 'your' 'preferred' 'colors')
with:#(red green blue 'orange' cyan)
collect:[:s :clr | ColoredListEntry string:s color:(Color name:clr) ].
l list:list.
top open
|
using a model (default listMessage is aspectMessage):
|top model l theModelsText|
model := Plug new.
model respondTo:#modelsAspect
with:[ theModelsText ].
top := StandardSystemView new.
top extent:100@200.
l := ListView origin:0.0 @ 0.0 corner:1.0 @ 1.0 in:top.
l model:model.
l aspect:#modelsAspect.
top open.
Delay waitForSeconds:3.
theModelsText := #('foo' 'bar' 'baz').
model changed:#modelsAspect.
|
using a model with different aspects
for two listViews:
|top model l1 l2 plainText|
plainText := #('').
model := Plug new.
model respondTo:#modelsUppercaseText
with:[ plainText asStringCollection
collect:[:l | l asUppercase]].
model respondTo:#modelsLowercaseText
with:[ plainText asStringCollection
collect:[:l | l asLowercase]].
top := StandardSystemView extent:200@200.
l1 := ListView origin:0.0 @ 0.0 corner:1.0 @ 0.5 in:top.
l1 model:model.
l1 aspect:#modelsAspect.
l1 listMessage:#modelsUppercaseText.
l2 := ListView origin:0.0 @ 0.5 corner:1.0 @ 1.0 in:top.
l2 model:model.
l2 aspect:#modelsAspect.
l2 listMessage:#modelsLowercaseText.
top open.
Delay waitForSeconds:3.
plainText := #('foo' 'bar' 'baz').
model changed:#modelsAspect.
|
using a big list (100000 lines):
|bigList top lv|
bigList := (1 to:100000) collect:[:lineNr | 'List line Nr. ' , lineNr printString].
top := StandardSystemView extent:200@200.
lv := ScrollableView for:ListView in:top.
lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
lv list:bigList expandTabs:false scanForNonStrings:false includesNonStrings:false.
top open.
|
using a huge virtual list (1 mio simulated lines):
|virtualList top lv|
virtualList := Plug new.
virtualList inheritFrom:SequenceableCollection.
virtualList respondTo:#size with:[ 1000000 ].
virtualList respondTo:#at: with:[:lineNr | 'List line Nr. ' , lineNr printString ].
top := StandardSystemView extent:200@200.
lv := ScrollableView for:ListView in:top.
lv origin:0.0 @ 0.0 corner:1.0 @ 1.0.
lv list:virtualList expandTabs:false scanForNonStrings:false includesNonStrings:false.
top open.
|
|