Improve the "double click word selection" method of textbox to follow some other rules other than white space.
This commit is contained in:
parent
7651b430eb
commit
64bd9b7491
@ -25,7 +25,8 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace nana{ namespace widgets
|
namespace nana {
|
||||||
|
namespace widgets
|
||||||
{
|
{
|
||||||
namespace skeletons
|
namespace skeletons
|
||||||
{
|
{
|
||||||
@ -1632,14 +1633,20 @@ namespace nana{ namespace widgets
|
|||||||
select_.a = select_.b = points_.caret;
|
select_.a = select_.b = points_.caret;
|
||||||
const auto& line = impl_->textbase.getline(select_.b.y);
|
const auto& line = impl_->textbase.getline(select_.b.y);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (select_.a.x < line.size() && !std::isalnum(line[select_.a.x]) && line[select_.a.x] != '_') {
|
||||||
|
++select_.b.x;
|
||||||
|
}
|
||||||
|
else {
|
||||||
// Expand the selection forward to the word's end.
|
// Expand the selection forward to the word's end.
|
||||||
while (select_.b.x < line.size() && !std::iswspace(line[select_.b.x]))
|
while (select_.b.x < line.size() && !std::iswspace(line[select_.b.x]) && (std::isalnum(line[select_.b.x]) || line[select_.b.x] == '_'))
|
||||||
++select_.b.x;
|
++select_.b.x;
|
||||||
|
|
||||||
// Expand the selection backward to the word's start.
|
// Expand the selection backward to the word's start.
|
||||||
while (select_.a.x > 0 && !std::iswspace(line[select_.a.x - 1]))
|
while (select_.a.x > 0 && !std::iswspace(line[select_.a.x - 1]) && (std::isalnum(line[select_.a.x - 1]) || line[select_.a.x - 1] == '_'))
|
||||||
--select_.a.x;
|
--select_.a.x;
|
||||||
|
}
|
||||||
select_.mode_selection = selection::mode::method_selected;
|
select_.mode_selection = selection::mode::method_selected;
|
||||||
impl_->try_refresh = sync_graph::refresh;
|
impl_->try_refresh = sync_graph::refresh;
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user