diff --git a/include/wx/osx/cocoa/private/textimpl.h b/include/wx/osx/cocoa/private/textimpl.h index bae8f8aa56..c96cb52944 100644 --- a/include/wx/osx/cocoa/private/textimpl.h +++ b/include/wx/osx/cocoa/private/textimpl.h @@ -140,6 +140,7 @@ public: virtual void Undo() wxOVERRIDE; virtual bool CanRedo() const wxOVERRIDE; virtual void Redo() wxOVERRIDE; + virtual void EmptyUndoBuffer() wxOVERRIDE; protected: void DoUpdateTextStyle(); diff --git a/include/wx/osx/core/private.h b/include/wx/osx/core/private.h index 1c21fae66c..d32434c800 100644 --- a/include/wx/osx/core/private.h +++ b/include/wx/osx/core/private.h @@ -730,6 +730,7 @@ public : virtual void Undo() ; virtual bool CanRedo() const; virtual void Redo() ; + virtual void EmptyUndoBuffer() ; virtual int GetNumberOfLines() const ; virtual long XYToPosition(long x, long y) const; virtual bool PositionToXY(long pos, long *x, long *y) const ; diff --git a/include/wx/osx/textentry.h b/include/wx/osx/textentry.h index 4a563a29db..14b795eed6 100644 --- a/include/wx/osx/textentry.h +++ b/include/wx/osx/textentry.h @@ -72,6 +72,8 @@ public: virtual bool CanUndo() const wxOVERRIDE; virtual bool CanRedo() const wxOVERRIDE; + virtual void EmptyUndoBuffer() wxOVERRIDE; + // Insertion point virtual void SetInsertionPoint(long pos) wxOVERRIDE; virtual void SetInsertionPointEnd() wxOVERRIDE; diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index df2a3f23bc..e165d730cd 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -3642,7 +3642,7 @@ public: bool CanUndo() const wxOVERRIDE; // Delete the undo history. - void EmptyUndoBuffer(); + void EmptyUndoBuffer() wxOVERRIDE; // Undo one action in the undo history. void Undo() wxOVERRIDE; diff --git a/include/wx/textentry.h b/include/wx/textentry.h index 0f8a6bcbd9..ed46d9b5ca 100644 --- a/include/wx/textentry.h +++ b/include/wx/textentry.h @@ -81,6 +81,8 @@ public: virtual bool CanUndo() const = 0; virtual bool CanRedo() const = 0; + virtual void EmptyUndoBuffer() { } + // insertion point // --------------- diff --git a/interface/wx/textentry.h b/interface/wx/textentry.h index 989f61ba3b..30ca009949 100644 --- a/interface/wx/textentry.h +++ b/interface/wx/textentry.h @@ -165,6 +165,16 @@ public: */ virtual bool CanUndo() const; + /** + Delete the undo history. + + Currently only implemented under macOS and only for multiline text + controls, does nothing in the other ports. + + @since 3.1.6 + */ + virtual void EmptyUndoBuffer(); + /** Sets the new text control value. diff --git a/src/osx/cocoa/textctrl.mm b/src/osx/cocoa/textctrl.mm index 3b8a92c671..b8bab36b96 100644 --- a/src/osx/cocoa/textctrl.mm +++ b/src/osx/cocoa/textctrl.mm @@ -1070,6 +1070,14 @@ void wxNSTextViewControl::Redo() [m_undoManager redo]; } +void wxNSTextViewControl::EmptyUndoBuffer() +{ + if ( !m_undoManager ) + return; + + [m_undoManager removeAllActions]; +} + void wxNSTextViewControl::DoUpdateTextStyle() { if ( m_useCharWrapping ) diff --git a/src/osx/textctrl_osx.cpp b/src/osx/textctrl_osx.cpp index 98f5950844..3a47d55b45 100644 --- a/src/osx/textctrl_osx.cpp +++ b/src/osx/textctrl_osx.cpp @@ -700,6 +700,10 @@ void wxTextWidgetImpl::Redo() { } +void wxTextWidgetImpl::EmptyUndoBuffer() +{ +} + long wxTextWidgetImpl::XYToPosition(long WXUNUSED(x), long WXUNUSED(y)) const { return 0 ; diff --git a/src/osx/textentry_osx.cpp b/src/osx/textentry_osx.cpp index f0b58ab524..4a971aadf0 100644 --- a/src/osx/textentry_osx.cpp +++ b/src/osx/textentry_osx.cpp @@ -293,6 +293,13 @@ bool wxTextEntry::CanRedo() const return GetTextPeer()->CanRedo() ; } +void wxTextEntry::EmptyUndoBuffer() +{ + wxCHECK_RET( GetTextPeer(), "Must create the control first" ); + + return GetTextPeer()->EmptyUndoBuffer() ; +} + wxTextWidgetImpl * wxTextEntry::GetTextPeer() const { wxWindow * const win = const_cast(this)->GetEditableWindow(); diff --git a/src/stc/gen_iface.py b/src/stc/gen_iface.py index d55b2cb703..db88540bfd 100755 --- a/src/stc/gen_iface.py +++ b/src/stc/gen_iface.py @@ -1094,6 +1094,7 @@ overrideNeeded = ( 'CanPaste', 'CanRedo', 'CanUndo', + 'EmptyUndoBuffer', 'Clear', 'AppendText', )