Skip to content

Commit 1185337

Browse files
committed
feat: 优化脚本控制台的使用;
1 parent 9349b8e commit 1185337

26 files changed

Lines changed: 2276 additions & 2202 deletions

.github/workflows/qt-build-test.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,18 @@ jobs:
3838
uses: github/codeql-action/init@v3
3939
with:
4040
languages: cpp
41+
build-mode: manual
42+
dependency-caching: true
43+
config: |
44+
paths-ignore:
45+
- 3rdparty/angel-lsp
46+
- 3rdparty/AngelScript
47+
- 3rdparty/antlr4-cpp
48+
- 3rdparty/cppdap
49+
- 3rdparty/cpptrace
50+
- 3rdparty/fmt
51+
- 3rdparty/Qt-Advanced-Docking-System
52+
- 3rdparty/qwindowkit
4153
4254
- name: Install Qt
4355
# Installs the Qt SDK

3rdparty/QConsoleWidget/QConsoleWidget.cpp

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
#include "QConsoleWidget.h"
1919
#include "QConsoleIODevice.h"
20-
#include "wingsyntaxhighlighter.h"
2120

2221
#include <QAbstractItemView>
2322
#include <QApplication>
@@ -75,14 +74,15 @@ QIODevice *QConsoleWidget::device() const { return iodevice_; }
7574

7675
QString QConsoleWidget::getCommandLine() {
7776
if (mode_ == Output)
78-
return QString();
77+
return {};
78+
7979
// select text in edit zone (from the input pos to the end)
8080
QTextCursor textCursor = this->textCursor();
8181
textCursor.movePosition(QTextCursor::End);
8282
textCursor.setPosition(inpos_, QTextCursor::KeepAnchor);
8383
QString code = textCursor.selectedText();
8484
code.replace(QChar::ParagraphSeparator, QChar::LineFeed);
85-
return code;
85+
return code.trimmed();
8686
}
8787

8888
void QConsoleWidget::paste() {
@@ -94,7 +94,9 @@ void QConsoleWidget::paste() {
9494
}
9595
}
9696

97-
void QConsoleWidget::handleReturnKey() {
97+
void QConsoleWidget::handleReturnKey(Qt::KeyboardModifiers mod) {
98+
Q_UNUSED(mod);
99+
98100
QString code = getCommandLine();
99101

100102
// start new block
@@ -117,7 +119,9 @@ void QConsoleWidget::handleReturnKey() {
117119
Q_EMIT consoleCommand(code);
118120
}
119121

120-
void QConsoleWidget::handleTabKey() {
122+
void QConsoleWidget::handleTabKey(Qt::KeyboardModifiers mod) {
123+
Q_UNUSED(mod);
124+
121125
QTextCursor tc = this->textCursor();
122126
int anchor = tc.anchor();
123127
int position = tc.position();
@@ -251,7 +255,7 @@ void QConsoleWidget::keyPressEvent(QKeyEvent *e) {
251255

252256
case Qt::Key_Tab:
253257
e->accept();
254-
handleTabKey();
258+
handleTabKey(e->modifiers());
255259
return;
256260

257261
case Qt::Key_Home:
@@ -264,7 +268,7 @@ void QConsoleWidget::keyPressEvent(QKeyEvent *e) {
264268
case Qt::Key_Enter:
265269
case Qt::Key_Return:
266270
e->accept();
267-
handleReturnKey();
271+
handleReturnKey(e->modifiers());
268272
break;
269273

270274
case Qt::Key_Escape:

3rdparty/QConsoleWidget/QConsoleWidget.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ class QConsoleWidget : public WingCodeEdit {
9292
bool canPaste() const;
9393
bool canCut() const;
9494

95-
virtual void handleReturnKey();
96-
virtual void handleTabKey();
95+
virtual void handleReturnKey(Qt::KeyboardModifiers mod);
96+
virtual void handleTabKey(Qt::KeyboardModifiers mod);
97+
9798
// reimp QPlainTextEdit functions
9899
void keyPressEvent(QKeyEvent *e) override;
99100
void contextMenuEvent(QContextMenuEvent *event) override;

3rdparty/WingCodeEdit

CMakeLists.txt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set(CMAKE_AUTORCC ON)
88

99
set(CMAKE_CXX_STANDARD 17)
1010
set(CMAKE_CXX_STANDARD_REQUIRED ON)
11-
set(PROJECT_VERSION "2.2.3")
11+
set(PROJECT_VERSION "2.3.0-WIP")
1212

1313
find_package(QT NAMES Qt6 REQUIRED COMPONENTS Widgets Network Concurrent
1414
PrintSupport Xml LinguistTools)
@@ -354,7 +354,9 @@ set(CLASS_SRC
354354
src/class/lsp.h
355355
src/class/resettabletimer.h
356356
src/class/resettabletimer.cpp
357-
src/class/astype_evaluator.h)
357+
src/class/astype_evaluator.h
358+
src/class/angelscriptconsolevisitor.h
359+
src/class/angelscriptconsolevisitor.cpp)
358360

359361
set(INTERNAL_PLG_SRC src/class/wingangelapi.h src/class/wingangelapi.cpp
360362
src/class/wingcstruct.h src/class/wingcstruct.cpp)

0 commit comments

Comments
 (0)