- fix: correct set the position of chinese input methods

This commit is contained in:
royqh1979@gmail.com 2021-11-08 21:19:48 +08:00
parent 93463c24ca
commit 4259480471
16 changed files with 516 additions and 330 deletions

View File

@ -2,7 +2,8 @@ Version 0.8.2 For Dev-C++ 7 Beta
- fix: highlighter can't correctly find the end of ANSI C-style Comments
- enhancement: add default color scheme to themes. Change theme option will change color scheme too.
- fix: when changing options in the option dialog's color scheme panle, color of the demo editor won't be not correctly updated
- enhancement: auto clear parsed symbols when the editor is hidden ( to reduce memory usage of un-active editors)
- enhancement: add option to auto clear parsed symbols when the editor is hidden ( to reduce total memory usage / turned off by default)
- fix: correct set the position of chinese input methods
Version 0.8.1 For Dev-C++ 7 Beta
- fix: ConsolePaurser.exe only exits when press ENTER

View File

@ -55,6 +55,7 @@ SOURCES += \
settingsdialog/editortooltipswidget.cpp \
settingsdialog/environmentfileassociationwidget.cpp \
settingsdialog/environmentfolderswidget.cpp \
settingsdialog/environmentperformancewidget.cpp \
settingsdialog/environmentshortcutwidget.cpp \
settingsdialog/executorproblemsetwidget.cpp \
settingsdialog/formattergeneralwidget.cpp \
@ -176,6 +177,7 @@ HEADERS += \
settingsdialog/editortooltipswidget.h \
settingsdialog/environmentfileassociationwidget.h \
settingsdialog/environmentfolderswidget.h \
settingsdialog/environmentperformancewidget.h \
settingsdialog/environmentshortcutwidget.h \
settingsdialog/executorproblemsetwidget.h \
settingsdialog/formattergeneralwidget.h \
@ -267,6 +269,7 @@ FORMS += \
settingsdialog/editortooltipswidget.ui \
settingsdialog/environmentfileassociationwidget.ui \
settingsdialog/environmentfolderswidget.ui \
settingsdialog/environmentperformancewidget.ui \
settingsdialog/environmentshortcutwidget.ui \
settingsdialog/executorproblemsetwidget.ui \
settingsdialog/formattergeneralwidget.ui \

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1375,7 +1375,11 @@ void Editor::onStatusChanged(SynStatusChanges changes)
&& !changes.testFlag(SynStatusChange::scReadOnly)
&& changes.testFlag(SynStatusChange::scCaretY))) {
mCurrentLineModified = false;
reparse();
if (pSettings->codeCompletion().clearWhenEditorHidden()
&& changes.testFlag(SynStatusChange::scOpenFile)) {
} else{
reparse();
}
if (pSettings->editor().syntaxCheckWhenLineChanged())
checkSyntaxInBack();
reparseTodo();
@ -1458,28 +1462,7 @@ void Editor::onStatusChanged(SynStatusChanges changes)
} else {
mCurrentHighlightedWord = "";
}
// mSelectionWord="";
// if (selAvail()) {
// BufferCoord wordBegin,wordEnd,bb,be;
// bb = blockBegin();
// be = blockEnd();
// wordBegin = wordStartEx(bb);
// wordEnd = wordEndEx(be);
// if (wordBegin.Line == bb.Line
// && wordBegin.Char == bb.Char
// && wordEnd.Line == be.Line
// && wordEnd.Char == be.Char) {
// if (wordBegin.Line>=1 && wordBegin.Line<=lines()->count()) {
// QString line = lines()->getString(wordBegin.Line-1);
// mSelectionWord = line.mid(wordBegin.Char-1,wordEnd.Char-wordBegin.Char);
// }
// }
//// qDebug()<<QString("(%1,%2)").arg(bb.Line).arg(bb.Char)
//// <<" - "<<QString("(%1,%2)").arg(be.Line).arg(be.Char)
//// <<" - "<<QString("(%1,%2)").arg(wordBegin.Line).arg(wordBegin.Char)
//// <<" - "<<QString("(%1,%2)").arg(wordEnd.Line).arg(wordEnd.Char)
//// <<" : "<<mSelectionWord;
// }
if (mOldHighlightedWord != mCurrentHighlightedWord) {
invalidate();
mOldHighlightedWord = mCurrentHighlightedWord;
@ -1490,16 +1473,6 @@ void Editor::onStatusChanged(SynStatusChanges changes)
if (pSettings->editor().showFunctionTips()) {
updateFunctionTip();
}
// fFunctionTip.ForceHide := false;
// if Assigned(fFunctionTipTimer) then begin
// if fFunctionTip.Activated and FunctionTipAllowed then begin
// fFunctionTip.Parser := fParser;
// fFunctionTip.FileName := fFileName;
// fFunctionTip.Show;
// end else begin // Reset the timer
// fFunctionTipTimer.Enabled := false;
// fFunctionTipTimer.Enabled := true;
// end;
}
@ -3148,6 +3121,16 @@ void Editor::onExportedFormatToken(PSynHighlighter syntaxHighlighter, int Line,
}
}
const QDateTime &Editor::hideTime() const
{
return mHideTime;
}
void Editor::setHideTime(const QDateTime &newHideTime)
{
mHideTime = newHideTime;
}
const std::shared_ptr<QHash<StatementKind, std::shared_ptr<ColorSchemeItem> > > &Editor::statementColors() const
{
return mStatementColors;

View File

@ -261,6 +261,7 @@ private:
TipType mCurrentTipType;
QString mOldHighlightedWord;
QString mCurrentHighlightedWord;
QDateTime mHideTime;
bool mSaving;
bool mCurrentLineModified;
@ -308,6 +309,9 @@ public:
const std::shared_ptr<QHash<StatementKind, std::shared_ptr<ColorSchemeItem> > > &statementColors() const;
void setStatementColors(const std::shared_ptr<QHash<StatementKind, std::shared_ptr<ColorSchemeItem> > > &newStatementColors);
const QDateTime &hideTime() const;
void setHideTime(const QDateTime &newHideTime);
protected:
void mouseReleaseEvent(QMouseEvent *event) override;

View File

@ -60,6 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
mOpenClosingLeftPanel(false),
mShouldRemoveAllSettings(false),
mClosing(false),
mOpenningFiles(false),
mSystemTurnedOff(false)
{
ui->setupUi(this);
@ -727,7 +728,7 @@ void MainWindow::rebuildOpenedFileHisotryMenu()
for (const QString& filename: pSettings->history().openedFiles()) {
QAction* action = new QAction(filename,mMenuRecentFiles);
connect(action, &QAction::triggered, [&filename,this](bool){
this->openFile(filename);
openFile(filename);
});
mMenuRecentFiles->addAction(action);
}
@ -843,8 +844,12 @@ void MainWindow::updateStatusbarMessage(const QString &s)
void MainWindow::openFiles(const QStringList &files)
{
mEditorList->beginUpdate();
mOpenningFiles = true;
auto end = finally([this] {
this->mEditorList->endUpdate();
mOpenningFiles = false;
updateEditorParser(ui->EditorTabsLeft);
updateEditorParser(ui->EditorTabsRight);
});
//Check if there is a project file in the list and open it
for (const QString& file:files) {
@ -4772,8 +4777,10 @@ PSymbolUsageManager &MainWindow::symbolUsageManager()
return mSymbolUsageManager;
}
static void updateEditorParser(QTabWidget* tabWidget,
Editor* editor) {
void MainWindow::updateEditorParser(QTabWidget* tabWidget) {
if (mOpenningFiles)
return;
Editor * editor = mEditorList->getEditor(-1,tabWidget);
if (pSettings->codeCompletion().clearWhenEditorHidden()) {
for (int i=0;i<tabWidget->count();i++) {
Editor * e = (Editor*)(tabWidget->widget(i));
@ -4790,13 +4797,26 @@ static void updateEditorParser(QTabWidget* tabWidget,
}
}
void MainWindow::updateEditorHideTime(QTabWidget* tabWidget) {
Editor * editor = mEditorList->getEditor(-1,tabWidget);
for (int i=0;i<tabWidget->count();i++) {
Editor * e = (Editor*)(tabWidget->widget(i));
if (e!=editor) {
if (!e->hideTime().isValid())
e->setHideTime(QDateTime::currentDateTime());
} else {
e->setHideTime(QDateTime());
}
}
}
void MainWindow::on_EditorTabsLeft_currentChanged(int)
{
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
if (editor) {
editor->reparseTodo();
}
updateEditorParser(ui->EditorTabsLeft,editor);
updateEditorParser(ui->EditorTabsLeft);
updateEditorHideTime(ui->EditorTabsLeft);
}
@ -4806,7 +4826,8 @@ void MainWindow::on_EditorTabsRight_currentChanged(int)
if (editor) {
editor->reparseTodo();
}
updateEditorParser(ui->EditorTabsRight,editor);
updateEditorParser(ui->EditorTabsRight);
updateEditorHideTime(ui->EditorTabsRight);
}
@ -5383,3 +5404,8 @@ void MainWindow::on_btnOpenProblemAnswer_clicked()
}
}
bool MainWindow::openningFiles() const
{
return mOpenningFiles;
}

View File

@ -155,6 +155,8 @@ public:
void openProject(const QString& filename);
void changeOptions(const QString& widgetName=QString(), const QString& groupName=QString());
bool openningFiles() const;
public slots:
void onCompileLog(const QString& msg);
void onCompileIssue(PCompileIssue issue);
@ -212,6 +214,8 @@ private:
void doCompileRun(RunType runType);
void updateProblemCaseOutput(POJProblemCase problemCase);
void applyCurrentProblemCaseChanges();
void updateEditorParser(QTabWidget* tabWidget);
void updateEditorHideTime(QTabWidget* tabWidget);
private slots:
void onAutoSaveTimeout();
@ -534,6 +538,7 @@ private:
CaretList mCaretList;
bool mClosing;
bool mOpenningFiles;
bool mSystemTurnedOff;
QPoint mEditorContextMenuPos;
QTcpServer mTcpServer;

View File

@ -2404,7 +2404,7 @@ bool SynEdit::canDoBlockIndent()
return true;
}
QRect SynEdit::calculateCaretRect()
QRect SynEdit::calculateCaretRect() const
{
DisplayCoord coord = displayXY();
if (!mInputPreeditString.isEmpty()) {
@ -2419,7 +2419,19 @@ QRect SynEdit::calculateCaretRect()
caretWidth = charColumns(mLines->getString(mCaretY-1)[mCaretX-1])*mCharWidth;
}
return QRect(caretPos.x(),caretPos.y(),caretWidth,
mTextHeight);
mTextHeight);
}
QRect SynEdit::calculateInputCaretRect() const
{
DisplayCoord coord = displayXY();
QPoint caretPos = rowColumnToPixels(coord);
int caretWidth=mCharWidth;
if (mCaretY <= mLines->count() && mCaretX <= mLines->getString(mCaretY-1).length()) {
caretWidth = charColumns(mLines->getString(mCaretY-1)[mCaretX-1])*mCharWidth;
}
return QRect(caretPos.x(),caretPos.y(),caretWidth,
mTextHeight);
}
void SynEdit::clearAreaList(SynEditingAreaList areaList)
@ -2946,6 +2958,10 @@ void SynEdit::setStatusChanged(SynStatusChanges changes)
void SynEdit::doOnStatusChange(SynStatusChanges)
{
if (mStatusChanges.testFlag(SynStatusChange::scCaretX)
|| mStatusChanges.testFlag(SynStatusChange::scCaretY)) {
qApp->inputMethod()->update(Qt::ImCursorPosition);
}
emit statusChanged(mStatusChanges);
mStatusChanges = SynStatusChange::scNone;
}
@ -6039,6 +6055,19 @@ bool SynEdit::viewportEvent(QEvent * event)
return QAbstractScrollArea::viewportEvent(event);
}
QVariant SynEdit::inputMethodQuery(Qt::InputMethodQuery property) const
{
QRect rect = calculateInputCaretRect();
switch(property) {
case Qt::ImCursorRectangle:
return rect;
default:
return QWidget::inputMethodQuery(property);
}
}
int SynEdit::maxScrollHeight() const
{
if (mOptions.testFlag(eoScrollPastEof))

View File

@ -524,7 +524,8 @@ private:
BufferCoord getPreviousLeftBrace(int x,int y);
bool canDoBlockIndent();
QRect calculateCaretRect();
QRect calculateCaretRect() const;
QRect calculateInputCaretRect() const;
//Commands
void doDeleteLastChar();
@ -717,6 +718,10 @@ void wheelEvent(QWheelEvent *event) override;
// QAbstractScrollArea interface
protected:
bool viewportEvent(QEvent * event) override;
// QWidget interface
public:
QVariant inputMethodQuery(Qt::InputMethodQuery property) const override;
};
#endif // SYNEDIT_H

