Re: 'Undo' don't work properly.

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

Re: 'Undo' don't work properly.

Steven Kelly
TextEditorUndo in the public repository now published: a working multi-level undo/redo for VW text widgets in 7.4-7.7. Thanks for the help, Tomáš! And of course a big thanks to Andre Schnoor for the original version back in 1996.

See the updated package comment for how to add a Redo key (and how to remap UserInterrupt if you choose Ctrl+Y as Redo).

Share and enjoy,
Steve

> -----Original Message-----
> From: Tomáš Dvořák [mailto:[hidden email]]
> Sent: 22 January 2010 14:54
> To: Steven Kelly
> Cc: [hidden email]; [hidden email]
> Subject: Re: [vwnc] 'Undo' don't work properly.
>
> I'm afraid I don't have access to public repository (and don't really
> want
> one). Even worse, it seems that my mails don't make it to the vwnc
> mailing
> list for some reason, so I probably don't even have a way to inform
> others. All I can do is provide informations about the changes I made
> to
> the package. It would be great if you could find a minute to publish it.
> I
> apologize for this ineffective reciprocal delegation, but in this case
> it
> still seems to be the easiest way to get the data to public repository.
>
> Best regards,
>    Tomas Dvorak
>
> Modified comment:
> -----------------8<----------
> This package adds multiple undo and redo levels to TextEditorController.
> This package is public domain, original implementation was written by
> Andre Schnoor (see revision 0.1 comment in public repository).
>
> Tested with VW 7.4.1, 7.7
>
> The implementation follows a simple, yet effective approach. There is
> no
> sophisticated notion of different edit actions or the like. Before a
> change is applied to the text, a copy of the current text is saved to
> an
> undo stack, along with the current selection indexes. These are simply
> restored upon "undo". Even larger texts should not impose problems,
> given
> todays average memory and CPU resources. Series of continous character
> typing are treated as a single block of action, i.e. "undo" will
> restore
> the state prior to when typing started. This saves room on the stack
> (and
> memory footprint) and pretty well suits practical needs. The default
> number of undo levels is 64 (may be easily changed).
> -----------------8<----------
>
> InputFieldView >> #editText: aTextOrStringOrNil
> "Set the text or string to appear in this input field.  nil
> indicates the
> field is to be empty."
>
> | aText |
> editTextCache := nil.
> aTextOrStringOrNil == nil
> ifTrue: [aText := Text new]
> ifFalse: [aText := self class guaranteeSafe:
> aTextOrStringOrNil asText].
> self isOpen
> ifTrue:
> [self triggerEvent: #changing.
> displayContents setCompositionWidth: self wrappingBox
> width.
> displayContents text: aText ]
> ifFalse:
> [displayContents setCompositionWidth: ComposedText
> defaultCompositionWidth.
> displayContents setText: aText].
> self setToTop.
> startBlock := stopBlock := nil.
> selectionShowing := true.
> self controller. "Make sure we have a controller"
> self resetController.
> self changedPreferredBounds: nil.
> self invalidate. "Added"
> self isOpen ifTrue: [self triggerEvent: #changed].
>
>
> On Fri, 22 Jan 2010 13:17:13 +0100, Steven Kelly <[hidden email]>
> wrote:
>
> > Thanks Tomáš, do please publish your change to the public repository.
> > You could update the package comment for 7.7 and add a note that it's
> in
> > the public domain (as Andre said in his original version, see version
> > comment from 0.1).
> >
> > Steve
> >
> >> -----Original Message-----
> >> From: Tomáš Dvořák [mailto:[hidden email]]
> >> Sent: 22 January 2010 10:30
> >> To: Steven Kelly; [hidden email]
> >> Subject: Re: [vwnc] 'Undo' don't work properly.
> >>
> >> So cool! Another step into 20th century :)
> >> I just tested it in 7.7 and it seems to work fine. I just had to add
> a
> >>
> >> self invalidate.
> >>
> >> message send into InputFieldView >> #editText:
> >> just after
> >> self changedPreferredBounds: nil.
> >> (made it look the same as in ComposedTextView >> #editText:) in
> order
> >> to
> >> have input field views redrawn after undo/redo.
> >>
> >> Otherwise, a great improvement. Thank you so much.
> >>
> >> Best regards..
> >>    Tomas Dvorak
> >>
> >> On Thu, 21 Jan 2010 20:27:31 +0100, Steven Kelly
> <[hidden email]>
> >> wrote:
> >>
> >> > Alan's right: that's why the Up and Down cursor keys don't work
> >> either.
> >> > The methods are so short that it's perfectly easy just to press
> Left
> >> or
> >> > Right enough times to get to the previous/next line. It would be
> >> trivial
> >> > to implement, because Smalltalk is so productive, but nobody has
> ever
> >> > wanted it. :-/
> >> >
> >> >
> >> > Back to the real world: Andre Schnoor implemented multi-level undo
> >> for
> >> > VW back in 7.4. With his permission I published it to the public
> >> > repository as TextEditorUndo, and have extended and updated it a
> >> little.
> >> > Current version seems good for 7.6, but VW reserves Ctrl+Y for
> User
> >> > interrupt by default: set it to e.g. F11 with InputState
> >> > interruptKeyValue: #F11.
> >> >
> >> >
> >> > And no, I haven't tested it in 7.7 yet: I too am too busy being
> >> > productive to actually get round to it :-)
> >> >
> >> >
> >> > Steve
> >> >
> >> >
> >> >
> >> > From: [hidden email] [mailto:[hidden email]]
> On
> >> > Behalf Of Alan Knight
> >> > Sent: 21 January 2010 19:09
> >> > To: Kyung-Don Kim
> >> > Cc: [hidden email]
> >> > Subject: Re: [vwnc] 'Undo' don't work properly.
> >> >
> >> >
> >> > The paradigm part of it is that Smalltalk tends to have short
> methods
> >> > and they are edited individually, so the editor does not need to
> be
> >> as
> >> > sophisticated as if you were doing complex or large file editing.
> And
> >> > the regular part is that nobody got around to doing it, at least
> for
> >> > this version of Smalltalk.
> >> >
> >> > At 11:53 AM 2010-01-21, Kyung-Don Kim wrote:
> >> >
> >> >
> >> >
> >> > Thanks.
> >> > I am confusing about visualworks does not have multi-level-text-
> undo
> >> > support.
> >> > It's too inconvenient to me.
> >> > Is it something about smalltalk-ish "PARADIGM"?
> >> > Yes, I'm newbie. I was going crazy due to undo in yesterday.
> >> >
> >> > 2010/1/22 Alan Knight <[hidden email]>
> >> >
> >> > There are two sorts of undo available. One is the text menu undo -
> it
> >> > does not have multi-level support. The other is the undo of IDE
> >> > operations, available via the left and right arrow buttons on the
> >> > browser toolbar. So if you saved or deleted a method and changed
> your
> >> > mind, that would undo it. But it won't help with text operations.
> The
> >> > other undo-ish option available is in things like browse change
> log
> >> and
> >> > method history, which will show you all the saved versions of a
> >> method.
> >> >
> >> >
> >> >
> >> > At 04:52 AM 2010-01-21, Kyung-Don Kim wrote:
> >> >
> >> >
> >> >
> >> > I'm using XP, VW7.7
> >> >
> >> > In IDE, 'Undo' don't work properly.
> >> >
> >> > It don't go back to undo history that It's just switch between
> undo,
> >> > redo.
> >> >
> >> > Does visualworks have undo history?
> >> >
> >> > _______________________________________________
> >> >
> >> > vwnc mailing list
> >> >
> >> > [hidden email]
> >> >
> >> > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
> >> >
> >> >
> >> > --
> >> >
> >> > Alan Knight [|], Engineering Manager, Cincom Smalltalk
> >> >
> >> > [hidden email]
> >> >
> >> > [hidden email]
> >> >
> >> > http://www.cincom.com/smalltalk
> >> >
> >> >
> >> > --
> >> >
> >> > Alan Knight [|], Engineering Manager, Cincom Smalltalk
> >> >
> >> > [hidden email]
> >> >
> >> > [hidden email]
> >> >
> >> > http://www.cincom.com/smalltalk
> >> >
> >>
> >
>


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
Reply | Threaded
Open this post in threaded view
|

