BalazsJako / ImGuiColorTextEdit

Colorizing text editor for ImGui
MIT License
1.44k stars 242 forks source link

Proposal : First version of an ExternalUndoBufferInterface #112

Open berdal84 opened 4 years ago

berdal84 commented 4 years ago

Hello,

First draft version of an external undo buffer interface.

The concept is simple, this interface consists on a single method that can receive an UndoRecord& as ar gument. This method is called only if the TextEditor as an mExternalUndoRecordBuffer not null.

I had to set public a lot of your classes: UndoRecord, EditorState and the type UndoBuffer.

I choose to modify as less possible things, but I think it should be better to introduce a boolean to says is undobuffer is internal or external and then use that boolean to avoid all internal undo/redo stuff.

I don't really know why UndoRecord.Undo() takes a TextEditor pointer. Is is to avoid to store it in each Record ?

Let me know your impressions about my proposal.

Cheers

berdal84 commented 4 years ago

I just added a fix in InsertText public method to add an UndoRecord. From outside of a TextEditor I was unable to undo a text insertion.

berdal84 commented 4 years ago

What do you think of my proposal @BalazsJako ?