Merge branch 'hotfix-1.3' into develop
This commit is contained in:
@@ -53,7 +53,7 @@ namespace nana{ namespace widgets
|
||||
return cmd_;
|
||||
}
|
||||
|
||||
virtual bool merge(const undoable_command_interface<EnumCommand>& rhs) override
|
||||
virtual bool merge(const undoable_command_interface<EnumCommand>&) override
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -273,8 +273,8 @@ namespace nana{ namespace widgets
|
||||
: editor_(editor)
|
||||
{}
|
||||
|
||||
void merge_lines(std::size_t first, std::size_t second) override{}
|
||||
void add_lines(std::size_t pos, std::size_t lines) override{}
|
||||
void merge_lines(std::size_t, std::size_t) override{}
|
||||
void add_lines(std::size_t, std::size_t) override{}
|
||||
void pre_calc_line(std::size_t, unsigned) override{}
|
||||
void pre_calc_lines(unsigned) override{}
|
||||
|
||||
@@ -283,12 +283,12 @@ namespace nana{ namespace widgets
|
||||
return editor_.textbase_.lines();
|
||||
}
|
||||
|
||||
std::size_t take_lines(std::size_t pos) const override
|
||||
std::size_t take_lines(std::size_t) const override
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
void update_line(std::size_t textline, std::size_t secondary_before) override
|
||||
void update_line(std::size_t textline, std::size_t) override
|
||||
{
|
||||
int top = editor_._m_text_top_base() + static_cast<int>(editor_.line_height() * (textline - editor_.points_.offset.y));
|
||||
editor_.graph_.rectangle({ editor_.text_area_.area.x, top, editor_.text_area_.area.width, editor_.line_height() }, true, API::bgcolor(editor_.window_));
|
||||
@@ -1294,7 +1294,6 @@ namespace nana{ namespace widgets
|
||||
select_.move_to_end = false;
|
||||
select_.mode_selection = selection::mode::no_selected;
|
||||
select_.ignore_press = false;
|
||||
select_.dragged = false;
|
||||
|
||||
API::create_caret(wd, 1, line_height());
|
||||
API::bgcolor(wd, colors::white);
|
||||
@@ -1693,13 +1692,10 @@ namespace nana{ namespace widgets
|
||||
|
||||
if(left_button)
|
||||
{
|
||||
auto caret_pos_before = caret();
|
||||
mouse_caret(scrpos);
|
||||
|
||||
if(select_.mode_selection != selection::mode::no_selected)
|
||||
if (selection::mode::mouse_selected == select_.mode_selection || selection::mode::method_selected == select_.mode_selection)
|
||||
set_end_caret();
|
||||
else if ((!select_.dragged) && (caret_pos_before != caret()))
|
||||
select_.dragged = true;
|
||||
|
||||
text_area_.border_renderer(graph_, _m_bgcolor());
|
||||
return true;
|
||||
@@ -1722,26 +1718,34 @@ namespace nana{ namespace widgets
|
||||
API::set_capture(window_, true);
|
||||
text_area_.captured = true;
|
||||
|
||||
//Set caret pos by screen point and get the caret pos.
|
||||
mouse_caret(arg.pos);
|
||||
if (arg.shift)
|
||||
|
||||
if (this->hit_select_area(behavior_->screen_to_caret(arg.pos), true))
|
||||
{
|
||||
if (points_.shift_begin_caret != points_.caret)
|
||||
{
|
||||
select_.a = points_.shift_begin_caret;
|
||||
select_.b = points_.caret;
|
||||
}
|
||||
select_.mode_selection = selection::mode::move_selected;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!select(false))
|
||||
//Set caret pos by screen point and get the caret pos.
|
||||
mouse_caret(arg.pos);
|
||||
if (arg.shift)
|
||||
{
|
||||
select_.a = points_.caret; //Set begin caret
|
||||
set_end_caret();
|
||||
if (points_.shift_begin_caret != points_.caret)
|
||||
{
|
||||
select_.a = points_.shift_begin_caret;
|
||||
select_.b = points_.caret;
|
||||
}
|
||||
}
|
||||
points_.shift_begin_caret = points_.caret;
|
||||
else
|
||||
{
|
||||
if (!select(false))
|
||||
{
|
||||
select_.a = points_.caret; //Set begin caret
|
||||
set_end_caret();
|
||||
}
|
||||
points_.shift_begin_caret = points_.caret;
|
||||
}
|
||||
select_.mode_selection = selection::mode::mouse_selected;
|
||||
}
|
||||
select_.mode_selection = selection::mode::mouse_selected;
|
||||
}
|
||||
|
||||
text_area_.border_renderer(graph_, _m_bgcolor());
|
||||
@@ -1750,19 +1754,19 @@ namespace nana{ namespace widgets
|
||||
else if (event_code::mouse_up == arg.evt_code)
|
||||
{
|
||||
select_.ignore_press = false;
|
||||
auto is_prev_no_selected = (select_.mode_selection == selection::mode::no_selected);
|
||||
bool updated = false;
|
||||
|
||||
if (select_.mode_selection == selection::mode::mouse_selected)
|
||||
{
|
||||
select_.mode_selection = selection::mode::no_selected;
|
||||
set_end_caret();
|
||||
}
|
||||
else if (is_prev_no_selected)
|
||||
else if (selection::mode::move_selected == select_.mode_selection)
|
||||
{
|
||||
if ((!select_.dragged) || (!move_select()))
|
||||
if (!move_select())
|
||||
select(false);
|
||||
updated = true;
|
||||
}
|
||||
select_.dragged = false;
|
||||
|
||||
API::release_capture(window_);
|
||||
|
||||
@@ -1772,8 +1776,7 @@ namespace nana{ namespace widgets
|
||||
|
||||
text_area_.border_renderer(graph_, _m_bgcolor());
|
||||
|
||||
//Redraw if is_prev_no_selected is true
|
||||
return is_prev_no_selected;
|
||||
return updated;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1913,11 +1916,21 @@ namespace nana{ namespace widgets
|
||||
return ((text_area_.area.x <= pos.x && pos.x < _m_end_pos(true)) && (text_area_.area.y <= pos.y && pos.y < _m_end_pos(false)));
|
||||
}
|
||||
|
||||
bool text_editor::hit_select_area(nana::upoint pos) const
|
||||
bool text_editor::hit_select_area(nana::upoint pos, bool ignore_when_select_all) const
|
||||
{
|
||||
nana::upoint a, b;
|
||||
if(_m_get_sort_select_points(a, b))
|
||||
{
|
||||
if (ignore_when_select_all)
|
||||
{
|
||||
if (a.x == 0 && a.y == 0 && (b.y + 1) == static_cast<unsigned>(textbase_.lines()))
|
||||
{
|
||||
//is select all
|
||||
if (b.x == static_cast<unsigned>(textbase_.getline(b.y).size()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if((pos.y > a.y || (pos.y == a.y && pos.x >= a.x)) && ((pos.y < b.y) || (pos.y == b.y && pos.x < b.x)))
|
||||
return true;
|
||||
}
|
||||
@@ -1926,7 +1939,10 @@ namespace nana{ namespace widgets
|
||||
|
||||
bool text_editor::move_select()
|
||||
{
|
||||
if(hit_select_area(points_.caret) || (select_.b == points_.caret))
|
||||
if (! attributes_.editable)
|
||||
return false;
|
||||
|
||||
if(hit_select_area(points_.caret, true) || (select_.b == points_.caret))
|
||||
{
|
||||
points_.caret = select_.b;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user