add textbox::set_undo_queue_length
a new method for setting the undo queue length
This commit is contained in:
parent
74e113b2cc
commit
c916d0ace3
@ -52,7 +52,15 @@ namespace nana{ namespace widgets
|
|||||||
{
|
{
|
||||||
max_steps_ = maxs;
|
max_steps_ = maxs;
|
||||||
if (maxs && (commands_.size() >= maxs))
|
if (maxs && (commands_.size() >= maxs))
|
||||||
|
{
|
||||||
|
auto move = commands_.size() - pos_;
|
||||||
commands_.erase(commands_.begin(), commands_.begin() + (commands_.size() - maxs + 1));
|
commands_.erase(commands_.begin(), commands_.begin() + (commands_.size() - maxs + 1));
|
||||||
|
pos_ = commands_.size() - std::min(move, commands_.size());
|
||||||
|
}
|
||||||
|
else if (0 == maxs)
|
||||||
|
{
|
||||||
|
clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t max_steps() const
|
std::size_t max_steps() const
|
||||||
@ -258,6 +266,7 @@ namespace nana{ namespace widgets
|
|||||||
void del();
|
void del();
|
||||||
void backspace(bool record_undo = true);
|
void backspace(bool record_undo = true);
|
||||||
void undo(bool reverse);
|
void undo(bool reverse);
|
||||||
|
void set_undo_queue_length(std::size_t len);
|
||||||
void move_ns(bool to_north); //Moves up and down
|
void move_ns(bool to_north); //Moves up and down
|
||||||
void move_left();
|
void move_left();
|
||||||
void move_right();
|
void move_right();
|
||||||
|
@ -228,6 +228,12 @@ namespace nana
|
|||||||
/// E.g. Whether caret moves to left of selected content or moves to left of last position when left arrow key is pressed.
|
/// E.g. Whether caret moves to left of selected content or moves to left of last position when left arrow key is pressed.
|
||||||
/// @param move_to_end determines whether to move caret to left of selected_content or to left of last position.
|
/// @param move_to_end determines whether to move caret to left of selected_content or to left of last position.
|
||||||
void select_behavior(bool move_to_end);
|
void select_behavior(bool move_to_end);
|
||||||
|
|
||||||
|
/// Sets the undo/redo queue length
|
||||||
|
/**
|
||||||
|
* @param len The length of the queue. If this parameter is zero, the undo/redo is disabled.
|
||||||
|
*/
|
||||||
|
void set_undo_queue_length(std::size_t len);
|
||||||
protected:
|
protected:
|
||||||
//Overrides widget's virtual functions
|
//Overrides widget's virtual functions
|
||||||
native_string_type _m_caption() const throw() override;
|
native_string_type _m_caption() const throw() override;
|
||||||
|
@ -2348,6 +2348,11 @@ namespace nana{ namespace widgets
|
|||||||
_m_scrollbar();
|
_m_scrollbar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void text_editor::set_undo_queue_length(std::size_t len)
|
||||||
|
{
|
||||||
|
undo_.max_steps(len);
|
||||||
|
}
|
||||||
|
|
||||||
void text_editor::move_ns(bool to_north)
|
void text_editor::move_ns(bool to_north)
|
||||||
{
|
{
|
||||||
const bool redraw_required = _m_cancel_select(0);
|
const bool redraw_required = _m_cancel_select(0);
|
||||||
|
@ -606,6 +606,14 @@ namespace drawerbase {
|
|||||||
editor->select_behavior(move_to_end);
|
editor->select_behavior(move_to_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void textbox::set_undo_queue_length(std::size_t len)
|
||||||
|
{
|
||||||
|
internal_scope_guard lock;
|
||||||
|
auto editor = get_drawer_trigger().editor();
|
||||||
|
if (editor)
|
||||||
|
editor->set_undo_queue_length(len);
|
||||||
|
}
|
||||||
|
|
||||||
//Override _m_caption for caption()
|
//Override _m_caption for caption()
|
||||||
auto textbox::_m_caption() const throw() -> native_string_type
|
auto textbox::_m_caption() const throw() -> native_string_type
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user