mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-04 03:40:14 +00:00
Implement commentSelection() and uncommentSelection()
This commit is contained in:
parent
83ff7d162c
commit
61e374fdfc
@ -287,12 +287,50 @@ void CSVWorld::ScriptEdit::updateLineNumberArea(const QRect &rect, int dy)
|
||||
|
||||
void CSVWorld::ScriptEdit::commentSelection()
|
||||
{
|
||||
QTextCursor begin = textCursor();
|
||||
QTextCursor end = begin;
|
||||
begin.setPosition(begin.selectionStart());
|
||||
begin.movePosition(QTextCursor::StartOfLine);
|
||||
|
||||
end.setPosition(end.selectionEnd());
|
||||
end.movePosition(QTextCursor::StartOfLine);
|
||||
|
||||
for (; begin <= end; begin.movePosition(QTextCursor::StartOfLine), begin.movePosition(QTextCursor::Down))
|
||||
{
|
||||
begin.insertText(";");
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::uncommentSelection()
|
||||
{
|
||||
QTextCursor begin = textCursor();
|
||||
QTextCursor end = begin;
|
||||
begin.setPosition(begin.selectionStart());
|
||||
begin.movePosition(QTextCursor::StartOfLine);
|
||||
|
||||
end.setPosition(end.selectionEnd());
|
||||
end.movePosition(QTextCursor::StartOfLine);
|
||||
|
||||
for (; begin <= end; begin.movePosition(QTextCursor::StartOfLine), begin.movePosition(QTextCursor::Down)) {
|
||||
// loop through line until a nonspace character is reached
|
||||
begin.select(QTextCursor::LineUnderCursor);
|
||||
QString line = begin.selectedText();
|
||||
|
||||
// get first nonspace character in line
|
||||
int index;
|
||||
for (index = 0; index != line.size(); ++index)
|
||||
{
|
||||
if (!line[index].isSpace())
|
||||
break;
|
||||
}
|
||||
|
||||
if (index != line.size() && line[index] == ';')
|
||||
{
|
||||
line.remove(index, 1);
|
||||
}
|
||||
|
||||
begin.insertText(line);
|
||||
}
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
|
||||
|
Loading…
x
Reference in New Issue
Block a user