2016-05-02 22:01:55 +02:00
|
|
|
/** @file
|
2013-11-25 22:18:06 +01:00
|
|
|
* @author Edouard DUPIN
|
|
|
|
* @copyright 2010, Edouard DUPIN, all right reserved
|
|
|
|
* @license GPL v3 (see license file)
|
|
|
|
*/
|
2016-10-03 22:01:55 +02:00
|
|
|
#include <appl/TextPluginSelectAll.hpp>
|
|
|
|
#include <appl/Gui/TextViewer.hpp>
|
2013-11-25 22:18:06 +01:00
|
|
|
|
2014-08-29 22:52:21 +02:00
|
|
|
appl::TextPluginSelectAll::TextPluginSelectAll() :
|
|
|
|
m_menuIdTitle(-1),
|
|
|
|
m_menuIdSelectAll(-1),
|
|
|
|
m_menuIdSelectNone(-1) {
|
2014-08-27 22:58:21 +02:00
|
|
|
m_activateOnReceiveShortCut = true;
|
2014-05-26 21:42:51 +02:00
|
|
|
addObjectType("appl::TextPluginSelectAll");
|
2013-11-25 22:18:06 +01:00
|
|
|
}
|
|
|
|
|
2014-08-07 23:41:48 +02:00
|
|
|
|
2013-11-25 22:18:06 +01:00
|
|
|
void appl::TextPluginSelectAll::onPluginEnable(appl::TextViewer& _textDrawer) {
|
2016-07-19 22:03:39 +02:00
|
|
|
ememory::SharedPtr<ewol::widget::Menu> menu = m_menuInterface.lock();
|
2014-08-29 22:52:21 +02:00
|
|
|
if (menu != nullptr) {
|
2017-03-16 21:14:14 +01:00
|
|
|
m_menuIdTitle = menu->addTitle("_T{Edit}");
|
2014-08-29 22:52:21 +02:00
|
|
|
if (m_menuIdTitle != -1) {
|
2017-03-16 21:14:14 +01:00
|
|
|
m_menuIdSelectAll = menu->add(m_menuIdTitle, "_T{Select All}", "", "appl::TextPluginSelectAll::menu:select-all");
|
|
|
|
m_menuIdSelectNone = menu->add(m_menuIdTitle, "_T{Un-Select}", "", "appl::TextPluginSelectAll::menu:select-none");
|
2014-08-29 22:52:21 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-25 22:18:06 +01:00
|
|
|
// add event :
|
2014-08-27 22:58:21 +02:00
|
|
|
_textDrawer.ext_shortCutAdd("ctrl+a", "appl::TextPluginSelectAll::All");
|
2014-08-29 22:52:21 +02:00
|
|
|
_textDrawer.ext_shortCutAdd("ctrl+shift+a", "appl::TextPluginSelectAll::None");
|
2013-11-25 22:18:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void appl::TextPluginSelectAll::onPluginDisable(appl::TextViewer& _textDrawer) {
|
2014-08-29 22:52:21 +02:00
|
|
|
_textDrawer.ext_shortCutRm("appl::TextPluginSelectAll::All");
|
|
|
|
_textDrawer.ext_shortCutRm("appl::TextPluginSelectAll::None");
|
2016-07-19 22:03:39 +02:00
|
|
|
ememory::SharedPtr<ewol::widget::Menu> menu = m_menuInterface.lock();
|
2014-08-29 22:52:21 +02:00
|
|
|
if (menu != nullptr) {
|
|
|
|
menu->remove(m_menuIdSelectNone);
|
|
|
|
menu->remove(m_menuIdSelectAll);
|
|
|
|
menu->remove(m_menuIdTitle);
|
|
|
|
}
|
|
|
|
m_menuIdTitle = -1;
|
|
|
|
m_menuIdSelectAll = -1;
|
|
|
|
m_menuIdSelectNone = -1;
|
2013-11-25 22:18:06 +01:00
|
|
|
}
|
|
|
|
|
2014-09-18 22:27:54 +02:00
|
|
|
|
2014-08-27 22:58:21 +02:00
|
|
|
bool appl::TextPluginSelectAll::onReceiveShortCut(appl::TextViewer& _textDrawer,
|
|
|
|
const std::string& _shortCutName) {
|
2013-11-25 22:18:06 +01:00
|
|
|
if (isEnable() == false) {
|
|
|
|
return false;
|
|
|
|
}
|
2014-08-27 22:58:21 +02:00
|
|
|
if (_shortCutName == "appl::TextPluginSelectAll::All") {
|
2013-11-25 22:18:06 +01:00
|
|
|
if (_textDrawer.hasBuffer() == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
_textDrawer.select(_textDrawer.begin(), _textDrawer.end());
|
|
|
|
return true;
|
|
|
|
}
|
2014-08-29 22:52:21 +02:00
|
|
|
if (_shortCutName == "appl::TextPluginSelectAll::None") {
|
|
|
|
if (_textDrawer.hasBuffer() == false) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
_textDrawer.unSelect();
|
|
|
|
return true;
|
|
|
|
}
|
2013-11-25 22:18:06 +01:00
|
|
|
return false;
|
|
|
|
}
|