27 #if defined (HAVE_CONFIG_H) 31 #if defined (HAVE_QSCINTILLA) 33 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) 34 # define HAVE_LEXER_OCTAVE 1 35 # include <Qsci/qscilexeroctave.h> 36 #elif defined (HAVE_QSCI_QSCILEXERMATLAB_H) 37 # define HAVE_LEXER_MATLAB 1 38 # include <Qsci/qscilexermatlab.h> 40 #include <Qsci/qscilexercpp.h> 41 #include <Qsci/qscilexerbash.h> 42 #include <Qsci/qscilexerperl.h> 43 #include <Qsci/qscilexerbatch.h> 44 #include <Qsci/qscilexerdiff.h> 45 #include <Qsci/qsciprinter.h> 46 #include <QApplication> 47 #include <QFileDialog> 48 #include <QMessageBox> 49 #include <QTextStream> 50 #include <QVBoxLayout> 51 #include <QInputDialog> 52 #include <QPrintDialog> 54 #include <QDesktopServices> 60 #include <QDialogButtonBox> 61 #include <QPushButton> 102 _ced = directory_arg;
115 connect (
_edit_area, SIGNAL (cursorPositionChanged (
int,
int)),
118 connect (
_edit_area, SIGNAL (SCN_CHARADDED (
int)),
121 connect (
_edit_area, SIGNAL (SCN_DOUBLECLICK (
int,
int,
int)),
124 connect (
_edit_area, SIGNAL (linesChanged ()),
127 connect (
_edit_area, SIGNAL (context_menu_edit_signal (
const QString&)),
137 QLabel *row_label =
new QLabel (tr (
"line:"),
this);
140 QLabel *col_label =
new QLabel (tr (
"col:"),
this);
147 QLabel *enc_label =
new QLabel (tr (
"encoding:"),
this);
151 _status_bar->addWidget (
new QLabel (
" ",
this), 0);
154 QLabel *eol_label =
new QLabel (tr (
"eol:"),
this);
158 _status_bar->addWidget (
new QLabel (
" ",
this), 0);
165 _edit_area->setMarginType (1, QsciScintilla::SymbolMargin);
174 _edit_area->setMarkerBackgroundColor (QColor (255,255,0),
176 _edit_area->markerDefine (QsciScintilla::RightArrow,
178 _edit_area->setMarkerBackgroundColor (QColor (192,192,192),
181 connect (
_edit_area, SIGNAL (marginClicked (
int,
int,
182 Qt::KeyboardModifiers)),
184 Qt::KeyboardModifiers)));
186 connect (
_edit_area, SIGNAL (context_menu_break_condition_signal (
int)),
190 _edit_area->setMarginsForegroundColor (QColor (96, 96, 96));
191 _edit_area->setMarginsBackgroundColor (QColor (232, 232, 220));
192 _edit_area->setMarginType (2, QsciScintilla::TextMargin);
195 _edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch);
203 _edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART,
false);
205 QVBoxLayout *edit_area_layout =
new QVBoxLayout ();
208 edit_area_layout->setMargin (0);
209 setLayout (edit_area_layout);
212 connect (
_edit_area, SIGNAL (modificationChanged (
bool)),
215 connect (
_edit_area, SIGNAL (copyAvailable (
bool)),
228 #if defined (Q_OS_WIN32) 229 _encoding = settings->value (
"editor/default_encoding",
"SYSTEM")
232 _encoding = settings->value (
"editor/default_encoding",
"UTF-8")
265 if (new_encoding.isEmpty ())
301 QRegExp rxfun1 (
"^[\t ]*function[^=]+=[\t ]*" 302 + word_at_cursor +
"[\t ]*\\([^\\)]*\\)[\t ]*$");
303 QRegExp rxfun2 (
"^[\t ]*function[\t ]+" 304 + word_at_cursor +
"[\t ]*\\([^\\)]*\\)[\t ]*$");
305 QRegExp rxfun3 (
"^[\t ]*function[\t ]+" 306 + word_at_cursor +
"[\t ]*$");
307 QRegExp rxfun4 (
"^[\t ]*function[^=]+=[\t ]*" 308 + word_at_cursor +
"[\t ]*$");
311 QStringList lines =
_edit_area->text ().split (
"\n");
316 if ((pos_fct = rxfun1.indexIn (lines.at (
line))) != -1)
318 if ((pos_fct = rxfun2.indexIn (lines.at (
line))) != -1)
320 if ((pos_fct = rxfun3.indexIn (lines.at (
line))) != -1)
322 if ((pos_fct = rxfun4.indexIn (lines.at (
line))) != -1)
376 cond =
'(' + cond +
") || (" +
_edit_area->selectedText () +
')';
384 QString new_condition
385 = QInputDialog::getText (
this, tr (
"Breakpoint condition"),
386 tr (prompt.c_str ()), QLineEdit::Normal, cond,
405 catch (
const interrupt_exception&)
413 cond = new_condition;
432 if (! trackedFiles.isEmpty ())
434 if (! fileName.isEmpty ())
476 int ans = QMessageBox::question (
nullptr, tr (
"Octave Editor"),
477 tr (
"Cannot add breakpoint to modified file.\n" 478 "Save and add breakpoint, or cancel?"),
479 QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save);
481 if (ans == QMessageBox::Save)
493 Qt::KeyboardModifiers
state)
497 unsigned int markers_mask =
_edit_area->markersAtLine (editor_linenr);
499 if (
state & Qt::ControlModifier)
532 #if defined (HAVE_LEXER_OCTAVE) 533 lexer =
new QsciLexerOctave ();
534 #elif defined (HAVE_LEXER_MATLAB) 535 lexer =
new QsciLexerMatlab ();
554 lexer =
new QsciLexerCPP ();
558 lexer =
new QsciLexerPerl ();
562 lexer =
new QsciLexerBatch ();
566 lexer =
new QsciLexerDiff ();
570 lexer =
new QsciLexerBash ();
575 #if defined (HAVE_LEXER_OCTAVE) 576 lexer =
new QsciLexerOctave ();
578 #elif defined (HAVE_LEXER_MATLAB) 579 lexer =
new QsciLexerMatlab ();
598 || QString(old_lexer->lexer ()) != QString(
lexer->
lexer ()))
633 bool update_apis =
false;
636 #if defined (HAVE_QSTANDARDPATHS) 637 QString prep_apis_path
638 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation)
641 QString prep_apis_path
642 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation)
647 bool octave_builtins = settings->value (
648 "editor/codeCompletion_octave_builtins",
true).toBool ();
649 bool octave_functions = settings->value (
650 "editor/codeCompletion_octave_functions",
true).toBool ();
666 if (octave_functions)
674 update_apis = ! apis_file.exists ();
676 if (octave_functions)
681 QDateTime apis_time = apis_file.lastModified ();
682 if (QDateTime::currentDateTime () > apis_time.addSecs (180))
701 QStringList keyword_list;
714 "file_editor_tab::update_lexer_settings");
719 if (octave_functions)
730 keyword = QString (
lexer->keywords (
i));
731 keyword_list = keyword.split (QRegExp (R
"(\s+)")); 732 for (j = 0; j < keyword_list.size (); j++)
738 disconnect (
_lexer_apis, SIGNAL (apiPreparationFinished ()),
nullptr,
nullptr);
740 if (QDir (
"/").mkpath (prep_apis_path))
743 connect (
_lexer_apis, SIGNAL (apiPreparationFinished ()),
752 lexer->readSettings (*settings);
758 QColor bg =
lexer->paper (0);
759 QColor fg =
lexer->color (0);
761 int bh, bs, bv, fh,
fs, fv,
h,
s, v;
762 bg.getHsv (&bh,&bs,&bv);
763 fg.getHsv (&fh,&
fs,&fv);
768 v = bv + (fv - bv)/5;
773 v = bv + (fv - bv)/8;
775 v = bv + (fv - bv)/4;
785 QColor hg = QApplication::palette ().color (QPalette::Highlight);
790 if (settings->value (
"editor/showLineNumbers",
true).toBool ())
796 QFont line_numbers_font =
lexer->defaultFont ();
797 int font_size = line_numbers_font.pointSize ();
798 font_size = font_size
799 + settings->value (
"editor/line_numbers_size", 0).toInt ();
802 line_numbers_font.setPointSize (font_size);
804 _edit_area->setMarginsFont (line_numbers_font);
817 for (
int idx = 0; idx < key_list.
numel (); idx++)
868 bool remove_on_success)
889 QsciPrinter *printer =
new QsciPrinter (QPrinter::HighResolution);
891 QPrintDialog printDlg (printer,
this);
893 if (printDlg.exec () == QDialog::Accepted)
991 line_info[0] = info.
line;
1005 line_info[0] = info.
line;
1028 const QString& cond)
1033 QString q_dir =
file_info.absolutePath ();
1034 QString q_function_name =
file_info.fileName ();
1037 q_function_name.chop (
file_info.suffix ().length () + 1);
1039 dir = q_dir.toStdString ();
1047 if (pos != std::string::npos && pos <
dir.length () - 1)
1049 if (
dir[pos+1] ==
'@')
1053 dir =
dir.substr (0, pos);
1059 const QString& condition)
1080 int editor_linenr, cur;
1081 _edit_area->getCursorPosition (&editor_linenr, &cur);
1108 if (nextcond != -1 && (nextcond < nextline || nextline == -1))
1109 nextline = nextcond;
1121 int line, cur, prevline, prevcond;
1130 if (prevcond != -1 && prevcond > prevline)
1131 prevline = prevcond;
1196 QsciScintilla::EolMode eol_mode)
1256 fetab_actions.mid (0,2),
1257 qobject_cast<
QWidget *> (sender ()));
1315 tr (
"Line number"),
line+1, 1,
1342 QsciScintilla::AutoCompletionSource
s =
_edit_area->autoCompletionSource ();
1345 case QsciScintilla::AcsAll:
1349 case QsciScintilla::AcsAPIs:
1353 case QsciScintilla::AcsDocument:
1357 case QsciScintilla::AcsNone:
1369 int lineFrom, lineTo, colFrom, colTo;
1370 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
1375 for (
int i = lineFrom;
i <= lineTo;
i++)
1383 _edit_area->setSelection (lineFrom, 0, lineTo,
1389 _edit_area->getCursorPosition (&cpline, &col);
1403 int lineFrom, lineTo;
1408 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
1416 _edit_area->getCursorPosition (&lineFrom, &col);
1429 QString ws =
"^([ \\t]*)";
1431 QString used_comment_str = comment_str.at (0);
1440 used_comment_str = QInputDialog::getText (
1441 this, tr (
"Comment selected text"),
1442 tr (
"Comment string to use:\n"), QLineEdit::Normal,
1446 if ((! ok) || used_comment_str.isEmpty ())
1457 QStringList comment_str_sorted (comment_str.at (0));
1460 for (
int i = 1;
i < comment_str.length ();
i++)
1463 for (
int j = 0; j < comment_str_sorted.length (); j++)
1465 if (comment_str.at (
i).length () > comment_str_sorted.at (j).length ())
1467 comment_str_sorted.insert (j, comment_str.at (
i));
1473 comment_str_sorted << comment_str.at (
i);
1478 for (
int i = 0;
i < comment_str_sorted.length ();
i++)
1484 rxc = QRegExp (ws +
"(" +
regexp +
")");
1488 int len = 0, lenc = 0;
1493 int lineFrom, lineTo, colFrom, colTo;
1494 int change_col_from = 1;
1495 int change_col_to = 1;
1498 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
1503 for (
int i = lineFrom;
i <= lineTo;
i++)
1512 if ((removed =
line.contains (rxc)))
1514 len = rxc.matchedLength ();
1515 QString matched_text = rxc.capturedTexts ().at (0);
1516 lenc = matched_text.remove (QRegExp (ws)).length ();
1522 if (
i == lineFrom && (colFrom < len-lenc || ! removed))
1523 change_col_from = 0;
1524 if (
i == lineTo && (colTo < len-lenc || ! removed))
1532 colFrom = colFrom + lenc;
1534 colTo = colTo + lenc;
1542 colFrom = colFrom - change_col_from*lenc;
1543 colTo = colTo - change_col_to*lenc;
1547 _edit_area->setSelection (lineFrom, colFrom, lineTo, colTo);
1552 _edit_area->getCursorPosition (&cpline, &col);
1554 _edit_area->insertAt (used_comment_str, cpline, 0);
1558 if (
line.contains (rxc))
1560 len = rxc.matchedLength ();
1561 QString matched_text = rxc.capturedTexts ().at (0);
1562 lenc = matched_text.remove (QRegExp (ws)).length ();
1563 _edit_area->setSelection (cpline, len-lenc, cpline, len);
1574 QString tooltip (
"");
1577 title = tr (
"<unnamed>");
1585 title =
file.fileName ();
1605 dlg->setAttribute (Qt::WA_DeleteOnClose);
1610 dlg->setWindowModality (Qt::NonModal);
1617 int decision = QMessageBox::Yes;
1623 QMessageBox::StandardButtons buttons = QMessageBox::Save |
1624 QMessageBox::Discard |
1625 QMessageBox::Cancel;
1630 QString available_actions =
1631 tr (
"Do you want to cancel closing, save or discard the changes?");
1637 file = tr (
"<unnamed>");
1640 =
new QMessageBox (QMessageBox::Warning, tr (
"Octave Editor"),
1643 "is about to be closed but has been modified. " 1646 buttons, qobject_cast<QWidget *> (parent ()));
1648 msgBox->setDefaultButton (QMessageBox::Save);
1650 connect (msgBox, SIGNAL (finished (
int)),
1656 return QMessageBox::Cancel;
1671 if (decision == QMessageBox::Save)
1676 else if (decision == QMessageBox::Discard)
1728 QFileInfo
file_info = QFileInfo (fileName);
1729 QString file_to_load;
1731 file_to_load =
file_info.canonicalFilePath ();
1733 file_to_load = fileName;
1734 QFile
file (file_to_load);
1735 if (!
file.open (QFile::ReadOnly))
1736 return file.errorString ();
1739 QTextStream in (&
file);
1741 QTextCodec *codec = QTextCodec::codecForName (
_encoding.toLatin1 ());
1742 in.setCodec (codec);
1744 QApplication::setOverrideCursor (Qt::WaitCursor);
1747 QApplication::restoreOverrideCursor ();
1781 QByteArray eol_lf = QByteArray (1,0x0a);
1782 QByteArray eol_cr = QByteArray (1,0x0d);
1783 QByteArray eol_crlf = eol_cr;
1784 eol_crlf.append (eol_lf);
1786 int count_crlf =
text.count (eol_crlf);
1787 int count_lf =
text.count (eol_lf) - count_crlf;
1788 int count_cr =
text.count (eol_cr) - count_crlf;
1791 #if defined (Q_OS_WIN32) 1792 int os_eol_mode = QsciScintilla::EolWindows;
1793 #elif defined (Q_OS_MAC) 1794 int os_eol_mode = QsciScintilla::EolMac;
1796 int os_eol_mode = QsciScintilla::EolUnix;
1799 QsciScintilla::EolMode eol_mode =
static_cast<QsciScintilla::EolMode
> (
1800 settings->value (
"editor/default_eol_mode",os_eol_mode).toInt ());
1804 if (count_crlf > count_max)
1806 eol_mode = QsciScintilla::EolWindows;
1807 count_max = count_crlf;
1809 if (count_lf > count_max)
1811 eol_mode = QsciScintilla::EolUnix;
1812 count_max = count_lf;
1814 if (count_cr > count_max)
1816 eol_mode = QsciScintilla::EolMac;
1817 count_max = count_cr;
1827 case QsciScintilla::EolWindows:
1830 case QsciScintilla::EolMac:
1833 case QsciScintilla::EolUnix:
1846 if (requester ==
this)
1874 #if defined (Q_OS_WIN32) 1875 int eol_mode = QsciScintilla::EolWindows;
1876 #elif defined (Q_OS_MAC) 1877 int eol_mode = QsciScintilla::EolMac;
1879 int eol_mode = QsciScintilla::EolUnix;
1882 static_cast<QsciScintilla::EolMode> (
1883 settings->value (
"editor/default_eol_mode",eol_mode).toInt ()));
1896 const QString& base_name_q)
1901 std::string base_name = base_name_q.toStdString ();
1905 sym = symtab.
find (base_name);
1919 std::string full_name = full_name_q.toStdString ();
1934 if (names(
i).string_value () == base_name)
1936 int ans = QMessageBox::question (
nullptr, tr (
"Debug or Save"),
1937 tr (
"This file is currently being executed.\n" 1938 "Quit debugging and save?"),
1939 QMessageBox::Save | QMessageBox::Cancel);
1941 if (ans == QMessageBox::Save)
1945 while (names.
numel () >
i)
1966 bool remove_on_success,
1967 bool restore_breakpoints)
1981 QFileInfo
file_info = QFileInfo (saveFileName);
1982 QString file_to_save;
1985 file_to_save =
file_info.canonicalFilePath ();
1987 if ((Fisdebugmode ())(0).
is_true ()
1992 file_to_save = saveFileName;
1993 QFile
file (file_to_save);
1997 if (trackedFiles.contains (file_to_save))
2001 if (!
file.open (QIODevice::WriteOnly))
2005 if (trackedFiles.contains (file_to_save))
2011 tr (
"Octave Editor"),
2012 tr (
"Could not open file %1 for write:\n%2.").
2013 arg (file_to_save).
arg (
file.errorString ()),
2014 QMessageBox::Ok,
nullptr);
2025 QTextCodec *codec = QTextCodec::codecForName (
_encoding.toLatin1 ());
2034 QTextStream out (&
file);
2035 out.setCodec (codec);
2037 QApplication::setOverrideCursor (Qt::WaitCursor);
2040 QApplication::restoreOverrideCursor ();
2046 file_to_save =
file_info.canonicalFilePath ();
2058 if (remove_on_success)
2067 if (restore_breakpoints)
2082 if (remove_on_success)
2095 fileDialog->setOption (QFileDialog::DontUseNativeDialog,
true);
2098 QGridLayout *extra =
new QGridLayout (fileDialog);
2099 QFrame *separator =
new QFrame (fileDialog);
2100 separator->setFrameShape (QFrame::HLine);
2101 separator->setFrameStyle (QFrame::Sunken);
2104 QLabel *label_eol =
new QLabel (tr (
"Line Endings:"));
2105 QComboBox *combo_eol =
new QComboBox ();
2106 combo_eol->addItem (
"Windows (CRLF)");
2107 combo_eol->addItem (
"Mac (CR)");
2108 combo_eol->addItem (
"Unix (LF)");
2113 QLabel *label_enc =
new QLabel (tr (
"File Encoding:"));
2114 QComboBox *combo_enc =
new QComboBox ();
2118 connect (combo_eol, SIGNAL (currentIndexChanged (
int)),
2120 connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
2124 extra->addWidget (separator,0,0,1,6);
2125 extra->addWidget (label_eol,1,0);
2126 extra->addWidget (combo_eol,1,1);
2127 extra->addItem (
new QSpacerItem (1,20,QSizePolicy::Fixed,
2128 QSizePolicy::Fixed), 1,2);
2129 extra->addWidget (label_enc,1,3);
2130 extra->addWidget (combo_enc,1,4);
2131 extra->addItem (
new QSpacerItem (1,20,QSizePolicy::Expanding,
2132 QSizePolicy::Fixed), 1,5);
2135 QGridLayout *dialog_layout =
dynamic_cast<QGridLayout *
> (fileDialog->layout ());
2136 dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
2137 1,dialog_layout->columnCount ());
2140 QStringList filters;
2141 filters << tr (
"Octave Files (*.m)")
2142 << tr (
"All Files (*)");
2143 fileDialog->setNameFilters (filters);
2144 fileDialog->setDefaultSuffix (
"m");
2153 fileDialog->selectNameFilter (filters.at (1));
2154 fileDialog->setDefaultSuffix (
"");
2159 fileDialog->selectFile (
"");
2160 fileDialog->setDirectory (
_ced);
2164 if (!
fname.isEmpty ())
2165 fileDialog->selectFile (
fname +
".m");
2168 fileDialog->setAcceptMode (QFileDialog::AcceptSave);
2169 fileDialog->setViewMode (QFileDialog::Detail);
2171 connect (fileDialog, SIGNAL (filterSelected (
const QString&)),
2174 if (remove_on_success)
2176 connect (fileDialog, SIGNAL (fileSelected (
const QString&)),
2179 connect (fileDialog, SIGNAL (rejected ()),
2184 connect (fileDialog, SIGNAL (fileSelected (
const QString&)),
2205 QRegExp rx (
"\\*\\.([^ ^\\)]*)[ \\)]");
2206 int index = rx.indexIn (
filter,0);
2209 file_dialog->setDefaultSuffix (rx.cap (1));
2211 file_dialog->setDefaultSuffix (
"");
2216 QFileInfo
file = QFileInfo (file_name);
2217 QString base_name =
file.baseName ();
2219 if ((
file.suffix () ==
"m")
2222 int ans = QMessageBox::question (
nullptr, tr (
"Octave Editor"),
2224 "is not a valid identifier.\n\n" 2225 "If you keep this filename, you will not be able to\n" 2226 "call your script using its name as an Octave command.\n\n" 2227 "Do you want to choose another name?").
arg (base_name),
2230 if (ans == QMessageBox::Yes)
2241 QMessageBox::critical (
nullptr,
2242 tr (
"Octave Editor"),
2243 tr (
"The current encoding %1\n" 2244 "can not be applied.\n\n" 2245 "Please select another one or cancel saving!").
arg (
_encoding));
2250 if (! codec->canEncode (
_edit_area->text ()))
2253 tr (
"Octave Editor"),
2254 tr (
"The current editor contents can not be encoded\n" 2255 "with the selected encoding %1.\n" 2256 "Using it will result in data loss!\n\n" 2257 "Do you want to choose another encoding?").
arg (
_encoding),
2260 if (ans == QMessageBox::Yes)
2317 if (! trackedFiles.isEmpty ())
2320 if (QFile::exists (
_file_name) && ! do_close)
2338 tr (
"Octave Editor"),
2339 tr (
"It seems that \'%1\' has been modified by another application. Do you want to reload it?").
2343 connect (msgBox, SIGNAL (finished (
int)),
2346 msgBox->setWindowModality (Qt::WindowModal);
2347 msgBox->setAttribute (Qt::WA_DeleteOnClose);
2366 QString modified =
"";
2368 modified = tr (
"\n\nWarning: The contents in the editor is modified!");
2374 =
new QMessageBox (QMessageBox::Warning, tr (
"Octave Editor"),
2375 tr (
"It seems that the file\n" 2377 "has been deleted or renamed. Do you want to save it now?%2").
2379 QMessageBox::Save | QMessageBox::Close,
nullptr);
2383 connect (msgBox, SIGNAL (finished (
int)),
2386 msgBox->setWindowModality (Qt::WindowModal);
2387 msgBox->setAttribute (Qt::WA_DeleteOnClose);
2400 if (settings->value (
"editor/code_folding",
true).toBool ())
2402 _edit_area->setMarginType (3, QsciScintilla::SymbolMargin);
2403 _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3);
2407 _edit_area->setFolding (QsciScintilla::NoFoldStyle, 3);
2411 if (settings->value (
"editor/show_edit_status_bar",
true).toBool ())
2417 QVariant default_var = QColor (240, 240, 240);
2418 QColor setting_color = settings->value (
"editor/highlight_current_line_color",
2419 default_var).value<QColor> ();
2420 _edit_area->setCaretLineBackgroundColor (setting_color);
2422 (settings->value (
"editor/highlightCurrentLine",
true).toBool ());
2424 bool match_keywords = settings->value
2425 (
"editor/codeCompletion_keywords",
true).toBool ();
2426 bool match_document = settings->value
2427 (
"editor/codeCompletion_document",
true).toBool ();
2429 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone;
2432 source = QsciScintilla::AcsAll;
2434 source = QsciScintilla::AcsAPIs;
2435 else if (match_document)
2436 source = QsciScintilla::AcsDocument;
2437 _edit_area->setAutoCompletionSource (source);
2440 (settings->value (
"editor/codeCompletion_replace",
false).toBool ());
2442 (settings->value (
"editor/codeCompletion_case",
true).toBool ());
2444 if (settings->value (
"editor/codeCompletion",
true).toBool ())
2446 (settings->value (
"editor/codeCompletion_threshold",2).toInt ());
2450 if (settings->value (
"editor/show_white_space",
false).toBool ())
2451 if (settings->value (
"editor/show_white_space_indent",
false).toBool ())
2452 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent);
2454 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible);
2456 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible);
2459 settings->value (
"editor/show_eol_chars",
false).toBool ());
2461 if (settings->value (
"editor/showLineNumbers",
true).toBool ())
2465 connect (
_edit_area, SIGNAL (linesChanged ()),
2471 disconnect (
_edit_area, SIGNAL (linesChanged ()),
nullptr,
nullptr);
2474 _smart_indent = settings->value (
"editor/auto_indent",
true).toBool ();
2477 (settings->value (
"editor/tab_indents_line",
false).toBool ());
2479 (settings->value (
"editor/backspace_unindents_line",
false).toBool ());
2481 (settings->value (
"editor/show_indent_guides",
false).toBool ());
2483 (settings->value (
"editor/indent_uses_tabs",
false).toBool ());
2485 (settings->value (
"editor/indent_width",2).toInt ());
2488 (settings->value (
"editor/tab_width",2).toInt ());
2490 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR,
2491 settings->value (
"editor/show_hscroll_bar",
true).toBool ());
2492 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1);
2493 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,
true);
2495 _long_title = settings->value (
"editor/longWindowTitle",
false).toBool ();
2498 _auto_endif = settings->value (
"editor/auto_endif",1).toInt ();
2501 int line_length = settings->value (
"editor/long_line_column",80).toInt ();
2504 if (settings->value (
"editor/long_line_marker",
true).toBool ())
2506 if (settings->value (
"editor/long_line_marker_line",
true).toBool ())
2507 _edit_area->setEdgeMode (QsciScintilla::EdgeLine);
2510 if (settings->value (
"editor/long_line_marker_background",
false)
2512 _edit_area->setEdgeMode (QsciScintilla::EdgeBackground);
2514 _edit_area->setEdgeMode (QsciScintilla::EdgeLine);
2518 _edit_area->setEdgeMode (QsciScintilla::EdgeNone);
2521 _edit_area->setWrapVisualFlags (QsciScintilla::WrapFlagByBorder);
2522 _edit_area->setWrapIndentMode (QsciScintilla::WrapIndentSame);
2524 if (settings->value (
"editor/wrap_lines",
false).toBool ())
2525 _edit_area->setWrapMode (QsciScintilla::WrapWord);
2527 _edit_area->setWrapMode (QsciScintilla::WrapNone);
2529 if (settings->value (
"editor/break_lines",
false).toBool ())
2535 settings->value (
"editor/break_lines_comments",
false).toBool ();
2539 settings->value (
"editor/highlight_all_occurrences",
true).toBool ();
2543 settings->value (
"editor/always_reload_changed_files",
false).toBool ();
2548 bool cursor_blinking;
2550 if (settings->contains (
"cursor_blinking"))
2551 cursor_blinking = settings->value (
"cursor_blinking",
true).toBool ();
2553 cursor_blinking = settings->value (
"terminal/cursorBlinking",
true).toBool ();
2555 if (cursor_blinking)
2556 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD,500);
2558 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETCARETPERIOD,0);
2609 if (ID !=
this && ID !=
nullptr)
2618 if (decision == QMessageBox::Yes)
2633 if (decision == QMessageBox::Save)
2651 if (ID !=
this || ID ==
nullptr)
2668 int editor_linenr = -1;
2671 if (editor_linenr != -1)
2679 int original_linenr = -1;
2682 if (original_linenr >= 0)
2685 int linenr_guess = editor_linenr +
line - original_linenr;
2703 dp, SLOT (handle_remove_via_original_linenr (
int)));
2705 dp, SLOT (handle_remove (
void)));
2713 if (ID !=
this || ID ==
nullptr)
2722 const QString& cond)
2724 if (ID !=
this || ID ==
nullptr)
2731 int editor_linenr = -1;
2739 if ((cond ==
"") != (bp->
get_cond () ==
""))
2757 bp, SLOT (handle_remove_via_original_linenr (
int)));
2760 bp, SLOT (handle_request_remove_via_editor_linenr
2763 bp, SLOT (handle_remove (
void)));
2766 bp, SLOT (handle_find_translation (
int,
int&,
2769 bp, SLOT (handle_find_just_before (
int,
int&,
int&)));
2772 bp, SLOT (handle_report_editor_linenr (
QIntList&,
2774 connect (bp, SIGNAL (request_remove (
int)),
2785 long int visible_lines
2786 =
_edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN);
2788 if (visible_lines > 2)
2799 int first_line =
_edit_area->firstVisibleLine ();
2801 if (always || vis_line == first_line
2802 || vis_line > first_line + visible_lines - 2)
2804 first_line += (vis_line - first_line - (visible_lines - 1) / 2);
2805 _edit_area->SendScintilla (2613, first_line);
2818 if (
_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE))
2863 if (! style_comment)
2874 int col_space = col;
2879 while (
c !=
' ' &&
c !=
'\t' && col_space > indentation)
2882 c =
_edit_area->SendScintilla (QsciScintillaBase::SCI_GETCHARAT, pos);
2887 int col_newline = col - 1;
2888 if (
c ==
' ' ||
c ==
'\t')
2889 col_newline = col_space + 1;
2893 QString newline = QString (
"\n");
2902 _edit_area->SendScintilla (QsciScintillaBase::SCI_LINEEND);
2929 word = word.trimmed ();
2931 if (! word.isEmpty ())
2936 int first_line =
_edit_area->firstVisibleLine ();
2939 bool find_result_available
2948 #
if defined (HAVE_QSCI_VERSION_2_6_0)
2955 int wlen = word.length ();
2957 while (find_result_available)
2960 _edit_area->getCursorPosition (&oline, &ocol);
2965 find_result_available =
_edit_area->findNext ();
2970 _edit_area->setFirstVisibleLine (first_line);
2981 QRegExp rxfun1 (
"^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$");
2982 QRegExp rxfun2 (
"^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$");
2983 QRegExp rxfun3 (
"^[\t ]*function[^=]+=[\t ]*([^\\s]+)[\t ]*$");
2984 QRegExp rxfun4 (
"^[\t ]*function[\t ]+([^\\s]+)[\t ]*$");
2986 QStringList lines =
_edit_area->text ().split (
"\n");
2988 for (
int i = 0;
i < lines.count ();
i++)
2990 if (rxfun1.indexIn (lines.at (
i)) != -1)
2991 return rxfun1.cap (1).remove (QRegExp (
"[ \t]*"));
2992 else if (rxfun2.indexIn (lines.at (
i)) != -1)
2993 return rxfun2.cap (1).remove (QRegExp (
"[ \t]*"));
2994 else if (rxfun3.indexIn (lines.at (
i)) != -1)
2995 return rxfun3.cap (1).remove (QRegExp (
"[ \t]*"));
2996 else if (rxfun4.indexIn (lines.at (
i)) != -1)
2997 return rxfun4.cap (1).remove (QRegExp (
"[ \t]*"));
void handle_find_dialog_finished(int decision)
void handle_file_resave_answer(int decision)
void comment_selected_text(const QWidget *ID, bool input_str)
QString load_file(const QString &fileName)
void print_file(const QWidget *ID)
void handle_char_added(int character)
void previous_bookmark(const QWidget *ID)
void convert_eol(const QWidget *ID, QsciScintilla::EolMode)
void set_focus(const QWidget *ID)
OCTINTERP_API void octave_sleep(double seconds)
void handle_copy_available(bool enableCopy)
void context_help_doc(bool)
For example cd octave end example noindent changes the current working directory to file
static void combo_encoding(QComboBox *combo, QString current=QString())
void request_remove_breakpoint_via_editor_linenr(int editor_linenr)
bool is_user_code(void) const
void remove_all_breakpoints(void)
std::string canonicalize_file_name(const std::string &name)
interpreter & __get_interpreter__(const std::string &who)
void check_restore_breakpoints(void)
bool valid_file_name(const QString &file=QString())
std::string string_value(bool force=false) const
void set_modified(bool modified=true)
bool check_valid_identifier(QString file_name)
void init_search_text(void)
void run_file(const QWidget *ID)
void edit_mfile_request(const QString &, const QString &, const QString &, int)
static bool file_in_path(const std::string &file, const std::string &dir)
bool _always_reload_changed_files
QsciScintilla::EolMode _save_as_desired_eol
bp_info(const QString &fname, int l=0, const QString &cond="")
void next_breakpoint(const QWidget *ID)
std::string dir_sep_chars(void)
void set_focus_editor_signal(QWidget *)
void next_bookmark(const QWidget *ID)
void editor_state_changed(bool copy_available, bool is_octave_file)
for fields that display a single number
void handle_request_remove_breakpoint(int line)
QFileSystemWatcher _file_system_watcher
void file_has_changed(const QString &path, bool do_close=false)
octave_map backtrace(size_t nskip, octave_idx_type &curr_user_frame, bool print_subfn=true) const
void add_octave_apis(octave_value_list key_ovl)
void file_name_query(const QWidget *ID)
void set_word_selection(const QString &word=QString())
void handle_file_modified_answer(int decision)
void find_next(const QWidget *ID)
void scintilla_command(const QWidget *, unsigned int)
void zoom_normal(const QWidget *ID)
bool is_defined(void) const
void handle_save_as_filter_selected(const QString &filter)
std::string function_name
T & elem(octave_idx_type n)
void remove_position_via_debugger_linenr(int debugger_linenr)
bool condition_valid(const std::string &cond)
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any simply delete all the lines from the buffer before leaving the editor When invoked with no edit the previously executed command
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
void update_window_title(bool modified)
intmap add_breakpoint(const std::string &fname="", const intmap &lines=intmap(), const std::string &condition="")
void zoom_out(const QWidget *ID)
void save_apis_info(void)
void context_edit(const QWidget *ID)
int remove_breakpoint(const std::string &fname="", const intmap &lines=intmap())
virtual std::string fcn_file_name(void) const
void closeEvent(QCloseEvent *event)
void do_breakpoint_marker(bool insert, const QWidget *ID, int line=-1, const QString &cond="")
int check_file_modified(void)
bool conditional_close(void)
void recover_from_exit(void)
void handle_combo_enc_current_index(QString text)
void execute_command_in_terminal_signal(const QString &)
void zoom_in(const QWidget *ID)
std::string concat(const std::string &dir, const std::string &file)
void unindent_selected_text(const QWidget *ID)
void toggle_bookmark(const QWidget *ID)
void handle_request_add_breakpoint(int line, const QString &cond)
symbol_table & __get_symbol_table__(const std::string &who)
void do_smart_indent_line_or_selected_text(void)
int buffer_error_messages
void insert_debugger_pointer(const QWidget *ID, int line=-1)
file_editor_tab(const QString &directory="")
A file_editor_tab object consists of a text area and three left margins.
void mru_add_file(const QString &file_name, const QString &encoding)
void get_current_position(int *pos, int *line, int *col)
bool valid_identifier(const char *s)
void notice_settings(const QSettings *settings, bool init=false)
QStringList comment_string(bool comment=true)
void move_match_brace(const QWidget *ID, bool select)
void find_previous(const QWidget *ID)
intmap remove_all_breakpoints_in_file(const std::string &fname, bool silent=false)
int is_style_comment(int pos=-1)
void file_name_changed(const QString &fileName, const QString &toolTip)
void handle_save_file_as_answer(const QString &fileName)
void previous_breakpoint(const QWidget *ID)
void do_indent_selected_text(bool indent)
void add_filename_to_list(const QString &, const QString &, QWidget *)
void request_find_previous(void)
void handle_double_click(int p, int l, int modifier)
void run_file_signal(const QFileInfo &info)
void smart_indent_line_or_selected_text(const QWidget *ID)
void toggle_breakpoint(const QWidget *ID)
void handle_context_menu_edit(const QString &)
bool unchanged_or_saved(void)
find_dialog * _find_dialog
void indent_selected_text(const QWidget *ID)
static void post_event(T *obj, void(T::*method)(void))
bool is_true(const std::string &s)
void set_current_directory(const QString &dir)
const Cell & contents(const_iterator p) const
QRect _find_dialog_geometry
void auto_margin_width(void)
void context_help(const QWidget *ID, bool)
std::map< int, int > intmap
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
const QString & get_cond(void) const
octave_value find(const std::string &name, const octave_value_list &args=octave_value_list(), bool skip_variables=false, bool local_funcs=true)
void set_file_name(const QString &fileName)
void report_marker_linenr(QIntList &lines, QStringList &conditions)
void save_file_as(const QWidget *ID)
void do_comment_selected_text(bool comment, bool input_str=false)
void save_file(const QWidget *ID)
void editor_check_conflict_save(const QString &saveFileName, bool remove_on_success)
void goto_line(const QWidget *ID, int line=-1)
void clear_selection_markers(void)
void delete_debugger_pointer(const QWidget *ID, int line=-1)
const QString oct_last_comment_str("editor/oct_last_comment_str")
QsciScintilla::EolMode detect_eol_mode(void)
void context_run(const QWidget *ID)
static uint32_t state[624]
void uncomment_selected_text(const QWidget *ID)
void warning(const char *fmt,...)
QStringList _bp_conditions
octave::unwind_protect frame
OCTINTERP_API std::string last_error_message(void)
octave_qscintilla * _edit_area
OCTAVE_EXPORT octave_value_list the first data row corresponds to an index of zero The a spreadsheet style form such as the file is read until end of file is reached The such as text
defaults to zero A value of zero computes the digamma a value the trigamma and so on The digamma function is defined
octave_user_code * user_code_value(bool silent=false) const
void update_eol_indicator(void)
void remove_breakpoint_callback(const bp_info &info)
bp_table & __get_bp_table__(const std::string &who)
void handle_lines_changed(void)
void handle_context_menu_break_condition(int linenr)
void center_current_line(bool always=true)
void remove_all_breakpoints_callback(const bp_info &info)
void remove_all_positions(void)
void handle_file_reload_answer(int decision)
call_stack & __get_call_stack__(const std::string &who)
void handle_cursor_moved(int line, int col)
void handle_save_file_as_answer_close(const QString &fileName)
void handle_combo_eol_current_index(int index)
bool _find_dialog_is_visible
void remove_breakpoint_via_debugger_linenr(int debugger_linenr)
static QSettings * get_settings(void)
octave::sys::file_stat fs(filename)
void smart_indent(bool do_smart_indent, int do_auto_close, int line)
bool _highlight_all_occurrences
void remove_bookmark(const QWidget *ID)
void set_encoding(const QString &new_encoding)
lexer(interpreter *interp=nullptr)
bool exit_debug_and_clear(const QString &full_name, const QString &base_name)
QString get_function_name(void)
void handle_octave_result(QObject *requester, QString &command, octave_value_list &result)
void show_dialog(QDialog *dlg, bool modal)
void show_auto_completion(const QWidget *ID)
void clear_user_function(const std::string &name)
void new_file(const QString &commands=QString())
nd example The result of the integration is returned in the value of it is recommended to verify this value for difficult integrands and then a warning is issued and as may be less efficient for a smooth or otherwise well behaved integrand than other methods such as Article No
void handle_save_file_as_answer_cancel(void)
octave_idx_type numel(void) const
Number of elements in the array.
void smart_indent_line_or_selected_text(int lineFrom, int lineTo)
void change_editor_state(const QWidget *ID)
std::string toStdString(const QString &s)
bool check_valid_codec(QTextCodec *codec)
void tab_remove_request(void)
void set_selection_marker_color(const QColor &c)
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
void update_lexer_settings(void)
void handle_margin_clicked(int line, int margin, Qt::KeyboardModifiers state)
void request_find_next(void)
void set_cond(const QString &cond)
void find_linenr_just_before(int linenr, int &original_linenr, int &editor_linenr)
void add_breakpoint_callback(const bp_info &info)
void show_selection_markers(int line, int col, int len)
Cell cell_value(void) const
void check_modified_file(void)
void find_translated_line_number(int original_linenr, int &translated_linenr, marker *&)
to define functions rather than attempting to enter them directly on the command line The block of commands is executed as soon as you exit the editor To avoid executing any commands
void find(const QWidget *ID, QList< QAction *>)
bool _line_break_comments