Add wxTextCtrl::EmptyUndoBuffer()

This is implemented for multi-line controls under macOS only currently.
This commit is contained in:
Dan Korn
2021-08-18 23:14:14 +02:00
committed by Vadim Zeitlin
parent 9b27eaad43
commit 3c9bb69d6e
10 changed files with 37 additions and 1 deletions

View File

@@ -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();

View File

@@ -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 ;

View File

@@ -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;

View File

@@ -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;

View File

@@ -81,6 +81,8 @@ public:
virtual bool CanUndo() const = 0;
virtual bool CanRedo() const = 0;
virtual void EmptyUndoBuffer() { }
// insertion point
// ---------------

View File

@@ -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.

View File

@@ -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 )

View File

@@ -700,6 +700,10 @@ void wxTextWidgetImpl::Redo()
{
}
void wxTextWidgetImpl::EmptyUndoBuffer()
{
}
long wxTextWidgetImpl::XYToPosition(long WXUNUSED(x), long WXUNUSED(y)) const
{
return 0 ;

View File

@@ -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<wxTextEntry *>(this)->GetEditableWindow();

View File

@@ -1094,6 +1094,7 @@ overrideNeeded = (
'CanPaste',
'CanRedo',
'CanUndo',
'EmptyUndoBuffer',
'Clear',
'AppendText',
)