Skip to content

Commit

Permalink
Mulit-line highlighted lines in editor #417
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorsandy committed Mar 12, 2021
1 parent 2951b15 commit b55e9c5
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 43 deletions.
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Last Update: July 19, 2020
# Copyright (c) 2017 - 2020 by Trevor SANDY
pkgname=lpub3d
pkgver=2.4.1.2042
pkgver=2.4.1.2043
pkgrel=1
pkgdesc="An LDraw Building Instruction Editor"
url="https://github.com/trevorsandy/lpub3d.git"
Expand Down
6 changes: 3 additions & 3 deletions builds/linux/obs/alldeps/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
lpub3d (2.4.1.2042) debian; urgency=medium
lpub3d (2.4.1.2043) debian; urgency=medium

* LPub3D version 2.4.1.1.2042_20210312 for Linux
* LPub3D version 2.4.1.1.2043_20210312 for Linux

-- Trevor SANDY <trevor.sandy@gmail.com> Fri, 12 Mar 2021 06:37:05 +0100
-- Trevor SANDY <trevor.sandy@gmail.com> Fri, 12 Mar 2021 06:37:43 +0100
2 changes: 1 addition & 1 deletion builds/linux/obs/alldeps/debian/lpub3d.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Format: 1.0
Source: lpub3d
Binary: lpub3d
Architecture: any
Version: 2.4.1.2042
Version: 2.4.1.2043
Maintainer: Trevor SANDY <trevor.sandy@gmail.com>
Homepage: https://trevorsandy.github.io/lpub3d/
Standards-Version: 3.9.7
Expand Down
4 changes: 2 additions & 2 deletions builds/linux/obs/alldeps/lpub3d.spec
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ BuildRequires: fdupes
Summary: An LDraw Building Instruction Editor
Name: lpub3d
Icon: lpub3d.xpm
Version: 2.4.1.2042
Version: 2.4.1.2043
Release: <B_CNT>%{?dist}
URL: https://trevorsandy.github.io/lpub3d
Vendor: Trevor SANDY
Expand Down Expand Up @@ -731,5 +731,5 @@ update-mime-database /usr/share/mime >/dev/null || true
update-desktop-database || true
%endif

* Fri Mar 12 2021 - trevor.dot.sandy.at.gmail.dot.com 2.4.1.2042
* Fri Mar 12 2021 - trevor.dot.sandy.at.gmail.dot.com 2.4.1.2043
- LPub3D Linux package (rpm) release
Binary file modified builds/utilities/ci/secure/.secrets.tar.enc
Binary file not shown.
2 changes: 1 addition & 1 deletion builds/utilities/version.info
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2 4 1 1 2042 a8195ed
2 4 1 1 2043 2951b15
2 changes: 1 addition & 1 deletion mainApp/docs/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LPub3D 2.4.1.1.2042 (12 03 2021 06:37:05)
LPub3D 2.4.1.1.2043 (12 03 2021 06:37:43)

Features, enhancements, fixes and changes
------------
Expand Down
2 changes: 1 addition & 1 deletion mainApp/docs/RELEASE_NOTES.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<table class="tg">
<tr>
<th class="tg-0pky">
<h4><a id="LPub3D_0"></a>LPub3D 2.4.1.1.2042 (12 03 2021 06:37:05)</h4>
<h4><a id="LPub3D_0"></a>LPub3D 2.4.1.1.2043 (12 03 2021 06:37:43)</h4>
<hr>
<p>
LPub3D Official release.<br>
Expand Down
63 changes: 31 additions & 32 deletions mainApp/editwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,18 +1135,25 @@ void EditWindow::updateSelectedParts() {
if(!cursor.hasSelection())
cursor.select(QTextCursor::LineUnderCursor);

QString content = cursor.selection().toPlainText();
selectedLines = content.count("\n")+1;
QStringList content = cursor.selection().toPlainText().split("\n");

selectedLines = content.size();

if (!selectedLines)
return;

auto getSelectedLineNumber = [&cursor] () {
int lineNumber = 0;

while(cursor.positionInBlock()>0) {
cursor.movePosition(QTextCursor::Up);
QTextCursor _cursor = cursor;
_cursor.select(QTextCursor::LineUnderCursor);

while(_cursor.positionInBlock()>0) {
_cursor.movePosition(QTextCursor::Up);
lineNumber++;
}

QTextBlock block = cursor.block().previous();
QTextBlock block = _cursor.block().previous();

while(block.isValid()) {
lineNumber += block.lineCount();
Expand All @@ -1157,36 +1164,28 @@ void EditWindow::updateSelectedParts() {

cursor.beginEditBlock();

while (currentLine != selectedLines)
while (currentLine < selectedLines)
{
cursor.select(QTextCursor::LineUnderCursor);
QString selection = cursor.selectedText();
_textEdit->moveCursor(QTextCursor::StartOfLine);

if (!selection.isEmpty())
QString selection = content.at(currentLine);
if (content.at(currentLine).startsWith("1") ||
content.at(currentLine).contains(" PLI BEGIN SUB "))
{
if (selection.startsWith("1") || selection.contains(" PLI BEGIN SUB ")) {
int lineNumber = getSelectedLineNumber();
TypeLine typeLine(fileOrderIndex,lineNumber);
lineTypeIndexes.append(typeLine);
toggleLines.append(lineNumber);
clearSelection = savedSelection.contains(lineNumber);
highlightSelectedLines(toggleLines, clearSelection); // toggle On/Off
toggleLines.clear();
if (clearSelection)
savedSelection.removeAll(lineNumber);
else
savedSelection.append(lineNumber);
}

// go to next selected line
if (++currentLine < selectedLines) {
cursor.movePosition(QTextCursor::Down);
_textEdit->setTextCursor(cursor);
}
} else {
break;
int lineNumber = getSelectedLineNumber();
TypeLine typeLine(fileOrderIndex,lineNumber);
lineTypeIndexes.append(typeLine);
toggleLines.append(lineNumber);
clearSelection = savedSelection.contains(lineNumber);
highlightSelectedLines(toggleLines, clearSelection);
if (clearSelection)
savedSelection.removeAll(lineNumber);
else
savedSelection.append(lineNumber);
toggleLines.clear();
}
// set next selected line
cursor.movePosition(QTextCursor::Down);
_textEdit->setTextCursor(cursor);
currentLine++;
}

// restore selection
Expand Down
2 changes: 1 addition & 1 deletion mainApp/org.trevorsandy.lpub3d.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<binary>lpub3d24</binary>
​</provides>
<releases>
<release version="2.4.1.2042" date="2021-03-12">
<release version="2.4.1.2043" date="2021-03-12">
<description>
<p>LPub3D Linux AppImage package</p>
</description>
Expand Down

0 comments on commit b55e9c5

Please sign in to comment.