[Minor] Do not scroll to the top when accepting method?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[Minor] Do not scroll to the top when accepting method?

Boris Popov, DeepCove Labs (SNN)
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
Reply | Threaded
Open this post in threaded view
|

Re: [Minor] Do not scroll to the top when accepting method?

Bob Westergaard


On 6/20/06, Boris Popov <[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)]]

Reply | Threaded
Open this post in threaded view
|

Re: [Minor] Do not scroll to the top when accepting method?

Bob Westergaard


On 6/20/06, Bob Westergaard <[hidden email]> wrote:


On 6/20/06, Boris Popov <[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


Of course, #scollPosition should do this:

  scrollPosition
     ^scrollOffset value


Reply | Threaded
Open this post in threaded view
|

Re: [Minor] Do not scroll to the top when accepting method?

Mark Pirogovsky-3
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)]]
>

Reply | Threaded
Open this post in threaded view
|

Re[2]: [Minor] Do not scroll to the top when accepting method?

Michael Lucas-Smith
In reply to this post by Bob Westergaard

I've published your code to public store as KeepScrollPositionOnSave


Cheers,
Michael


>




On 6/20/06, Boris Popov <[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)]]