mirror of
https://github.com/fltk/fltk.git
synced 2026-05-18 00:05:33 +08:00
Fixed leak in Fl_Text_Buffer #716
This commit is contained in:
+17
-1
@@ -327,13 +327,29 @@ public:
|
||||
*/
|
||||
int undo(int *cp=0);
|
||||
|
||||
/**
|
||||
Check if undo is anabled and if the last action can be undone.
|
||||
\see canUndo()
|
||||
*/
|
||||
bool can_undo();
|
||||
|
||||
/**
|
||||
Redo previous undo action.
|
||||
*/
|
||||
int redo(int *cp=0);
|
||||
|
||||
/**
|
||||
Lets the undo system know if we can undo changes
|
||||
Check if undo is anabled and if the last undo action can be redone.
|
||||
\see canUndo()
|
||||
*/
|
||||
bool can_redo();
|
||||
|
||||
/**
|
||||
Enable or disable undo actions for this text buffer.
|
||||
Undo actions are enable for text buffer by default. If used as a style buffer
|
||||
in Fl_Text_Display, undo actions are disabled as they are handled by the
|
||||
text buffer.
|
||||
\see can_undo()
|
||||
*/
|
||||
void canUndo(char flag=1);
|
||||
|
||||
|
||||
+23
-1
@@ -158,6 +158,10 @@ public:
|
||||
clear();
|
||||
}
|
||||
|
||||
int size() {
|
||||
return list_size_;
|
||||
}
|
||||
|
||||
void push(Fl_Text_Undo_Action* action) {
|
||||
if (list_size_ == list_capacity_) {
|
||||
list_capacity_ += 25;
|
||||
@@ -628,6 +632,13 @@ int Fl_Text_Buffer::undo(int *cursorPos) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
Check if undo is anabled and if the last action can be undone.
|
||||
*/
|
||||
bool Fl_Text_Buffer::can_undo() {
|
||||
return (mCanUndo && mUndo && !mUndo->empty());
|
||||
}
|
||||
|
||||
/**
|
||||
Redo previous undo action.
|
||||
*/
|
||||
@@ -642,7 +653,18 @@ int Fl_Text_Buffer::redo(int *cursorPos) {
|
||||
// running the redo action will also generate a new undo action
|
||||
// Note: there is a slight chance that the current undo action and the
|
||||
// generated action merge into one.
|
||||
return apply_undo(redo_action, cursorPos);
|
||||
int ret = apply_undo(redo_action, cursorPos);
|
||||
|
||||
delete redo_action;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
Check if undo is anabled and if the last undo action can be redone.
|
||||
\see canUndo()
|
||||
*/
|
||||
bool Fl_Text_Buffer::can_redo() {
|
||||
return (mCanUndo && mRedoList->size());
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -442,8 +442,6 @@ void Fl_Text_Display::highlight_data(Fl_Text_Buffer *styleBuffer,
|
||||
damage(FL_DAMAGE_EXPOSE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
\brief Find the longest line of all visible lines.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user