edn/sources/appl/TextPluginRmLine.cpp

46 lines
1.4 KiB
C++
Raw Normal View History

2016-05-02 22:01:55 +02:00
/** @file
* @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/TextPluginRmLine.hpp>
#include <appl/Gui/TextViewer.hpp>
appl::TextPluginRmLine::TextPluginRmLine() {
m_activateOnReceiveShortCut = true;
addObjectType("appl::TextPluginRmLine");
}
void appl::TextPluginRmLine::onPluginEnable(appl::TextViewer& _textDrawer) {
// add event :
_textDrawer.ext_shortCutAdd("ctrl+w", "appl::TextPluginRmLine::Rm");
}
void appl::TextPluginRmLine::onPluginDisable(appl::TextViewer& _textDrawer) {
2014-08-29 22:52:21 +02:00
_textDrawer.ext_shortCutRm("appl::TextPluginRmLine::Rm");
}
bool appl::TextPluginRmLine::onReceiveShortCut(appl::TextViewer& _textDrawer,
2017-08-28 00:09:10 +02:00
const etk::String& _shortCutName) {
if (isEnable() == false) {
return false;
}
if (_shortCutName == "appl::TextPluginRmLine::Rm") {
if (_textDrawer.hasBuffer() == false) {
return false;
}
if (_textDrawer.hasTextSelected() == true) {
appl::Buffer::Iterator start = _textDrawer.getStartLine(_textDrawer.selectStart());
appl::Buffer::Iterator end = _textDrawer.getEndLine(_textDrawer.selectStop())+1;
_textDrawer.replace("", start, end);
} else {
appl::Buffer::Iterator start = _textDrawer.getStartLine(_textDrawer.cursor());
appl::Buffer::Iterator end = _textDrawer.getEndLine(_textDrawer.cursor())+1;
_textDrawer.replace("", start, end);
}
return true;
}
return false;
}