How hard would it be to keep the current scroll and cursor position when
accepting a method? Thanks, -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 [hidden email] CONFIDENTIALITY NOTICE This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments. Thank you. smime.p7s (4K) Download Attachment |
On 6/20/06, Boris Popov <[hidden email]> wrote: Override BrowserCodeTool>>#accept:from: to do:How hard would it be to keep the current scroll and cursor position when It shouldn't be too hard if you don't mind adding a extension and maintaining an override or two. Add a method #scollPosition to AutoScrollingView modified := nil. [|scrollPosition| scrollPosition := aController view scrollPosition. self compileMethodText: aText from: aController. aController view scrollTo: scrollPosition] ensure: [modified := false] You'll also likely want to override BrowersCodeTool>>updateContents to be like this: updateContents | compiledMethod source text scrollPosition| modified := false. self updateTextWidget. (self selectors size > 1 or: [self selectedClass isNil]) ifTrue: [^self text: '']. self selector isNil ifTrue: [^self text: self selectedClass sourceCodeTemplate asText]. compiledMethod := self methodClass compiledMethodAt: self selector ifAbsent: [self warn: (#MethodHasBeenRemoved << #pdp >> 'Method has been removed'). ^self text: '']. source := self methodClass sourceCodeForMethod: compiledMethod at: self selector. text := source asText makeSelectorBoldIn: self methodClass. compiledMethod isProbed ifTrue: [compiledMethod highlightProbesIn: text]. builder ifNotNil: [(builder componentAt: #textEditor) ifNotNil: [:w| scrollPosition := w widget scrollPosition]]. self text: text. self updateSelection. scrollPosition ifNotNil: [(builder componentAt: #textEditor) ifNotNil: [:w| w widget scrollTo: (scrollPosition)]] |
On 6/20/06, Bob Westergaard <[hidden email]> wrote:
Of course, #scollPosition should do this: scrollPosition ^scrollOffset value |
In reply to this post by Bob Westergaard
What is wrong with adding that type of functionality to the base ?
--Mark Bob Westergaard wrote: > > > On 6/20/06, Boris Popov <[hidden email] > <mailto:[hidden email]>> wrote: > > How hard would it be to keep the current scroll and cursor position when > accepting a method? > > > > It shouldn't be too hard if you don't mind adding a extension and > maintaining an override or two. > > Add a method #scollPosition to AutoScrollingView > > Override BrowserCodeTool>>#accept:from: to do: > > modified := nil. > [|scrollPosition| > scrollPosition := aController view scrollPosition. > self compileMethodText: aText from: aController. > aController view scrollTo: scrollPosition] > ensure: [modified := false] > > You'll also likely want to override BrowersCodeTool>>updateContents to > be like this: > > updateContents > | compiledMethod source text scrollPosition| > modified := false. > self updateTextWidget. > (self selectors size > 1 or: [self selectedClass isNil]) > ifTrue: [^self text: '']. > self selector isNil > ifTrue: [^self text: self selectedClass sourceCodeTemplate asText]. > compiledMethod := self methodClass compiledMethodAt: self selector > ifAbsent: > [self warn: (#MethodHasBeenRemoved << #pdp >> > 'Method has been removed'). > ^self text: '']. > source := self methodClass sourceCodeForMethod: compiledMethod > at: self selector. > text := source asText makeSelectorBoldIn: self methodClass. > compiledMethod isProbed > ifTrue: [compiledMethod highlightProbesIn: text]. > builder ifNotNil: > [(builder componentAt: #textEditor) ifNotNil: > [:w| scrollPosition := w widget scrollPosition]]. > self text: text. > self updateSelection. > scrollPosition ifNotNil: > [(builder componentAt: #textEditor) > ifNotNil: [:w| w widget scrollTo: (scrollPosition)]] > |
In reply to this post by Bob Westergaard
I've published your code to public store as KeepScrollPositionOnSave Cheers,
|
Free forum by Nabble | Edit this page |