Merge branch 'hotfix-1.4' of https://github.com/PeterAddy960/nana into PeterAddy960-hotfix-1.4
This commit is contained in:
@@ -1574,7 +1574,8 @@ namespace nana{ namespace widgets
|
||||
_m_handle_move_key(arg);
|
||||
break;
|
||||
case keyboard::os_del:
|
||||
if (this->attr().editable)
|
||||
// send delete to set_accept function
|
||||
if (this->attr().editable && (!impl_->capacities.pred_acceptive || impl_->capacities.pred_acceptive(key)))
|
||||
del();
|
||||
break;
|
||||
default:
|
||||
@@ -1746,6 +1747,13 @@ namespace nana{ namespace widgets
|
||||
return impl_->undo.max_steps();
|
||||
}
|
||||
|
||||
void text_editor::clear_undo()
|
||||
{
|
||||
auto size = impl_->undo.max_steps();
|
||||
impl_->undo.max_steps(0);
|
||||
impl_->undo.max_steps(size);
|
||||
}
|
||||
|
||||
auto text_editor::customized_renderers() -> renderers&
|
||||
{
|
||||
return impl_->customized_renderers;
|
||||
@@ -2065,6 +2073,25 @@ namespace nana{ namespace widgets
|
||||
return (select_.a != select_.b);
|
||||
}
|
||||
|
||||
bool text_editor::get_selected_points(nana::upoint &a, nana::upoint &b) const
|
||||
{
|
||||
if (select_.a == select_.b)
|
||||
return false;
|
||||
|
||||
if (select_.a < select_.b)
|
||||
{
|
||||
a = select_.a;
|
||||
b = select_.b;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = select_.b;
|
||||
b = select_.a;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void text_editor::set_end_caret()
|
||||
{
|
||||
bool new_sel_end = (select_.b != points_.caret);
|
||||
@@ -2097,25 +2124,6 @@ namespace nana{ namespace widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
bool text_editor::get_select_points(nana::upoint& a, nana::upoint& b) const
|
||||
{
|
||||
if (select_.a == select_.b)
|
||||
return false;
|
||||
|
||||
if (select_.a < select_.b)
|
||||
{
|
||||
a = select_.a;
|
||||
b = select_.b;
|
||||
}
|
||||
else
|
||||
{
|
||||
a = select_.b;
|
||||
b = select_.a;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool text_editor::hit_text_area(const point& pos) const
|
||||
{
|
||||
return _m_text_area().is_hit(pos);
|
||||
@@ -2124,7 +2132,7 @@ namespace nana{ namespace widgets
|
||||
bool text_editor::hit_select_area(nana::upoint pos, bool ignore_when_select_all) const
|
||||
{
|
||||
nana::upoint a, b;
|
||||
if(get_select_points(a, b))
|
||||
if (get_selected_points(a, b))
|
||||
{
|
||||
if (ignore_when_select_all)
|
||||
{
|
||||
@@ -3046,7 +3054,7 @@ namespace nana{ namespace widgets
|
||||
nana::upoint text_editor::_m_erase_select()
|
||||
{
|
||||
nana::upoint a, b;
|
||||
if (get_select_points(a, b))
|
||||
if (get_selected_points(a, b))
|
||||
{
|
||||
auto & textbase = this->textbase();
|
||||
if(a.y != b.y)
|
||||
@@ -3077,7 +3085,7 @@ namespace nana{ namespace widgets
|
||||
std::wstring text;
|
||||
|
||||
nana::upoint a, b;
|
||||
if (get_select_points(a, b))
|
||||
if (get_selected_points(a, b))
|
||||
{
|
||||
auto & textbase = this->textbase();
|
||||
if (a.y != b.y)
|
||||
@@ -3168,7 +3176,7 @@ namespace nana{ namespace widgets
|
||||
bool text_editor::_m_cancel_select(int align)
|
||||
{
|
||||
nana::upoint a, b;
|
||||
if (get_select_points(a, b))
|
||||
if (get_selected_points(a, b))
|
||||
{
|
||||
switch(align)
|
||||
{
|
||||
@@ -3263,7 +3271,7 @@ namespace nana{ namespace widgets
|
||||
const bool at_left = (select_.b < select_.a);
|
||||
|
||||
nana::upoint a, b;
|
||||
get_select_points(a, b);
|
||||
get_selected_points(a, b);
|
||||
if (caret.y < a.y || (caret.y == a.y && caret.x < a.x))
|
||||
{//forward
|
||||
undo_ptr->set_caret_pos();
|
||||
@@ -3459,7 +3467,7 @@ namespace nana{ namespace widgets
|
||||
const wchar_t *sbegin = nullptr, *send = nullptr;
|
||||
|
||||
nana::upoint a, b;
|
||||
if (get_select_points(a, b))
|
||||
if (get_selected_points(a, b))
|
||||
{
|
||||
if (a.y < text_coord.y && text_coord.y < b.y)
|
||||
{
|
||||
|
||||
@@ -322,6 +322,25 @@ namespace drawerbase {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool textbox::getline(std::size_t line_index,std::size_t start_point,std::string& text) const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if(editor)
|
||||
{
|
||||
std::wstring line_text;
|
||||
if(editor->getline(line_index,line_text))
|
||||
{
|
||||
if(line_text.length() >= start_point)
|
||||
{
|
||||
text = to_utf8(line_text.substr(start_point));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Gets the caret position
|
||||
bool textbox::caret_pos(point& pos, bool text_coordinate) const
|
||||
{
|
||||
@@ -464,6 +483,13 @@ namespace drawerbase {
|
||||
return (editor ? editor->selected() : false);
|
||||
}
|
||||
|
||||
bool textbox::get_selected_points(nana::upoint &a, nana::upoint &b) const
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
return (editor ? editor->get_selected_points(a, b) : false);
|
||||
}
|
||||
|
||||
void textbox::select(bool yes)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
@@ -479,7 +505,7 @@ namespace drawerbase {
|
||||
internal_scope_guard lock;
|
||||
auto editor = get_drawer_trigger().editor();
|
||||
if (editor)
|
||||
editor->get_select_points(points.first, points.second);
|
||||
editor->get_selected_points(points.first, points.second);
|
||||
|
||||
return points;
|
||||
}
|
||||
@@ -542,6 +568,11 @@ namespace drawerbase {
|
||||
return *this;
|
||||
}
|
||||
|
||||
void textbox::clear_undo()
|
||||
{
|
||||
get_drawer_trigger().editor()->clear_undo();
|
||||
}
|
||||
|
||||
void textbox::set_highlight(const std::string& name, const ::nana::color& fgcolor, const ::nana::color& bgcolor)
|
||||
{
|
||||
internal_scope_guard lock;
|
||||
|
||||
Reference in New Issue
Block a user