- feature done: find symbol occurencies

- feature: open containing folder
 - feature: open terminal
This commit is contained in:
royqh1979@gmail.com 2021-09-03 16:39:20 +08:00
parent 913a300d0f
commit 842daf38a5
13 changed files with 704 additions and 316 deletions

View File

@ -22,6 +22,7 @@ SOURCES += \
compiler/executablerunner.cpp \
compiler/filecompiler.cpp \
compiler/stdincompiler.cpp \
cpprefacter.cpp \
parser/cppparser.cpp \
parser/cpppreprocessor.cpp \
parser/cpptokenizer.cpp \
@ -94,6 +95,7 @@ HEADERS += \
compiler/executablerunner.h \
compiler/filecompiler.h \
compiler/stdincompiler.h \
cpprefacter.h \
parser/cppparser.h \
parser/cpppreprocessor.h \
parser/cpptokenizer.h \
@ -195,6 +197,8 @@ RESOURCES += \
icons.qrc \
translations.qrc
RC_ICONS = images/devcpp.ico
#win32:CONFIG(release, debug|release): LIBS += -L$$OUT_PWD/../../QScintilla/src/release/ -lqscintilla2_qt5d
#else:win32:CONFIG(debug, debug|release): LIBS += -L$$OUT_PWD/../../QScintilla/src/debug/ -lqscintilla2_qt5d
#else:unix: LIBS += -L$$OUT_PWD/../../QScintilla/src/ -lqscintilla2_qt5d

Binary file not shown.

File diff suppressed because it is too large Load Diff

121
RedPandaIDE/cpprefacter.cpp Normal file
View File

@ -0,0 +1,121 @@
#include "cpprefacter.h"
#include "mainwindow.h"
#include "settings.h"
#include "editor.h"
#include "editorlist.h"
#include <QFile>
#include "HighlighterManager.h"
CppRefacter::CppRefacter(QObject *parent) : QObject(parent)
{
}
bool CppRefacter::findOccurence(Editor *editor, const BufferCoord &pos)
{
if (!editor->parser()->freeze())
return false;
auto action = finally([&editor]{
editor->parser()->unFreeze();
});
// get full phrase (such as s.name instead of name)
BufferCoord pBeginPos,pEndPos;
QString phrase = getWordAtPosition(editor,pos,pBeginPos,pEndPos,Editor::WordPurpose::wpInformation);
// Find it's definition
PStatement statement = editor->parser()->findStatementOf(
editor->filename(),
phrase,
pos.Line);
// definition of the symbol not found
if (!statement)
return false;
PSearchResults results = pMainWindow->searchResultModel()->addSearchResults(
phrase,
editor->filename(),
pos.Line
);
PSearchResultTreeItem item = findOccurenceInFile(
editor->filename(),
statement,
editor->parser());
if (item && !(item->results.isEmpty())) {
results->results.append(item);
}
pMainWindow->searchResultModel()->notifySearchResultsUpdated();
return true;
}
PSearchResultTreeItem CppRefacter::findOccurenceInFile(
const QString &filename,
const PStatement &statement,
const PCppParser& parser)
{
PSearchResultTreeItem parentItem = std::make_shared<SearchResultTreeItem>();
parentItem->filename = filename;
parentItem->parent = nullptr;
QStringList buffer;
SynEdit editor;
if (pMainWindow->editorList()->getContentFromOpenedEditor(
filename,buffer)){
editor.lines()->setContents(buffer);
} else {
QByteArray encoding;
QFile file(filename);
editor.lines()->LoadFromFile(file,ENCODING_AUTO_DETECT,encoding);
}
editor.setHighlighter(HighlighterManager().getCppHighlighter());
int posY = 0;
while (posY < editor.lines()->count()) {
QString line = editor.lines()->getString(posY);
if (line.isEmpty()) {
posY++;
continue;
}
if (posY == 0) {
editor.highlighter()->resetState();
} else {
editor.highlighter()->setState(
editor.lines()->ranges(posY-1),
editor.lines()->braceLevels(posY-1),
editor.lines()->bracketLevels(posY-1),
editor.lines()->parenthesisLevels(posY-1)
);
}
editor.highlighter()->setLine(line,posY);
while (!editor.highlighter()->eol()) {
int start = editor.highlighter()->getTokenPos() + 1;
QString token = editor.highlighter()->getToken();
if (token == statement->command) {
//same name symbol , test if the same statement;
BufferCoord p,pBeginPos,pEndPos;
p.Line = posY+1;
p.Char = start;
QString phrase = getWordAtPosition(&editor, p, pBeginPos,pEndPos,
Editor::WordPurpose::wpInformation);
PStatement tokenStatement = parser->findStatementOf(
filename,
phrase, p.Line);
if (tokenStatement
&& (tokenStatement->line == statement->line)
&& (tokenStatement->fileName == statement->fileName)) {
PSearchResultTreeItem item = std::make_shared<SearchResultTreeItem>();
item->filename = filename;
item->line = p.Line;
item->start = start;
item->len = phrase.length();
item->parent = parentItem.get();
item->text = line;
item->text.replace('\t',' ');
parentItem->results.append(item);
}
}
editor.highlighter()->next();
}
posY++;
}
return parentItem;
}

