Skip to content

Commit

Permalink
Merge branch 'develop' into 'master'
Browse files Browse the repository at this point in the history
Develop

See merge request devel/studio!292
  • Loading branch information
rgoltermann committed May 29, 2019
2 parents 3e849bb + cf8e17e commit 5f2f53e
Show file tree
Hide file tree
Showing 36 changed files with 790 additions and 571 deletions.
23 changes: 19 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
Version 0.11.2
Version 0.11.3
========================

# General
- **added Drag and Drop in GDX Table View**
- fixed performance issue with very long lines (see #1008)
- fixed shortcut ctrl+shift+home not working as expected (see #1009)
- fixed status bar cursor position not updating in lst files

# GDX Viewer
- added column auto-shrink for table view
- added shortcut for auto-shrink (Ctrl+R)

# Search
- many improvements and bug fixes to highlighting of search results
- general fixes of bugs, crashes, etc.
- added shortcut Ctrl+Enter for "Search All"
- improved tab order in search dialog. now repolace textfield comes right after search textfield
- added ability to replace in more than one file at a time. there is a safety dialog showing how many files are being affected and the user can start a search to find all matches being affected.
- Find Next/Previous now respects all search options and will jump to the next file if there are also matches
- lst files now also have a match counter when stepping through with Find Next/Previous
- results view now supports enter key to select and jump to a result
- changed position of search dialog
- minor layout adjustments to search dialog

16 changes: 13 additions & 3 deletions jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ pipeline {

options {
parallelsAlwaysFailFast()
buildDiscarder(logRotator(numToKeepStr: '20', daysToKeepStr: '5'))
disableConcurrentBuilds()
}

Expand All @@ -30,6 +29,7 @@ pipeline {
post {
always {
recordIssues aggregatingResults: true, enabledForFailure: true, tools: [gcc4(reportEncoding: 'UTF-8')]
recordIssues enabledForFailure: true, tools: [taskScanner(ignoreCase: true, includePattern: '**/*.c, **/*.cpp, **/*.h, **/*.pro, **/*.pri', normalTags: 'TODO')]
}
}
}
Expand Down Expand Up @@ -195,7 +195,12 @@ pipeline {
stage ('windowsX86') {
agent { label 'windowsX86' }
steps {
bat 'windeployqt --release --compiler-runtime --force src\\bin\\studio.exe'
bat '''
windeployqt --release --compiler-runtime --force src\\bin\\studio.exe

copy "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Redist\\MSVC\\14.15.26706\\x86\\Microsoft.VC141.CRT\\*" "src\\bin"
copy "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Professional\\VC\\Redist\\MSVC\\14.15.26706\\vc_redist.x86.exe" "src\\bin"
'''
fileOperations([folderCreateOperation('tmp/studio'), folderCopyOperation(destinationFolderPath: 'tmp/studio', sourceFolderPath: 'src/bin')])
withCredentials([certificate(aliasVariable: '', credentialsId: '302df092-b329-47b9-8f7a-605da075126d', keystoreVariable: 'WIN_CERT_FILE', passwordVariable: 'WIN_CERT_PASSWD')]) {
bat '''
Expand All @@ -219,7 +224,12 @@ pipeline {
stage ('windowsX64') {
agent { label 'windowsX64' }
steps {
bat 'windeployqt --release --compiler-runtime --force src\\bin\\studio.exe'
bat '''
windeployqt --release --compiler-runtime --force src\\bin\\studio.exe

copy "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Redist\\MSVC\\14.12.25810\\x64\\Microsoft.VC141.CRT\\*" "src\\bin"
copy "C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Redist\\MSVC\\14.12.25810\\vc_redist.x64.exe" "src\\bin"
'''
fileOperations([folderCreateOperation('tmp/studio'), folderCopyOperation(destinationFolderPath: 'tmp/studio', sourceFolderPath: 'src/bin')])
withCredentials([certificate(aliasVariable: '', credentialsId: '302df092-b329-47b9-8f7a-605da075126d', keystoreVariable: 'WIN_CERT_FILE', passwordVariable: 'WIN_CERT_PASSWD')]) {
bat '''
Expand Down
4 changes: 2 additions & 2 deletions jenkinsfile-ci
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ pipeline {

options {
parallelsAlwaysFailFast()
buildDiscarder(logRotator(numToKeepStr: '10', daysToKeepStr: '2'))
disableConcurrentBuilds()
}

Expand All @@ -21,7 +20,8 @@ pipeline {
}
post {
always {
recordIssues aggregatingResults: true, enabledForFailure: true, tools: [gcc4(reportEncoding: 'UTF-8')]
recordIssues aggregatingResults: true, enabledForFailure: true, tools: [gcc(reportEncoding: 'UTF-8')]
recordIssues enabledForFailure: true, tools: [taskScanner(ignoreCase: true, includePattern: '**/*.c, **/*.cpp, **/*.h, **/*.pro, **/*.pri', normalTags: 'TODO')]
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ enum class FileKind {
Lxi,
Log,
Gdx,
Ref,
Dir
Ref
};
Q_ENUM_NS(FileKind)

Expand Down Expand Up @@ -130,6 +129,8 @@ operator<<(QTextStream &dbg, T enumValue)
return dbg << mo->enumerator(enumIdx).valueToKey(int(enumValue));
}

const int MAX_SEARCH_RESULTS = 50000;

}
}

Expand Down
44 changes: 22 additions & 22 deletions src/editors/codeedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "syntax.h"
#include "keys.h"
#include "editorhelper.h"
#include "viewhelper.h"
#include "locators/searchlocator.h"
#include "locators/settingslocator.h"

Expand Down Expand Up @@ -1231,14 +1232,9 @@ void CodeEdit::updateExtraSelections()
extraSelCurrentLine(selections);
if (!mBlockEdit) {
QString selectedText = textCursor().selectedText();
QString searchTerm = SearchLocator::searchDialog()->searchTerm();
bool regex = SearchLocator::searchDialog()->regex();

QRegularExpression regexp;
regexp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
if (regex) regexp.setPattern(searchTerm); // treat as regex
else regexp.setPattern(QRegularExpression::escape(searchTerm));// take literally
regexp.setPattern(regexp.pattern() + "\\b"); // only match whole selection
QRegularExpression regexp = SearchLocator::searchDialog()->results()
? SearchLocator::searchDialog()->results()->searchRegex()
: QRegularExpression();

// word boundary (\b) only matches start-of-string when first character is \w
// so \b will only be added when first character of selectedText is a \w
Expand Down Expand Up @@ -1333,29 +1329,33 @@ bool CodeEdit::extraSelMatchParentheses(QList<QTextEdit::ExtraSelection> &select

void CodeEdit::extraSelMatches(QList<QTextEdit::ExtraSelection> &selections)
{
SearchResultList *matches = SearchLocator::searchResults();
SearchDialog *searchDialog = SearchLocator::searchDialog();
if (!searchDialog || searchDialog->searchTerm().isEmpty()) return;

QTextBlock block = firstVisibleBlock();
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
SearchResultList* list = searchDialog->results();
if (!list) return;

QList<Result> fileResults = matches->filteredResultList(property("location").toString());
if (list->filteredResultList(ViewHelper::location(this)).isEmpty()) return;

QRegularExpression regEx = list->searchRegex();

QTextBlock block = firstVisibleBlock();
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
while (block.isValid() && top < viewport()->height()) {
QList<Result> rowResults;
for (Result r : fileResults) {
if (r.lineNr() == block.blockNumber()+1)
rowResults << r;
}
top += qRound(blockBoundingRect(block).height());

for (Result r: rowResults) {
QRegularExpressionMatchIterator i = regEx.globalMatch(block.text());
while (i.hasNext()) {
QRegularExpressionMatch m = i.next();
QTextEdit::ExtraSelection selection;
selection.cursor = textCursor();
selection.cursor.setPosition(block.position() + r.colNr());
selection.cursor.setPosition(block.position() + r.colNr() + r.length(), QTextCursor::KeepAnchor);
QTextCursor tc(document());
tc.setPosition(block.position() + m.capturedStart(0));
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, m.capturedLength(0));
selection.cursor = tc;
selection.format.setBackground(mSettings->colorScheme().value("Edit.matchesBg", QColor(Qt::green).lighter(160)));
selections << selection;
}
top += qRound(blockBoundingRect(block).height());

block = block.next();
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/editors/textmapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ QString TextMapper::lines(int localLineNrFrom, int lineCount) const
// get the text of the line
}

bool TextMapper::findText(QRegularExpression seachRegex, QTextDocument::FindFlags flags, bool &continueFind)
bool TextMapper::findText(QRegularExpression searchRegex, QTextDocument::FindFlags flags, bool &continueFind)
{
bool backwards = flags.testFlag(QTextDocument::FindBackward);
int part = backwards ? 2 : 1;
Expand Down Expand Up @@ -561,8 +561,8 @@ bool TextMapper::findText(QRegularExpression seachRegex, QTextDocument::FindFlag
}

QRegularExpressionMatch match;
if (backwards) textBlock.lastIndexOf(seachRegex, ind, &match);
else textBlock.indexOf(seachRegex, ind, &match);
if (backwards) textBlock.lastIndexOf(searchRegex, ind, &match);
else textBlock.indexOf(searchRegex, ind, &match);
if (match.hasMatch() || match.hasPartialMatch()) {
QStringRef ref = textBlock.leftRef(match.capturedStart());
int line = ref.count("\n");
Expand Down
2 changes: 1 addition & 1 deletion src/editors/textmapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class TextMapper: public QObject
int knownLineNrs() const;

QString lines(int localLineNrFrom, int lineCount) const;
bool findText(QRegularExpression seachRegex, QTextDocument::FindFlags flags, bool &continueFind);
bool findText(QRegularExpression searchRegex, QTextDocument::FindFlags flags, bool &continueFind);

QString selectedText() const;
void copyToClipboard();
Expand Down
6 changes: 4 additions & 2 deletions src/editors/textview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void TextView::zoomOut(int range)
mEdit->zoomOut(range);
}

bool TextView::jumpTo(int lineNr, int charNr)
bool TextView::jumpTo(int lineNr, int charNr, int length)
{
if (lineNr > mMapper.knownLineNrs()) return false;
int vTop = mMapper.absTopLine()+mMapper.visibleOffset();
Expand All @@ -127,6 +127,8 @@ bool TextView::jumpTo(int lineNr, int charNr)
vTop = mMapper.absTopLine()+mMapper.visibleOffset();
}
mMapper.setPosRelative(lineNr - mMapper.absTopLine(), charNr);
if (length != 0)
mMapper.setPosRelative(lineNr - mMapper.absTopLine(), charNr + length, QTextCursor::KeepAnchor);
updatePosAndAnchor();
emit selectionChanged();
setFocus();
Expand Down Expand Up @@ -186,7 +188,7 @@ bool TextView::findText(QRegularExpression searchRegex, QTextDocument::FindFlags
if (found) {
mMapper.scrollToPosition();
topLineMoved();
updatePosAndAnchor();
emit selectionChanged();
}
return found;
}
Expand Down
2 changes: 1 addition & 1 deletion src/editors/textview.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class TextView : public QAbstractScrollArea
int knownLines() const;
void zoomIn(int range = 1);
void zoomOut(int range = 1);
bool jumpTo(int lineNr, int charNr);
bool jumpTo(int lineNr, int charNr, int length = 0);
QPoint position() const;
QPoint anchor() const;
bool hasSelection() const;
Expand Down
38 changes: 0 additions & 38 deletions src/editors/textviewedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,44 +158,6 @@ void TextViewEdit::extraSelCurrentLine(QList<QTextEdit::ExtraSelection> &selecti
selections.append(selection);
}

void TextViewEdit::extraSelMatches(QList<QTextEdit::ExtraSelection> &selections)
{
SearchDialog *searchDialog = SearchLocator::searchDialog();
if (!searchDialog) return;
QString searchTerm = searchDialog->searchTerm();
if (searchTerm.isEmpty()) return;
QRegularExpression regEx = searchDialog->createRegex();

QTextBlock block = firstVisibleBlock();
int fromPos = block.position();
int toPos = fromPos;
int top = qRound(blockBoundingGeometry(block).translated(contentOffset()).top());
while (block.isValid() && top < viewport()->height()) {
toPos = block.position() + block.length();
top += qRound(blockBoundingRect(block).height());
block = block.next();
}

QTextCursor lastItem = QTextCursor(document());
lastItem.setPosition(document()->findBlockByNumber(mMapper.visibleOffset() - mMapper.absTopLine()).position());
QTextCursor item;
QFlags<QTextDocument::FindFlag> flags;
flags.setFlag(QTextDocument::FindCaseSensitively, searchDialog->caseSens());

do {
item = document()->find(regEx, lastItem, flags);
if (lastItem == item) break;
lastItem = item;
if (!item.isNull()) {
if (item.position() > toPos) break;
QTextEdit::ExtraSelection selection;
selection.cursor = item;
selection.format.setBackground(mSettings->colorScheme().value("Edit.matchesBg", QColor(Qt::green).lighter(160)));
selections << selection;
}
} while (!item.isNull());
}

int TextViewEdit::topVisibleLine()
{
return mMapper.absTopLine() + mMapper.visibleOffset();
Expand Down
13 changes: 0 additions & 13 deletions src/editors/textviewedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,6 @@ public slots:
void recalcWordUnderCursor() override;
int effectiveBlockNr(const int &localBlockNr) const override;
void extraSelCurrentLine(QList<QTextEdit::ExtraSelection> &selections) override;
void extraSelMatches(QList<QTextEdit::ExtraSelection> &selections) override;

// void extraSelCurrentWord(QList<QTextEdit::ExtraSelection>& selections) override;

// QString lineNrText(int blockNr) override {
// double byteNr = mTopByte + document()->findBlockByNumber(blockNr-1).position();
// double percent = byteNr * 100 / mOversizeMapper.size;
// QString res = QString::number(percent, 'f', mDigits) % QString(mDigits-1, '0');
// if (percent < 1.0 || res.startsWith("100")) return ('%' + res).left(mDigits+3);
// if (percent < 10.0) return (' ' + res).left(mDigits+3);
// return res.left(mDigits+3);
// }

private:
int topVisibleLine() override;
Expand All @@ -78,7 +66,6 @@ public slots:
bool mKeepWordUnderCursor = false;
};


} // namespace studio
} // namespace gams

Expand Down
7 changes: 4 additions & 3 deletions src/editors/viewhelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ QString ViewHelper::location(QWidget *widget)
void ViewHelper::setLocation(QWidget *widget, QString location)
{
widget->setProperty("location", location);
// if there is an inner edit: set the property additionally
if (AbstractEdit *ed = toAbstractEdit(widget)) {
// if there is an inner edit: set the property additionally
if (ed != widget)
ed->setProperty("location", location);
if (ed != widget) ed->setProperty("location", location);
} else if (TextView* tv = toTextView(widget)) {
if (tv != widget) tv->edit()->setProperty("location", location);
}
}

Expand Down
12 changes: 7 additions & 5 deletions src/file/filemeta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,6 @@ void FileMeta::linkDocument(QTextDocument *doc)
connect(mDocument, &QTextDocument::contentsChange, this, &FileMeta::contentsChange);
connect(mDocument, &QTextDocument::blockCountChanged, this, &FileMeta::blockCountChanged);
}
// if (mHighlighter)
// mHighlighter->setMarks(mFileRepo->textMarkRepo()->marks(mId));
}

void FileMeta::unlinkAndFreeDocument()
Expand Down Expand Up @@ -513,16 +511,20 @@ FileMeta::FileDifferences FileMeta::compare(QString fileName)
return res;
}

void FileMeta::jumpTo(NodeId groupId, bool focus, int line, int column)
void FileMeta::jumpTo(NodeId groupId, bool focus, int line, int column, int length)
{
emit mFileRepo->openFile(this, groupId, focus, codecMib());
if (!mEditors.size()) return;

AbstractEdit* edit = ViewHelper::toAbstractEdit(mEditors.first());
if (edit && line < edit->document()->blockCount()) {
QTextBlock block = edit->document()->findBlockByNumber(line);
QTextCursor tc = QTextCursor(block);
tc.setPosition(block.position()+qMin(column, block.length()-1));

tc.movePosition(QTextCursor::Right, QTextCursor::MoveAnchor, qMin(column, block.length()-1));
tc.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor, length);
edit->setTextCursor(tc);

// center line vertically
qreal lines = qreal(edit->rect().height()) / edit->cursorRect().height();
qreal line = qreal(edit->cursorRect().bottom()) / edit->cursorRect().height();
Expand All @@ -532,7 +534,7 @@ void FileMeta::jumpTo(NodeId groupId, bool focus, int line, int column)
return;
}
if (TextView *tv = ViewHelper::toTextView(mEditors.first())) {
tv->jumpTo(line, column);
tv->jumpTo(line, column, length);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/file/filemeta.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class FileMeta: public QObject
void renameToBackup();
FileDifferences compare(QString fileName = QString());

void jumpTo(NodeId groupId, bool focus, int line = 0, int column = 0);
void jumpTo(NodeId groupId, bool focus, int line = 0, int column = 0, int length = 0);
void rehighlight(int line);
void rehighlightBlock(QTextBlock block, QTextBlock endBlock = QTextBlock());
syntax::SyntaxHighlighter *highlighter() const;
Expand Down
2 changes: 1 addition & 1 deletion src/file/filemetarepo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ QVector<FileMeta*> FileMetaRepo::openFiles() const
QHashIterator<FileId, FileMeta*> i(mFiles);
while (i.hasNext()) {
i.next();
if (i.value()->isOpen()) res << i.value();
if (i.value()->isOpen() && res.indexOf(i.value()) == -1) res << i.value();
}
return res;
}
Expand Down
Loading

0 comments on commit 5f2f53e

Please sign in to comment.