work save
This commit is contained in:
parent
100ceeda6c
commit
24b69f5749
|
@ -61,7 +61,8 @@ SOURCES += \
|
|||
widgets/consolewidget.cpp \
|
||||
widgets/issuestable.cpp \
|
||||
widgets/qconsole.cpp \
|
||||
widgets/qpatchedcombobox.cpp
|
||||
widgets/qpatchedcombobox.cpp \
|
||||
widgets/searchdialog.cpp
|
||||
|
||||
HEADERS += \
|
||||
HighlighterManager.h \
|
||||
|
@ -117,7 +118,8 @@ HEADERS += \
|
|||
widgets/consolewidget.h \
|
||||
widgets/issuestable.h \
|
||||
widgets/qconsole.h \
|
||||
widgets/qpatchedcombobox.h
|
||||
widgets/qpatchedcombobox.h \
|
||||
widgets/searchdialog.h
|
||||
|
||||
FORMS += \
|
||||
settingsdialog/debuggeneralwidget.ui \
|
||||
|
@ -133,7 +135,8 @@ FORMS += \
|
|||
settingsdialog/editorsyntaxcheckwidget.ui \
|
||||
settingsdialog/environmentappearencewidget.ui \
|
||||
settingsdialog/executorgeneralwidget.ui \
|
||||
settingsdialog/settingsdialog.ui
|
||||
settingsdialog/settingsdialog.ui \
|
||||
widgets/searchdialog.ui
|
||||
|
||||
TRANSLATIONS += \
|
||||
RedPandaIDE_zh_CN.ts
|
||||
|
|
|
@ -1479,15 +1479,15 @@ void MainWindow::on_actionView_CPU_Window_triggered()
|
|||
mCPUDialog->show();
|
||||
}
|
||||
|
||||
void MainWindow::on_txtEvaludate_returnPressed()
|
||||
{
|
||||
QString s=ui->txtEvaludate->text().trimmed();
|
||||
if (!s.isEmpty()) {
|
||||
mDebugger->sendCommand("print",s,false);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::on_actionExit_triggered()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void MainWindow::on_cbEvaluate_textActivated(const QString &arg1)
|
||||
{
|
||||
QString s=arg1.trimmed();
|
||||
if (!s.isEmpty()) {
|
||||
mDebugger->sendCommand("print",s,false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -164,10 +164,10 @@ private slots:
|
|||
|
||||
void on_actionView_CPU_Window_triggered();
|
||||
|
||||
void on_txtEvaludate_returnPressed();
|
||||
|
||||
void on_actionExit_triggered();
|
||||
|
||||
void on_cbEvaluate_textActivated(const QString &arg1);
|
||||
|
||||
public slots:
|
||||
void onCompileLog(const QString& msg);
|
||||
void onCompileIssue(PCompileIssue issue);
|
||||
|
|
|
@ -393,7 +393,20 @@
|
|||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="txtEvaludate"/>
|
||||
<widget class="QComboBox" name="cbEvaluate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertAtTop</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -553,7 +566,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>946</width>
|
||||
<height>25</height>
|
||||
<height>26</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
|
|
|
@ -32,7 +32,7 @@ int SynSearch::findAll(const QString &newText)
|
|||
int start=0;
|
||||
int next=-1;
|
||||
while (true) {
|
||||
if (options.testFlag(ssoMatchCase)) {
|
||||
if (options().testFlag(ssoMatchCase)) {
|
||||
next = newText.indexOf(pattern(),start,Qt::CaseSensitive);
|
||||
} else {
|
||||
next = newText.indexOf(pattern(),start,Qt::CaseInsensitive);
|
||||
|
|
|
@ -4174,7 +4174,7 @@ int SynEdit::searchReplace(const QString &ASearch, const QString &AReplace, SynS
|
|||
if (ASearch.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
int Result = 0;
|
||||
int result = 0;
|
||||
// get the text range to search in, ignore the "Search in selection only"
|
||||
// option if nothing is selected
|
||||
bool bBackward = AOptions.testFlag(ssoBackwards);
|
||||
|
@ -4241,90 +4241,105 @@ int SynEdit::searchReplace(const QString &ASearch, const QString &AReplace, SynS
|
|||
mUndoList->EndBlock();
|
||||
doOnPaintTransient(SynTransientType::ttAfter);
|
||||
});
|
||||
int n;
|
||||
while ((ptCurrent.Line >= ptStart.Line) && (ptCurrent.Line <= ptEnd.Line)) {
|
||||
nInLine := fSearchEngine.FindAll(Lines[ptCurrent.Line - 1]);
|
||||
iResultOffset := 0;
|
||||
if bBackward then
|
||||
n := Pred(fSearchEngine.ResultCount)
|
||||
int nInLine = mSearchEngine->findAll(mLines->getString(ptCurrent.Line - 1));
|
||||
int iResultOffset = 0;
|
||||
if (bBackward)
|
||||
n = mSearchEngine->resultCount()-1;
|
||||
else
|
||||
n := 0;
|
||||
n = 0;
|
||||
// Operate on all results in this line.
|
||||
while nInLine > 0 do begin
|
||||
while (nInLine > 0) {
|
||||
// An occurrence may have been replaced with a text of different length
|
||||
nFound := fSearchEngine.Results[n] + iResultOffset;
|
||||
nSearchLen := fSearchEngine.Lengths[n];
|
||||
if bBackward then
|
||||
Dec(n)
|
||||
int nFound = mSearchEngine->result(n) + 1 + iResultOffset;
|
||||
int nSearchLen = mSearchEngine->length(n);
|
||||
int nReplaceLen = 0;
|
||||
if (bBackward)
|
||||
n--;
|
||||
else
|
||||
Inc(n);
|
||||
Dec(nInLine);
|
||||
n++;
|
||||
nInLine--;
|
||||
// Is the search result entirely in the search range?
|
||||
if not InValidSearchRange(nFound, nFound + nSearchLen) then
|
||||
bool isInValidSearchRange = true;
|
||||
int first = nFound;
|
||||
int last = nFound + nSearchLen;
|
||||
if ((mActiveSelectionMode == SynSelectionMode::smNormal)
|
||||
|| !AOptions.testFlag(ssoSelectedOnly)) {
|
||||
if (((ptCurrent.Line == ptStart.Line) && (first < ptStart.Char)) ||
|
||||
((ptCurrent.Line == ptEnd.Line) && (last > ptEnd.Char)))
|
||||
isInValidSearchRange = false;
|
||||
} else if (mActiveSelectionMode == SynSelectionMode::smColumn) {
|
||||
// solves bug in search/replace when smColumn mode active and no selection
|
||||
isInValidSearchRange = (first >= ptStart.Char) && (last <= ptEnd.Char)
|
||||
|| (ptEnd.Char - ptStart.Char < 1);
|
||||
}
|
||||
if (!isInValidSearchRange)
|
||||
continue;
|
||||
Inc(Result);
|
||||
result++;
|
||||
// Select the text, so the user can see it in the OnReplaceText event
|
||||
// handler or as the search result.
|
||||
ptCurrent.Char = nFound;
|
||||
setBlockBegin(ptCurrent);
|
||||
|
||||
ptCurrent.Char := nFound;
|
||||
BlockBegin := ptCurrent;
|
||||
//Be sure to use the Ex version of CursorPos so that it appears in the middle if necessary
|
||||
SetCaretXYEx(False, BufferCoord(1, ptCurrent.Line));
|
||||
EnsureCursorPosVisibleEx(True);
|
||||
Inc(ptCurrent.Char, nSearchLen);
|
||||
BlockEnd := ptCurrent;
|
||||
InternalCaretXY := ptCurrent;
|
||||
if bBackward then
|
||||
InternalCaretXY := BlockBegin
|
||||
setCaretXYEx(false, BufferCoord{1, ptCurrent.Line});
|
||||
ensureCursorPosVisibleEx(true);
|
||||
ptCurrent.Char += nSearchLen;
|
||||
setBlockEnd(ptCurrent);
|
||||
//internalSetCaretXY(ptCurrent);
|
||||
if (bBackward)
|
||||
internalSetCaretXY(blockBegin());
|
||||
else
|
||||
InternalCaretXY := ptCurrent;
|
||||
internalSetCaretXY(ptCurrent);
|
||||
// If it's a search only we can leave the procedure now.
|
||||
if not (bReplace or bReplaceAll) then
|
||||
exit;
|
||||
if (! (bReplace || bReplaceAll))
|
||||
return result;
|
||||
// Prompt and replace or replace all. If user chooses to replace
|
||||
// all after prompting, turn off prompting.
|
||||
if bPrompt and Assigned(fOnReplaceText) then begin
|
||||
nAction := DoOnReplaceText(ASearch, AReplace, ptCurrent.Line, nFound, nSearchLen);
|
||||
if nAction = raCancel then
|
||||
exit;
|
||||
end else
|
||||
nAction := raReplace;
|
||||
if nAction <> raSkip then begin
|
||||
SynReplaceAction nAction;
|
||||
if (bPrompt && this->mOnReplaceText) {
|
||||
nAction = mOnReplaceText(ASearch, AReplace, ptCurrent.Line, nFound, nSearchLen);
|
||||
if (nAction == SynReplaceAction::raCancel)
|
||||
return result;
|
||||
} else
|
||||
nAction = SynReplaceAction::raReplace;
|
||||
if (nAction != SynReplaceAction::raSkip) {
|
||||
// user has been prompted and has requested to silently replace all
|
||||
// so turn off prompting
|
||||
if nAction = raReplaceAll then begin
|
||||
if (not bReplaceAll) or bPrompt then begin
|
||||
bReplaceAll := TRUE;
|
||||
IncPaintLock;
|
||||
end;
|
||||
bPrompt := False;
|
||||
if bEndUndoBlock = false then
|
||||
BeginUndoBlock;
|
||||
bEndUndoBlock := true;
|
||||
end;
|
||||
//Allow advanced substition in the search engine
|
||||
SelText := fSearchEngine.Replace(SelText, AReplace);
|
||||
nReplaceLen := CaretX - nFound;
|
||||
end;
|
||||
if (nAction == SynReplaceAction::raReplaceAll) {
|
||||
if ((not bReplaceAll) || bPrompt) {
|
||||
bReplaceAll = true;
|
||||
incPaintLock();
|
||||
}
|
||||
bPrompt = false;
|
||||
if (bEndUndoBlock == false)
|
||||
mUndoList->BeginBlock();
|
||||
bEndUndoBlock = true;
|
||||
}
|
||||
setSelText(mSearchEngine->replace(selText(), AReplace));
|
||||
nReplaceLen = caretX() - nFound;
|
||||
}
|
||||
// fix the caret position and the remaining results
|
||||
if not bBackward then begin
|
||||
InternalCaretX := nFound + nReplaceLen;
|
||||
if (nSearchLen <> nReplaceLen) and (nAction <> raSkip) then begin
|
||||
Inc(iResultOffset, nReplaceLen - nSearchLen);
|
||||
if (fActiveSelectionMode <> smColumn) and (CaretY = ptEnd.Line) then begin
|
||||
Inc(ptEnd.Char, nReplaceLen - nSearchLen);
|
||||
BlockEnd := ptEnd;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
if not bReplaceAll then
|
||||
exit;
|
||||
end;
|
||||
if (!bBackward) {
|
||||
internalSetCaretX(nFound + nReplaceLen);
|
||||
if ((nSearchLen != nReplaceLen) && (nAction != SynReplaceAction::raSkip)) {
|
||||
iResultOffset += nReplaceLen - nSearchLen;
|
||||
if ((mActiveSelectionMode != SynSelectionMode::smColumn) && (caretY() == ptEnd.Line)) {
|
||||
ptEnd.Char+=nReplaceLen - nSearchLen;
|
||||
setBlockEnd(ptEnd);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!bReplaceAll)
|
||||
return result;
|
||||
}
|
||||
// search next / previous line
|
||||
if bBackward then
|
||||
Dec(ptCurrent.Line)
|
||||
if (bBackward)
|
||||
ptCurrent.Line--;
|
||||
else
|
||||
Inc(ptCurrent.Line);
|
||||
end;
|
||||
ptCurrent.Line++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -125,8 +125,8 @@ using SynPaintProc = std::function<void(const QPaintDevice& paintDevice )>;
|
|||
using SynPreparePaintHighlightTokenProc = std::function<void(int row,
|
||||
int column, const QString& token, PSynHighlighterAttribute attr,
|
||||
SynFontStyles& style, QColor& foreground, QColor& background)>;
|
||||
using SynReplaceTextProc = std::function<void(const QString& ASearch, const QString& AReplace,
|
||||
int Line, int Column, int wordLen, SynReplaceAction& action)>;
|
||||
using SynReplaceTextProc = std::function<SynReplaceAction(const QString& ASearch, const QString& AReplace,
|
||||
int Line, int ch, int wordLen)>;
|
||||
//using SynSpecialLineColorsProc = std::function<void(int Line,
|
||||
// bool& Special, QColor& foreground, QColor& backgroundColor)>;
|
||||
//using SynEditingAreasProc = std::function<void(int Line, SynEditingAreaList& areaList,
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
#include "searchdialog.h"
|
||||
#include "ui_searchdialog.h"
|
||||
|
||||
SearchDialog::SearchDialog(QWidget *parent) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::SearchDialog)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
}
|
||||
|
||||
SearchDialog::~SearchDialog()
|
||||
{
|
||||
delete ui;
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
#ifndef SEARCHDIALOG_H
|
||||
#define SEARCHDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
namespace Ui {
|
||||
class SearchDialog;
|
||||
}
|
||||
|
||||
class SearchDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SearchDialog(QWidget *parent = nullptr);
|
||||
~SearchDialog();
|
||||
|
||||
private:
|
||||
Ui::SearchDialog *ui;
|
||||
};
|
||||
|
||||
#endif // SEARCHDIALOG_H
|
|
@ -0,0 +1,107 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SearchDialog</class>
|
||||
<widget class="QDialog" name="SearchDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>684</width>
|
||||
<height>548</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<property name="spacing">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Text to Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>445</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>455</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton">
|
||||
<property name="text">
|
||||
<string>Find</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pushButton_2">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
Loading…
Reference in New Issue