28 #if defined (HAVE_CONFIG_H)
32 #if defined (HAVE_QSCINTILLA)
34 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H)
35 # define HAVE_LEXER_OCTAVE 1
36 # include <Qsci/qscilexeroctave.h>
37 #elif defined (HAVE_QSCI_QSCILEXERMATLAB_H)
38 # define HAVE_LEXER_MATLAB 1
39 # include <Qsci/qscilexermatlab.h>
41 #include <Qsci/qscilexercpp.h>
42 #include <Qsci/qscilexerbash.h>
43 #include <Qsci/qscilexerperl.h>
44 #include <Qsci/qscilexerbatch.h>
45 #include <Qsci/qscilexerdiff.h>
46 #include <Qsci/qsciprinter.h>
47 #include <QApplication>
48 #include <QFileDialog>
49 #include <QMessageBox>
50 #include <QTextStream>
51 #include <QVBoxLayout>
52 #include <QInputDialog>
53 #include <QPrintDialog>
55 #include <QDesktopServices>
61 #include <QDialogButtonBox>
62 #include <QPushButton>
100 _ced = directory_arg;
112 connect (
_edit_area, SIGNAL (cursorPositionChanged (
int,
int)),
115 connect (
_edit_area, SIGNAL (linesChanged ()),
118 connect (
_edit_area, SIGNAL (context_menu_edit_signal (
const QString&)),
128 QLabel *row_label =
new QLabel (tr (
"line:"),
this);
131 QLabel *col_label =
new QLabel (tr (
"col:"),
this);
138 QLabel *enc_label =
new QLabel (tr (
"encoding:"),
this);
142 _status_bar->addWidget (
new QLabel (
" ",
this), 0);
145 QLabel *eol_label =
new QLabel (tr (
"eol:"),
this);
149 _status_bar->addWidget (
new QLabel (
" ",
this), 0);
156 _edit_area->setMarginType (1, QsciScintilla::SymbolMargin);
165 _edit_area->setMarkerBackgroundColor (QColor (255,255,0),
167 _edit_area->markerDefine (QsciScintilla::RightArrow,
169 _edit_area->setMarkerBackgroundColor (QColor (192,192,192),
172 connect (
_edit_area, SIGNAL (marginClicked (
int,
int,
173 Qt::KeyboardModifiers)),
175 Qt::KeyboardModifiers)));
177 connect (
_edit_area, SIGNAL (context_menu_break_condition_signal (
int)),
181 _edit_area->setMarginsForegroundColor (QColor (96, 96, 96));
182 _edit_area->setMarginsBackgroundColor (QColor (232, 232, 220));
183 _edit_area->setMarginType (2, QsciScintilla::TextMargin);
186 _edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch);
194 _edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART,
false);
196 QVBoxLayout *edit_area_layout =
new QVBoxLayout ();
199 edit_area_layout->setMargin (0);
200 setLayout (edit_area_layout);
203 connect (
_edit_area, SIGNAL (modificationChanged (
bool)),
206 connect (
_edit_area, SIGNAL (copyAvailable (
bool)),
219 #if defined (Q_OS_WIN32)
220 _encoding = settings->value (
"editor/default_encoding",
"SYSTEM")
223 _encoding = settings->value (
"editor/default_encoding",
"UTF-8")
257 if (new_encoding.isEmpty ())
296 QRegExp rxfun1 (
"^[\t ]*function[^=]+=[\t ]*"
297 + word_at_cursor +
"[\t ]*\\([^\\)]*\\)[\t ]*$");
298 QRegExp rxfun2 (
"^[\t ]*function[\t ]+"
299 + word_at_cursor +
"[\t ]*\\([^\\)]*\\)[\t ]*$");
300 QRegExp rxfun3 (
"^[\t ]*function[\t ]+"
301 + word_at_cursor +
"[\t ]*$");
302 QRegExp rxfun4 (
"^[\t ]*function[^=]+=[\t ]*"
303 + word_at_cursor +
"[\t ]*$");
306 QStringList lines =
_edit_area->text ().split (
"\n");
309 for (line = 0; line < lines.count (); line++)
311 if ((pos_fct = rxfun1.indexIn (lines.at (line))) != -1)
313 if ((pos_fct = rxfun2.indexIn (lines.at (line))) != -1)
315 if ((pos_fct = rxfun3.indexIn (lines.at (line))) != -1)
317 if ((pos_fct = rxfun4.indexIn (lines.at (line))) != -1)
324 _edit_area->setCursorPosition (line, pos_fct);
327 int vis_line =
_edit_area->SendScintilla(2220, line);
372 cond =
"(" + cond +
") || (" +
_edit_area->selectedText () +
")";
380 QString new_condition
381 = QInputDialog::getText (
this, tr (
"Breakpoint condition"),
382 tr (prompt.c_str ()), QLineEdit::Normal, cond,
397 catch (
const octave::execution_exception& e) { }
398 catch (
const octave::interrupt_exception&)
406 cond = new_condition;
426 if (! trackedFiles.isEmpty ())
428 if (! fileName.isEmpty ())
469 int ans = QMessageBox::question (0, tr (
"Octave Editor"),
470 tr (
"Cannot add breakpoint to modified file.\n"
471 "Save and add breakpoint, or cancel?"),
472 QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save);
474 if (ans == QMessageBox::Save)
487 Qt::KeyboardModifiers
state)
491 unsigned int markers_mask =
_edit_area->markersAtLine (editor_linenr);
493 if (state & Qt::ControlModifier)
529 #if defined (HAVE_LEXER_OCTAVE)
530 lexer =
new QsciLexerOctave ();
531 #elif defined (HAVE_LEXER_MATLAB)
532 lexer =
new QsciLexerMatlab ();
551 lexer =
new QsciLexerCPP ();
555 lexer =
new QsciLexerPerl ();
559 lexer =
new QsciLexerBatch ();
563 lexer =
new QsciLexerDiff ();
567 lexer =
new QsciLexerBash ();
572 #if defined (HAVE_LEXER_OCTAVE)
573 lexer =
new QsciLexerOctave ();
575 #elif defined (HAVE_LEXER_MATLAB)
576 lexer =
new QsciLexerMatlab ();
596 bool update_apis_file =
false;
599 #if defined (HAVE_QT4)
600 QString prep_apis_path
601 = QDesktopServices::storageLocation (QDesktopServices::HomeLocation)
604 QString prep_apis_path
605 = QStandardPaths::writableLocation (QStandardPaths::HomeLocation)
610 bool octave_builtins = settings->value (
611 "editor/codeCompletion_octave_builtins",
true).toBool ();
612 bool octave_functions = settings->value (
613 "editor/codeCompletion_octave_functions",
true).toBool ();
623 if (octave_functions)
631 update_apis_file = ! apis_file.exists ();
634 if (! update_apis_file && octave_functions)
637 QDateTime apis_date = apis_file.lastModified ();
641 #if defined (HAVE_QT4)
642 QFileInfo local_pkg_list
643 = QFileInfo (QDesktopServices::storageLocation (QDesktopServices::HomeLocation)
644 +
"/.octave_packages");
646 QFileInfo local_pkg_list
647 = QFileInfo (QStandardPaths::writableLocation (QStandardPaths::HomeLocation)
648 +
"/.octave_packages");
651 if (local_pkg_list.exists ()
652 && (apis_date < local_pkg_list.lastModified ()))
653 update_apis_file =
true;
657 QFileInfo global_pkg_list = QFileInfo (
659 +
"/share/octave/octave_packages");
660 if (global_pkg_list.exists ()
661 && (apis_date < global_pkg_list.lastModified ()))
662 update_apis_file =
true;
676 QStringList keyword_list;
690 if (octave_functions)
701 keyword = QString(lexer->keywords (i));
702 keyword_list = keyword.split (QRegExp (
"\\s+"));
703 for (j = 0; j < keyword_list.size (); j++)
709 disconnect (
_lexer_apis, SIGNAL (apiPreparationFinished ()), 0, 0);
711 if (QDir(
"/").mkpath (prep_apis_path))
714 connect (
_lexer_apis, SIGNAL (apiPreparationFinished ()),
721 lexer->readSettings (*settings);
725 _edit_area->setCaretForegroundColor (lexer->color (0));
726 _edit_area->setIndentationGuidesForegroundColor (lexer->color (0));
729 QColor bg = lexer->paper (0);
730 QColor fg = lexer->color (0);
732 int bh, bs, bv, fh,
fs, fv,
h,
s, v;
733 bg.getHsv (&bh,&bs,&bv);
734 fg.getHsv (&fh,&fs,&fv);
739 v = bv + (fv - bv)/8;
741 v = bv + (fv - bv)/4;
744 _edit_area->setMarkerForegroundColor (lexer->color (0));
745 _edit_area->setMarginsForegroundColor (lexer->color (0));
750 if (settings->value (
"editor/showLineNumbers",
true).toBool ())
764 for (
int idx = 0; idx < key_list.
numel (); idx++)
777 if (lexer ==
"octave" || lexer ==
"matlab")
779 else if (lexer ==
"perl" || lexer ==
"bash" || lexer ==
"diff")
781 else if (lexer ==
"cpp")
783 else if (lexer ==
"batch")
837 bool remove_on_success)
860 QsciPrinter *printer =
new QsciPrinter (QPrinter::HighResolution);
862 QPrintDialog printDlg (printer,
this);
864 if (printDlg.exec () == QDialog::Accepted)
969 line_info[0] = info.
line;
979 line_info[0] = info.
line;
996 QFileInfo file_info (fname);
998 QString q_dir = file_info.absolutePath ();
999 QString q_function_name = file_info.fileName ();
1002 q_function_name.chop (file_info.suffix ().length () + 1);
1004 dir = q_dir.toStdString ();
1012 if (pos != std::string::npos && pos <
dir.length () - 1)
1014 if (
dir[pos+1] ==
'@')
1018 dir = dir.substr (0, pos);
1025 const QString& condition)
1048 int editor_linenr, cur;
1049 _edit_area->getCursorPosition (&editor_linenr, &cur);
1077 if (nextcond != -1 && (nextcond < nextline || nextline == -1))
1078 nextline = nextcond;
1091 int line, cur, prevline, prevcond;
1100 if (prevcond != -1 && prevcond > prevline)
1101 prevline = prevcond;
1229 fetab_actions.mid (0,2),
1230 qobject_cast<
QWidget *> (sender ()));
1281 _edit_area->getCursorPosition (&line, &index);
1282 line = QInputDialog::getInt (
_edit_area, tr (
"Goto line"),
1283 tr (
"Line number"), line+1, 1,
1312 QsciScintilla::AutoCompletionSource
s =
_edit_area->autoCompletionSource ();
1315 case QsciScintilla::AcsAll:
1319 case QsciScintilla::AcsAPIs:
1323 case QsciScintilla::AcsDocument:
1327 case QsciScintilla::AcsNone:
1340 int lineFrom, lineTo, colFrom, colTo;
1341 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
1346 for (
int i = lineFrom;
i <= lineTo;
i++)
1354 _edit_area->setSelection (lineFrom, 0, lineTo,
1360 _edit_area->getCursorPosition (&cpline, &col);
1378 int lineFrom, lineTo, colFrom, colTo;
1379 _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo);
1384 for (
int i = lineFrom;
i <= lineTo;
i++)
1391 if (
line.startsWith (comment_str))
1393 _edit_area->setSelection (
i, 0,
i, comment_str.length ());
1399 _edit_area->setSelection (lineFrom, 0, lineTo,
1405 _edit_area->getCursorPosition (&cpline, &col);
1407 _edit_area->insertAt (comment_str, cpline, 0);
1411 if (
line.startsWith (comment_str))
1413 _edit_area->setSelection (cpline, 0, cpline, comment_str.length ());
1425 QString tooltip (
"");
1428 title = tr (
"<unnamed>");
1436 title = file.fileName ();
1458 dlg->setAttribute (Qt::WA_DeleteOnClose);
1463 dlg->setWindowModality (Qt::NonModal);
1471 int decision = QMessageBox::Yes;
1477 QMessageBox::StandardButtons buttons = QMessageBox::Save |
1478 QMessageBox::Discard |
1479 QMessageBox::Cancel;
1484 QString available_actions =
1485 tr (
"Do you want to cancel closing, save or discard the changes?");
1491 file = tr (
"<unnamed>");
1494 =
new QMessageBox (QMessageBox::Warning, tr (
"Octave Editor"),
1497 "is about to be closed but has been modified. "
1499 arg (file).
arg (available_actions),
1500 buttons, qobject_cast<QWidget *> (parent ()));
1502 msgBox->setDefaultButton (QMessageBox::Save);
1504 connect (msgBox, SIGNAL (finished (
int)),
1510 return QMessageBox::Cancel;
1526 if (decision == QMessageBox::Save)
1531 else if (decision == QMessageBox::Discard)
1586 QFileInfo file_info = QFileInfo (fileName);
1587 QString file_to_load;
1588 if (file_info.exists ())
1589 file_to_load = file_info.canonicalFilePath ();
1591 file_to_load = fileName;
1592 QFile
file (file_to_load);
1593 if (! file.open (QFile::ReadOnly))
1594 return file.errorString ();
1597 QTextStream in (&file);
1599 QTextCodec *codec = QTextCodec::codecForName (
_encoding.toLatin1 ());
1602 QApplication::setOverrideCursor (Qt::WaitCursor);
1605 QApplication::restoreOverrideCursor ();
1635 QsciScintilla::EolMode
1640 QByteArray eol_lf = QByteArray (1,0x0a);
1641 QByteArray eol_cr = QByteArray (1,0x0d);
1642 QByteArray eol_crlf = eol_cr;
1643 eol_crlf.append (eol_lf);
1645 int count_crlf = text.count (eol_crlf);
1646 int count_lf = text.count (eol_lf) - count_crlf;
1647 int count_cr = text.count (eol_cr) - count_crlf;
1650 #if defined (Q_OS_WIN32)
1651 int os_eol_mode = QsciScintilla::EolWindows;
1652 #elif defined (Q_OS_MAC)
1653 int os_eol_mode = QsciScintilla::EolMac;
1655 int os_eol_mode = QsciScintilla::EolUnix;
1658 QsciScintilla::EolMode eol_mode =
static_cast<QsciScintilla::EolMode
> (
1659 settings->value(
"editor/default_eol_mode",os_eol_mode).toInt ());
1663 if (count_crlf > count_max)
1665 eol_mode = QsciScintilla::EolWindows;
1666 count_max = count_crlf;
1668 if (count_lf > count_max)
1670 eol_mode = QsciScintilla::EolUnix;
1671 count_max = count_lf;
1673 if (count_cr > count_max)
1675 eol_mode = QsciScintilla::EolMac;
1676 count_max = count_cr;
1687 case QsciScintilla::EolWindows:
1690 case QsciScintilla::EolMac:
1693 case QsciScintilla::EolUnix:
1706 if (requester ==
this)
1708 if (command ==
"dbstatus")
1735 #if defined (Q_OS_WIN32)
1736 int eol_mode = QsciScintilla::EolWindows;
1737 #elif defined (Q_OS_MAC)
1738 int eol_mode = QsciScintilla::EolMac;
1740 int eol_mode = QsciScintilla::EolUnix;
1743 static_cast<QsciScintilla::EolMode> (
1744 settings->value(
"editor/default_eol_mode",eol_mode).toInt ()));
1758 const QString& base_name_q)
1760 std::string base_name = base_name_q.toStdString ();
1766 catch (
const octave::execution_exception&
e)
1778 std::string full_name = full_name_q.toStdString ();
1791 if (names(
i).string_value () == base_name)
1793 int ans = QMessageBox::question (0, tr (
"Debug or Save"),
1794 tr (
"This file is currently being executed.\n"
1795 "Quit debugging and save?"),
1796 QMessageBox::Save | QMessageBox::Cancel);
1798 if (ans == QMessageBox::Save)
1802 while (names.
numel () >
i)
1823 bool remove_on_success,
bool restore_breakpoints)
1837 QFileInfo file_info = QFileInfo (saveFileName);
1838 QString file_to_save;
1839 if (file_info.exists ())
1841 file_to_save = file_info.canonicalFilePath ();
1848 file_to_save = saveFileName;
1849 QFile
file (file_to_save);
1853 if (trackedFiles.contains (file_to_save))
1857 if (! file.open (QIODevice::WriteOnly))
1861 if (trackedFiles.contains (file_to_save))
1867 tr (
"Octave Editor"),
1868 tr (
"Could not open file %1 for write:\n%2.").
1869 arg (file_to_save).
arg (file.errorString ()),
1870 QMessageBox::Ok, 0);
1881 QTextCodec *codec = QTextCodec::codecForName (
_encoding.toLatin1 ());
1890 QTextStream out (&file);
1891 out.setCodec (codec);
1893 QApplication::setOverrideCursor (Qt::WaitCursor);
1896 QApplication::restoreOverrideCursor ();
1901 file_info = QFileInfo (file);
1902 file_to_save = file_info.canonicalFilePath ();
1914 if (remove_on_success)
1923 if (restore_breakpoints)
1939 if (remove_on_success)
1952 fileDialog->setOption(QFileDialog::DontUseNativeDialog,
true);
1955 QGridLayout *extra =
new QGridLayout (fileDialog);
1956 QFrame *separator =
new QFrame (fileDialog);
1957 separator->setFrameShape (QFrame::HLine);
1958 separator->setFrameStyle (QFrame::Sunken);
1961 QLabel *label_eol =
new QLabel (tr (
"Line Endings:"));
1962 QComboBox *combo_eol =
new QComboBox ();
1963 combo_eol->addItem (
"Windows (CRLF)");
1964 combo_eol->addItem (
"Mac (CR)");
1965 combo_eol->addItem (
"Unix (LF)");
1970 QLabel *label_enc =
new QLabel (tr (
"File Encoding:"));
1971 QComboBox *combo_enc =
new QComboBox ();
1975 connect (combo_eol, SIGNAL (currentIndexChanged (
int)),
1977 connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
1981 extra->addWidget (separator,0,0,1,6);
1982 extra->addWidget (label_eol,1,0);
1983 extra->addWidget (combo_eol,1,1);
1984 extra->addItem (
new QSpacerItem (1,20,QSizePolicy::Fixed,
1985 QSizePolicy::Fixed), 1,2);
1986 extra->addWidget (label_enc,1,3);
1987 extra->addWidget (combo_enc,1,4);
1988 extra->addItem (
new QSpacerItem (1,20,QSizePolicy::Expanding,
1989 QSizePolicy::Fixed), 1,5);
1992 QGridLayout *dialog_layout =
dynamic_cast<QGridLayout*
> (fileDialog->layout ());
1993 dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
1994 1,dialog_layout->columnCount ());
1997 QStringList filters;
1998 filters << tr (
"Octave Files (*.m)")
1999 << tr (
"All Files (*)");
2000 fileDialog->setNameFilters (filters);
2001 fileDialog->setDefaultSuffix (
"m");
2007 if (file_info.suffix () !=
"m")
2009 fileDialog->selectNameFilter (filters.at (1));
2010 fileDialog->setDefaultSuffix (
"");
2015 fileDialog->selectFile (
"");
2016 fileDialog->setDirectory (
_ced);
2020 if (! fname.isEmpty ())
2021 fileDialog->selectFile (fname +
".m");
2024 fileDialog->setAcceptMode (QFileDialog::AcceptSave);
2025 fileDialog->setViewMode (QFileDialog::Detail);
2027 connect (fileDialog, SIGNAL (filterSelected (
const QString&)),
2030 if (remove_on_success)
2032 connect (fileDialog, SIGNAL (fileSelected (
const QString&)),
2035 connect (fileDialog, SIGNAL (rejected ()),
2040 connect (fileDialog, SIGNAL (fileSelected (
const QString&)),
2064 QRegExp rx (
"\\*\\.([^ ^\\)]*)[ \\)]");
2065 int index = rx.indexIn (filter,0);
2068 file_dialog->setDefaultSuffix (rx.cap (1));
2070 file_dialog->setDefaultSuffix (
"");
2076 QFileInfo
file = QFileInfo (file_name);
2077 QString base_name = file.baseName ();
2079 if ((file.suffix () ==
"m")
2082 int ans = QMessageBox::question (0, tr (
"Octave Editor"),
2084 "is not a valid identifier.\n\n"
2085 "If you keep this filename, you will not be able to\n"
2086 "call your script using its name as an Octave command.\n\n"
2087 "Do you want to choose another name?").
arg (base_name),
2090 if (ans == QMessageBox::Yes)
2100 if (! codec->canEncode (
_edit_area->text ()))
2103 tr (
"Octave Editor"),
2104 tr (
"The current editor contents can not be encoded\n"
2105 "with the selected codec %1.\n"
2106 "Using it will result in data loss!\n\n"
2107 "Do you want to chose another codec?").
arg (
_encoding),
2110 if (ans == QMessageBox::Yes)
2171 if (! trackedFiles.isEmpty ())
2186 tr (
"Octave Editor"),
2187 tr (
"It seems that \'%1\' has been modified by another application. Do you want to reload it?").
2191 connect (msgBox, SIGNAL (finished (
int)),
2194 msgBox->setWindowModality (Qt::WindowModal);
2195 msgBox->setAttribute (Qt::WA_DeleteOnClose);
2201 QString modified =
"";
2203 modified = tr (
"\n\nWarning: The contents in the editor is modified!");
2209 =
new QMessageBox (QMessageBox::Warning, tr (
"Octave Editor"),
2210 tr (
"It seems that the file\n"
2212 "has been deleted or renamed. Do you want to save it now?%2").
2214 QMessageBox::Save | QMessageBox::Close, 0);
2218 connect (msgBox, SIGNAL (finished (
int)),
2221 msgBox->setWindowModality (Qt::WindowModal);
2222 msgBox->setAttribute (Qt::WA_DeleteOnClose);
2236 if (settings->value (
"editor/code_folding",
true).toBool ())
2238 _edit_area->setMarginType (3, QsciScintilla::SymbolMargin);
2239 _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3);
2243 _edit_area->setFolding (QsciScintilla::NoFoldStyle, 3);
2247 if (settings->value (
"editor/show_edit_status_bar",
true).toBool ())
2253 QVariant default_var = QColor (240, 240, 240);
2254 QColor setting_color = settings->value (
"editor/highlight_current_line_color",
2255 default_var).value<QColor> ();
2256 _edit_area->setCaretLineBackgroundColor (setting_color);
2258 (settings->value (
"editor/highlightCurrentLine",
true).toBool ());
2260 bool match_keywords = settings->value
2261 (
"editor/codeCompletion_keywords",
true).toBool ();
2262 bool match_document = settings->value
2263 (
"editor/codeCompletion_document",
true).toBool ();
2265 QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone;
2268 source = QsciScintilla::AcsAll;
2270 source = QsciScintilla::AcsAPIs;
2271 else if (match_document)
2272 source = QsciScintilla::AcsDocument;
2273 _edit_area->setAutoCompletionSource (source);
2276 (settings->value (
"editor/codeCompletion_replace",
false).toBool ());
2278 (settings->value (
"editor/codeCompletion_case",
true).toBool ());
2280 if (settings->value (
"editor/codeCompletion",
true).toBool ())
2282 (settings->value (
"editor/codeCompletion_threshold",2).toInt ());
2286 if (settings->value (
"editor/show_white_space",
false).toBool ())
2287 if (settings->value (
"editor/show_white_space_indent",
false).toBool ())
2288 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisibleAfterIndent);
2290 _edit_area->setWhitespaceVisibility (QsciScintilla::WsVisible);
2292 _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible);
2295 settings->value(
"editor/show_eol_chars",
false).toBool ());
2297 if (settings->value (
"editor/showLineNumbers",
true).toBool ())
2301 connect (
_edit_area, SIGNAL (linesChanged ()),
2307 disconnect (
_edit_area, SIGNAL (linesChanged ()), 0, 0);
2311 (settings->value (
"editor/auto_indent",
true).toBool ());
2312 _smart_indent = settings->value (
"editor/auto_indent",
true).toBool ();
2314 (settings->value (
"editor/tab_indents_line",
false).toBool ());
2316 (settings->value (
"editor/backspace_unindents_line",
false).toBool ());
2318 (settings->value (
"editor/show_indent_guides",
false).toBool ());
2320 (settings->value (
"editor/indent_uses_tabs",
false).toBool ());
2322 (settings->value (
"editor/indent_width",2).toInt ());
2325 (settings->value (
"editor/tab_width",2).toInt ());
2327 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR,
2328 settings->value (
"editor/show_hscroll_bar",
true).toBool ());
2329 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1);
2330 _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,
true);
2332 _long_title = settings->value (
"editor/longWindowTitle",
false).toBool ();
2336 settings->value (
"editor/long_line_column",80).toInt ());
2337 if (settings->value (
"editor/long_line_marker",
true).toBool ())
2338 _edit_area->setEdgeMode (QsciScintilla::EdgeLine);
2340 _edit_area->setEdgeMode (QsciScintilla::EdgeNone);
2344 settings->value (
"editor/always_reload_changed_files",
false).toBool ();
2397 if (ID !=
this && ID != 0)
2407 if (decision == QMessageBox::Yes)
2423 if (decision == QMessageBox::Save)
2442 if (ID !=
this || ID == 0)
2459 int editor_linenr = -1;
2462 if (editor_linenr != -1)
2470 int original_linenr = -1;
2473 if (original_linenr >= 0)
2476 int linenr_guess = editor_linenr + line - original_linenr;
2494 dp, SLOT (handle_remove_via_original_linenr (
int)));
2495 connect (
this, SIGNAL (remove_all_positions (
void)),
2496 dp, SLOT (handle_remove (
void)));
2505 if (ID !=
this || ID == 0)
2514 const QString& cond)
2516 if (ID !=
this || ID == 0)
2523 int editor_linenr = -1;
2531 if ((cond ==
"") != (bp->
get_cond () ==
""))
2548 bp, SLOT (handle_remove_via_original_linenr (
int)));
2551 bp, SLOT (handle_request_remove_via_editor_linenr
2554 bp, SLOT (handle_remove (
void)));
2555 connect (
this, SIGNAL (find_translated_line_number (
int,
int&,
2557 bp, SLOT (handle_find_translation (
int,
int&,
2560 bp, SLOT (handle_find_just_before (
int,
int&,
int&)));
2563 bp, SLOT (handle_report_editor_linenr (
QIntList&,
2565 connect (bp, SIGNAL (request_remove (
int)),
2577 long int visible_lines
2578 =
_edit_area->SendScintilla (QsciScintillaBase::SCI_LINESONSCREEN);
2580 if (visible_lines > 2)
2583 _edit_area->getCursorPosition (&line, &index);
2589 int vis_line =
_edit_area->SendScintilla (2220, line);
2591 int first_line =
_edit_area->firstVisibleLine ();
2593 if (always || vis_line == first_line
2594 || vis_line > first_line + visible_lines - 2)
2596 first_line += (vis_line - first_line - (visible_lines - 1) / 2);
2597 _edit_area->SendScintilla (2613, first_line);
2612 if (
_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE))
2634 QRegExp bkey = QRegExp (
"^[\t ]*(if|for|while|switch|case|do|function"
2635 "|unwind_protect|unwind_protect_cleanup|try)"
2637 if (prev_line.contains (bkey))
2646 QRegExp mkey = QRegExp (
"^[\t ]*(else|elseif|catch)[\t #%\n]");
2647 if (prev_line.contains (mkey))
2652 if (prev_ind == act_ind)
2654 else if (prev_ind > act_ind)
2662 QRegExp ekey = QRegExp (
"^[\t ]*(end|endif|endfor|endwhile|until|endfunction"
2663 "|end_try_catch|end_unwind_protext)[\t #%\n(;]");
2664 if (prev_line.contains (ekey))
2681 QRegExp rxfun1 (
"^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$");
2682 QRegExp rxfun2 (
"^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$");
2683 QRegExp rxfun3 (
"^[\t ]*function[^=]+=[\t ]*([^\\s]+)[\t ]*$");
2684 QRegExp rxfun4 (
"^[\t ]*function[\t ]+([^\\s]+)[\t ]*$");
2686 QStringList lines =
_edit_area->text ().split (
"\n");
2688 for (
int i = 0;
i < lines.count ();
i++)
2690 if (rxfun1.indexIn (lines.at (
i)) != -1)
2691 return rxfun1.cap (1).remove (QRegExp(
"[ \t]*"));
2692 else if (rxfun2.indexIn (lines.at (
i)) != -1)
2693 return rxfun2.cap (1).remove (QRegExp(
"[ \t]*"));
2694 else if (rxfun3.indexIn (lines.at (
i)) != -1)
2695 return rxfun3.cap (1).remove (QRegExp(
"[ \t]*"));
2696 else if (rxfun4.indexIn (lines.at (
i)) != -1)
2697 return rxfun4.cap (1).remove (QRegExp(
"[ \t]*"));
void report_marker_linenr(QIntList &lines, QStringList &conditions)
void remove_position_via_debugger_linenr(int debugger_linenr)
void handle_file_resave_answer(int decision)
void find_linenr_just_before(int linenr, int &original_linenr, int &editor_linenr)
void file_has_changed(const QString &fileName)
const Cell & contents(const_iterator p) const
OCTINTERP_API octave_value_list F__keywords__(const octave_value_list &=octave_value_list(), int=0)
bool is_true(const std::string &s)
OCTINTERP_API void octave_sleep(double seconds)
void closeEvent(QCloseEvent *event)
void update_window_title(bool modified)
void set_cond(const QString &cond)
For example cd octave end example noindent changes the current working directory to file
void remove_breakpoint_callback(const bp_info &info)
void convert_eol(const QWidget *ID, QsciScintilla::EolMode)
void previous_bookmark(const QWidget *ID)
std::string canonicalize_file_name(const std::string &name)
void handle_request_add_breakpoint(int line, const QString &cond)
static intmap add_breakpoint(const std::string &fname="", const intmap &lines=intmap(), const std::string &condition=bp_empty_string)
bool _find_dialog_is_visible
void indent_selected_text(const QWidget *ID)
void context_help(const QWidget *ID, bool)
void set_file_name(const QString &fileName)
void remove_breakpoint_via_debugger_linenr(int debugger_linenr)
find_dialog * _find_dialog
bool is_user_code(void) const
QFileSystemWatcher _file_system_watcher
octave_idx_type numel(void) const
Number of elements in the array.
static std::string dir_sep_chars(void)
void handle_save_file_as_answer_close(const QString &fileName)
void zoom_normal(const QWidget *ID)
void handle_combo_enc_current_index(QString text)
void handle_combo_eol_current_index(int index)
void zoom_out(const QWidget *ID)
octave_user_code * user_code_value(bool silent=false) const
void handle_lines_changed(void)
bool is_defined(void) const
std::string function_name
void handle_context_menu_break_condition(int linenr)
void file_name_query(const QWidget *ID)
bool unchanged_or_saved(void)
void toggle_breakpoint(const QWidget *ID)
void add_breakpoint_callback(const bp_info &info)
void check_restore_breakpoints(void)
QString fromStdString(const std::string &s)
void center_current_line(bool always=true)
void handle_copy_available(bool enableCopy)
static void combo_encoding(QComboBox *combo, QString current=QString())
T & elem(octave_idx_type n)
void handle_cursor_moved(int line, int col)
OCTINTERP_API octave_value_list F__builtins__(const octave_value_list &=octave_value_list(), int=0)
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
void update_eol_indicator()
void handle_find_dialog_finished(int decision)
void handle_octave_result(QObject *requester, QString &command, octave_value_list &result)
void request_find_next(void)
void check_modified_file(void)
void save_file_as(const QWidget *ID)
Cell cell_value(void) const
void context_help_doc(bool)
bp_info(const QString &fname, int l=0, const QString &cond="")
static void clear_user_function(const std::string &name)
OCTINTERP_API octave_value_list Fisdebugmode(const octave_value_list &=octave_value_list(), int=0)
void set_focus(const QWidget *ID)
int buffer_error_messages
void file_name_changed(const QString &fileName, const QString &toolTip)
const QString & get_cond(void) const
bool valid_identifier(const char *s)
void insert_debugger_pointer(const QWidget *ID, int line=-1)
static bool file_in_path(const std::string &file, const std::string &dir)
std::string string_value(bool force=false) const
void notice_settings(const QSettings *settings, bool init=false)
bool exit_debug_and_clear(const QString &full_name, const QString &base_name)
void print_file(const QWidget *ID)
bool check_valid_codec(QTextCodec *codec)
std::map< int, int > intmap
void find_next(const QWidget *ID)
void change_editor_state(const QWidget *ID)
void recover_from_exit(void)
void goto_line(const QWidget *ID, int line=-1)
void do_comment_selected_text(bool comment)
void handle_margin_clicked(int line, int margin, Qt::KeyboardModifiers state)
void find_previous(const QWidget *ID)
void next_bookmark(const QWidget *ID)
static void post_event(T *obj, void(T::*method)(void))
void save_file(const QWidget *ID)
void move_match_brace(const QWidget *ID, bool select)
void context_run(const QWidget *ID)
void remove_bookmark(const QWidget *ID)
void unindent_selected_text(const QWidget *ID)
static intmap remove_all_breakpoints_in_file(const std::string &fname, bool silent=false)
void set_current_directory(const QString &dir)
void add_filename_to_list(const QString &, const QString &, QWidget *)
MArray< T > filter(MArray< T > &b, MArray< T > &a, MArray< T > &x, MArray< T > &si, int dim=0)
void handle_file_modified_answer(int decision)
void find(const QWidget *ID, QList< QAction * >)
static QSettings * get_settings(void)
void execute_command_in_terminal_signal(const QString &)
void mru_add_file(const QString &file_name, const QString &encoding)
void handle_context_menu_edit(const QString &)
void handle_file_reload_answer(int decision)
void delete_debugger_pointer(const QWidget *ID, int line=-1)
QString get_function_name()
octave_qscintilla * _edit_area
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 ACM Transactions on Mathematical Article No
static std::string concat(const std::string &, const std::string &)
void show_dialog(QDialog *dlg, bool modal)
static uint32_t state[624]
void edit_mfile_request(const QString &, const QString &, const QString &, int)
void toggle_bookmark(const QWidget *ID)
void request_remove_breakpoint_via_editor_linenr(int editor_linenr)
void warning(const char *fmt,...)
octave::unwind_protect frame
bool check_valid_identifier(QString file_name)
void handle_save_file_as_answer(const QString &fileName)
OCTINTERP_API std::string last_error_message(void)
void context_edit(const QWidget *ID)
virtual std::string fcn_file_name(void) const
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
void do_indent_selected_text(bool indent)
void remove_all_breakpoints_callback(const bp_info &info)
static bool condition_valid(const std::string &cond)
void next_breakpoint(const QWidget *ID)
bool _always_reload_changed_files
QString comment_string(const QString &)
void handle_save_as_filter_selected(const QString &filter)
void do_smart_indent(void)
QRect _find_dialog_geometry
=val(i)}if ode{val(i)}occurs in table i
void previous_breakpoint(const QWidget *ID)
QsciScintilla::EolMode detect_eol_mode()
int check_file_modified()
void do_breakpoint_marker(bool insert, const QWidget *ID, int line=-1, const QString &cond="")
void uncomment_selected_text(const QWidget *ID)
void add_octave_apis(octave_value_list key_ovl)
void handle_save_file_as_answer_cancel()
QStringList _bp_conditions
static int remove_breakpoint(const std::string &fname="", const intmap &lines=intmap())
bool conditional_close(void)
void request_find_previous(void)
octave::sys::file_stat fs(filename)
void editor_check_conflict_save(const QString &saveFileName, bool remove_on_success)
QString load_file(const QString &fileName)
QsciScintilla::EolMode _save_as_desired_eol
void show_auto_completion(const QWidget *ID)
void remove_all_breakpoints(void)
void find_translated_line_number(int original_linenr, int &translated_linenr, marker *&)
void scintilla_command(const QWidget *, unsigned int)
void zoom_in(const QWidget *ID)
void handle_request_remove_breakpoint(int line)
void run_file(const QWidget *ID)
void comment_selected_text(const QWidget *ID)
void remove_all_positions(void)
std::string toStdString(const QString &s)
void set_modified(bool modified=true)
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 tab_remove_request()
void new_file(const QString &commands=QString())
void run_file_signal(const QFileInfo &info)
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 editor_state_changed(bool copy_available, bool is_octave_file)
static octave_map backtrace(size_t nskip=0)
bool valid_file_name(const QString &file=QString())
static octave_value find(const std::string &name, const octave_value_list &args=octave_value_list(), bool skip_variables=false, bool local_funcs=true)
OCTINTERP_API octave_value_list F__list_functions__(const octave_value_list &=octave_value_list(), int=0)
void set_encoding(const QString &new_encoding)
file_editor_tab(const QString &directory="")
A file_editor_tab object consists of a text area and three left margins.