2 * Copyright Johannes Sixt
3 * This file is licensed under the GNU General Public License Version 2.
4 * See the file COPYING in the toplevel directory of the source directory.
11 #include <qtextedit.h>
12 #include <qsyntaxhighlighter.h>
14 #include "dbgdriver.h"
16 // forward declarations
20 class SourceWindow
: public QTextEdit
24 SourceWindow(const char* fileName
, QWidget
* parent
, const char* name
);
29 bool fileNameMatches(const QString
& other
);
30 void scrollTo(int lineNo
, const DbgAddr
& address
);
31 const QString
& fileName() const { return m_fileName
; }
32 void updateLineItems(const KDebugger
* dbg
);
33 void setPC(bool set
, int lineNo
, const DbgAddr
& address
, int frameNo
);
34 enum FindDirection
{ findForward
= 1, findBackward
= -1 };
35 void find(const QString
& text
, bool caseSensitive
, FindDirection dir
);
36 bool wordAtPoint(const QPoint
& p
, QString
& word
, QRect
& r
);
38 * Translates row number (zero-based) to zero-based source line number.
39 * If sourceRow is non-zero, it is filled with the source code row
40 * belonging to the line number.
42 int rowToLine(int row
, int* sourceRow
= 0);
43 /** Translates zero-based source line number to row number (zero-based) */
44 int lineToRow(int line
);
45 /** Is the row disassembled? */
46 bool isRowExpanded(int row
);
47 /** Does the row show disassembled code? */
48 bool isRowDisassCode(int row
);
50 /** lineNo is zero-based */
51 void disassembled(int lineNo
, const QList
<DisassembledCode
>& disass
);
53 void activeLine(int& lineNo
, DbgAddr
& address
);
56 virtual void drawFrame(QPainter
* p
);
57 virtual bool eventFilter(QObject
* watched
, QEvent
* e
);
58 virtual void contextMenuEvent(QContextMenuEvent
* e
);
59 virtual void mousePressEvent(QMouseEvent
* ev
);
60 virtual void keyPressEvent(QKeyEvent
* ev
);
61 virtual void paletteChange(const QPalette
&);
62 void expandRow(int row
);
63 void collapseRow(int row
);
64 void scrollToRow(int row
);
65 /** translates (0-based) line number plus a code address into a row number */
66 int lineToRow(int row
, const DbgAddr
& address
);
68 void actionExpandRow(int row
);
69 void actionCollapseRow(int row
);
72 void clickedLeft(const QString
&, int, const DbgAddr
& address
, bool);
73 void clickedMid(const QString
&, int, const DbgAddr
& address
);
74 void disassemble(const QString
&, int);
75 void expanded(int lineNo
); /* source lineNo has been expanded */
76 void collapsed(int lineNo
); /* source lineNo has been collapsed */
79 void setTabWidth(int numChars
);
80 void cursorChanged(int row
);
84 enum LineItem
{ liPC
= 1, liPCup
= 2,
85 liBP
= 4, liBPdisabled
= 8, liBPtemporary
= 16,
86 liBPconditional
= 32, liBPorphan
= 64,
87 liBPany
= liBP
|liBPdisabled
|liBPtemporary
|liBPconditional
|liBPorphan
91 QString code
; /* a line of text */
92 std::vector
<QString
> disass
; /* its disassembled code */
93 std::vector
<DbgAddr
> disassAddr
; /* the addresses thereof */
94 bool canDisass
; /* if line can be disassembled */
95 SourceLine() : canDisass(true) { }
96 int findAddressRowOffset(const DbgAddr
& address
) const;
98 std::vector
<SourceLine
> m_sourceCode
;
100 std::vector
<int> m_rowToLine
; //!< The source line number for each row
101 std::vector
<uchar
> m_lineItems
; //!< Icons displayed on the line
102 QPixmap m_pcinner
; /* PC at innermost frame */
103 QPixmap m_pcup
; /* PC at frame up the stack */
104 QPixmap m_brkena
; /* enabled breakpoint */
105 QPixmap m_brkdis
; /* disabled breakpoint */
106 QPixmap m_brktmp
; /* temporary breakpoint marker */
107 QPixmap m_brkcond
; /* conditional breakpoint marker */
108 QPixmap m_brkorph
; /* orphaned breakpoint marker */
109 int m_curRow
; //!< The highlighted row
110 int m_widthItems
; //!< The width of the item column
111 int m_widthPlus
; //!< The width of the expander column
114 class HighlightCpp
: public QSyntaxHighlighter
116 SourceWindow
* m_srcWnd
;
119 HighlightCpp(SourceWindow
* srcWnd
);
120 virtual int highlightParagraph(const QString
& text
, int state
);
123 #endif // SOURCEWND_H