fix bug where textbox highlight fails
This commit is contained in:
parent
4e425d1d8d
commit
1be4b4e667
@ -948,11 +948,13 @@ namespace nana{ namespace widgets
|
|||||||
class text_editor::keyword_parser
|
class text_editor::keyword_parser
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void parse(const std::wstring& text, const implementation::inner_keywords& keywords)
|
void parse(const wchar_t* c_str, std::size_t len, implementation::inner_keywords& keywords) //need string_view
|
||||||
{
|
{
|
||||||
if ( keywords.base.empty() || text.empty() )
|
if ( keywords.base.empty() || (0 == len) || (*c_str == 0) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
std::wstring text{ c_str, len };
|
||||||
|
|
||||||
using index = std::wstring::size_type;
|
using index = std::wstring::size_type;
|
||||||
|
|
||||||
std::vector<entity> entities;
|
std::vector<entity> entities;
|
||||||
@ -987,7 +989,7 @@ namespace nana{ namespace widgets
|
|||||||
{
|
{
|
||||||
entities.emplace_back();
|
entities.emplace_back();
|
||||||
auto & last = entities.back();
|
auto & last = entities.back();
|
||||||
last.begin = text.c_str() + pos;
|
last.begin = c_str + pos;
|
||||||
last.end = last.begin + ds.text.size();
|
last.end = last.begin + ds.text.size();
|
||||||
last.scheme = ki->second.get();
|
last.scheme = ki->second.get();
|
||||||
}
|
}
|
||||||
@ -3411,7 +3413,7 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
//Parse highlight keywords
|
//Parse highlight keywords
|
||||||
keyword_parser parser;
|
keyword_parser parser;
|
||||||
parser.parse({ text_ptr, text_len }, impl_->keywords);
|
parser.parse(text_ptr, text_len, impl_->keywords);
|
||||||
|
|
||||||
const auto line_h_pixels = line_height();
|
const auto line_h_pixels = line_height();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user