NDEVR
API Documentation
TerminalDialog.h
1#pragma once
2#include "DLLInfo.h"
3#include <NDEVR/String.h>
4#include <NDEVR/LogStream.h>
5#include <QPlainTextEdit>
6#include <QTextCharFormat>
7#include <QPointer>
8namespace NDEVR
9{
10 class String;
11 class Connection;
12 struct ConnectionInfo;
30 class HARDWARE_WIDGETS_API TerminalDialog : public QTextEdit, public LogStream
31 {
32 Q_OBJECT
33 public:
38 explicit TerminalDialog(QWidget* parent = nullptr);
42 virtual ~TerminalDialog();
47 void putData(const StringView& data);
57 void setAutoPullData(bool set);
62 void setPushDataOnEnter(bool set);
67 void setConnection(const ConnectionInfo& info);
73 void setConnection(Connection* connection, bool add_all);
77 void setProgress(uint04, fltp04) override { };
83 void addMessage(uint04 id, const LogMessage& message) override;
88 void setCommandTermination(const StringView& termination);
93 void setAutoEcho(bool auto_echo);
94 protected:
99 void showEvent(QShowEvent* e) override;
104 void keyPressEvent(QKeyEvent* e) override;
109 void mousePressEvent(QMouseEvent* e) override;
114 void mouseDoubleClickEvent(QMouseEvent* e) override;
119 void contextMenuEvent(QContextMenuEvent* e) override;
120 private:
125 void addData(const StringView& data);
131 void addData(const QString& data, const QTextCharFormat& text_char_format);
135 void pushData();
142 void parseEscapeSequence(int attribute, QListIterator<QString>& i, QTextCharFormat& textCharFormat);
146 void eraseLastLine();
147 protected slots:
149 private:
150 Buffer<LogMessage> m_queued_messages;
151 QTextCursor m_cursor;
152 QTextCharFormat m_default_format;
153 String m_data_to_push;
154 String m_data_buffer;
155 String m_command_termination = String("\n");
156 QPointer<Connection> m_connection;
157 bool m_auto_pull_data = false;
158 bool m_push_on_enter = true;
159 bool m_ignore_next_tx = false;
160 bool m_auto_echo = false;
161 bool m_is_logger = false;
162 bool m_owns_connection = false;
163 };
164}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A standard interface for all types of connections that allow transmitting and receiving of data betwe...
Definition Connection.h:316
A light-weight base class for Log that allows processes to update, without the need for additional in...
A class that allows for specific log information to be conveyed to a InfoPipe object including inform...
Definition LogMessage.h:48
A listener that receives and processes log messages and progress updates from an InfoPipe.
Definition LogStream.h:49
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
virtual ~TerminalDialog()
Destructor.
void setConnection(Connection *connection, bool add_all)
Sets the connection to an existing Connection object.
void putData(const StringView &data)
Writes data to the terminal display.
void setConnection(const ConnectionInfo &info)
Sets the connection using connection info, creating a new connection.
void setAutoEcho(bool auto_echo)
Sets whether sent commands are automatically echoed to the terminal display.
void setAsLogger(InfoPipe *log)
Configures the terminal as a log output for an InfoPipe.
void setProgress(uint04, fltp04) override
No-op implementation of LogStream progress reporting.
TerminalDialog(QWidget *parent=nullptr)
Constructs a TerminalDialog.
void setCommandTermination(const StringView &termination)
Sets the string appended to commands when sent to the connection.
void mousePressEvent(QMouseEvent *e) override
Handles mouse press events for cursor positioning.
void contextMenuEvent(QContextMenuEvent *e) override
Handles context menu events for copy/paste operations.
void setAutoPullData(bool set)
Sets whether the terminal automatically polls the connection for data.
void keyPressEvent(QKeyEvent *e) override
Handles key press events for terminal input.
void pullDataSlot()
Slot that polls the connection for new data.
void mouseDoubleClickEvent(QMouseEvent *e) override
Handles mouse double-click events for text selection.
void setPushDataOnEnter(bool set)
Sets whether pressing Enter sends the current input to the connection.
void showEvent(QShowEvent *e) override
Handles the widget show event and starts data pulling if configured.
void addMessage(uint04 id, const LogMessage &message) override
Adds a log message to the terminal display queue.
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
A structure designed to store information about a specific Connection.
Definition Connection.h:90