#define TYPENUM 5
-
Editor *e;
-char *UnitTypes[5] = {"CLASS","PROCEDURE","FUNCTION","PROCESS","COROUTINE"};
-
-
+/**
+ * @attention Currently not in use
+ */
+char *UnitTypes[TYPENUM] = {
+ "CLASS",
+ "PROCEDURE",
+ "FUNCTION",
+ "PROCESS",
+ "COROUTINE"
+};
+
+/**
+ * My_Edit constructor. Initializes and sets variables of Multiline editor
+ * widget.
+ * @param parent Parent widget of this widget. If set, this widget becomes a
+ * child window inside parent. If not set this widget becomes a
+ * top level window. Default: NULL
+ * @param name If set, name is sent to the Qobject constructor, so widget is
+ * identifiable (e.g. in Qt Designer)
+ */
My_Edit::My_Edit(QWidget *parent, const char *name)
: QMultiLineEdit(parent, name)
{
name = NULL;
}
+/**
+ * @copydoc QWidget::keyPressEvent(QKeyEvent*)
+ */
void My_Edit::keyPressEvent(QKeyEvent *ev)
{
QMultiLineEdit::keyPressEvent(ev);
emit cursorMove();
}
-
-void Editor::closeEvent ( QCloseEvent * e ) {
+/**
+ * @copydoc QWidget::closeEvent(QCloseEvent*)
+ */
+void Editor::closeEvent(QCloseEvent * e) {
e->ignore();
}
-Editor::Editor( char *hdir,QWidget * parent , const char * name)
- : QWidget( parent, name )
+/**
+ * Editor constructor. Initializes and sets variables of Loglan Editor.
+ * @param hdir Home directory of program (specified in configuration file)
+ * @param parent Parent widget of this widget. If set, this widget becomes a
+ * child window inside parent. If not set this widget becomes a
+ * top level window. Default: NULL
+ * @param name If set, name is sent to the Qobject constructor, so widget is
+ * identifiable (e.g. in Qt Designer)
+ */
+Editor::Editor(char *hdir,QWidget * parent , const char * name)
+ : QWidget(parent, name)
{
QFont f1("Helvetica", 10, QFont::Bold);
resize(400, 300);
}
+/**
+ * Editor destructor
+ */
Editor::~Editor()
{
}
+/**
+ * Displays line:column position of cursor
+ */
void Editor::updateline()
{
char pom[255];
position->setText(pom);
}
-void Editor::resizeEvent(QResizeEvent *)
+/**
+ * Event invoked when resizing editor window.
+ * @copydoc QWidget::resizeEvent(QResizeEvent*)
+ * @param event Currently does nothing
+ */
+void Editor::resizeEvent(QResizeEvent *event)
{
if (e && m) {
e->setGeometry(0, m->height(), width(),
}
}
-
+/**
+ * Displays additional window
+ */
void Editor::load()
{
QString fn = QFileDialog::getOpenFileName(file_path.data(), "*.log");
load(fn);
}
-
+/**
+ * Loads given file content to the editor.
+ * @param fileName Filename of file which will be read.
+ */
void Editor::load(const char *fileName)
{
fname.sprintf("%s", fileName);
setCaption(fileName);
}
-
+/**
+ * Saves editor content to the file.
+ * If content has been read from file, it is written to this file. Otherwise
+ * dialog is shown to save content to the specified by user, file.
+ */
void Editor::save()
{
if (fname.isEmpty()) {
setCaption(fname);
}
+/**
+ * Saves editor content to the file.
+ * Forces saving editor content to the new file. Special dialog is shown for
+ * that purpose.
+ */
void Editor::save_as()
{
QString fn = QFileDialog::getSaveFileName(file_path.data(), "*.log");
setCaption(fname);
}
+/**
+ * Saves editor content to the given filename.
+ * @param fileName File name of the file where content should be saved.
+ */
void Editor::save(const char *fileName)
{
QFile f(fileName);
f.close();
}
-
+/**
+ * Empties editor content.
+ */
void Editor::create()
{
e->clear();
fname.sprintf("%s", "");
}
+/**
+ * @attention Currently not in use
+ */
void Editor::print()
{
}
+/**
+ * @attention Currently not in use.
+ *
+ * Saves and compiles code.
+ */
void Editor::cmp()
{
save();
compile(COMP_MODE);
}
+/**
+ * @attention Currently not in use.
+ *
+ * Generates program.
+ */
void Editor::gen()
{
compile(GEN_MODE);
}
+/**
+ * @attention Currently not in use.
+ *
+ * Saves, compiles and generates code.
+ */
void Editor::comp_all()
{
save();
compile(ALL_MODE);
}
+/**
+ * Invokes compiler in the giving mode.
+ * @param mode Mode of compilation. Possible values:
+ * - COMP_MODE - compilation mode
+ * - GEN_MODE - program generation mode
+ * - ALL_MODE - compilation & generation mode.
+ */
void Editor::compile(int mode)
{
char cmd[255];
/* if (i>=0) {*/
QString fn = fname.data();
+
/* fn.truncate(i);*/
switch(mode) {
case COMP_MODE:
system(cmd);
sprintf(cmd, "%s %s >> comp_data!", gen_path.data(), fn.data());
break;
- } /*switch */
+ }
system(cmd);
QFile f("comp_data!");
/*}*/
}
+/**
+ * Displays window with editor properties
+ */
void Editor::props()
{
QDialog dlg(this, "Properties", TRUE);
};
}
-/* --------------------------------------- */
-
+/**
+ * @attention Currently not in use
+ */
void Editor::log_unit()
{
QString txt;
tmpQLabel->setText("Unit type:");
QListBox lst(&dlg, "type");
- for(i=0; i < TYPENUM; i++) {
+ for(i = 0; i < TYPENUM; i++) {
lst.insertItem(UnitTypes[i]);
}
lst.setGeometry(130, 60, 180, 80);
}
}
-
+/**
+ * @attention Currently not in use
+ */
void Editor::log_prog()
{
QString txt;
}
}
-
+/**
+ * Searches for given text in editor content.
+ * Displays window to set search parameters. If text is found sets cursor
+ * position on it.
+ */
void Editor::findText()
{
QDialog dlg(this, "", TRUE);
}
}
+/**
+ * Searches for next occurence of given text in editor content.
+ * Displays window to set search parameters. If text is found sets cursor
+ * position on it.
+ */
void Editor::find_next()
{
int pom,res,line;
QString *txt;
- e->getCursorPosition(&pom,&res);
+ e->getCursorPosition(&pom, &res);
for(line = pom + 1; line < e->numLines(); line++) {
txt = new QString(e->textLine(line));
if (sensitive)
- res=txt->find(find_text,0,TRUE);
+ res=txt->find(find_text, 0, TRUE);
else
- res=txt->find(find_text,0,FALSE);
+ res=txt->find(find_text, 0, FALSE);
delete txt;
if (res >= 0) {
- e->setCursorPosition(line,1);
+ e->setCursorPosition(line, 1);
break;
}
}
}
+/**
+ * Program main function.
+ * argv[1] is mandatory and should be a path to the home directory of
+ * application (same as in configuration file).
+ * @param argc Number of program arguments
+ * @param argv Program arguments
+ */
int main(int argc, char **argv)
{
QApplication a(argc, argv);
//a.setStyle(WindowsStyle);
+ /*
+ Defaults are zeroed, so created Editor widget become top-level window.
+ */
e = new Editor(argv[1]);
e->resize(600, 400);
e->show();