Recent

Author Topic: Undo, Redo  (Read 5926 times)

jcmontherock

  • Full Member
  • ***
  • Posts: 234
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.
Windows 11 UTF8-64 - Lazarus 3.2-64 - FPC 3.2.2

Ñuño_Martínez

  • Hero Member
  • *****
  • Posts: 1186
    • 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!
Also visit the Game Development Portal

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 9794
  • Debugger - SynEdit - and more
    • 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

  • Full Member
  • ***
  • Posts: 234
Re: Undo, Redo
« Reply #3 on: February 14, 2018, 11:05:57 pm »
I will use SynEdit1.Modified. Thanks to everybody.
Windows 11 UTF8-64 - Lazarus 3.2-64 - FPC 3.2.2

 

TinyPortal © 2005-2018