View File

@ -3262,7 +3262,7 @@ void Settings::CodeCompletion::doLoad()
mIgnoreCase = boolValue("ignore_case",true);
mAppendFunc = boolValue("append_func",true);
mShowCodeIns = boolValue("show_code_ins",true);
mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",true);
mClearWhenEditorHidden = boolValue("clear_when_editor_hidden",false);
}
Settings::CodeFormatter::CodeFormatter(Settings *settings):

View File

@ -34,7 +34,6 @@ void EditorCodeCompletionWidget::doLoad()
ui->chkIgnoreCases->setChecked(pSettings->codeCompletion().ignoreCase());
ui->chkAppendFunc->setChecked(pSettings->codeCompletion().appendFunc());
ui->chkShowCodeIns->setChecked(pSettings->codeCompletion().showCodeIns());
ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
}
void EditorCodeCompletionWidget::doSave()
@ -55,7 +54,6 @@ void EditorCodeCompletionWidget::doSave()
pSettings->codeCompletion().setIgnoreCase(ui->chkIgnoreCases->isChecked());
pSettings->codeCompletion().setAppendFunc(ui->chkAppendFunc->isChecked());
pSettings->codeCompletion().setShowCodeIns(ui->chkShowCodeIns->isChecked());
pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
pSettings->codeCompletion().save();
}