Re: 'Undo' don't work properly.

Steven Kelly
Thanks Tomas, I've published 0.7 with this bug fixed and your new select functionality added. My fix hopefully removed the root of the problem, rather than just avoiding the symptom - see the version comment if you want the gory details!

Steve

> -----Original Message-----
> From: Tomáš Dvořák [mailto:[hidden email]]
> Sent: 19 February 2010 14:29
> To: Steven Kelly; [hidden email]
> Cc: Mark Plas
> Subject: Re: [vwnc] 'Undo' don't work properly.
>
> Actually, I made two more changes since our last email.
>
> Firtst, I modified undoRestore to read
>
> TextEditorController >> #undoRestore
> "Resore previously saved text and selection"
> | undoInfo |
> self undoIndex isZero ifTrue:[ ^self ].
> self undoIndex = self undoStack size ifTrue:
> ["Need to save the current state"
> self undoSave.
> undoIndex := self undoStack size - 1].
> undoIndex ifZero: [^self].
> undoInfo := undoStack at: self undoIndex.
> self doRestore: undoInfo.
> undoIndex := self undoIndex - 1.
>
> I cannot reproduce the bug, but it has happened several times to me
> that
> undoIndex was nonzero at the [^self] point, but undoStack was empty.
> The
> UHE that followed was unfortunate.
>
> Second, I added a
>
> selectFrom: start to: stop
> "Make the selection the text from start to stop in the text.
> Make the selection visible."
> typing == true ifTrue: [self undoSave].
> super selectFrom: start to: stop.
>
> This assures, that if you write something, make a selection with shift
> and
> arrows, then start typing again (thus replacing the selection),
> replacing
> the selection is a separate undo action from the text written at the
> beginning.
>
> I don't remember having any problems with this package ever since.
>
> Sorry for not reporting earlier.
> Thank you, best regards,
>    Tomáš Dvořák
>
>
> On Fri, 19 Feb 2010 12:07:18 +0100, Steven Kelly <[hidden email]>
> wrote:
>
> > TextEditorUndo in the public repository now published: a working
> > multi-level undo/redo for VW text widgets in 7.4-7.7. Thanks for the
> > help, Tomáš! And of course a big thanks to Andre Schnoor for the
> > original version back in 1996.
> >
> > See the updated package comment for how to add a Redo key (and how to
> > remap UserInterrupt if you choose Ctrl+Y as Redo).
> >
> > Share and enjoy,
> > Steve
> >
> >> -----Original Message-----
> >> From: Tomáš Dvořák [mailto:[hidden email]]
> >> Sent: 22 January 2010 14:54
> >> To: Steven Kelly
> >> Cc: [hidden email]; [hidden email]
> >> Subject: Re: [vwnc] 'Undo' don't work properly.
> >>
> >> I'm afraid I don't have access to public repository (and don't
> really
> >> want
> >> one). Even worse, it seems that my mails don't make it to the vwnc
> >> mailing
> >> list for some reason, so I probably don't even have a way to inform
> >> others. All I can do is provide informations about the changes I
> made
> >> to
> >> the package. It would be great if you could find a minute to publish
> it.
> >> I
> >> apologize for this ineffective reciprocal delegation, but in this
> case
> >> it
> >> still seems to be the easiest way to get the data to public
> repository.
> >>
> >> Best regards,
> >>    Tomas Dvorak
> >>
> >> Modified comment:
> >> -----------------8<----------
> >> This package adds multiple undo and redo levels to
> TextEditorController.
> >> This package is public domain, original implementation was written
> by
> >> Andre Schnoor (see revision 0.1 comment in public repository).
> >>
> >> Tested with VW 7.4.1, 7.7
> >>
> >> The implementation follows a simple, yet effective approach. There
> is
> >> no
> >> sophisticated notion of different edit actions or the like. Before a
> >> change is applied to the text, a copy of the current text is saved
> to
> >> an
> >> undo stack, along with the current selection indexes. These are
> simply
> >> restored upon "undo". Even larger texts should not impose problems,
> >> given
> >> todays average memory and CPU resources. Series of continous
> character
> >> typing are treated as a single block of action, i.e. "undo" will
> >> restore
> >> the state prior to when typing started. This saves room on the stack
> >> (and
> >> memory footprint) and pretty well suits practical needs. The default
> >> number of undo levels is 64 (may be easily changed).
> >> -----------------8<----------
> >>
> >> InputFieldView >> #editText: aTextOrStringOrNil
> >> "Set the text or string to appear in this input field.  nil
> >> indicates the
> >> field is to be empty."
> >>
> >> | aText |
> >> editTextCache := nil.
> >> aTextOrStringOrNil == nil
> >> ifTrue: [aText := Text new]
> >> ifFalse: [aText := self class guaranteeSafe:
> >> aTextOrStringOrNil asText].
> >> self isOpen
> >> ifTrue:
> >> [self triggerEvent: #changing.
> >> displayContents setCompositionWidth: self wrappingBox
> >> width.
> >> displayContents text: aText ]
> >> ifFalse:
> >> [displayContents setCompositionWidth: ComposedText
> >> defaultCompositionWidth.
> >> displayContents setText: aText].
> >> self setToTop.
> >> startBlock := stopBlock := nil.
> >> selectionShowing := true.
> >> self controller. "Make sure we have a controller"
> >> self resetController.
> >> self changedPreferredBounds: nil.
> >> self invalidate. "Added"
> >> self isOpen ifTrue: [self triggerEvent: #changed].
> >>
> >>
> >> On Fri, 22 Jan 2010 13:17:13 +0100, Steven Kelly
> <[hidden email]>
> >> wrote:
> >>
> >> > Thanks Tomáš, do please publish your change to the public
> repository.
> >> > You could update the package comment for 7.7 and add a note that
> it's
> >> in
> >> > the public domain (as Andre said in his original version, see
> version
> >> > comment from 0.1).
> >> >
> >> > Steve
> >> >
> >> >> -----Original Message-----
> >> >> From: Tomáš Dvořák [mailto:[hidden email]]
> >> >> Sent: 22 January 2010 10:30
> >> >> To: Steven Kelly; [hidden email]
> >> >> Subject: Re: [vwnc] 'Undo' don't work properly.
> >> >>
> >> >> So cool! Another step into 20th century :)
> >> >> I just tested it in 7.7 and it seems to work fine. I just had to
> add
> >> a
> >> >>
> >> >> self invalidate.
> >> >>
> >> >> message send into InputFieldView >> #editText:
> >> >> just after
> >> >> self changedPreferredBounds: nil.
> >> >> (made it look the same as in ComposedTextView >> #editText:) in
> >> order
> >> >> to
> >> >> have input field views redrawn after undo/redo.
> >> >>
> >> >> Otherwise, a great improvement. Thank you so much.
> >> >>
> >> >> Best regards..
> >> >>    Tomas Dvorak
> >> >>
> >> >> On Thu, 21 Jan 2010 20:27:31 +0100, Steven Kelly
> >> <[hidden email]>
> >> >> wrote:
> >> >>
> >> >> > Alan's right: that's why the Up and Down cursor keys don't work
> >> >> either.
> >> >> > The methods are so short that it's perfectly easy just to press
> >> Left
> >> >> or
> >> >> > Right enough times to get to the previous/next line. It would
> be
> >> >> trivial
> >> >> > to implement, because Smalltalk is so productive, but nobody
> has
> >> ever
> >> >> > wanted it. :-/
> >> >> >
> >> >> >
> >> >> > Back to the real world: Andre Schnoor implemented multi-level
> undo
> >> >> for
> >> >> > VW back in 7.4. With his permission I published it to the
> public
> >> >> > repository as TextEditorUndo, and have extended and updated it
> a
> >> >> little.
> >> >> > Current version seems good for 7.6, but VW reserves Ctrl+Y for
> >> User
> >> >> > interrupt by default: set it to e.g. F11 with InputState
> >> >> > interruptKeyValue: #F11.
> >> >> >
> >> >> >
> >> >> > And no, I haven't tested it in 7.7 yet: I too am too busy being
> >> >> > productive to actually get round to it :-)
> >> >> >
> >> >> >
> >> >> > Steve
> >> >> >
> >> >> >
> >> >> >
> >> >> > From: [hidden email] [mailto:[hidden email]]
> >> On
> >> >> > Behalf Of Alan Knight
> >> >> > Sent: 21 January 2010 19:09
> >> >> > To: Kyung-Don Kim
> >> >> > Cc: [hidden email]
> >> >> > Subject: Re: [vwnc] 'Undo' don't work properly.
> >> >> >
> >> >> >
> >> >> > The paradigm part of it is that Smalltalk tends to have short
> >> methods
> >> >> > and they are edited individually, so the editor does not need
> to
> >> be
> >> >> as
> >> >> > sophisticated as if you were doing complex or large file
> editing.
> >> And
> >> >> > the regular part is that nobody got around to doing it, at
> least
> >> for
> >> >> > this version of Smalltalk.
> >> >> >
> >> >> > At 11:53 AM 2010-01-21, Kyung-Don Kim wrote:
> >> >> >
> >> >> >
> >> >> >
> >> >> > Thanks.
> >> >> > I am confusing about visualworks does not have multi-level-
> text-
> >> undo
> >> >> > support.
> >> >> > It's too inconvenient to me.
> >> >> > Is it something about smalltalk-ish "PARADIGM"?
> >> >> > Yes, I'm newbie. I was going crazy due to undo in yesterday.
> >> >> >
> >> >> > 2010/1/22 Alan Knight <[hidden email]>
> >> >> >
> >> >> > There are two sorts of undo available. One is the text menu
> undo -
> >> it
> >> >> > does not have multi-level support. The other is the undo of IDE
> >> >> > operations, available via the left and right arrow buttons on
> the
> >> >> > browser toolbar. So if you saved or deleted a method and
> changed
> >> your
> >> >> > mind, that would undo it. But it won't help with text
> operations.
> >> The
> >> >> > other undo-ish option available is in things like browse change
> >> log
> >> >> and
> >> >> > method history, which will show you all the saved versions of a
> >> >> method.
> >> >> >
> >> >> >
> >> >> >
> >> >> > At 04:52 AM 2010-01-21, Kyung-Don Kim wrote:
> >> >> >
> >> >> >
> >> >> >
> >> >> > I'm using XP, VW7.7
> >> >> >
> >> >> > In IDE, 'Undo' don't work properly.
> >> >> >
> >> >> > It don't go back to undo history that It's just switch between
> >> undo,
> >> >> > redo.
> >> >> >
> >> >> > Does visualworks have undo history?
> >> >> >
> >> >> > _______________________________________________
> >> >> >
> >> >> > vwnc mailing list
> >> >> >
> >> >> > [hidden email]
> >> >> >
> >> >> > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc
> >> >> >
> >> >> >
> >> >> > --
> >> >> >
> >> >> > Alan Knight [|], Engineering Manager, Cincom Smalltalk
> >> >> >
> >> >> > [hidden email]
> >> >> >
> >> >> > [hidden email]
> >> >> >
> >> >> > http://www.cincom.com/smalltalk
> >> >> >
> >> >> >
> >> >> > --
> >> >> >
> >> >> > Alan Knight [|], Engineering Manager, Cincom Smalltalk
> >> >> >
> >> >> > [hidden email]
> >> >> >
> >> >> > [hidden email]
> >> >> >
> >> >> > http://www.cincom.com/smalltalk
> >> >> >
> >> >>
> >> >
> >>
> >
>
>
> --
> Tomáš Dvořák
> .......................................................
> e-FRACTAL s.r.o. - place where projects grow
> Vinohradská 1597/174, 130 00 Praha 3, www.e-fractal.cz
> tel: +420 222 523 000, fax: +420 222 524 060
> .......................................................


_______________________________________________
vwnc mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/vwnc