Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!hookup!news.sprintlink.net!pipex!news.oleane.net!oleane!jussieu.fr!univ-lyon1.fr!swidir.switch.ch!unifr_news!news
From: georg.eberle@unifr.ch (Georg Eberle)
Subject: Auto Indent for TextPane in ST/V
Message-ID: <1995Jan27.093240.9995@unifr.ch>
Sender: news@unifr.ch (User for news)
Organization: iiUF
X-Newsreader: WinVN 0.92.1
Date: Fri, 27 Jan 1995 09:32:40 GMT
Lines: 50

Good Morning,

for all of you who use ST/V and it's fantastic editor (TextPane)
and ever wanted an auto indent feature just file in the following
method:

!TextPane methods !
   
characterInput: aCharacter

        "Private - The user typed aCharacter. This method has been modified
        in order to enable auto indenting."

    | l i n s |

#modifiedByEBI.
    self isReadOnly ifTrue: [ ^self ].
    self isGapSelection
        ifFalse: [ self hideSelection ].
    newSelection := self replaceWithChar: aCharacter.
    (aCharacter == Lf)
        ifTrue: [self selectAfter: newSelection corner.
            i := 1.
            s := ''.
            l := self lineAt: (selection origin y) - 1.
            n := l size.
            [(i <= n) and: [(l at: i) = $ ]]
                whileTrue: [i := i +1.
                    s := s, ' '].
            newSelection := self replaceWithText: s].
    modified := true.
    self
        selectAfter: newSelection corner;
        makeSelectionVisible;
        displayChangesForCharInput;
        showSelection.! !

It works fine on ST/V 2.0 Win32 but should also work with VST 3.0.
If it works with ST/V 2.0 I got no idea.

Hope that you find it usefull

	Georg Eberle
	georg.eberle@unifr.ch

/-------------------------------------------------------------------------\
| Georg Eberle (georg.eberle@unifr.ch)            | A black hole is where |
| iiUF                                            |   God divides by zero |
| 1700 Friburg (Switzerland)                      |                       |
\-------------------------------------------------------------------------/
