VirtualBox

source: vbox/trunk/src/VBox/Frontends/VirtualBox/src/guestctrl/UIGuestControlConsole.h@ 98103

Last change on this file since 98103 was 98103, checked in by vboxsync, 21 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1/* $Id: UIGuestControlConsole.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * VBox Qt GUI - UIGuestControlConsole class declaration.
4 */
5
6/*
7 * Copyright (C) 2016-2023 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28#ifndef FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h
29#define FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34/* Qt includes: */
35# include <QPlainTextEdit>
36
37/* COM includes: */
38#include "COMEnums.h"
39#include "CGuest.h"
40
41class UIGuestControlInterface;
42/** QPlainTextEdit extension to provide a simple terminal like widget. */
43class UIGuestControlConsole : public QPlainTextEdit
44{
45
46 Q_OBJECT;
47
48
49public:
50
51 UIGuestControlConsole(const CGuest &comGuest, QWidget* parent = 0);
52 /* @p strOutput is displayed in the console */
53 void putOutput(const QString &strOutput);
54
55protected:
56
57 void keyPressEvent(QKeyEvent *pEvent) RT_OVERRIDE;
58 void mousePressEvent(QMouseEvent *pEvent) RT_OVERRIDE;
59 void mouseDoubleClickEvent(QMouseEvent *pEvent) RT_OVERRIDE;
60 void contextMenuEvent(QContextMenuEvent *pEvent) RT_OVERRIDE;
61
62private slots:
63
64 void sltOutputReceived(const QString &strOutput);
65
66private:
67
68 typedef QVector<QString> CommandHistory;
69 typedef QMap<QString, int> TabDictionary;
70
71 void reset();
72 void startNextLine();
73 /** Return the text of the curent line */
74 QString getCommandString();
75 /** Replaces the content of the last line with m_strPromt + @p stringNewContent */
76 void replaceLineContent(const QString &stringNewContent);
77 /** Get next/prev command from history. Return @p originalString if history is empty. */
78 QString getNextCommandFromHistory(const QString &originalString = QString());
79 QString getPreviousCommandFromHistory(const QString &originalString = QString());
80 void completeByTab();
81 void commandEntered(const QString &strCommand);
82
83 /* Return a list of words that start with @p strSearch */
84 QList<QString> matchedWords(const QString &strSearch) const;
85 CGuest m_comGuest;
86 const QString m_strGreet;
87 const QString m_strPrompt;
88 TabDictionary m_tabDictinary;
89 /* A vector of entered commands */
90 CommandHistory m_tCommandHistory;
91 unsigned m_uCommandHistoryIndex;
92 UIGuestControlInterface *m_pControlInterface;
93};
94
95#endif /* !FEQT_INCLUDED_SRC_guestctrl_UIGuestControlConsole_h */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette