46 TextFont.setStyleHint(QFont::Courier);
48 document()->setDefaultFont(
TextFont);
60 QFileInfo Info (Name_);
71 viewport()->setFocus();
73 setWordWrapMode(QTextOption::NoWrap);
76 connect(
this, SIGNAL(cursorPositionChanged()),
106 QFileInfo Info (FileName);
107 QString ext = Info.extension (
false);
108 if (ext ==
"vhd" || ext ==
"vhdl")
112 else if (ext ==
"va")
114 else if (ext ==
"m" || ext ==
"oct")
137 if (!file.open (QIODevice::WriteOnly))
140 QTextStream stream (&file);
141 stream <<
"Textfile settings file, Qucs " PACKAGE_VERSION
"\n"
143 <<
"Duration=" <<
SimTime <<
"\n"
145 <<
"Library=" <<
Library <<
"\n"
149 <<
"Icon=" <<
Icon <<
"\n"
151 <<
"DeviceType=" <<
devtype <<
"\n";
165 if (!file.open (QIODevice::ReadOnly))
168 QTextStream stream (&file);
169 QString
Line, Setting;
172 while (!stream.atEnd ()) {
173 Line = stream.readLine ();
174 Setting = Line.section (
'=', 0, 0);
175 Line = Line.section (
'=', 1).stripWhiteSpace ();
176 if (Setting ==
"Simulation") {
178 }
else if (Setting ==
"Duration") {
180 }
else if (Setting ==
"Module") {
181 }
else if (Setting ==
"Library") {
183 }
else if (Setting ==
"Libraries") {
185 }
else if (Setting ==
"ShortDesc") {
187 }
else if (Setting ==
"LongDesc") {
189 }
else if (Setting ==
"Icon") {
191 }
else if (Setting ==
"Recreate") {
193 }
else if (Setting ==
"DeviceType") {
215 DataSet = Info.baseName (
true) +
".dat";
217 if(Info.extension(
false) ==
"m" || Info.extension(
false) ==
"oct")
230 viewport()->setFocus ();
232 if (document()->isUndoAvailable())
236 if (document()->isRedoAvailable ())
242 App->
symEdit->setMenuText (tr(
"Edit Text Symbol"));
243 App->
symEdit->setStatusTip (tr(
"Edits the symbol for this text document"));
245 tr(
"Edit Text Symbol\n\nEdits the symbol for this text document"));
249 App->
insEntity->setStatusTip (tr(
"Inserts skeleton of VHDL entity"));
251 tr(
"VHDL entity\n\nInserts the skeleton of a VHDL entity"));
255 App->
insEntity->setStatusTip (tr(
"Inserts skeleton of Verilog module"));
257 tr(
"Verilog module\n\nInserts the skeleton of a Verilog module"));
262 App->
insEntity->setStatusTip (tr(
"Inserts skeleton of Octave function"));
264 tr(
"Octave function\n\nInserts the skeleton of a Octave function"));
275 QTextCursor pos = textCursor();
276 int x = pos.blockNumber();
277 int y = pos.columnNumber();
292 else if((!document()->isModified() &&
DocChanged)) {
297 App->
undo->setEnabled(document()->isUndoAvailable());
298 App->
redo->setEnabled(document()->isRedoAvailable());
310 QMenu *popup = QPlainTextEdit::createStandardContextMenu();
325 if (!file.open (QIODevice::ReadOnly))
329 QTextStream stream (&file);
330 insertPlainText(stream.read ());
331 document()->setModified(
false);
334 lastSaved = QDateTime::currentDateTime ();
351 if (!file.open (QIODevice::WriteOnly))
355 QTextStream stream (&file);
356 stream << toPlainText();
357 document()->setModified (
false);
365 QList<QTextEdit::ExtraSelection> extraSelections;
366 this->setExtraSelections(extraSelections);
382 QFont f = document()->defaultFont();
383 f.setPointSize(f.pointSize()*2);
384 document()->setDefaultFont(f);
387 QFont f = document()->defaultFont();
388 f.setPointSize(f.pointSize()*s);
389 document()->setDefaultFont(f);
401 TextFont.setStyleHint(QFont::Courier);
403 document()->setDefaultFont(
TextFont);
426 QTextCursor cursor = this->textCursor();
428 if(!cursor.hasSelection())
432 int start = cursor.selectionStart();
433 int end = cursor.selectionEnd();
435 cursor.setPosition(start);
436 int firstLine = cursor.blockNumber();
437 cursor.setPosition(end, QTextCursor::KeepAnchor);
438 int lastLine = cursor.blockNumber();
459 QStringList newlines;
460 for (
int i=firstLine; i<=lastLine; i++) {
461 QString line = document()->findBlockByLineNumber(i).text();
462 if (line.startsWith(co)){
464 line.remove(0,co.length());
469 line = line.insert(0, co);
473 insertPlainText(newlines.join(
"\n"));
482 appendPlainText(
"entity is\n port ( : in bit);\nend;\n"
483 "architecture of is\n signal : bit;\nbegin\n\nend;\n\n");
485 appendPlainText (
"module ( );\ninput ;\noutput ;\nbegin\n\nend\n"
488 appendPlainText (
"function = ( )\n"
517 return Info.baseName (
true);
529 QList<QTextEdit::ExtraSelection> extraSelections;
532 QTextEdit::ExtraSelection selection;
534 QColor lineColor = QColor(Qt::blue).lighter(195);
536 selection.format.setBackground(lineColor);
537 selection.format.setProperty(QTextFormat::FullWidthSelection,
true);
538 selection.cursor = textCursor();
539 selection.cursor.clearSelection();
540 extraSelections.append(selection);
543 setExtraSelections(extraSelections);
void slotCursorPosChanged()
TextDoc::slotCursorPosChanged update status bar with line:column.
int save()
TextDoc::save saves the current document and it settings.
void becomeCurrent(bool)
TextDoc::becomeCurrent sets text document as current.
~TextDoc()
TextDoc::~TextDoc Text document destructor.
Definition of the TextDoc class.
const char * smallsave_xpm[]
float zoomBy(float)
TextDoc::zoomBy increases/decreases the text font size.
tQucsSettings QucsSettings
bool saveSettings(void)
TextDoc::saveSettings saves the text document settings .cfg.
void setLanguage(int)
TextDoc::setLanguage(int)
Definitions and declarations for the main application.
QString getModuleName(void)
TextDoc::getModuleName parse the module name ou of the text file contents.
void printCursorPosition(int, int)
bool loadSimulationTime(QString &)
TextDoc::loadSimulationTime set SimTime member variable.
bool load()
TextDoc::load loads a text document.
SyntaxHighlighter * syntaxHighlight
bool loadSettings(void)
TextDoc::loadSettings loads the text document settings.
void slotSetChanged()
TextDoc::slotSetChanged togles tab icon to indicate unsaved changes.
void refreshLanguage(void)
TextDoc(QucsApp *, const QString &)
TextDoc::TextDoc Text document constructor.
void setName(const QString &)
TextDoc::setName sets the text file name on its tab.
void insertSkeleton()
TextDoc::insertSkeleton adds a basic skeleton for type of text file.
void commentSelected()
TextDoc::commentSelected toggles the comment of selected text See also QucsApp::slotEditActivate.
void showNoZoom()
TextDoc::showNoZoom resets the font scaling.
void highlightCurrentLine()
TextDoc::highlightCurrentLine mark the current line.
QMenu * createStandardContextMenu(const QPoint &)
TextDoc::createStandardContextMenu creates the standard context menu.