Debian Codegraph @

sourcecodepane.h

raw symbols SCIP
1 // File: sourcecodepane.h
2 /*
3 Pep8-1 is a virtual machine for writing machine language and assembly
4 language programs.
5
6 Copyright (C) 2009 J. Stanley Warford, Pepperdine University
7
8 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22 #ifndef SOURCECODEPANE_H
23 #define SOURCECODEPANE_H
24
25 #include <QWidget>
26 #include <QString>
27 #include <QList>
28 #include "asm.h" // For Code in QList<Code *> codeList;
29 #include "pephighlighter.h" // For syntax highlighting
30 #include "enu.h"
31
32 namespace Ui {
33 class SourceCodePane;
34 }
35
36 class SourceCodePane : public QWidget {
37 Q_OBJECT
38 Q_DISABLE_COPY(SourceCodePane)
39 public:
40 explicit SourceCodePane(QWidget *parent = 0);
41 virtual ~SourceCodePane();
42
43 bool assemble();
44 // Pre: The source code pane contains a Pep/8 source program.
45 // Post: If the program assembles correctly, true is returned, and codeList is populated
46 // with the code objects. Otherwise false is returned and codeList is partially populated.
47 // Post: Pep::symbolTable is populated with values not adjusted for .BURN.
48 // Post: Pep::byteCount is the byte count for the object code not adjusted for .BURN.
49 // Post: Pep::burnCount is the number of .BURN instructions encountered in the source program.
50
51 QList<int> getObjectCode();
52 // Pre: codeList is populated with code from a complete correct Pep/8 source program.
53 // Post: objectCode is populated with the object code, one byte per entry, and returned.
54
55 QStringList getAssemblerListingList();
56 // Pre: codeList is populated with code from a complete correct Pep/8 source program.
57 // Post: assemlberListingList is populated with the assembler listing.
58 // Post: listingTraceList is populated with the object code.
59 // Post: hasCheckBox is populated with the checkBox list that specifies whether a trace line can have a break point.
60 // Post: assemblerListingList is returned.
61
62 QStringList getListingTraceList();
63 // Pre: listingTraceList is populated.
64 // Post: ListingTraceList is returned.
65
66 QList<bool> getHasCheckBox();
67 // Pre: hasCheckBox is populated.
68 // Post: hasCheckBox is returned.
69
70 void adjustCodeList(int addressDelta);
71 // Pre: codeList is populated with code from a complete correct Pep/8 source program.
72 // Post: The memAddress field of each code object is incremented by addressDelta.
73
74 void installOS();
75 // Pre: objectCode is populated with code from a complete correct Pep/8 OS source program.
76 // Post: objectCode is loaded into OS rom of Pep::Mem.
77
78 bool installDefaultOs();
79 // Post: the pep/8 operating system is installed into memory, and true is returned
80 // If assembly fails, false is returned
81 // This function should only be called on program startup once
82
83 void removeErrorMessages();
84 // Post: Searces for the string ";ERROR: " on each line and removes the end of the line.
85 // Post: Searces for the string ";WARNING: " on each line and removes the end of the line.
86
87 void appendMessageInSourceCodePaneAt(int lineNumber, QString message);
88 // Post: Appends message to the end of line lineNumber in color color.
89
90 void setSourceCodePaneText(QString string);
91 // Post: Sets text in source code pane to string.
92
93 void clearSourceCode();
94 // Post: Clears the source code pane
95
96 bool isModified();
97 // Post: Returns true if the source code pane has been modified
98
99 void setModifiedFalse();
100 // Post: Sets isModified of the source code pane to false
101
102 QString toPlainText();
103 // Post: Contents of the source code pane are returned
104
105 void setCurrentFile(QString string);
106 // Post: Title bar of the window is set to "Object Code - 'string'"
107
108 void highlightOnFocus();
109 // Post: Highlights the label based on the label window color saved in the UI file
110
111 bool hasFocus();
112 // Post: returns if the pane has focus
113
114 void undo();
115 // Post: the last action in the text edit is undone
116
117 void redo();
118 // Post: the last undo in the text edit is redone
119
120 bool isUndoable();
121 // Returns the undoability of the text edit
122
123 bool isRedoable();
124 // Returns the redoability of the text edit
125
126 void cut();
127 // Post: selected text in the text edit is cut to the clipboard
128
129 void copy();
130 // Post: selected text in the text edit is copied to the clipboard
131
132 void paste();
133 // Post: selected text in the clipboard is pasted to the text edit
134
135 void setReadOnly(bool b);
136 // Post: the text edit's read only attribute is set to b
137
138 void tab();
139
140 public slots:
141 void onFontChanged(QFont font);
142
143 private:
144 Ui::SourceCodePane *ui;
145 QList<Code *> codeList;
146 QList<int> objectCode;
147 QStringList assemblerListingList;
148 QStringList listingTraceList;
149 QList<bool> hasCheckBox;
150
151 PepHighlighter *pepHighlighter;
152
153 void mouseReleaseEvent(QMouseEvent *);
154
155 void mouseDoubleClickEvent(QMouseEvent *);
156
157 private slots:
158 void setLabelToModified(bool modified);
159
160 signals:
161 void undoAvailable(bool);
162 void redoAvailable(bool);
163
164 void labelDoubleClicked(Enu::EPane pane);
165 };
166
167 #endif // SOURCECODEPANE_H
168