- 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 - fix: save project's layout shouldn't modify the project file
- enhancement: use expression processing in syntax highlighting for identifiers - 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 - 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 Red Panda C++ Version 0.14.4
- enhancement: git - log - enhancement: git - log

View File

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

View File

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

View File

@ -6216,15 +6216,19 @@ void MainWindow::on_actionLocate_in_Files_View_triggered()
{ {
Editor * editor = mEditorList->getEditor(); Editor * editor = mEditorList->getEditor();
if (editor) { if (editor) {
QString fileDir = extractFileDir(editor->filename()); QModelIndex index = mFileSystemModel.index(editor->filename());
if (!fileDir.isEmpty()) { if (!index.isValid()) {
setFilesViewRoot(fileDir); QString fileDir = extractFileDir(editor->filename());
QModelIndex index = mFileSystemModel.index(editor->filename()); if (!fileDir.isEmpty())
ui->treeFiles->setCurrentIndex(index); setFilesViewRoot(fileDir);
ui->treeFiles->scrollTo(index, QAbstractItemView::PositionAtCenter); else
ui->tabInfos->setCurrentWidget(ui->tabFiles); return;
openCloseLeftPanel(true); 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(); setDefaultKeystrokes();
mRightEdgeColor = Qt::lightGray; mRightEdgeColor = Qt::lightGray;
/* IME input */
mImeCount = 0;
mMBCSStepAside = false;
/* end of IME input */
mWantReturns = true; mWantReturns = true;
mWantTabs = false; mWantTabs = false;
mTabWidth = 4; mTabWidth = 4;
@ -1095,6 +1091,11 @@ void SynEdit::setCaretAndSelection(const BufferCoord &ptCaret, const BufferCoord
setBlockEnd(ptAfter); setBlockEnd(ptAfter);
} }
bool SynEdit::inputMethodOn()
{
return !mInputPreeditString.isEmpty();
}
void SynEdit::collapseAll() void SynEdit::collapseAll()
{ {
for (int i = mAllFoldRanges.count()-1;i>=0;i--){ for (int i = mAllFoldRanges.count()-1;i>=0;i--){
@ -2940,7 +2941,6 @@ void SynEdit::doOnPaintTransient(SynTransientType TransientType)
void SynEdit::updateLastCaretX() void SynEdit::updateLastCaretX()
{ {
mMBCSStepAside = false;
mLastCaretColumn = displayX(); mLastCaretColumn = displayX();
} }
@ -4712,17 +4712,15 @@ void SynEdit::moveCaretVert(int DY, bool isSelection)
} }
BufferCoord vDstLineChar = displayToBufferPos(ptDst); BufferCoord vDstLineChar = displayToBufferPos(ptDst);
int SaveLastCaretX = mLastCaretColumn; int SaveLastCaretX = mLastCaretColumn;
bool NewStepAside = mMBCSStepAside;
// set caret and block begin / end // set caret and block begin / end
incPaintLock(); incPaintLock();
moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection); moveCaretAndSelection(mBlockBegin, vDstLineChar, isSelection);
decPaintLock(); 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 // UpdateLastCaretX, called by SetCaretXYEx, changes them. This is the one
// case where we don't want that. // case where we don't want that.
mMBCSStepAside = NewStepAside;
mLastCaretColumn = SaveLastCaretX; mLastCaretColumn = SaveLastCaretX;
} }

View File

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