improve text_editor set_accept
This commit is contained in:
parent
2829a6c2de
commit
1d31809051
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Data Exchanger Implementation
|
* Data Exchanger Implementation
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -38,6 +38,8 @@ namespace system{
|
|||||||
|
|
||||||
void get(std::string& text_utf8);
|
void get(std::string& text_utf8);
|
||||||
void get(std::wstring& text);
|
void get(std::wstring& text);
|
||||||
|
|
||||||
|
std::wstring wget();
|
||||||
private:
|
private:
|
||||||
bool _m_set(format, const void* buf, std::size_t size, native_window_type);
|
bool _m_set(format, const void* buf, std::size_t size, native_window_type);
|
||||||
void* _m_get(format, size_t& size);
|
void* _m_get(format, size_t& size);
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* A text editor implementation
|
* A text editor implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -2344,24 +2344,29 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
void text_editor::paste()
|
void text_editor::paste()
|
||||||
{
|
{
|
||||||
std::wstring text;
|
auto text = system::dataexch{}.wget();
|
||||||
nana::system::dataexch().get(text);
|
|
||||||
|
|
||||||
//If it is required check the acceptable
|
//If it is required check the acceptable
|
||||||
if (accepts::no_restrict != impl_->capacities.acceptive)
|
if ((accepts::no_restrict != impl_->capacities.acceptive) || impl_->capacities.pred_acceptive)
|
||||||
{
|
{
|
||||||
for (auto i = text.begin(); i != text.end(); ++i)
|
for (auto i = text.begin(); i != text.end(); ++i)
|
||||||
{
|
{
|
||||||
if (!_m_accepts(*i))
|
if (_m_accepts(*i))
|
||||||
|
{
|
||||||
|
if (accepts::no_restrict == impl_->capacities.acceptive)
|
||||||
|
put(*i);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (accepts::no_restrict != impl_->capacities.acceptive)
|
||||||
{
|
{
|
||||||
text.erase(i, text.end());
|
text.erase(i, text.end());
|
||||||
break;
|
put(std::move(text));
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!text.empty())
|
|
||||||
put(std::move(text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void text_editor::enter(bool record_undo)
|
void text_editor::enter(bool record_undo)
|
||||||
@ -2814,8 +2819,12 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
bool text_editor::_m_accepts(char_type ch) const
|
bool text_editor::_m_accepts(char_type ch) const
|
||||||
{
|
{
|
||||||
if(accepts::no_restrict == impl_->capacities.acceptive)
|
if (accepts::no_restrict == impl_->capacities.acceptive)
|
||||||
|
{
|
||||||
|
if (impl_->capacities.pred_acceptive)
|
||||||
|
return impl_->capacities.pred_acceptive(ch);
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
//Checks the input whether it meets the requirement for a numeric.
|
//Checks the input whether it meets the requirement for a numeric.
|
||||||
auto str = text();
|
auto str = text();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Data Exchanger Implementation
|
* Data Exchanger Implementation
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2017 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -183,6 +183,14 @@ namespace nana{ namespace system{
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::wstring dataexch::wget()
|
||||||
|
{
|
||||||
|
std::wstring str;
|
||||||
|
this->get(str);
|
||||||
|
return str;
|
||||||
|
}
|
||||||
|
|
||||||
//private:
|
//private:
|
||||||
bool dataexch::_m_set(format fmt, const void* buf, std::size_t size, native_window_type owner)
|
bool dataexch::_m_set(format fmt, const void* buf, std::size_t size, native_window_type owner)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user