- change: "locate in files view" won't change the working folder, if current file is in subfolders of the working folder

- enhancement: hide function tips, when input method is visible
This commit is contained in:
Roy Qu 2022-03-10 12:15:44 +08:00
parent 44d5453263
commit dad39f6f74
6 changed files with 45 additions and 24 deletions

View File

@ -24,6 +24,8 @@ Red Panda C++ Version 0.14.5
- fix: save project's layout shouldn't modify the project file
- enhancement: use expression processing in syntax highlighting for identifiers
- fix: if a function's declaration can't be found, it will be wrongly highlighted as variable
- change: "locate in files view" won't change the working folder, if current file is in subfolders of the working folder
- enhancement: hide function tips, when input method is visible
Red Panda C++ Version 0.14.4
- enhancement: git - log

View File

@ -178,6 +178,8 @@ Editor::Editor(QWidget *parent, const QString& filename,
mParentPageControl->addTab(this,"");
updateCaption();
}
connect(&mFunctionTipTimer, &QTimer::timeout,
this, &Editor::onFunctionTipsTimer);
}
Editor::~Editor() {
@ -1548,7 +1550,10 @@ void Editor::onStatusChanged(SynStatusChanges changes)
// Update the function tip
if (pSettings->editor().showFunctionTips()) {
updateFunctionTip();
updateFunctionTip(false);
mFunctionTipTimer.stop();
mFunctionTipTimer.start(500);
// updateFunctionTip();
}
}
@ -1612,6 +1617,12 @@ void Editor::onLinesInserted(int first, int count)
}
}
void Editor::onFunctionTipsTimer()
{
mFunctionTipTimer.stop();
updateFunctionTip(true);
}
bool Editor::isBraceChar(QChar ch)
{
switch( ch.unicode()) {
@ -3367,12 +3378,16 @@ QString Editor::getHintForFunction(const PStatement &statement, const PStatement
return result;
}
void Editor::updateFunctionTip()
void Editor::updateFunctionTip(bool showTip)
{
if (pMainWindow->completionPopup()->isVisible()) {
pMainWindow->functionTip()->hide();
return;
}
if (inputMethodOn()) {
pMainWindow->functionTip()->hide();
return;
}
if (!highlighter())
return;
@ -3571,7 +3586,8 @@ void Editor::updateFunctionTip()
currentParamPos
);
cancelHint();
pMainWindow->functionTip()->show();
if (showTip)
pMainWindow->functionTip()->show();
}
void Editor::clearUserCodeInTabStops()

View File

@ -232,6 +232,7 @@ private slots:
void onTipEvalValueReady(const QString& value);
void onLinesDeleted(int first,int count);
void onLinesInserted(int first,int count);
void onFunctionTipsTimer();
private:
bool isBraceChar(QChar ch);
@ -277,7 +278,7 @@ private:
QString getHintForFunction(const PStatement& statement, const PStatement& scope,
const QString& filename, int line);
void updateFunctionTip();
void updateFunctionTip(bool showTip);
void clearUserCodeInTabStops();
void popUserCodeInTabStops();
void onExportedFormatToken(PSynHighlighter syntaxHighlighter, int Line, int column, const QString& token,
@ -329,6 +330,7 @@ private:
BufferCoord mHighlightCharPos1;
BufferCoord mHighlightCharPos2;
std::shared_ptr<QHash<StatementKind, std::shared_ptr<ColorSchemeItem> > > mStatementColors;
QTimer mFunctionTipTimer;
// QWidget interface
protected:

View File

@ -6216,15 +6216,19 @@ void MainWindow::on_actionLocate_in_Files_View_triggered()
{
Editor * editor = mEditorList->getEditor();
if (editor) {
QString fileDir = extractFileDir(editor->filename());
if (!fileDir.isEmpty()) {
setFilesViewRoot(fileDir);
QModelIndex index = mFileSystemModel.index(editor->filename());
ui->treeFiles->setCurrentIndex(index);
ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->tabInfos->setCurrentWidget(ui->tabFiles);
openCloseLeftPanel(true);
QModelIndex index = mFileSystemModel.index(editor->filename());
if (!index.isValid()) {
QString fileDir = extractFileDir(editor->filename());
if (!fileDir.isEmpty())
setFilesViewRoot(fileDir);
else
return;
index = mFileSystemModel.index(editor->filename());
}
ui->treeFiles->setCurrentIndex(index);
ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter);
ui->tabInfos->setCurrentWidget(ui->tabFiles);
openCloseLeftPanel(true);
}
}

View File

@ -122,10 +122,6 @@ SynEdit::SynEdit(QWidget *parent) : QAbstractScrollArea(parent)
setDefaultKeystrokes();
mRightEdgeColor = Qt::lightGray;
/* IME input */
mImeCount = 0;
mMBCSStepAside = false;
/* end of IME input */
mWantReturns = true;
mWantTabs = false;
mTabWidth = 4;
@ -1095,6 +1091,11 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord
setBlockEnd(ptAfter);
}
bool SynEdit::inputMethodOn()
{
return !mInputPreeditString.isEmpty();
}
void SynEdit::collapseAll()
{
for (int i = mAllFoldRanges.count()-1;i>=0;i--){
@ -2940,7 +2941,6 @@ void SynEdit::doOnPaintTransient(SynTransientType TransientType)
void SynEdit::updateLastCaretX()
{
mMBCSStepAside = false;
mLastCaretColumn = displayX();
}
@ -4712,17 +4712,15 @@ void SynEdit::moveCaretVert(int DY, bool isSelection)
}
BufferCoord vDstLineChar = displayToBufferPos(ptDst);
int SaveLastCaretX = mLastCaretColumn;
bool NewStepAside = mMBCSStepAside;
// set caret and block begin / end
incPaintLock();
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
decPaintLock();
// Set fMBCSStepAside and restore fLastCaretX after moving caret, since
// Restore fLastCaretX after moving caret, since
// UpdateLastCaretX, called by SetCaretXYEx, changes them. This is the one
// case where we don't want that.
mMBCSStepAside = NewStepAside;
mLastCaretColumn = SaveLastCaretX;
}

View File

@ -236,6 +236,8 @@ public:
const BufferCoord& ptBefore,
const BufferCoord& ptAfter);
bool inputMethodOn();
void collapseAll();
void unCollpaseAll();
void uncollapseAroundLine(int line);
@ -624,10 +626,7 @@ private:
QFont mFontForNonAscii;
SynFontSmoothMethod mFontSmoothing;
bool mMouseMoved;
/* IME input */
int mImeCount;
bool mMBCSStepAside;
/* end of IME input */
bool mInserting;
bool mPainting;
PSynEditStringList mLines;