* * *

Author Topic: Undo, Redo  (Read 294 times)

jcmontherock

  • New member
  • *
  • Posts: 9
Undo, Redo
« on: February 14, 2018, 05:14:25 pm »
Could you add a public function into TCustomSynEdit to know the entry number of UndoList, like:

result := fUndoList.RealCount;

It will be very usefull to know, if we have to save the edited file or not.

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 719
    • Burdjia
Re: Undo, Redo
« Reply #1 on: February 14, 2018, 06:07:32 pm »
To know if you have to save the text, use the "Modified" property instead:

Code: Pascal  [Select]
  1. IF MyEditor.Modified THEN
  2.   MyEditor.Lines.SaveToFile (FileName);
  3.  
Are you interested in game programming? Join the Pascal Game Development community!

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 4471
    • wiki
Re: Undo, Redo
« Reply #2 on: February 14, 2018, 09:07:30 pm »
undo count would not fully solve the modified issue.

Imagine this case:

1) load file
2) edit / maybe 5 undo entries
3) save (0 undo, not modified)
4) edit / add 2 undo entries
5) perform undo twice.
  0 undo, not modified, 2 redo
6) perform one more undo.
  0 undo, but modified, 3 redo

You also can not determine, if you are back to the very original version you loaded in step1.
Undo list is limited, after reaching capacity old entries are discarded.

1) load file
2) edit / add more undo entries than capacity
3) undo all existing entries
 since some undo got discarded, you are still not back to 1


That said, there may be other reason for exposing the count.
You can add a feature request on our bug tracker.  But it will not be any time soon.
Patches welcome, but a test case should be included. (simulating with/without grouped undo / mixing undo and redo / ...)
« Last Edit: February 14, 2018, 09:11:31 pm by Martin_fr »

jcmontherock

  • New member
  • *
  • Posts: 9
Re: Undo, Redo
« Reply #3 on: February 14, 2018, 11:05:57 pm »
I will use SynEdit1.Modified. Thanks to everybody.

 

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads Open Hub project report for Lazarus