View File

@ -0,0 +1,27 @@
#include "environmentperformancewidget.h"
#include "ui_environmentperformancewidget.h"
#include "../settings.h"
EnvironmentPerformanceWidget::EnvironmentPerformanceWidget(const QString& name, const QString& group, QWidget *parent) :
SettingsWidget(name,group,parent),
ui(new Ui::EnvironmentPerformanceWidget)
{
ui->setupUi(this);
}
EnvironmentPerformanceWidget::~EnvironmentPerformanceWidget()
{
delete ui;
}
void EnvironmentPerformanceWidget::doLoad()
{
ui->chkClearWhenEditorHidden->setChecked(pSettings->codeCompletion().clearWhenEditorHidden());
}
void EnvironmentPerformanceWidget::doSave()
{
pSettings->codeCompletion().setClearWhenEditorHidden(ui->chkClearWhenEditorHidden->isChecked());
pSettings->codeCompletion().save();
}

View File

@ -0,0 +1,26 @@
#ifndef ENVIRONMENTPERFORMANCEWIDGET_H
#define ENVIRONMENTPERFORMANCEWIDGET_H
#include <QWidget>
#include "settingswidget.h"
namespace Ui {
class EnvironmentPerformanceWidget;
}
class EnvironmentPerformanceWidget : public SettingsWidget
{
Q_OBJECT
public:
explicit EnvironmentPerformanceWidget(const QString& name, const QString& group, QWidget *parent = nullptr);
~EnvironmentPerformanceWidget();
void doLoad() override;
void doSave() override;
private:
Ui::EnvironmentPerformanceWidget *ui;
};
#endif // ENVIRONMENTPERFORMANCEWIDGET_H

View File

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>EnvironmentPerformanceWidget</class>
<widget class="QWidget" name="EnvironmentPerformanceWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Reduce Memory Usage</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QCheckBox" name="chkClearWhenEditorHidden">
<property name="text">
<string>Auto clear parsed symbols when editor hidden</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@ -18,6 +18,7 @@
#include "environmentshortcutwidget.h"
#include "environmentfileassociationwidget.h"
#include "environmentfolderswidget.h"
#include "environmentperformancewidget.h"
#include "executorgeneralwidget.h"
#include "executorproblemsetwidget.h"
#include "debuggeneralwidget.h"
@ -114,6 +115,10 @@ PSettingsDialog SettingsDialog::optionDialog()
widget->init();
dialog->addWidget(widget);
widget = new EnvironmentPerformanceWidget(tr("Performance"),tr("Environment"));
widget->init();
dialog->addWidget(widget);
connect((EnvironmentFoldersWidget*)widget,
&EnvironmentFoldersWidget::shouldQuitApp,
dialog.get(),