1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
// *************************************************************************
// gdboutputwidget.cpp - description
// -------------------
// begin : 10th April 2003
// copyright : (C) 2003 by John Birch
// email : jbb@kdevelop.org
// **************************************************************************
//
// **************************************************************************
// * *
// * This program is free software; you can redistribute it and/or modify *
// * it under the terms of the GNU General Public License as published by *
// * the Free Software Foundation; either version 2 of the License, or *
// * (at your option) any later version. *
// * *
// **************************************************************************
#ifndef _GDBOUTPUTWIDGET_H_
#define _GDBOUTPUTWIDGET_H_
#include <qwidget.h>
#include <qtextedit.h>
#include <qtimer.h>
#include <qstringlist.h>
class KHistoryCombo;
class QTextEdit;
class QToolButton;
class QDomElement;
namespace GDBDebugger
{
class GDBOutputWidget : public QWidget
{
Q_OBJECT
public:
GDBOutputWidget( QWidget *parent=0, const char *name=0 );
~GDBOutputWidget();
void savePartialProjectSession(QDomElement* el);
void restorePartialProjectSession(const QDomElement* el);
void clear();
public slots:
void slotInternalCommandStdout(const char* line);
void slotUserCommandStdout(const char* line);
void slotReceivedStderr(const char* line);
void slotDbgStatus (const QString &status, int statusFlag);
void slotGDBCmd();
void flushPending();
protected:
virtual void focusInEvent(QFocusEvent *e);
signals:
void userGDBCmd(const QString &cmd);
void breakInto();
private:
QString html_escape(const QString& s);
void newStdoutLine(const QString& line, bool internal);
/** Arranges for 'line' to be shown to the user.
Adds 'line' to pendingOutput_ and makes sure
updateTimer_ is running. */
void showLine(const QString& line);
/** Makes 'l' no longer then 'max_size' by
removing excessive elements from the top.
*/
void trimList(QStringList& l, unsigned max_size);
KHistoryCombo* m_userGDBCmdEditor;
QToolButton* m_Interrupt;
QTextEdit* m_gdbView;
void setShowInternalCommands(bool);
friend class OutputText;
/** The output from user commands only and from
all commands. We keep it here so that if we switch
"Show internal commands" on, we can show previous
internal commands.
*/
QStringList userCommands_, allCommands_;
/** Same output, without any fancy formatting. Keeping it
here because I can't find any way to extract raw text,
without formatting, out of QTextEdit except for
selecting everything and calling 'copy()'. The latter
approach is just ugly. */
QStringList userCommandsRaw_, allCommandsRaw_;
/** For performance reasons, we don't immediately add new text
to QTExtEdit. Instead we add it to pendingOutput_ and
flush it on timer.
*/
QString pendingOutput_;
QTimer updateTimer_;
bool showInternalCommands_;
int maxLines_;
};
/** Add popup menu specific to gdb output window to QTextEdit.
*/
class OutputText : public QTextEdit
{
Q_OBJECT
public:
OutputText(GDBOutputWidget* parent)
: QTextEdit(parent),
parent_(parent)
{}
QPopupMenu* createPopupMenu(const QPoint& pos);
private slots:
void copyAll();
void toggleShowInternalCommands();
private:
GDBOutputWidget* parent_;
};
}
#endif
|