3 // Copyright by Johannes Sixt
4 // This file is under GPL, the GNU General Public Licence
10 #include <qtextedit.h>
11 #include <qsyntaxhighlighter.h>
13 #include "dbgdriver.h"
15 // forward declarations
19 class SourceWindow
: public QTextEdit
23 SourceWindow(const char* fileName
, QWidget
* parent
, const char* name
);
28 bool fileNameMatches(const QString
& other
);
29 void scrollTo(int lineNo
, const DbgAddr
& address
);
30 const QString
& fileName() const { return m_fileName
; }
31 void updateLineItems(const KDebugger
* dbg
);
32 void setPC(bool set
, int lineNo
, const DbgAddr
& address
, int frameNo
);
33 enum FindDirection
{ findForward
= 1, findBackward
= -1 };
34 void find(const QString
& text
, bool caseSensitive
, FindDirection dir
);
35 bool wordAtPoint(const QPoint
& p
, QString
& word
, QRect
& r
);
37 * Translates row number (zero-based) to zero-based source line number.
38 * If sourceRow is non-zero, it is filled with the source code row
39 * belonging to the line number.
41 int rowToLine(int row
, int* sourceRow
= 0);
42 /** Translates zero-based source line number to row number (zero-based) */
43 int lineToRow(int line
);
44 /** Is the row disassembled? */
45 bool isRowExpanded(int row
);
46 /** Does the row show disassembled code? */
47 bool isRowDisassCode(int row
);
49 /** lineNo is zero-based */
50 void disassembled(int lineNo
, const QList
<DisassembledCode
>& disass
);
52 void activeLine(int& lineNo
, DbgAddr
& address
);
55 virtual void drawFrame(QPainter
* p
);
56 virtual bool eventFilter(QObject
* watched
, QEvent
* e
);
57 virtual void contextMenuEvent(QContextMenuEvent
* e
);
58 virtual void mousePressEvent(QMouseEvent
* ev
);
59 virtual void keyPressEvent(QKeyEvent
* ev
);
60 virtual void paletteChange(const QPalette
&);
61 void expandRow(int row
);
62 void collapseRow(int row
);
63 void scrollToRow(int row
);
64 /** translates (0-based) line number plus a code address into a row number */
65 int lineToRow(int row
, const DbgAddr
& address
);
67 void actionExpandRow(int row
);
68 void actionCollapseRow(int row
);
71 void clickedLeft(const QString
&, int, const DbgAddr
& address
, bool);
72 void clickedMid(const QString
&, int, const DbgAddr
& address
);
73 void disassemble(const QString
&, int);
74 void expanded(int lineNo
); /* source lineNo has been expanded */
75 void collapsed(int lineNo
); /* source lineNo has been collapsed */
77 void setTabWidth(int numChars
);
78 void cursorChanged(int row
);
82 enum LineItem
{ liPC
= 1, liPCup
= 2,
83 liBP
= 4, liBPdisabled
= 8, liBPtemporary
= 16,
84 liBPconditional
= 32, liBPorphan
= 64,
85 liBPany
= liBP
|liBPdisabled
|liBPtemporary
|liBPconditional
|liBPorphan
89 QString code
; /* a line of text */
90 std::vector
<QString
> disass
; /* its disassembled code */
91 std::vector
<DbgAddr
> disassAddr
; /* the addresses thereof */
92 bool canDisass
; /* if line can be disassembled */
93 SourceLine() : canDisass(true) { }
94 int findAddressRowOffset(const DbgAddr
& address
) const;
96 std::vector
<SourceLine
> m_sourceCode
;
98 std::vector
<int> m_rowToLine
; //!< The source line number for each row
99 std::vector
<uchar
> m_lineItems
; //!< Icons displayed on the line
100 QPixmap m_pcinner
; /* PC at innermost frame */
101 QPixmap m_pcup
; /* PC at frame up the stack */
102 QPixmap m_brkena
; /* enabled breakpoint */
103 QPixmap m_brkdis
; /* disabled breakpoint */
104 QPixmap m_brktmp
; /* temporary breakpoint marker */
105 QPixmap m_brkcond
; /* conditional breakpoint marker */
106 QPixmap m_brkorph
; /* orphaned breakpoint marker */
107 QFont m_lineNoFont
; //!< The font used to draw line numbers
108 int m_curRow
; //!< The highlighted row
109 int m_widthItems
; //!< The width of the item column
110 int m_widthPlus
; //!< The width of the expander column
111 int m_widthLineNo
; //!< The width of the line number columns
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