diff --git a/protoDebuger/ProtoDebug.qml b/protoDebuger/ProtoDebug.qml index 437e4c5..ab94b7c 100644 --- a/protoDebuger/ProtoDebug.qml +++ b/protoDebuger/ProtoDebug.qml @@ -5,6 +5,7 @@ import QtQuick.Controls.Material 2.12 Item { + id: debug_form objectName: "ProtoDebug" width: 800 height: 600 @@ -52,7 +53,7 @@ Item { font.pixelSize: 30 font.bold: true } - Flickable { + ScrollView { id: flick Layout.preferredHeight: parent.height - 100 Layout.preferredWidth: parent.width/2 - 20 @@ -60,7 +61,6 @@ Item { contentWidth: lua_script.paintedWidth contentHeight: lua_script.paintedHeight - clip: true Layout.leftMargin: 10 ColorAnimation { @@ -91,19 +91,28 @@ Item { onCursorRectangleChanged: flick.ensureVisible(cursorRectangle) } } - - TextArea { - id: text_output - Layout.preferredHeight: parent.height - 100 - text: qsTr("") - font.pixelSize: 20 + ScrollView{ Layout.columnSpan: 1 - Layout.preferredWidth: parent.width/2 - 20 - background: Rectangle { - border.color: text_output.enabled ? "#21be2b" : "transparent" - } + Layout.preferredWidth: parent.width/2 - 35 + Layout.preferredHeight: parent.height - 200 Layout.leftMargin: 10 + height: parent.height + TextArea { + id: text_output + height: parent.height + text: qsTr("") + font.pixelSize: 20 + cursorVisible: true; + focus: true; + readOnly: true + selectByMouse:true; + selectByKeyboard: true + background: Rectangle { + border.color: text_output.enabled ? "#21be2b" : "transparent" + } + + } } RowLayout{ visible: true @@ -168,10 +177,17 @@ Item { text: qsTr("执行命令") Layout.bottomMargin: 10 onClicked: { - } } - + Button { + id: button3 + text: qsTr("清空缓冲区") + Layout.bottomMargin: 10 + onClicked: { + console.log("dfsd") + debug_form.clearbuff() + } + } } } } @@ -195,6 +211,10 @@ Item { showbuf += str; text_output.text = showbuf; } + function clearbuff(){ + showbuf = ""; + text_output.text = showbuf; + } } diff --git a/protoDebuger/lua_wraper.cpp b/protoDebuger/lua_wraper.cpp index 94fe680..e705393 100644 --- a/protoDebuger/lua_wraper.cpp +++ b/protoDebuger/lua_wraper.cpp @@ -95,6 +95,7 @@ void LuaDelegate::OnClientLeave(QString ip, uint32_t port, uint32_t sockptr) lua_call(mVM,3,0); } + void LuaDelegate::DumpStack() { static int count = 0; diff --git a/protoDebuger/lua_wraper.h b/protoDebuger/lua_wraper.h index 74d142c..8af03f0 100644 --- a/protoDebuger/lua_wraper.h +++ b/protoDebuger/lua_wraper.h @@ -50,6 +50,7 @@ public: void OnNetworkData(char*,char*,uint32_t port); void OnNewTcpClient(QString ip,uint32_t port,uint32_t sockptr); void OnClientLeave(QString ip,uint32_t port,uint32_t sockptr); + void ClearShowBuffer(); void DumpStack(); diff --git a/protoDebuger/sharedata.h b/protoDebuger/sharedata.h index ca12165..494ad1f 100644 --- a/protoDebuger/sharedata.h +++ b/protoDebuger/sharedata.h @@ -32,16 +32,13 @@ public: int OnDataRecv(QByteArray); int ShowDataInQML(QString x); int SendUartData(const char *); - Q_INVOKABLE void getValFromQml(int v) { - emit valueFromCpp(456); + emit valueFromCpp(456); } - Q_INVOKABLE int openUart(QString port,QString baudRate,QString dataBits,QString stopBits, QString flow); Q_INVOKABLE int openNetwork(QString ip,unsigned int port,bool is_ws,int type); Q_INVOKABLE int closeNetwork(QString); - Q_INVOKABLE int closeSerial(); Q_INVOKABLE int TestLua(); Q_INVOKABLE int TestShowData(); @@ -49,14 +46,13 @@ public: Q_INVOKABLE int saveLuaScript(QString); Q_INVOKABLE bool luaStatus(); Q_INVOKABLE bool DoLuaCmd(QString); - QString _txt = "hello world\r\n"; - signals: void txtchanged(); void valueFromCpp(int val); void sendToQml(int count); void disConnected(); + void clearBuffer(); public slots: void on_network_data_recv();