Skip to content

Commit cff9412

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

26 files changed

Lines changed: 2339 additions & 2235 deletions

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

Lines changed: 75 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ permissions:
66
on:
77
push:
88
branches:
9-
- main
9+
- main
1010
pull_request:
1111
branches:
12-
- main
12+
- main
1313

1414
env:
1515
BUILD_TYPE: Release
@@ -29,40 +29,82 @@ jobs:
2929
arch: win64_msvc2022_64
3030

3131
steps:
32-
- uses: actions/checkout@v3
33-
with:
34-
submodules: 'recursive'
35-
token: ${{ secrets.CONTRIBUTORS_TOKEN }}
32+
- uses: actions/checkout@v3
33+
with:
34+
submodules: 'recursive'
35+
token: ${{ secrets.CONTRIBUTORS_TOKEN }}
3636

37-
- name: Initialize CodeQL
38-
uses: github/codeql-action/init@v3
39-
with:
40-
languages: cpp
37+
- name: Initialize CodeQL (only on Linux)
38+
if: ${{ matrix.os == 'ubuntu-latest' }}
39+
uses: github/codeql-action/init@v3
40+
with:
41+
languages: cpp
4142

42-
- name: Install Qt
43-
# Installs the Qt SDK
44-
uses: jurplel/install-qt-action@v4
45-
with:
46-
version: 6.8.1
47-
host: ${{ matrix.os == 'windows-latest' && 'windows' || 'linux' }}
48-
target: 'desktop'
49-
arch: ${{ matrix.arch }}
50-
modules: ${{ matrix.os == 'windows-latest' && 'qtactiveqt' || '' }}
51-
cache: true
43+
- name: Install Qt
44+
# Installs the Qt SDK
45+
uses: jurplel/install-qt-action@v4
46+
with:
47+
version: 6.8.1
48+
host: ${{ matrix.os == 'windows-latest' && 'windows' || 'linux' }}
49+
target: 'desktop'
50+
arch: ${{ matrix.arch }}
51+
modules: ${{ matrix.os == 'windows-latest' && 'qtactiveqt' || '' }}
52+
cache: true
5253

53-
- name: Configure CMake
54-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
55-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
56-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
54+
- name: Configure CMake
55+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
56+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
57+
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
5758

58-
- name: Build
59-
# Build your program with the given configuration
60-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
59+
- name: Build
60+
# Build your program with the given configuration
61+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
6162

62-
- name: Perform CodeQL Analysis
63-
uses: github/codeql-action/analyze@v3
63+
- uses: actions/upload-artifact@v4
64+
with:
65+
name: WingHexExplorer2-${{ matrix.os == 'windows-latest' && 'windows' || 'linux' }}-build-cache
66+
path: ${{github.workspace}}/build
6467

65-
- uses: actions/upload-artifact@v4
66-
with:
67-
name: WingHexExplorer2-${{ matrix.os == 'windows-latest' && 'windows' || 'linux' }}-${{ matrix.qt_version }}-build-cache
68-
path: ${{github.workspace}}/build
68+
- name: Perform CodeQL analysis (produce SARIF)
69+
if: ${{ matrix.os == 'ubuntu-latest' }}
70+
uses: github/codeql-action/analyze@v3
71+
with:
72+
output: codeql-results
73+
upload: false
74+
75+
- name: Filter SARIF (exclude third-party dirs)
76+
if: ${{ matrix.os == 'ubuntu-latest' }}
77+
uses: advanced-security/filter-sarif@v1
78+
with:
79+
patterns: |
80+
+**/*.c
81+
+**/*.cpp
82+
+**/*.cc
83+
+**/*.cxx
84+
+**/*.h
85+
+**/*.hpp
86+
+**/*.hh
87+
-3rdparty/angel-lsp/**
88+
-3rdparty/AngelScript/**
89+
-3rdparty/antlr4-cpp/**
90+
-3rdparty/cppdap/**
91+
-3rdparty/cpptrace/**
92+
-3rdparty/fmt/**
93+
-3rdparty/Qt-Advanced-Docking-System/**
94+
-3rdparty/qwindowkit/**
95+
input: codeql-results/cpp.sarif
96+
output: codeql-results/cpp.sarif
97+
98+
- name: Upload filtered SARIF to GitHub Code Scanning
99+
if: ${{ matrix.os == 'ubuntu-latest' }}
100+
uses: github/codeql-action/upload-sarif@v3
101+
with:
102+
sarif_file: codeql-results/cpp.sarif
103+
104+
- name: Attach CodeQL SARIF artifact
105+
if: ${{ matrix.os == 'ubuntu-latest' }}
106+
uses: actions/upload-artifact@v4
107+
with:
108+
name: codeql-results
109+
path: codeql-results
110+
retention-days: 1

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)