27
RedPandaIDE/cpprefacter.h Normal file
View File

@ -0,0 +1,27 @@
#ifndef CPPREFACTER_H
#define CPPREFACTER_H
#include <QObject>
#include "parser/parserutils.h"
#include "widgets/searchresultview.h"
#include "parser/cppparser.h"
class Editor;
class BufferCoord;
class CppRefacter : public QObject
{
Q_OBJECT
public:
explicit CppRefacter(QObject *parent = nullptr);
bool findOccurence(Editor * editor, const BufferCoord& pos);
signals:
private:
PSearchResultTreeItem findOccurenceInFile(
const QString& filename,
const PStatement& statement,
const PCppParser& parser);
};
#endif // CPPREFACTER_H

View File

@ -647,7 +647,7 @@ void Editor::onPreparePaintHighlightToken(int line, int aChar, const QString &to
if (mParser && mCompletionPopup && (attr->name() == SYNS_AttrIdentifier)) {
BufferCoord p{aChar,line};
BufferCoord pBeginPos,pEndPos;
QString s= getWordAtPosition(p, pBeginPos,pEndPos, WordPurpose::wpInformation);
QString s= getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation);
// qDebug()<<s;
PStatement statement = mParser->findStatementOf(mFilename,
s , p.Line);
@ -702,11 +702,11 @@ bool Editor::event(QEvent *event)
break;
case TipType::Identifier:
if (pMainWindow->debugger()->executing())
s = getWordAtPosition(p, pBeginPos,pEndPos, WordPurpose::wpEvaluation); // debugging
s = getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpEvaluation); // debugging
else if (//devEditor.ParserHints and
!mCompletionPopup->isVisible()
&& !mHeaderCompletionPopup->isVisible())
s = getWordAtPosition(p, pBeginPos,pEndPos, WordPurpose::wpInformation); // information during coding
s = getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpInformation); // information during coding
break;
case TipType::Selection:
s = selText(); // when a selection is available, always only use that
@ -1669,13 +1669,13 @@ void Editor::showCompletion(bool autoComplete)
BufferCoord{caretX() - 1,
caretY()}, s, tokenFinished,tokenType, attr)) {
if (tokenType == SynHighlighterTokenType::PreprocessDirective) {//Preprocessor
word = getWordAtPosition(caretXY(),pBeginPos,pEndPos, WordPurpose::wpDirective);
word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpDirective);
if (!word.startsWith('#')) {
//showTabnineCompletion();
return;
}
} else if (tokenType == SynHighlighterTokenType::Comment) { //Comment, javadoc tag
word = getWordAtPosition(caretXY(),pBeginPos,pEndPos, WordPurpose::wpJavadoc);
word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpJavadoc);
if (!word.startsWith('@')) {
return;
}
@ -1721,7 +1721,7 @@ void Editor::showCompletion(bool autoComplete)
);
if (word.isEmpty())
word=getWordAtPosition(caretXY(),pBeginPos,pEndPos, WordPurpose::wpCompletion);
word=getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpCompletion);
//if not fCompletionBox.Visible then
mCompletionPopup->prepareSearch(word, mFilename, pBeginPos.Line);
@ -1760,7 +1760,7 @@ void Editor::showHeaderCompletion(bool autoComplete)
mHeaderCompletionPopup->setParser(mParser);
BufferCoord pBeginPos,pEndPos;
QString word = getWordAtPosition(caretXY(),pBeginPos,pEndPos,
QString word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos,
WordPurpose::wpHeaderCompletionStart);
if (word.isEmpty())
return;
@ -1943,7 +1943,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
ExecuteCommand(
SynEditorCommand::ecDeleteLastChar,
QChar(), nullptr); // Simulate backspace in editor
phrase = getWordAtPosition(caretXY(),
phrase = getWordAtPosition(this,caretXY(),
pBeginPos,pEndPos,
purpose);
mLastIdCharPressed = phrase.length();
@ -1967,7 +1967,7 @@ bool Editor::onCompletionKeyPressed(QKeyEvent *event)
QChar ch = event->text().front();
if (isIdentChar(ch)) {
setSelText(ch);
phrase = getWordAtPosition(caretXY(),
phrase = getWordAtPosition(this,caretXY(),
pBeginPos,pEndPos,
purpose);
mLastIdCharPressed = phrase.length();
@ -1994,7 +1994,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
ExecuteCommand(
SynEditorCommand::ecDeleteLastChar,
QChar(), nullptr); // Simulate backspace in editor
phrase = getWordAtPosition(caretXY(),
phrase = getWordAtPosition(this,caretXY(),
pBeginPos,pEndPos,
WordPurpose::wpHeaderCompletion);
mLastIdCharPressed = phrase.length();
@ -2019,7 +2019,7 @@ bool Editor::onHeaderCompletionKeyPressed(QKeyEvent *event)
QChar ch = event->text().front();
if (isIdentChar(ch)) {
setSelText(ch);
phrase = getWordAtPosition(caretXY(),
phrase = getWordAtPosition(this,caretXY(),
pBeginPos,pEndPos,
WordPurpose::wpHeaderCompletion);
mLastIdCharPressed = phrase.length();
@ -2177,7 +2177,7 @@ void Editor::gotoDeclaration(const BufferCoord &pos)
{
// Exit early, don't bother creating a stream (which is slow)
BufferCoord pBeginPos, pEndPos;
QString phrase = getWordAtPosition(pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
if (phrase.isEmpty())
return;
@ -2207,7 +2207,7 @@ void Editor::gotoDefinition(const BufferCoord &pos)
{
// Exit early, don't bother creating a stream (which is slow)
BufferCoord pBeginPos, pEndPos;
QString phrase = getWordAtPosition(pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
QString phrase = getWordAtPosition(this,pos,pBeginPos,pEndPos, WordPurpose::wpInformation);
if (phrase.isEmpty())
return;
@ -2228,31 +2228,31 @@ void Editor::gotoDefinition(const BufferCoord &pos)
}
}
QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin, BufferCoord &pWordEnd, WordPurpose purpose)
QString getWordAtPosition(SynEdit *editor, const BufferCoord &p, BufferCoord &pWordBegin, BufferCoord &pWordEnd, Editor::WordPurpose purpose)
{
QString result = "";
QString s;
if ((p.Line<1) || (p.Line>lines()->count())) {
if ((p.Line<1) || (p.Line>editor->lines()->count())) {
pWordBegin = p;
pWordEnd = p;
return "";
}
s = lines()->getString(p.Line - 1);
s = editor->lines()->getString(p.Line - 1);
int len = s.length();
int wordBegin = p.Char - 1 - 1; //BufferCoord::Char starts with 1
int wordEnd = p.Char - 1 - 1;
// Copy forward until end of word
if (purpose == WordPurpose::wpEvaluation
|| purpose == WordPurpose::wpInformation) {
if (purpose == Editor::WordPurpose::wpEvaluation
|| purpose == Editor::WordPurpose::wpInformation) {
while (wordEnd + 1 < len) {
if ((purpose == WordPurpose::wpEvaluation)
if ((purpose == Editor::WordPurpose::wpEvaluation)
&& (s[wordEnd + 1] == '[')) {
if (!findComplement(s, '[', ']', wordEnd, 1))
break;
} else if (isIdentChar(s[wordEnd + 1])) {
} else if (editor->isIdentChar(s[wordEnd + 1])) {
wordEnd++;
} else
break;
@ -2260,9 +2260,9 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
}
// Copy backward until #
if (purpose == WordPurpose::wpDirective) {
if (purpose == Editor::WordPurpose::wpDirective) {
while ((wordBegin >= 0) && (wordBegin < len)) {
if (isIdentChar(s[wordBegin]))
if (editor->isIdentChar(s[wordBegin]))
wordBegin--;
else if (s[wordBegin] == '#') {
wordBegin--;
@ -2273,9 +2273,9 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
}
// Copy backward until @
if (purpose == WordPurpose::wpJavadoc) {
if (purpose == Editor::WordPurpose::wpJavadoc) {
while ((wordBegin >= 0) && (wordBegin < len)) {
if (isIdentChar(s[wordBegin]))
if (editor->isIdentChar(s[wordBegin]))
wordBegin--;
else if (s[wordBegin] == '@') {
wordBegin--;
@ -2286,9 +2286,9 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
}
// Copy backward until begin of path
if (purpose == WordPurpose::wpHeaderCompletion) {
if (purpose == Editor::WordPurpose::wpHeaderCompletion) {
while ((wordBegin >= 0) && (wordBegin < len)) {
if (isIdentChar(s[wordBegin]))
if (editor->isIdentChar(s[wordBegin]))
wordBegin--;
else if (s[wordBegin] == '/'
|| s[wordBegin] == '\\'
@ -2300,7 +2300,7 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
}
}
if (purpose == WordPurpose::wpHeaderCompletionStart) {
if (purpose == Editor::WordPurpose::wpHeaderCompletionStart) {
while ((wordBegin >= 0) && (wordBegin < len)) {
if (s[wordBegin] == '"'
|| s[wordBegin] == '<') {
@ -2310,7 +2310,7 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
|| s[wordBegin] == '\\'
|| s[wordBegin] == '.') {
wordBegin--;
} else if (isIdentChar(s[wordBegin]))
} else if (editor->isIdentChar(s[wordBegin]))
wordBegin--;
else
break;
@ -2319,16 +2319,16 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
// && ( wordBegin < len)
// Copy backward until begin of word
if (purpose == WordPurpose::wpCompletion
|| purpose == WordPurpose::wpEvaluation
|| purpose == WordPurpose::wpInformation) {
if (purpose == Editor::WordPurpose::wpCompletion
|| purpose == Editor::WordPurpose::wpEvaluation
|| purpose == Editor::WordPurpose::wpInformation) {
while ((wordBegin >= 0) && (wordBegin<len)) {
if (s[wordBegin] == ']') {
if (!findComplement(s, ']', '[', wordBegin, -1))
break;
else
wordBegin++; // step over mathing [
} else if (isIdentChar(s[wordBegin])) {
} else if (editor->isIdentChar(s[wordBegin])) {
wordBegin--;
} else if (s[wordBegin] == '.'
|| s[wordBegin] == ':'
@ -2375,9 +2375,9 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
&& (
result[0] == '.'
|| result[0] == '-')
&& (purpose == WordPurpose::wpCompletion
|| purpose == WordPurpose::wpEvaluation
|| purpose == WordPurpose::wpInformation)) {
&& (purpose == Editor::WordPurpose::wpCompletion
|| purpose == Editor::WordPurpose::wpEvaluation
|| purpose == Editor::WordPurpose::wpInformation)) {
int i = wordBegin;
int line=p.Line;
while (line>=1) {
@ -2391,7 +2391,7 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
if (i<0) {
line--;
if (line>=1) {
s=lines()->getString(line-1);
s=editor->lines()->getString(line-1);
i=s.length();
continue;
} else
@ -2401,7 +2401,7 @@ QString Editor::getWordAtPosition(const BufferCoord &p, BufferCoord &pWordBegin,
BufferCoord pDummy;
highlightPos.Line = line;
highlightPos.Char = i+1;
result = getWordAtPosition(highlightPos,pWordBegin,pDummy,purpose)+result;
result = getWordAtPosition(editor, highlightPos,pWordBegin,pDummy,purpose)+result;
break;
}
}
@ -2527,7 +2527,7 @@ void Editor::checkSyntaxInBack()
pMainWindow->checkSyntaxInBack(this);
}
const PCppParser &Editor::parser() const
const PCppParser &Editor::parser()
{
return mParser;
}

View File

@ -137,17 +137,13 @@ public:
void removeBreakpointFocus();
void modifyBreakpointProperty(int line);
void setActiveBreakpointFocus(int Line, bool setFocus=true);
QString getWordAtPosition(const BufferCoord& p,
BufferCoord& pWordBegin,
BufferCoord& pWordEnd,
WordPurpose purpose);
QString getPreviousWordAtPositionForSuggestion(const BufferCoord& p);
void reformat();
void checkSyntaxInBack();
void gotoDeclaration(const BufferCoord& pos);
void gotoDefinition(const BufferCoord& pos);
const PCppParser &parser() const;
const PCppParser &parser();
private slots:
void onModificationChanged(bool status) ;
@ -260,4 +256,11 @@ protected:
void mouseReleaseEvent(QMouseEvent *event) override;
};
QString getWordAtPosition(SynEdit* editor,
const BufferCoord& p,
BufferCoord& pWordBegin,
BufferCoord& pWordEnd,
Editor::WordPurpose purpose);
#endif // EDITOR_H

View File

@ -1,3 +1,4 @@
#include <windows.h>
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "editorlist.h"
@ -11,6 +12,7 @@
#include <QCloseEvent>
#include <QComboBox>
#include <QDesktopServices>
#include <QFileDialog>
#include <QInputDialog>
#include <QLabel>
@ -24,6 +26,7 @@
#include <QMessageBox>
#include <QTextCodec>
#include <QDebug>
#include "cpprefacter.h"
#include <widgets/searchdialog.h>
@ -1102,6 +1105,39 @@ void MainWindow::maximizeEditor()
}
}
void MainWindow::openShell(const QString &folder, const QString &shellCommand)
{
QProcess process;
process.setWorkingDirectory(folder);
process.setProgram(shellCommand);
process.setCreateProcessArgumentsModifier([](QProcess::CreateProcessArguments * args){
args->flags |= CREATE_NEW_CONSOLE;
args->startupInfo->dwFlags &= ~STARTF_USESTDHANDLES; //
});
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString path = env.value("PATH");
if (pSettings->compilerSets().defaultSet()) {
foreach(const QString& dir, pSettings->compilerSets().defaultSet()->binDirs()) {
#ifdef Q_OS_WIN
path+=";";
#else
path+=":";
#endif
path+=dir;
}
}
#ifdef Q_OS_WIN
path+=";";
#else
path+=":";
#endif
path+=pSettings->dirs().app();
env.insert("PATH",path);
process.setProcessEnvironment(env);
process.startDetached();
}
void MainWindow::onAutoSaveTimeout()
{
if (!pSettings->editor().enableAutoSave())
@ -1154,6 +1190,15 @@ void MainWindow::onEditorContextMenu(const QPoint &pos)
menu.addAction(ui->actionGoto_Declaration);
menu.addAction(ui->actionGoto_Definition);
menu.addAction(ui->actionFind_references);
menu.addSeparator();
menu.addAction(ui->actionOpen_Containing_Folder);
menu.addAction(ui->actionOpen_Terminal);
//these actions needs parser
ui->actionGoto_Declaration->setEnabled(!editor->parser()->parsing());
ui->actionGoto_Definition->setEnabled(!editor->parser()->parsing());
ui->actionFind_references->setEnabled(!editor->parser()->parsing());
} else {
//mouse on gutter
int line;
@ -1996,8 +2041,13 @@ void MainWindow::on_actionFind_Previous_triggered()
void MainWindow::on_cbSearchHistory_currentIndexChanged(int index)
{
ui->btnSearchAgin->setEnabled(!ui->cbSearchHistory->currentText().isEmpty());
mSearchResultModel.setCurrentIndex(index);
PSearchResults results = mSearchResultModel.results(index);
if (results && results->searchType == SearchType::Search) {
ui->btnSearchAgin->setEnabled(true);
} else {
ui->btnSearchAgin->setEnabled(false);
}
}
void MainWindow::on_btnSearchAgin_clicked()
@ -2206,3 +2256,41 @@ void MainWindow::on_actionGoto_Definition_triggered()
}
}
void MainWindow::on_actionFind_references_triggered()
{
Editor * editor = mEditorList->getEditor();
BufferCoord pos;
if (editor && editor->PointToCharLine(mContextMenuPos,pos)) {
CppRefacter refactor;
refactor.findOccurence(editor,pos);
ui->tabMessages->setCurrentWidget(ui->tabSearch);
openCloseBottomPanel(true);
}
}
void MainWindow::on_actionOpen_Containing_Folder_triggered()
{
Editor* editor = mEditorList->getEditor();
if (editor) {
QFileInfo info(editor->filename());
if (!info.path().isEmpty()) {
QDesktopServices::openUrl(info.path());
}
}
}
void MainWindow::on_actionOpen_Terminal_triggered()
{
Editor* editor = mEditorList->getEditor();
if (editor) {
QFileInfo info(editor->filename());
if (!info.path().isEmpty()) {
openShell(info.path(),"cmd.exe");
}
}
}

View File

@ -132,6 +132,7 @@ private:
void doAutoSave(Editor *e);
void buildContextMenus();
void maximizeEditor();
void openShell(const QString& folder, const QString& shellCommand);
private slots:
void onAutoSaveTimeout();
@ -274,6 +275,12 @@ private slots:
void on_actionGoto_Definition_triggered();
void on_actionFind_references_triggered();
void on_actionOpen_Containing_Folder_triggered();
void on_actionOpen_Terminal_triggered();
private:
Ui::MainWindow *ui;
EditorList *mEditorList;

View File

@ -255,7 +255,7 @@
<enum>QTabWidget::South</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>3</number>
</property>
<widget class="QWidget" name="tabIssues">
<attribute name="icon">
@ -467,7 +467,7 @@
<enum>QTabWidget::North</enum>
</property>
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tabDebugConsole">
<attribute name="title">
@ -1552,6 +1552,29 @@
<string>Find references</string>
</property>
</action>
<action name="actionOpen_Containing_Folder">
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/090-explorer.png</normalon>
</iconset>
</property>
<property name="text">
<string>Open containing folder</string>
</property>
<property name="shortcut">
<string>Ctrl+B</string>
</property>
</action>
<action name="actionOpen_Terminal">
<property name="icon">
<iconset>
<normalon>:/icons/images/newlook24/030-dos.png</normalon>
</iconset>
</property>
<property name="text">
<string>Open a terminal here</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>

View File

@ -254,6 +254,7 @@ public:
bool GetLineOfMouse(int& line);
bool PointToCharLine(const QPoint& point, BufferCoord& coord);
bool PointToLine(const QPoint& point, int& line);
bool isIdentChar(const QChar& ch);
// setter && getters
@ -369,9 +370,6 @@ signals:
void fontChanged();
void tabSizeChanged();
protected:
bool isIdentChar(const QChar& ch);
protected:
virtual bool onGetSpecialLineColors(int Line,
QColor& foreground, QColor& backgroundColor) ;

View File

@ -217,6 +217,24 @@ void SynEditStringList::setText(const QString &text)
PutTextStr(text);
}
void SynEditStringList::setContents(const QStringList &text)
{
beginUpdate();
auto action = finally([this]{
endUpdate();
});
clear();
if (text.count() > 0) {
mIndexOfLongestLine = -1;
int FirstAdded = mList.count();
foreach (const QString& s,text) {
addItem(s);
}
emit inserted(FirstAdded,text.count());
}
}
QStringList SynEditStringList::contents()
{
QStringList Result;
@ -288,8 +306,10 @@ void SynEditStringList::clear()
{
if (!mList.isEmpty()) {
beginUpdate();
int oldCount = mList.count();
mIndexOfLongestLine = -1;
mList.clear();
emit deleted(0,oldCount);
endUpdate();
}
}

View File

@ -67,6 +67,7 @@ public:
void* getObject(int Index);
QString text();
void setText(const QString& text);
void setContents(const QStringList& text);
QStringList contents();
void putString(int Index, const QString& s);