GNU Octave  4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
file-editor.cc
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2011-2017 Jacob Dawid
4 
5 This file is part of Octave.
6 
7 Octave is free software; you can redistribute it and/or modify it
8 under the terms of the GNU General Public License as published by the
9 Free Software Foundation; either version 3 of the License, or (at your
10 option) any later version.
11 
12 Octave is distributed in the hope that it will be useful, but WITHOUT
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 for more details.
16 
17 You should have received a copy of the GNU General Public License
18 along with Octave; see the file COPYING. If not, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if defined (HAVE_CONFIG_H)
24 # include "config.h"
25 #endif
26 
27 #if defined (HAVE_QSCINTILLA)
28 
29 #include "file-editor.h"
30 #include "resource-manager.h"
31 #include "shortcut-manager.h"
32 
33 #include <QApplication>
34 #include <QFile>
35 #include <QFileDialog>
36 #include <QFont>
37 #include <QInputDialog>
38 #include <QMessageBox>
39 #include <QMimeData>
40 #include <QProcess>
41 #include <QStyle>
42 #include <QTabBar>
43 #include <QTextStream>
44 #include <QVBoxLayout>
45 #include <Qsci/qscicommandset.h>
46 
47 #include "octave-link.h"
48 #include "utils.h"
49 #include "main-window.h"
50 #include <oct-map.h>
51 
54 {
55  // Set current editing directory before construct because loaded
56  // files will change ced accordingly.
57  ced = QDir::currentPath ();
58 
59  // set action that are later added by the main window to null,
60  // preventing access to them when they are still undefined
61  _undo_action = 0;
62  _copy_action = 0;
63  _paste_action = 0;
65 
66  construct ();
67 
68  // actions that should also be available in the find dialog
71 
72  setVisible (false);
73  setAcceptDrops(true);
74 
75  _file_encoding = QString (); // for selecting an encoding in open dialog
76 }
77 
79 {
80  if (_mru_file_menu)
81  delete _mru_file_menu;
82 }
83 
84 bool
86 {
87  // When the applications is closing all editor tabs are checked whether
88  // they need to be saved. During these ckecked the tabs are not closed
89  // since the user might cancel closing octave during one of these saving
90  // dialogs. Therefore, saving the session for restoring at next start
91  // is not done before the application is definitely closing
92 
93  // Have all file editor tabs signal what their filenames are.
94  editor_tab_map.clear ();
95  emit fetab_file_name_query (0);
96 
97  // Save all tabs with confirmation.
100 
101  // If there was a cancellation, make the already saved/discarded tabs
102  // recovering from the exit by removing the read-only state and by
103  // recovering the debugger breakpoints. Finally return false in order to
104  // cancel closing the application
106  {
107  emit fetab_recover_from_exit ();
108  return false;
109  }
110 
111  // Here, the application will be closed -> store the session
112 
113  // Save open files for restoring in next session; this only is possible
114  QSettings *settings = resource_manager::get_settings ();
115 
116  // save filenames (even if last session will not be restored next time)
117  // together with encoding and the tab index
118  QStringList fetFileNames;
119  QStringList fet_encodings;
120  QStringList fet_index;
121 
122  // save all open tabs before they are definitely closed
124  p != editor_tab_map.end (); p++)
125  {
126  QString file_name = p->first; // get file name of tab
127  if (! file_name.isEmpty ()) // do not append unnamed files
128  {
129  fetFileNames.append (file_name);
130  fet_encodings.append (editor_tab_map[file_name].encoding);
131  QString index;
132  fet_index.append (index.setNum
133  (_tab_widget->indexOf (editor_tab_map[file_name].fet_ID)));
134  }
135  }
136 
137  settings->setValue ("editor/savedSessionTabs", fetFileNames);
138  settings->setValue ("editor/saved_session_encodings", fet_encodings);
139  settings->setValue ("editor/saved_session_tab_index", fet_index);
140  settings->sync ();
141 
142  // Finally close all the tabs and return indication that we can exit
143  // the application
144  for (int i = 0; i < _tab_widget->count (); i++)
145  {
146  delete _tab_widget->widget (i);
147  _tab_widget->removeTab (i);
148  }
149 
150  return true;
151 }
152 
153 void
155 {
157 
158  // set focus to current tab
159  QWidget *fileEditorTab = _tab_widget->currentWidget ();
160  if (fileEditorTab)
161  emit fetab_set_focus (fileEditorTab);
162 }
163 
164 void
166 {
167  ced = dir;
168  emit fetab_set_directory (ced); // for save dialog
169 }
170 
171 QMenu *
173 {
174  return _debug_menu;
175 }
176 
177 QToolBar *
179 {
180  return _tool_bar;
181 }
182 
183 void
185 {
186  _run_action->setEnabled (false);
187  _run_action->setShortcut (QKeySequence ());
188 }
189 
190 void
192 {
193  _run_action->setEnabled (true);
194  shortcut_manager::set_shortcut (_run_action, "editor_run:run_file");
195 }
196 
197 void
199 {
200  // Custom editor? If yes, we can only call the editor without passing
201  // some initial contents and even without being sure a new file is opened
202  if (call_custom_editor ())
203  return;
204 
205  // New file isn't a file_editor_tab function since the file
206  // editor tab has yet to be created and there is no object to
207  // pass a signal to. Hence, functionality is here.
208 
209  file_editor_tab *fileEditorTab = new file_editor_tab (ced);
210  if (fileEditorTab)
211  {
212  add_file_editor_tab (fileEditorTab, ""); // new tab with empty title
213  fileEditorTab->new_file (commands); // title is updated here
214  focus (); // focus editor and new tab
215  }
216 }
217 
218 void
220 {
221  request_new_file (commands);
222 }
223 
224 void
226 {
227  bool ok;
228  // get the name of the new function
229  QString new_name = QInputDialog::getText (this, tr ("New Function"),
230  tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
231  if (ok && new_name.length () > 0)
232  {
233  // append suffix if it not already exists
234  if (new_name.rightRef (2) != ".m")
235  new_name.append (".m");
236  // check whether new files are created without prompt
237  QSettings *settings = resource_manager::get_settings ();
238  if (! settings->value ("editor/create_new_file",false).toBool ())
239  {
240  // no, so enable this settings and wait for end of new file loading
241  settings->setValue ("editor/create_new_file",true);
242  connect (this, SIGNAL (file_loaded_signal ()),
243  this, SLOT (restore_create_file_setting ()));
244  }
245  // start the edit command
246  emit execute_command_in_terminal_signal ("edit " + new_name);
247  }
248 }
249 
250 void
252 {
253  // restore the new files creation setting
254  QSettings *settings = resource_manager::get_settings ();
255  settings->setValue ("editor/create_new_file",false);
256  disconnect (this, SIGNAL (file_loaded_signal ()),
257  this, SLOT (restore_create_file_setting ()));
258 }
259 
260 void
262 {
263  // Open file isn't a file_editor_tab function since the file
264  // editor tab has yet to be created and there is no object to
265  // pass a signal to. Hence, functionality is here.
266 
267  // Create a NonModal message.
268  QFileDialog *fileDialog = new QFileDialog (this);
269  fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
270 
271  // Giving trouble under KDE (problem is related to Qt signal handling on unix,
272  // see https://bugs.kde.org/show_bug.cgi?id=260719 ,
273  // it had/has no effect on Windows, though)
274  fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
275 
276  // define a new grid layout with the extra elements
277  QGridLayout *extra = new QGridLayout (fileDialog);
278  QFrame *separator = new QFrame (fileDialog);
279  separator->setFrameShape (QFrame::HLine); // horizontal line as separator
280  separator->setFrameStyle (QFrame::Sunken);
281 
282  // combo box for encoding
283  QLabel *label_enc = new QLabel (tr ("File Encoding:"));
284  QComboBox *combo_enc = new QComboBox ();
286  _file_encoding = QString (); // default, no special encoding
287 
288  // track changes in the combo boxes
289  connect (combo_enc, SIGNAL (currentIndexChanged (QString)),
290  this, SLOT (handle_combo_enc_current_index (QString)));
291 
292  // build the extra grid layout
293  extra->addWidget (separator,0,0,1,3);
294  extra->addWidget (label_enc,1,0);
295  extra->addWidget (combo_enc,1,1);
296  extra->addItem (new QSpacerItem (1,20,QSizePolicy::Expanding,
297  QSizePolicy::Fixed), 1,2);
298 
299  // and add the extra grid layout to the dialog's layout
300  QGridLayout *dialog_layout = dynamic_cast<QGridLayout*> (fileDialog->layout ());
301  dialog_layout->addLayout (extra,dialog_layout->rowCount (),0,
302  1,dialog_layout->columnCount ());
303 
304  fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
305  fileDialog->setViewMode (QFileDialog::Detail);
306  fileDialog->setFileMode (QFileDialog::ExistingFiles);
307  fileDialog->setDirectory (ced);
308 
309  connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
310  this, SLOT (request_open_files (const QStringList&)));
311 
312  fileDialog->setWindowModality (Qt::NonModal);
313  fileDialog->setAttribute (Qt::WA_DeleteOnClose);
314  fileDialog->show ();
315 }
316 
317 void
319 {
320  _file_encoding = new_encoding;
321 }
322 
323 // Check whether this file is already open in the editor.
324 QWidget *
325 file_editor::find_tab_widget (const QString& file) const
326 {
327  QWidget *retval = 0;
328 
330  p != editor_tab_map.end (); p++)
331  {
332  QString tab_file = p->first;
333 
334  if (same_file (file.toStdString (), tab_file.toStdString ())
335  || file == tab_file) // needed as same_file ("","") is false.
336  {
337  retval = p->second.fet_ID;
338  break;
339  }
340  }
341 
342  return retval;
343 }
344 
345 bool
346 file_editor::call_custom_editor (const QString& file_name, int line)
347 {
348  // Check if the user wants to use a custom file editor.
349  QSettings *settings = resource_manager::get_settings ();
350 
351  if (settings->value ("useCustomFileEditor",false).toBool ())
352  {
353  if (line > -1) // check for a specific line (debugging)
354  return true; // yes: do ont open a file in external editor
355 
356  QString editor = settings->value ("customFileEditor").toString ();
357  editor.replace ("%f", file_name);
358  editor.replace ("%l", QString::number (line));
359 
360  bool started_ok = QProcess::startDetached (editor);
361 
362  if (started_ok != true)
363  {
364  QMessageBox *msgBox
365  = new QMessageBox (QMessageBox::Critical,
366  tr ("Octave Editor"),
367  tr ("Could not start custom file editor\n%1").
368  arg (editor),
369  QMessageBox::Ok, this);
370 
371  msgBox->setWindowModality (Qt::NonModal);
372  msgBox->setAttribute (Qt::WA_DeleteOnClose);
373  msgBox->show ();
374  }
375 
376  if (line < 0 && ! file_name.isEmpty ())
377  handle_mru_add_file (QFileInfo (file_name).canonicalFilePath (),
378  QString ());
379 
380  return true;
381  }
382 
383  return false;
384 }
385 
386 bool
388 {
389  main_window *w = static_cast<main_window *>(main_win ());
390  QList<QDockWidget *> w_list = w->tabifiedDockWidgets (this);
391  QDockWidget *console =
392  static_cast<QDockWidget *> (w->get_dock_widget_list ().at (0));
393 
394  for (int i = 0; i < w_list.count (); i++)
395  {
396  if (w_list.at (i) == console)
397  return true;
398  }
399 
400  return false;
401 }
402 
403 // The following slot is called after files have been selected in the
404 // open file dialog, possibly with a new selected encoding stored in
405 // _file_encoding
406 void
407 file_editor::request_open_files (const QStringList& open_file_names)
408 {
409  for (int i = 0; i < open_file_names.count (); i++)
410  request_open_file (open_file_names.at (i), _file_encoding);
411 }
412 
413 // Open a file, if not already open, and mark the current execution location
414 // and/or a breakpoint with condition cond.
415 void
416 file_editor::request_open_file (const QString& openFileName,
417  const QString& encoding,
418  int line, bool debug_pointer,
419  bool breakpoint_marker, bool insert,
420  const QString& cond)
421 {
422  if (call_custom_editor (openFileName, line))
423  return; // custom editor called
424 
425  if (openFileName.isEmpty ())
426  {
427  // This happens if edit is calles without an argument
428  // Open eitor with empty edit area instead (as new file would do)
429  request_new_file ("");
430  }
431  else
432  {
433  // Have all file editor tabs signal what their filenames are.
434  editor_tab_map.clear ();
435  emit fetab_file_name_query (0);
436 
437  // Check whether this file is already open in the editor.
438  QWidget *tab = find_tab_widget (openFileName);
439 
440  if (tab)
441  {
442  _tab_widget->setCurrentWidget (tab);
443 
444  if (line > 0)
445  {
446  emit fetab_goto_line (tab, line);
447 
448  if (debug_pointer)
449  emit fetab_insert_debugger_pointer (tab, line);
450 
451  if (breakpoint_marker)
452  emit fetab_do_breakpoint_marker (insert, tab, line, cond);
453  }
454 
455  if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ()))
456  {
457  emit fetab_set_focus (tab);
458  focus ();
459  }
460  }
461  else
462  {
463  file_editor_tab *fileEditorTab = 0;
464  // Reuse <unnamed> tab if it hasn't yet been modified.
465  bool reusing = false;
466  tab = find_tab_widget ("");
467  if (tab)
468  {
469  fileEditorTab = static_cast<file_editor_tab *>(tab);
470  if (fileEditorTab->qsci_edit_area ()->isModified ())
471  fileEditorTab = 0;
472  else
473  reusing = true;
474  }
475 
476  // If <unnamed> was absent or modified, create a new tab.
477  if (!fileEditorTab)
478  fileEditorTab = new file_editor_tab ();
479 
480  if (fileEditorTab)
481  {
482  fileEditorTab->set_encoding (encoding);
483  QString result = fileEditorTab->load_file (openFileName);
484  if (result == "")
485  {
486  // Supply empty title then have the file_editor_tab update
487  // with full or short name.
488  if (!reusing)
489  add_file_editor_tab (fileEditorTab, "");
490  fileEditorTab->update_window_title (false);
491  // file already loaded, add file to mru list here
492  QFileInfo file_info = QFileInfo (openFileName);
493  handle_mru_add_file (file_info.canonicalFilePath (),
494  encoding);
495 
496  if (line > 0)
497  {
498  emit fetab_goto_line (fileEditorTab, line);
499 
500  if (debug_pointer)
501  emit fetab_insert_debugger_pointer (fileEditorTab,
502  line);
503  if (breakpoint_marker)
504  emit fetab_do_breakpoint_marker (insert, fileEditorTab,
505  line, cond);
506  }
507  }
508  else
509  {
510  delete fileEditorTab;
511 
512  if (QFile::exists (openFileName))
513  {
514  // File not readable:
515  // create a NonModal message about error.
516  QMessageBox *msgBox
517  = new QMessageBox (QMessageBox::Critical,
518  tr ("Octave Editor"),
519  tr ("Could not open file\n%1\nfor read: %2.").
520  arg (openFileName).arg (result),
521  QMessageBox::Ok, this);
522 
523  msgBox->setWindowModality (Qt::NonModal);
524  msgBox->setAttribute (Qt::WA_DeleteOnClose);
525  msgBox->show ();
526  }
527  else
528  {
529  // File does not exist, should it be created?
530  bool create_file = true;
531  QMessageBox *msgBox;
532  QSettings *settings = resource_manager::get_settings ();
533 
534  if (! settings->value ("editor/create_new_file", false).toBool ())
535  {
536  msgBox = new QMessageBox (QMessageBox::Question,
537  tr ("Octave Editor"),
538  tr ("File\n%1\ndoes not exist. "
539  "Do you want to create it?").arg (openFileName),
540  QMessageBox::NoButton,0);
541  QPushButton *create_button =
542  msgBox->addButton (tr ("Create"), QMessageBox::YesRole);
543  msgBox->addButton (tr ("Cancel"), QMessageBox::RejectRole);
544  msgBox->setDefaultButton (create_button);
545  msgBox->exec ();
546 
547  QAbstractButton *clicked_button = msgBox->clickedButton ();
548  if (clicked_button != create_button)
549  create_file = false;
550 
551  delete msgBox;
552  }
553 
554  if (create_file)
555  {
556  // create the file and call the editor again
557  QFile file (openFileName);
558  if (! file.open (QIODevice::WriteOnly))
559  {
560  // error opening the file
561  msgBox = new QMessageBox (QMessageBox::Critical,
562  tr ("Octave Editor"),
563  tr ("Could not open file\n%1\nfor write: %2.").
564  arg (openFileName).arg (file.errorString ()),
565  QMessageBox::Ok, this);
566 
567  msgBox->setWindowModality (Qt::NonModal);
568  msgBox->setAttribute (Qt::WA_DeleteOnClose);
569  msgBox->show ();
570  }
571  else
572  {
573  file.close ();
574  request_open_file (openFileName);
575  }
576  }
577  }
578  }
579  }
580 
581  if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ()))
582  {
583  // really show editor and the current editor tab
584  focus ();
585  emit file_loaded_signal ();
586  }
587  }
588  }
589 }
590 
591 // open a file from the mru list
592 void
594 {
595  if (action)
596  {
597  request_open_file (action->data ().toStringList ().at (0),
598  action->data ().toStringList ().at (1));
599  }
600 }
601 
602 void
603 file_editor::check_conflict_save (const QString& saveFileName,
604  bool remove_on_success)
605 {
606  // Have all file editor tabs signal what their filenames are.
607  editor_tab_map.clear ();
608  emit fetab_file_name_query (0);
609 
610  // Check whether this file is already open in the editor.
611  QWidget *tab = find_tab_widget (saveFileName);
612 
613  if (tab)
614  {
615  // Note: to overwrite the contents of some other file editor tab
616  // with the same name requires identifying which file editor tab
617  // that is (not too difficult) then close that tab. Of course,
618  // that could trigger another dialog box if the file editor tab
619  // with the same name has modifications in it. This could become
620  // somewhat confusing to the user. For now, opt to do nothing.
621 
622  // Create a NonModal message about error.
623  QMessageBox *msgBox
624  = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"),
625  tr ("File not saved! A file with the selected name\n%1\n"
626  "is already open in the editor").
627  arg (saveFileName),
628  QMessageBox::Ok, 0);
629 
630  msgBox->setWindowModality (Qt::NonModal);
631  msgBox->setAttribute (Qt::WA_DeleteOnClose);
632  msgBox->show ();
633 
634  return;
635  }
636 
637  QObject *saveFileObject = sender ();
638  QWidget *saveFileWidget = 0;
639 
640  for (int i = 0; i < _tab_widget->count (); i++)
641  {
642  if (_tab_widget->widget (i) == saveFileObject)
643  {
644  saveFileWidget = _tab_widget->widget (i);
645  break;
646  }
647  }
648  if (! saveFileWidget)
649  {
650  // Create a NonModal message about error.
651  QMessageBox *msgBox
652  = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"),
653  tr ("The associated file editor tab has disappeared."),
654  QMessageBox::Ok, 0);
655 
656  msgBox->setWindowModality (Qt::NonModal);
657  msgBox->setAttribute (Qt::WA_DeleteOnClose);
658  msgBox->show ();
659 
660  return;
661  }
662 
663  // Can save without conflict, have the file editor tab do so.
664  emit fetab_save_file (saveFileWidget, saveFileName, remove_on_success);
665 }
666 
667 void
669  const QString& ffile,
670  const QString& curr_dir, int line)
671 {
672  // Is it a regular function within the search path? (Call __which__)
673  octave_value_list fct = F__which__ (ovl (fname.toStdString ()),0);
674  octave_map map = fct(0).map_value ();
675 
676  QString type = QString::fromStdString (
677  map.contents ("type").data ()[0].string_value ());
678  QString name = QString::fromStdString (
679  map.contents ("name").data ()[0].string_value ());
680 
681  QString message = QString ();
682  QString filename = QString ();
683 
684  if (type == QString("built-in function"))
685  {
686  // built in function: can't edit
687  message = tr ("%1 is a built-in function");
688  }
689  else if (type.isEmpty ())
690  {
691  // function not known to octave -> try directory of edited file
692  // get directory
693  QDir dir;
694  if (ffile.isEmpty ())
695  {
696  if (curr_dir.isEmpty ())
697  dir = QDir (ced);
698  else
699  dir = QDir (curr_dir);
700  }
701  else
702  dir = QDir (QFileInfo (ffile).canonicalPath ());
703 
704  // function not known to octave -> try directory of edited file
705  QFileInfo file = QFileInfo (dir, fname + ".m");
706 
707  if (file.exists ())
708  {
709  filename = file.canonicalFilePath (); // local file exists
710  }
711  else
712  {
713  // local file does not exist -> try private directory
714  file = QFileInfo (ffile);
715  file = QFileInfo (QDir (file.canonicalPath () + "/private"),
716  fname + ".m");
717 
718  if (file.exists ())
719  {
720  filename = file.canonicalFilePath (); // private function exists
721  }
722  else
723  {
724  message = tr ("Can not find function %1"); // no file found
725  }
726  }
727  }
728 
729  if (! message.isEmpty ())
730  {
731  QMessageBox *msgBox
732  = new QMessageBox (QMessageBox::Critical,
733  tr ("Octave Editor"),
734  message.arg (name),
735  QMessageBox::Ok, this);
736 
737  msgBox->setWindowModality (Qt::NonModal);
738  msgBox->setAttribute (Qt::WA_DeleteOnClose);
739  msgBox->show ();
740  return;
741  }
742 
743  if (filename.isEmpty ())
744  filename = QString::fromStdString (
745  map.contents ("file").data ()[0].string_value ());
746 
747  if (! filename.endsWith (".m"))
748  filename.append (".m");
749 
750  request_open_file (filename, QString (), line); // default encoding
751 }
752 
753 void
755  int line)
756 {
757  request_open_file (file, QString (), line, true); // default encoding
758 }
759 
760 void
762  int line)
763 {
764  if (! file.isEmpty ())
765  {
766  // Have all file editor tabs signal what their filenames are.
767  editor_tab_map.clear ();
768  emit fetab_file_name_query (0);
769 
770  // Check whether this file is already open in the editor.
771  QWidget *tab = find_tab_widget (file);
772 
773  if (tab)
774  {
775  _tab_widget->setCurrentWidget (tab);
776 
777  if (line > 0)
778  emit fetab_delete_debugger_pointer (tab, line);
779 
780  emit fetab_set_focus (tab);
781  }
782  }
783 }
784 
785 void
787  const QString& file,
788  int line,
789  const QString& cond)
790 {
791  request_open_file (file, QString (), line, false, true, insert, cond);
792 }
793 
794 void
796 {
797  request_open_file (file);
798 }
799 
800 void
802 {
803  if (editor_tab_has_focus ())
804  emit fetab_scintilla_command (_tab_widget->currentWidget (),
805  QsciScintillaBase::SCI_UNDO);
806 }
807 
808 void
810 {
811  emit fetab_scintilla_command (_tab_widget->currentWidget (),
812  QsciScintillaBase::SCI_REDO);
813 }
814 
815 void
817 {
818  if (editor_tab_has_focus ())
819  emit fetab_scintilla_command (_tab_widget->currentWidget (),
820  QsciScintillaBase::SCI_COPY);
821 }
822 
823 void
825 {
826  emit fetab_scintilla_command (_tab_widget->currentWidget (),
827  QsciScintillaBase::SCI_CUT);
828 }
829 
830 void
832 {
833  if (editor_tab_has_focus ())
834  emit fetab_scintilla_command (_tab_widget->currentWidget (),
835  QsciScintillaBase::SCI_PASTE);
836 }
837 
838 void
840 {
841  if (editor_tab_has_focus ())
842  emit fetab_scintilla_command (_tab_widget->currentWidget (),
843  QsciScintillaBase::SCI_SELECTALL);
844 }
845 
846 void
848 {
849  emit fetab_context_help (_tab_widget->currentWidget (), false);
850 }
851 void
853 {
854  emit fetab_context_help (_tab_widget->currentWidget (), true);
855 }
856 
857 void
859 {
860  emit fetab_context_edit (_tab_widget->currentWidget ());
861 }
862 
863 void
865 {
866  emit fetab_save_file (_tab_widget->currentWidget ());
867 }
868 
869 void
871 {
872  emit fetab_save_file_as (_tab_widget->currentWidget ());
873 }
874 
875 void
877 {
878  emit fetab_print_file (_tab_widget->currentWidget ());
879 }
880 
881 void
883 {
884  emit fetab_run_file (_tab_widget->currentWidget ());
885 }
886 
887 void
889 {
890  emit fetab_context_run (_tab_widget->currentWidget ());
891 }
892 
893 void
895 {
896  emit fetab_toggle_bookmark (_tab_widget->currentWidget ());
897 }
898 
899 void
901 {
902  emit fetab_next_bookmark (_tab_widget->currentWidget ());
903 }
904 
905 void
907 {
908  emit fetab_previous_bookmark (_tab_widget->currentWidget ());
909 }
910 
911 void
913 {
914  emit fetab_remove_bookmark (_tab_widget->currentWidget ());
915 }
916 
917 // FIXME: What should this do with conditional breakpoints?
918 void
920 {
921  emit fetab_toggle_breakpoint (_tab_widget->currentWidget ());
922 }
923 
924 void
926 {
927  emit fetab_next_breakpoint (_tab_widget->currentWidget ());
928 }
929 
930 void
932 {
933  emit fetab_previous_breakpoint (_tab_widget->currentWidget ());
934 }
935 
936 void
938 {
939  emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ());
940 }
941 
942 // slots for Edit->Commands actions
943 void
945 {
946  emit fetab_scintilla_command (_tab_widget->currentWidget (),
947  QsciScintillaBase::SCI_DELWORDLEFT);
948 }
949 void
951 {
952  emit fetab_scintilla_command (_tab_widget->currentWidget (),
953  QsciScintillaBase::SCI_DELWORDRIGHT);
954 }
955 void
957 {
958  emit fetab_scintilla_command (_tab_widget->currentWidget (),
959  QsciScintillaBase::SCI_DELLINELEFT);
960 }
961 void
963 {
964  emit fetab_scintilla_command (_tab_widget->currentWidget (),
965  QsciScintillaBase::SCI_DELLINERIGHT);
966 }
967 void
969 {
970  emit fetab_scintilla_command (_tab_widget->currentWidget (),
971  QsciScintillaBase::SCI_LINEDELETE);
972 }
973 void
975 {
976  emit fetab_scintilla_command (_tab_widget->currentWidget (),
977  QsciScintillaBase::SCI_LINECOPY);
978 }
979 void
981 {
982  emit fetab_scintilla_command (_tab_widget->currentWidget (),
983  QsciScintillaBase::SCI_LINECUT);
984 }
985 void
987 {
988  emit fetab_scintilla_command (_tab_widget->currentWidget (),
989  QsciScintillaBase::SCI_SELECTIONDUPLICATE);
990 }
991 void
993 {
994  emit fetab_scintilla_command (_tab_widget->currentWidget (),
995  QsciScintillaBase::SCI_LINETRANSPOSE);
996 }
997 void
999 {
1000  emit fetab_comment_selected_text (_tab_widget->currentWidget ());
1001 }
1002 void
1004 {
1005  emit fetab_uncomment_selected_text (_tab_widget->currentWidget ());
1006 }
1007 
1008 // slots for Edit->Format actions
1009 void
1011 {
1012  emit fetab_scintilla_command (_tab_widget->currentWidget (),
1013  QsciScintillaBase::SCI_UPPERCASE);
1014 }
1015 void
1017 {
1018  emit fetab_scintilla_command (_tab_widget->currentWidget (),
1019  QsciScintillaBase::SCI_LOWERCASE);
1020 }
1021 void
1023 {
1024  emit fetab_indent_selected_text (_tab_widget->currentWidget ());
1025 }
1026 
1027 void
1029 {
1030  emit fetab_unindent_selected_text (_tab_widget->currentWidget ());
1031 }
1032 
1033 void
1035 {
1036  emit fetab_convert_eol (_tab_widget->currentWidget (),
1037  QsciScintilla::EolWindows);
1038 }
1039 void
1041 {
1042  emit fetab_convert_eol (_tab_widget->currentWidget (),
1043  QsciScintilla::EolUnix);
1044 }
1045 void
1047 {
1048  emit fetab_convert_eol (_tab_widget->currentWidget (),
1049  QsciScintilla::EolMac);
1050 }
1051 
1052 void
1054 {
1055  emit fetab_find (_tab_widget->currentWidget (), _fetab_actions);
1056 }
1057 
1058 void
1060 {
1061  emit fetab_find_next (_tab_widget->currentWidget ());
1062 }
1063 
1064 void
1066 {
1067  emit fetab_find_previous (_tab_widget->currentWidget ());
1068 }
1069 
1070 void
1072 {
1073  emit fetab_goto_line (_tab_widget->currentWidget ());
1074 }
1075 
1076 void
1078 {
1079  emit fetab_move_match_brace (_tab_widget->currentWidget (), false);
1080 }
1081 
1082 void
1084 {
1085  emit fetab_move_match_brace (_tab_widget->currentWidget (), true);
1086 }
1087 
1088 void
1090 {
1091  emit fetab_completion (_tab_widget->currentWidget ());
1092 }
1093 
1094 void
1095 file_editor::handle_mru_add_file (const QString& file_name,
1096  const QString& encoding)
1097 {
1098  int index;
1099  while ((index = _mru_files.indexOf (file_name)) >= 0)
1100  {
1101  _mru_files.removeAt (index);
1102  _mru_files_encodings.removeAt (index);
1103  }
1104 
1105  _mru_files.prepend (file_name);
1106  _mru_files_encodings.prepend (encoding);
1107 
1108  mru_menu_update ();
1109 }
1110 
1111 void
1113 {
1114  int num_files = qMin (_mru_files.size (), int (MaxMRUFiles));
1115 
1116  // configure and show active actions of mru-menu
1117  for (int i = 0; i < num_files; ++i)
1118  {
1119  QString text = tr ("&%1 %2").
1120  arg ((i+1) % int (MaxMRUFiles)).arg (_mru_files.at (i));
1121  _mru_file_actions[i]->setText (text);
1122 
1123  QStringList action_data;
1124  action_data << _mru_files.at (i) << _mru_files_encodings.at (i);
1125  _mru_file_actions[i]->setData (action_data);
1126 
1127  _mru_file_actions[i]->setVisible (true);
1128  }
1129 
1130  // hide unused mru-menu entries
1131  for (int j = num_files; j < MaxMRUFiles; ++j)
1132  _mru_file_actions[j]->setVisible (false);
1133 
1134  // delete entries in string-list beyond MaxMRUFiles
1135  while (_mru_files.size () > MaxMRUFiles)
1136  {
1137  _mru_files.removeLast ();
1138  _mru_files_encodings.removeLast ();
1139  }
1140 
1141  // save actual mru-list in settings
1142  QSettings *settings = resource_manager::get_settings ();
1143 
1144  settings->setValue ("editor/mru_file_list", _mru_files);
1145  settings->setValue ("editor/mru_file_encodings", _mru_files_encodings);
1146  settings->sync ();
1147 }
1148 
1149 void
1151  const QString& tip)
1152 {
1153  QObject *fileEditorTab = sender ();
1154  if (fileEditorTab)
1155  {
1156  for (int i = 0; i < _tab_widget->count (); i++)
1157  {
1158  if (_tab_widget->widget (i) == fileEditorTab)
1159  {
1160  _tab_widget->setTabText (i, fname);
1161  _tab_widget->setTabToolTip (i, tip);
1162  }
1163  }
1164  }
1165 }
1166 
1167 void
1169 {
1170  file_editor_tab *editor_tab
1171  = static_cast<file_editor_tab *> (_tab_widget->currentWidget ());
1172  editor_tab->conditional_close ();
1173 }
1174 
1175 void
1177 {
1178  file_editor_tab *editor_tab;
1179 
1180  // loop over all tabs starting from last one otherwise deletion changes index
1181  for (int index = _tab_widget->count ()-1; index >= 0; index--)
1182  {
1183  editor_tab = static_cast<file_editor_tab *> (_tab_widget->widget (index));
1184  editor_tab->conditional_close ();
1185  }
1186 }
1187 
1188 void
1190 {
1191  file_editor_tab *editor_tab;
1192  QWidget *tabID = _tab_widget->currentWidget ();
1193 
1194  // loop over all tabs starting from last one otherwise deletion changes index
1195  for (int index = _tab_widget->count ()-1; index >= 0; index--)
1196  {
1197  if (tabID != _tab_widget->widget (index))
1198  {
1199  editor_tab
1200  = static_cast<file_editor_tab *> (_tab_widget->widget (index));
1201  editor_tab->conditional_close ();
1202  }
1203  }
1204 }
1205 
1206 void
1208 {
1209  file_editor_tab *editor_tab
1210  = static_cast<file_editor_tab *> (_tab_widget->widget (index));
1211  editor_tab->conditional_close ();
1212 }
1213 
1214 void
1216 {
1217  QObject *fileEditorTab = sender ();
1218  if (fileEditorTab)
1219  {
1220  for (int i = 0; i < _tab_widget->count (); i++)
1221  {
1222  if (_tab_widget->widget (i) == fileEditorTab)
1223  {
1224  _tab_widget->removeTab (i);
1225  // Deleting sender is dodgy, but works because the signal
1226  // is the last item in the sender's routines.
1227  delete fileEditorTab;
1228  break;
1229  }
1230  }
1231  }
1232  check_actions ();
1233 
1234  focus (); // focus stays in editor when tab is closed
1235 }
1236 
1237 void
1239  const QString& encoding, QWidget *ID)
1240 {
1241  // Should we allow multiple tabs for a single file?
1242  editor_tab_map[fileName].fet_ID = ID;
1243  editor_tab_map[fileName].encoding = encoding;
1244 }
1245 
1246 // context menu of edit area
1247 void
1249 {
1250  emit fetab_change_request (_tab_widget->widget (index));
1251 }
1252 
1254 {
1255  // remove all standard actions from scintilla
1256  QList<QAction *> all_actions = menu->actions ();
1257  QAction* a;
1258 
1259  foreach (a, all_actions)
1260  menu->removeAction (a);
1261 
1262  // add editor's actions with icons and customized shortcuts
1263  menu->addAction (_undo_action);
1264  menu->addAction (_redo_action);
1265  menu->addSeparator ();
1266  menu->addAction (_cut_action);
1267  menu->addAction (_copy_action);
1268  menu->addAction (_paste_action);
1269  menu->addSeparator ();
1270  menu->addAction (_selectall_action);
1271  menu->addSeparator ();
1272  menu->addAction (_run_selection_action);
1273 }
1274 
1275 void
1276 file_editor::toggle_preference (const QString& preference, bool def)
1277 {
1278  QSettings *settings = resource_manager::get_settings ();
1279  bool old = settings->value (preference,def).toBool ();
1280  settings->setValue (preference,! old);
1281  notice_settings (settings);
1282 }
1283 
1284 void
1286 {
1287  toggle_preference ("editor/showLineNumbers",true);
1288 }
1289 void
1291 {
1292  toggle_preference ("editor/show_white_space",false);
1293 }
1294 void
1296 {
1297  toggle_preference ("editor/show_eol_chars",false);
1298 }
1299 void
1301 {
1302  toggle_preference ("editor/show_indent_guides",false);
1303 }
1304 void
1306 {
1307  toggle_preference ("editor/long_line_marker",true);
1308 }
1309 void
1311 {
1312  toggle_preference ("editor/show_toolbar",true);
1313 }
1314 void
1316 {
1317  toggle_preference ("editor/show_edit_status_bar",true);
1318 }
1319 void
1321 {
1322  toggle_preference ("editor/show_hscroll_bar",true);
1323 }
1324 
1325 void
1327 {
1328  emit fetab_zoom_in (_tab_widget->currentWidget ());
1329 }
1330 
1331 void
1333 {
1334  emit fetab_zoom_out (_tab_widget->currentWidget ());
1335 }
1336 
1337 void
1339 {
1340  emit fetab_zoom_normal (_tab_widget->currentWidget ());
1341 }
1342 
1343 void
1344 file_editor::edit_status_update (bool undo, bool redo)
1345 {
1346  if (_undo_action)
1347  _undo_action->setEnabled (undo);
1348  _redo_action->setEnabled (redo);
1349 }
1350 
1351 void
1353  bool is_octave_file)
1354 {
1355  // In case there is some scenario where traffic could be coming from
1356  // all the file editor tabs, just process info from the current active tab.
1357  if (sender () == _tab_widget->currentWidget ())
1358  {
1359  if (_copy_action)
1360  _copy_action->setEnabled (copy_available);
1361  _cut_action->setEnabled (copy_available);
1362  _run_selection_action->setEnabled (copy_available);
1363  _run_action->setEnabled (is_octave_file);
1364 
1365  setFocusProxy (_tab_widget->currentWidget ());
1366  }
1367 }
1368 
1369 void
1370 file_editor::notice_settings (const QSettings *settings)
1371 {
1372  int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
1373  QStyle *st = style ();
1374  int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
1375 
1376  if (icon_size_settings == 1)
1377  icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
1378  else if (icon_size_settings == -1)
1379  icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
1380 
1381  _tool_bar->setIconSize (QSize (icon_size,icon_size));
1382 
1383  int tab_width_min = settings->value ("editor/notebook_tab_width_min", 160)
1384  .toInt ();
1385  int tab_width_max = settings->value ("editor/notebook_tab_width_max", 300)
1386  .toInt ();
1387 
1388  if (settings->value ("editor/longWindowTitle", false).toBool ())
1389  {
1390  QString style_sheet = QString ("QTabBar::tab "
1391  "{min-width: %1px; max-width: %2px;}")
1392  .arg (tab_width_min).arg (tab_width_max);
1393  _tab_widget->setElideMode (Qt::ElideLeft);
1394  _tab_widget->setStyleSheet (style_sheet);
1395  }
1396  else
1397  _tab_widget->setElideMode (Qt::ElideNone);
1398 
1399  _tab_widget->setUsesScrollButtons (true);
1400 
1401  bool show_it;
1402  show_it = settings->value ("editor/showLineNumbers",true).toBool ();
1403  _show_linenum_action->setChecked (show_it);
1404  show_it = settings->value ("editor/show_white_space",false).toBool ();
1405  _show_whitespace_action->setChecked (show_it);
1406  show_it = settings->value ("editor/show_eol_chars",false).toBool ();
1407  _show_eol_action->setChecked (show_it);
1408  show_it = settings->value ("editor/show_indent_guides",false).toBool ();
1409  _show_indguide_action->setChecked (show_it);
1410  show_it = settings->value ("editor/long_line_marker",true).toBool ();
1411  _show_longline_action->setChecked (show_it);
1412 
1413  show_it = settings->value ("editor/show_toolbar",true).toBool ();
1414  _show_toolbar_action->setChecked (show_it);
1415  _tool_bar->setVisible (show_it);
1416  show_it = settings->value ("editor/show_edit_status_bar",true).toBool ();
1417  _show_statusbar_action->setChecked (show_it);
1418  show_it = settings->value ("editor/show_hscroll_bar",true).toBool ();
1419  _show_hscrollbar_action->setChecked (show_it);
1420 
1421  set_shortcuts ();
1422 
1423  // Relay signal to file editor tabs.
1424  emit fetab_settings_changed (settings);
1425 }
1426 
1427 void
1429 {
1430  emit request_settings_dialog ("editor");
1431 }
1432 
1433 void
1435 {
1436  emit request_settings_dialog ("editor_styles");
1437 }
1438 
1439 // insert global actions, that should also be displayed in the editor window,
1440 // into the editor's menu and/or toolbar
1441 void
1443 {
1444  // actions/menus that have to be added to the toolbar or the menu
1445  QAction *open_action = shared_actions.at (OPEN_ACTION);
1446  QAction *new_action = shared_actions.at (NEW_SCRIPT_ACTION);
1447  QAction *new_fcn_action = shared_actions.at (NEW_FUNCTION_ACTION);
1448  _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action);
1449  _fileMenu->insertAction (open_action, new_fcn_action);
1450  _fileMenu->insertAction (new_fcn_action, new_action);
1451  _tool_bar->insertAction (_popdown_mru_action, open_action);
1452  _tool_bar->insertAction (open_action, new_action);
1453 
1454  // actions that are additionally enabled/disabled later by the editor
1455  // undo
1456  _undo_action = shared_actions.at (UNDO_ACTION);
1457  _tool_bar->insertAction (_redo_action,_undo_action);
1458  _edit_menu->insertAction (_redo_action,_undo_action);
1459  _undo_action->setEnabled (false);
1460  // copy
1461  _copy_action = shared_actions.at (COPY_ACTION);
1462  _tool_bar->insertAction (_cut_action,_copy_action);
1463  _edit_menu->insertAction (_cut_action,_copy_action);
1464  _copy_action->setEnabled (false);
1465  // select all
1466  _selectall_action = shared_actions.at (SELECTALL_ACTION);
1467  _edit_menu->insertAction (_find_action,_selectall_action);
1468  _edit_menu->insertSeparator (_find_action);
1469  // paste
1470  _paste_action = shared_actions.at (PASTE_ACTION);
1471  _tool_bar->insertAction (_find_action,_paste_action);
1472  _edit_menu->insertAction (_selectall_action,_paste_action);
1473  _edit_menu->insertSeparator (_selectall_action);
1474  _paste_action->setEnabled (false);
1475  // find files
1476  _find_files_action = shared_actions.at (FIND_FILES_ACTION);
1477  _edit_menu->insertAction (_find_action, _find_files_action);
1478 }
1479 
1480 QAction*
1481 file_editor::add_action (QMenu *menu, const QIcon &icon, const QString &text,
1482  const char *member)
1483 {
1484  QAction *a;
1485 
1486  if (menu)
1487  a = menu->addAction (icon, text, this, member);
1488  else
1489  {
1490  a = new QAction (this);
1491  connect (a, SIGNAL (triggered ()), this, member);
1492  }
1493 
1494  addAction (a); // important for shortcut context
1495  a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
1496 
1497  return a;
1498 }
1499 
1500 // function enabling/disabling the menu accelerators depending on the
1501 // focus of the editor
1502 void
1504 {
1505  QHash<QMenu*, QStringList>::const_iterator i = _hash_menu_text.constBegin();
1506 
1507  while (i != _hash_menu_text.constEnd())
1508  {
1509  i.key ()->setTitle (i.value ().at (! enable));
1510  ++i;
1511  }
1512 
1513  // when editor loses focus, enable the actions, which are always active
1514  // in the main window due to missing info on selected text and undo actions
1515  if (! enable && _copy_action && _undo_action)
1516  {
1517  _copy_action->setEnabled (true);
1518  _undo_action->setEnabled (true);
1519  }
1520 }
1521 
1522 QMenu*
1524 {
1525  QMenu *menu = p->addMenu (name);
1526 
1527  QString base_name = name; // get a copy
1528  // replace intended '&' ("&&") by a temp. string
1529  base_name.replace ("&&","___octave_amp_replacement___");
1530  // remove single '&' (shortcut)
1531  base_name.remove ("&");
1532  // restore intended '&'
1533  base_name.replace ("___octave_amp_replacement___","&&");
1534 
1535  // remember names with and without shortcut
1536  _hash_menu_text[menu] = QStringList () << name << base_name;
1537 
1538  return menu;
1539 }
1540 
1541 void
1543 {
1544  QWidget *editor_widget = new QWidget (this);
1545 
1546  // FIXME: what was the intended purpose of this unused variable?
1547  // QStyle *editor_style = QApplication::style ();
1548  _menu_bar = new QMenuBar (editor_widget);
1549 #if defined (Q_OS_MAC)
1550  _menu_bar->setNativeMenuBar (false);
1551 #endif
1552  _tool_bar = new QToolBar (editor_widget);
1553  _tool_bar->setMovable (true);
1554  _tab_widget = new tab_widget (editor_widget);
1555  _tab_widget->setTabsClosable (true);
1556 #if defined (HAVE_QTABWIDGET_SETMOVABLE)
1557  _tab_widget->setMovable (true);
1558 #endif
1559 
1560  // the mru-list and an empty array of actions
1561  QSettings *settings = resource_manager::get_settings ();
1562  _mru_files = settings->value ("editor/mru_file_list").toStringList ();
1563  _mru_files_encodings = settings->value ("editor/mru_file_encodings")
1564  .toStringList ();
1565 
1566  if (_mru_files_encodings.count () != _mru_files.count ())
1567  {
1568  // encodings don't have the same count -> do not use them!
1569  _mru_files_encodings = QStringList ();
1570  for (int i = 0; i < _mru_files.count (); i++)
1571  _mru_files_encodings << QString ();
1572  }
1573 
1574  for (int i = 0; i < MaxMRUFiles; ++i)
1575  {
1576  _mru_file_actions[i] = new QAction (this);
1577  _mru_file_actions[i]->setVisible (false);
1578  }
1579 
1580  // menu bar
1581 
1582  // file menu
1583 
1584  _fileMenu = m_add_menu (_menu_bar, tr ("&File"));
1585 
1586  // new and open menus are inserted later by the main window
1587  _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), _fileMenu);
1588  for (int i = 0; i < MaxMRUFiles; ++i)
1589  _mru_file_menu->addAction (_mru_file_actions[i]);
1590  _fileMenu->addMenu (_mru_file_menu);
1591 
1592  _fileMenu->addSeparator ();
1593 
1595  tr ("&Edit Function"), SLOT (request_context_edit (bool)));
1596 
1597  _fileMenu->addSeparator ();
1598 
1600  tr ("&Save File"), SLOT (request_save_file (bool)));
1602  tr ("Save File &As..."), SLOT (request_save_file_as (bool)));
1603 
1604  _fileMenu->addSeparator ();
1605 
1606  _close_action = add_action (_fileMenu, resource_manager::icon ("window-close",false),
1607  tr ("&Close"), SLOT (request_close_file (bool)));
1608  _close_all_action = add_action (_fileMenu, resource_manager::icon ("window-close",false),
1609  tr ("Close All"), SLOT (request_close_all_files (bool)));
1611  tr ("Close Other Files"), SLOT (request_close_other_files (bool)));
1612 
1613  _fileMenu->addSeparator ();
1614 
1616  tr ("Print..."), SLOT (request_print_file (bool)));
1617 
1618  // edit menu (undo, copy, paste and select all later via main window)
1619 
1620  _edit_menu = m_add_menu (_menu_bar, tr ("&Edit"));
1621 
1623  tr ("&Redo"), SLOT (request_redo (bool)));
1624  _redo_action->setEnabled (false);
1625 
1626  _edit_menu->addSeparator ();
1627 
1629  tr ("Cu&t"), SLOT (request_cut (bool)));
1630  _cut_action->setEnabled (false);
1631 
1632  _find_action = add_action (_edit_menu, resource_manager::icon ("edit-find-replace"),
1633  tr ("&Find and Replace..."), SLOT (request_find (bool)));
1634 
1636  tr ("Find &Next..."), SLOT (request_find_next (bool)));
1637 
1639  tr ("Find &Previous..."), SLOT (request_find_previous (bool)));
1640 
1641  _edit_menu->addSeparator ();
1642 
1643  _edit_cmd_menu = _edit_menu->addMenu (tr ("&Commands"));
1644 
1646  tr ("Delete Line"), SLOT (request_delete_line (bool)));
1648  tr ("Copy Line"), SLOT (request_copy_line (bool)));
1650  tr ("Cut Line"), SLOT (request_cut_line (bool)));
1651 
1652  _edit_cmd_menu->addSeparator ();
1653 
1655  tr ("Delete to Start of Word"), SLOT (request_delete_start_word (bool)));
1657  tr ("Delete to End of Word"), SLOT (request_delete_end_word (bool)));
1659  tr ("Delete to Start of Line"), SLOT (request_delete_start_line (bool)));
1661  tr ("Delete to End of Line"), SLOT (request_delete_end_line (bool)));
1662 
1663  _edit_cmd_menu->addSeparator ();
1664 
1666  tr ("Duplicate Selection/Line"), SLOT (request_duplicate_selection (bool)));
1668  tr ("Transpose Line"), SLOT (request_transpose_line (bool)));
1669 
1670  _edit_cmd_menu->addSeparator ();
1671 
1673  tr ("&Show Completion List"), SLOT (request_completion (bool)));
1674 
1675  _edit_fmt_menu = _edit_menu->addMenu (tr ("&Format"));
1676 
1678  tr ("&Uppercase Selection"), SLOT (request_upper_case (bool)));
1680  tr ("&Lowercase Selection"), SLOT (request_lower_case (bool)));
1681 
1682  _edit_fmt_menu->addSeparator ();
1683 
1685  tr ("&Comment"), SLOT (request_comment_selected_text (bool)));
1687  tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool)));
1688 
1689  _edit_fmt_menu->addSeparator ();
1690 
1692  tr ("&Indent"), SLOT (request_indent_selected_text (bool)));
1694  tr ("&Unindent"), SLOT (request_unindent_selected_text (bool)));
1695 
1696  _edit_fmt_menu->addSeparator ();
1697 
1699  tr ("Convert Line Endings to &Windows (CRLF)"),
1700  SLOT (request_conv_eol_windows (bool)));
1702  tr ("Convert Line Endings to &Unix (LF)"),
1703  SLOT (request_conv_eol_unix (bool)));
1705  tr ("Convert Line Endings to &Mac (CR)"),
1706  SLOT (request_conv_eol_mac (bool)));
1707 
1708  _edit_nav_menu = _edit_menu->addMenu (tr ("Navi&gation"));
1709 
1711  tr ("Go &to Line..."), SLOT (request_goto_line (bool)));
1712 
1713  _edit_cmd_menu->addSeparator ();
1714 
1716  tr ("Move to Matching Brace"), SLOT (request_move_match_brace (bool)));
1718  tr ("Select to Matching Brace"), SLOT (request_sel_match_brace (bool)));
1719 
1720  _edit_nav_menu->addSeparator ();
1721 
1723  tr ("&Next Bookmark"), SLOT (request_next_bookmark (bool)));
1725  tr ("Pre&vious Bookmark"), SLOT (request_previous_bookmark (bool)));
1727  tr ("Toggle &Bookmark"), SLOT (request_toggle_bookmark (bool)));
1729  tr ("&Remove All Bookmarks"), SLOT (request_remove_bookmark (bool)));
1730 
1731  _edit_menu->addSeparator ();
1732 
1734  tr ("&Preferences..."), SLOT (request_preferences (bool)));
1736  tr ("&Styles Preferences..."), SLOT (request_styles_preferences (bool)));
1737 
1738  // view menu
1739 
1740  QMenu *view_menu = m_add_menu (_menu_bar, tr ("&View"));
1741 
1742  _view_editor_menu = view_menu->addMenu (tr ("&Editor"));
1743 
1745  tr ("Show &Line Numbers"), SLOT (show_line_numbers (bool)));
1746  _show_linenum_action->setCheckable (true);
1747 
1749  tr ("Show &Whitespace Characters"), SLOT (show_white_space (bool)));
1750  _show_whitespace_action->setCheckable (true);
1751 
1753  tr ("Show Line &Endings"), SLOT (show_eol_chars (bool)));
1754  _show_eol_action->setCheckable (true);
1755 
1757  tr ("Show &Indentation Guides"), SLOT (show_indent_guides (bool)));
1758  _show_indguide_action->setCheckable (true);
1759 
1761  tr ("Show Long Line &Marker"), SLOT (show_long_line (bool)));
1762  _show_longline_action->setCheckable (true);
1763 
1764  _view_editor_menu->addSeparator ();
1765 
1767  tr ("Show &Toolbar"), SLOT (show_toolbar (bool)));
1768  _show_toolbar_action->setCheckable (true);
1769 
1771  tr ("Show &Statusbar"), SLOT (show_statusbar (bool)));
1772  _show_statusbar_action->setCheckable (true);
1773 
1775  tr ("Show &Horizontal Scrollbar"), SLOT (show_hscrollbar (bool)));
1776  _show_hscrollbar_action->setCheckable (true);
1777 
1778  view_menu->addSeparator ();
1779 
1780  _zoom_in_action = add_action (view_menu, resource_manager::icon ("zoom-in"),
1781  tr ("Zoom &In"), SLOT (zoom_in (bool)));
1782  _zoom_out_action = add_action (view_menu, resource_manager::icon ("zoom-out"),
1783  tr ("Zoom &Out"), SLOT (zoom_out (bool)));
1784  _zoom_normal_action = add_action (view_menu, QIcon (),
1785  tr ("&Normal Size"), SLOT (zoom_normal (bool)));
1786 
1787  _menu_bar->addMenu (view_menu);
1788 
1789  // debug menu
1790 
1791  _debug_menu = m_add_menu (_menu_bar, tr ("&Debug"));
1792 
1794  resource_manager::icon ("bp-toggle"), tr ("Toggle &Breakpoint"),
1795  SLOT (request_toggle_breakpoint (bool)));
1797  resource_manager::icon ("bp-next"), tr ("&Next Breakpoint"),
1798  SLOT (request_next_breakpoint (bool)));
1800  resource_manager::icon ("bp-prev"), tr ("Pre&vious Breakpoint"),
1801  SLOT (request_previous_breakpoint (bool)));
1803  resource_manager::icon ("bp-rm-all"), tr ("&Remove All Breakpoints"),
1804  SLOT (request_remove_breakpoint (bool)));
1805 
1806  _debug_menu->addSeparator ();
1807 
1808  // The other debug actions will be added by the main window.
1809 
1810  // run menu
1811 
1812  QMenu *_run_menu = m_add_menu (_menu_bar, tr ("&Run"));
1813 
1814  _run_action = add_action (_run_menu, resource_manager::icon ("system-run"),
1815  tr ("Save File and Run"), SLOT (request_run_file (bool)));
1816  _run_selection_action = add_action (_run_menu, QIcon (),
1817  tr ("Run &Selection"), SLOT (request_context_run (bool)));
1818  _run_selection_action->setEnabled (false);
1819 
1820  // help menu
1821 
1822  QMenu *_help_menu = m_add_menu (_menu_bar, tr ("&Help"));
1823 
1824  _context_help_action = add_action (_help_menu, QIcon (),
1825  tr ("&Help on Keyword"), SLOT (request_context_help (bool)));
1826  _context_doc_action = add_action (_help_menu, QIcon (),
1827  tr ("&Documentation on Keyword"), SLOT (request_context_doc (bool)));
1828 
1829  // tab navigation (no menu, only actions)
1830 
1831  _switch_left_tab_action = add_action (0, QIcon (), "",
1832  SLOT (switch_left_tab ()));
1833  _switch_right_tab_action = add_action (0, QIcon (), "",
1834  SLOT (switch_right_tab ()));
1835  _move_tab_left_action = add_action (0, QIcon (), "",
1836  SLOT (move_tab_left ()));
1837  _move_tab_right_action = add_action (0, QIcon (), "",
1838  SLOT (move_tab_right ()));
1839 
1840  // toolbar
1841 
1842  // popdown menu with mru files
1843  QToolButton *popdown_button = new QToolButton ();
1844  popdown_button->setToolTip (tr ("Recent Files"));
1845  popdown_button->setMenu (_mru_file_menu);
1846  popdown_button->setPopupMode (QToolButton::InstantPopup);
1847  popdown_button->setToolButtonStyle (Qt::ToolButtonTextOnly);
1848 
1849  // new and open actions are inserted later from main window
1850  _popdown_mru_action = _tool_bar->addWidget (popdown_button);
1851  _tool_bar->addAction (_save_action);
1852  _tool_bar->addAction (_save_as_action);
1853  _tool_bar->addAction (_print_action);
1854  _tool_bar->addSeparator ();
1855  // _undo_action: later via main window
1856  _tool_bar->addAction (_redo_action);
1857  // _copy_action: later via the main window
1858  _tool_bar->addAction (_cut_action);
1859  // _paste_action: later via the main window
1860  _tool_bar->addAction (_find_action);
1861  //_tool_bar->addAction (_find_next_action);
1862  //_tool_bar->addAction (_find_previous_action);
1863  _tool_bar->addSeparator ();
1864  _tool_bar->addAction (_run_action);
1865  _tool_bar->addSeparator ();
1866  _tool_bar->addAction (_toggle_breakpoint_action);
1868  _tool_bar->addAction (_next_breakpoint_action);
1870 
1871  // layout
1872  QVBoxLayout *vbox_layout = new QVBoxLayout ();
1873  vbox_layout->addWidget (_menu_bar);
1874  vbox_layout->addWidget (_tool_bar);
1875  vbox_layout->addWidget (_tab_widget);
1876  vbox_layout->setMargin (0);
1877  editor_widget->setLayout (vbox_layout);
1878  setWidget (editor_widget);
1879 
1880  // signals
1881  connect (this, SIGNAL (execute_command_in_terminal_signal (const QString&)),
1882  main_win (), SLOT (execute_command_in_terminal (const QString&)));
1883 
1884  connect (this, SIGNAL (request_settings_dialog (const QString&)),
1885  main_win (),
1886  SLOT (process_settings_dialog_request (const QString&)));
1887 
1888  connect (main_win (), SIGNAL (new_file_signal (const QString&)),
1889  this, SLOT (request_new_file (const QString&)));
1890 
1891  connect (main_win (), SIGNAL (open_file_signal (const QString&)),
1892  this, SLOT (request_open_file (const QString&)));
1893 
1894  connect (main_win (), SIGNAL (edit_mfile_request (const QString&,
1895  const QString&, const QString&, int)),
1896  this, SLOT (handle_edit_mfile_request (const QString&,
1897  const QString&, const QString&, int)));
1898 
1899  connect (_mru_file_menu, SIGNAL (triggered (QAction *)),
1900  this, SLOT (request_mru_open_file (QAction *)));
1901 
1902  mru_menu_update ();
1903 
1904  connect (_tab_widget, SIGNAL (tabCloseRequested (int)),
1905  this, SLOT (handle_tab_close_request (int)));
1906 
1907  connect (_tab_widget, SIGNAL (currentChanged (int)),
1908  this, SLOT (active_tab_changed (int)));
1909 
1910  resize (500, 400);
1911  setWindowIcon (QIcon (":/actions/icons/logo.png"));
1912  set_title (tr ("Editor"));
1913 
1914  restore_session (settings);
1915 
1916  check_actions ();
1917 }
1918 
1919 void
1920 file_editor::restore_session (QSettings *settings)
1921 {
1922  //restore previous session
1923  if (! settings->value ("editor/restoreSession", true).toBool ())
1924  return;
1925 
1926  // get the data from the settings file
1927  QStringList sessionFileNames = settings->value ("editor/savedSessionTabs",
1928  QStringList ()).toStringList ();
1929  QStringList session_encodings = settings->value ("editor/saved_session_encodings",
1930  QStringList ()).toStringList ();
1931  QStringList session_index = settings->value ("editor/saved_session_tab_index",
1932  QStringList ()).toStringList ();
1933 
1934  // fill a list of the struct and sort it (depending on index)
1935  QList<session_data> s_data;
1936 
1937  bool do_encoding = (session_encodings.count () == sessionFileNames.count ());
1938  bool do_index = (session_index.count () == sessionFileNames.count ());
1939 
1940  for (int n = 0; n < sessionFileNames.count (); ++n)
1941  {
1942  QFileInfo file = QFileInfo (sessionFileNames.at (n));
1943  if (! file.exists ())
1944  continue;
1945 
1946  session_data item = { QString (), sessionFileNames.at (n), QString ()};
1947  if (do_index)
1948  item.index = session_index.at (n);
1949  if (do_encoding)
1950  item.encoding = session_encodings.at (n);
1951 
1952  s_data << item;
1953  }
1954 
1955  qSort (s_data);
1956 
1957  // finally open the file with the desired encoding in the desired order
1958  for (int n = 0; n < s_data.count (); ++n)
1959  request_open_file (s_data.at (n).file_name, s_data.at (n).encoding);
1960 }
1961 
1962 void
1964 {
1965  _tab_widget->addTab (f, fn);
1966 
1967  // signals from the qscintilla edit area
1968  connect (f->qsci_edit_area (), SIGNAL (status_update (bool, bool)),
1969  this, SLOT (edit_status_update (bool, bool)));
1970 
1971  connect (f->qsci_edit_area (), SIGNAL (show_doc_signal (const QString&)),
1972  main_win (), SLOT (handle_show_doc (const QString&)));
1973 
1974  connect (f->qsci_edit_area (), SIGNAL (create_context_menu_signal (QMenu *)),
1975  this, SLOT (create_context_menu (QMenu *)));
1976 
1977  connect (f->qsci_edit_area (),
1978  SIGNAL (execute_command_in_terminal_signal (const QString&)),
1979  main_win (), SLOT (execute_command_in_terminal (const QString&)));
1980 
1981  // Signals from the file editor_tab
1982  connect (f, SIGNAL (file_name_changed (const QString&, const QString&)),
1983  this, SLOT (handle_file_name_changed (const QString&,
1984  const QString&)));
1985 
1986  connect (f, SIGNAL (editor_state_changed (bool, bool)),
1987  this, SLOT (handle_editor_state_changed (bool, bool)));
1988 
1989  connect (f, SIGNAL (tab_remove_request ()),
1990  this, SLOT (handle_tab_remove_request ()));
1991 
1992  connect (f, SIGNAL (add_filename_to_list (const QString&,
1993  const QString&, QWidget*)),
1994  this, SLOT (handle_add_filename_to_list (const QString&,
1995  const QString&,
1996  QWidget*)));
1997 
1998  connect (f, SIGNAL (editor_check_conflict_save (const QString&, bool)),
1999  this, SLOT (check_conflict_save (const QString&, bool)));
2000 
2001  connect (f, SIGNAL (mru_add_file (const QString&, const QString&)),
2002  this, SLOT (handle_mru_add_file (const QString&, const QString&)));
2003 
2004  connect (f, SIGNAL (run_file_signal (const QFileInfo&)),
2005  main_win (), SLOT (run_file_in_terminal (const QFileInfo&)));
2006 
2007  connect (f, SIGNAL (request_open_file (const QString&)),
2008  this, SLOT (request_open_file (const QString&)));
2009 
2010  connect (f, SIGNAL (edit_mfile_request (const QString&, const QString&,
2011  const QString&, int)),
2012  this, SLOT (handle_edit_mfile_request (const QString&,
2013  const QString&,
2014  const QString&, int)));
2015 
2016  // Signals from the file_editor non-trivial operations
2017  connect (this, SIGNAL (fetab_settings_changed (const QSettings *)),
2018  f, SLOT (notice_settings (const QSettings *)));
2019 
2020  connect (this, SIGNAL (fetab_change_request (const QWidget*)),
2021  f, SLOT (change_editor_state (const QWidget*)));
2022 
2023  connect (this, SIGNAL (fetab_file_name_query (const QWidget*)),
2024  f, SLOT (file_name_query (const QWidget*)));
2025 
2026  connect (this, SIGNAL (fetab_save_file (const QWidget*, const QString&,
2027  bool)),
2028  f, SLOT (save_file (const QWidget*, const QString&, bool)));
2029 
2030  connect (this, SIGNAL (fetab_check_modified_file (void)),
2031  f, SLOT (check_modified_file (void)));
2032 
2033  connect (f, SIGNAL (execute_command_in_terminal_signal (const QString&)),
2034  main_win (), SLOT (execute_command_in_terminal (const QString&)));
2035 
2036  // Signals from the file_editor trivial operations
2037  connect (this, SIGNAL (fetab_recover_from_exit (void)),
2038  f, SLOT (recover_from_exit (void)));
2039 
2040  connect (this, SIGNAL (fetab_set_directory (const QString&)),
2041  f, SLOT (set_current_directory (const QString&)));
2042 
2043  connect (this, SIGNAL (fetab_zoom_in (const QWidget*)),
2044  f, SLOT (zoom_in (const QWidget*)));
2045  connect (this, SIGNAL (fetab_zoom_out (const QWidget*)),
2046  f, SLOT (zoom_out (const QWidget*)));
2047  connect (this, SIGNAL (fetab_zoom_normal (const QWidget*)),
2048  f, SLOT (zoom_normal (const QWidget*)));
2049 
2050  connect (this, SIGNAL (fetab_context_help (const QWidget*, bool)),
2051  f, SLOT (context_help (const QWidget*, bool)));
2052 
2053  connect (this, SIGNAL (fetab_context_edit (const QWidget*)),
2054  f, SLOT (context_edit (const QWidget*)));
2055 
2056  connect (this, SIGNAL (fetab_save_file (const QWidget*)),
2057  f, SLOT (save_file (const QWidget*)));
2058 
2059  connect (this, SIGNAL (fetab_save_file_as (const QWidget*)),
2060  f, SLOT (save_file_as (const QWidget*)));
2061 
2062  connect (this, SIGNAL (fetab_print_file (const QWidget*)),
2063  f, SLOT (print_file (const QWidget*)));
2064 
2065  connect (this, SIGNAL (fetab_run_file (const QWidget*)),
2066  f, SLOT (run_file (const QWidget*)));
2067 
2068  connect (this, SIGNAL (fetab_context_run (const QWidget*)),
2069  f, SLOT (context_run (const QWidget*)));
2070 
2071  connect (this, SIGNAL (fetab_toggle_bookmark (const QWidget*)),
2072  f, SLOT (toggle_bookmark (const QWidget*)));
2073 
2074  connect (this, SIGNAL (fetab_next_bookmark (const QWidget*)),
2075  f, SLOT (next_bookmark (const QWidget*)));
2076 
2077  connect (this, SIGNAL (fetab_previous_bookmark (const QWidget*)),
2078  f, SLOT (previous_bookmark (const QWidget*)));
2079 
2080  connect (this, SIGNAL (fetab_remove_bookmark (const QWidget*)),
2081  f, SLOT (remove_bookmark (const QWidget*)));
2082 
2083  connect (this, SIGNAL (fetab_toggle_breakpoint (const QWidget*)),
2084  f, SLOT (toggle_breakpoint (const QWidget*)));
2085 
2086  connect (this, SIGNAL (fetab_next_breakpoint (const QWidget*)),
2087  f, SLOT (next_breakpoint (const QWidget*)));
2088 
2089  connect (this, SIGNAL (fetab_previous_breakpoint (const QWidget*)),
2090  f, SLOT (previous_breakpoint (const QWidget*)));
2091 
2092  connect (this, SIGNAL (fetab_remove_all_breakpoints (const QWidget*)),
2093  f, SLOT (remove_all_breakpoints (const QWidget*)));
2094 
2095  connect (this, SIGNAL (fetab_scintilla_command (const QWidget *,
2096  unsigned int)),
2097  f, SLOT (scintilla_command (const QWidget *, unsigned int)));
2098 
2099  connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*)),
2100  f, SLOT (comment_selected_text (const QWidget*)));
2101 
2102  connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*)),
2103  f, SLOT (uncomment_selected_text (const QWidget*)));
2104 
2105  connect (this, SIGNAL (fetab_indent_selected_text (const QWidget*)),
2106  f, SLOT (indent_selected_text (const QWidget*)));
2107 
2108  connect (this, SIGNAL (fetab_unindent_selected_text (const QWidget*)),
2109  f, SLOT (unindent_selected_text (const QWidget*)));
2110 
2111  connect (this,
2112  SIGNAL (fetab_convert_eol (const QWidget*, QsciScintilla::EolMode)),
2113  f, SLOT (convert_eol (const QWidget*, QsciScintilla::EolMode)));
2114 
2115  connect (this, SIGNAL (fetab_find (const QWidget*, QList<QAction *>)),
2116  f, SLOT (find (const QWidget*, QList<QAction *>)));
2117 
2118  connect (this, SIGNAL (fetab_find_next (const QWidget*)),
2119  f, SLOT (find_next (const QWidget*)));
2120 
2121  connect (this, SIGNAL (fetab_find_previous (const QWidget*)),
2122  f, SLOT (find_previous (const QWidget*)));
2123 
2124  connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)),
2125  f, SLOT (goto_line (const QWidget*, int)));
2126 
2127  connect (this, SIGNAL (fetab_move_match_brace (const QWidget*, bool)),
2128  f, SLOT (move_match_brace (const QWidget*, bool)));
2129 
2130  connect (this, SIGNAL (fetab_completion (const QWidget*)),
2131  f, SLOT (show_auto_completion (const QWidget*)));
2132 
2133  connect (this, SIGNAL (fetab_set_focus (const QWidget*)),
2134  f, SLOT (set_focus (const QWidget*)));
2135 
2136  connect (this, SIGNAL (fetab_insert_debugger_pointer (const QWidget*, int)),
2137  f, SLOT (insert_debugger_pointer (const QWidget*, int)));
2138 
2139  connect (this, SIGNAL (fetab_delete_debugger_pointer (const QWidget*, int)),
2140  f, SLOT (delete_debugger_pointer (const QWidget*, int)));
2141 
2142  connect (this, SIGNAL (fetab_do_breakpoint_marker (bool, const QWidget*,
2143  int, const QString&)),
2144  f, SLOT (do_breakpoint_marker (bool, const QWidget*, int,
2145  const QString&)));
2146 
2147  _tab_widget->setCurrentWidget (f);
2148 
2149  check_actions ();
2150 }
2151 
2152 bool
2154 {
2155  QWidget * foc_w = focusWidget ();
2156  if (foc_w && foc_w->inherits ("octave_qscintilla"))
2157  return true;
2158  return false;
2159 }
2160 
2161 void
2163 {
2164  // Shortcuts also available in the main window, as well as the realted
2165  // ahotcuts, are defined in main_window and added to the editor
2166 
2167  // File menu
2168  shortcut_manager::set_shortcut (_edit_function_action, "editor_file:edit_function");
2169  shortcut_manager::set_shortcut (_save_action, "editor_file:save");
2170  shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as");
2171  shortcut_manager::set_shortcut (_close_action, "editor_file:close");
2172  shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all");
2173  shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other");
2174  shortcut_manager::set_shortcut (_print_action, "editor_file:print");
2175 
2176  // Edit menu
2177  shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo");
2178  shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut");
2179  shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace");
2180  shortcut_manager::set_shortcut (_find_next_action, "editor_edit:find_next");
2181  shortcut_manager::set_shortcut (_find_previous_action, "editor_edit:find_previous");
2182 
2183  shortcut_manager::set_shortcut (_delete_start_word_action, "editor_edit:delete_start_word");
2184  shortcut_manager::set_shortcut (_delete_end_word_action, "editor_edit:delete_end_word");
2185  shortcut_manager::set_shortcut (_delete_start_line_action, "editor_edit:delete_start_line");
2186  shortcut_manager::set_shortcut (_delete_end_line_action, "editor_edit:delete_end_line");
2187  shortcut_manager::set_shortcut (_delete_line_action, "editor_edit:delete_line");
2188  shortcut_manager::set_shortcut (_copy_line_action, "editor_edit:copy_line");
2189  shortcut_manager::set_shortcut (_cut_line_action, "editor_edit:cut_line");
2190  shortcut_manager::set_shortcut (_duplicate_selection_action, "editor_edit:duplicate_selection");
2191  shortcut_manager::set_shortcut (_transpose_line_action, "editor_edit:transpose_line");
2192  shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection");
2193  shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection");
2194 
2195  shortcut_manager::set_shortcut (_upper_case_action, "editor_edit:upper_case");
2196  shortcut_manager::set_shortcut (_lower_case_action, "editor_edit:lower_case");
2197  shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection");
2198  shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection");
2199  shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list");
2200  shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line");
2201  shortcut_manager::set_shortcut (_move_to_matching_brace, "editor_edit:move_to_brace");
2202  shortcut_manager::set_shortcut (_sel_to_matching_brace, "editor_edit:select_to_brace");
2203  shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark");
2204  shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark");
2205  shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark");
2206  shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark");
2207  shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences");
2208  shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences");
2209 
2210  shortcut_manager::set_shortcut (_conv_eol_windows_action, "editor_edit:conv_eol_winows");
2211  shortcut_manager::set_shortcut (_conv_eol_unix_action, "editor_edit:conv_eol_unix");
2212  shortcut_manager::set_shortcut (_conv_eol_mac_action, "editor_edit:conv_eol_mac");
2213 
2214  // View menu
2215  shortcut_manager::set_shortcut (_show_linenum_action, "editor_view:show_line_numbers");
2216  shortcut_manager::set_shortcut (_show_whitespace_action, "editor_view:show_white_spaces");
2217  shortcut_manager::set_shortcut (_show_eol_action, "editor_view:show_eol_chars");
2218  shortcut_manager::set_shortcut (_show_indguide_action, "editor_view:show_ind_guides");
2219  shortcut_manager::set_shortcut (_show_longline_action, "editor_view:show_long_line");
2220  shortcut_manager::set_shortcut (_show_toolbar_action, "editor_view:show_toolbar");
2221  shortcut_manager::set_shortcut (_show_statusbar_action, "editor_view:show_statusbar");
2222  shortcut_manager::set_shortcut (_show_hscrollbar_action, "editor_view:show_hscrollbar");
2223  shortcut_manager::set_shortcut (_zoom_in_action, "editor_view:zoom_in");
2224  shortcut_manager::set_shortcut (_zoom_out_action, "editor_view:zoom_out");
2225  shortcut_manager::set_shortcut (_zoom_normal_action, "editor_view:zoom_normal");
2226 
2227  // Debug menu
2228  shortcut_manager::set_shortcut (_toggle_breakpoint_action, "editor_debug:toggle_breakpoint");
2229  shortcut_manager::set_shortcut (_next_breakpoint_action, "editor_debug:next_breakpoint");
2230  shortcut_manager::set_shortcut (_previous_breakpoint_action, "editor_debug:previous_breakpoint");
2231  shortcut_manager::set_shortcut (_remove_all_breakpoints_action, "editor_debug:remove_breakpoints");
2232 
2233  // Run menu
2234  shortcut_manager::set_shortcut (_run_action, "editor_run:run_file");
2235  shortcut_manager::set_shortcut (_run_selection_action, "editor_run:run_selection");
2236 
2237  // Help menu
2238  shortcut_manager::set_shortcut (_context_help_action, "editor_help:help_keyword");
2239  shortcut_manager::set_shortcut (_context_doc_action, "editor_help:doc_keyword");
2240 
2241  // Tab navigation without menu entries
2242  shortcut_manager::set_shortcut (_switch_left_tab_action, "editor_tabs:switch_left_tab");
2243  shortcut_manager::set_shortcut (_switch_right_tab_action, "editor_tabs:switch_right_tab");
2244  shortcut_manager::set_shortcut (_move_tab_left_action, "editor_tabs:move_tab_left");
2245  shortcut_manager::set_shortcut (_move_tab_right_action, "editor_tabs:move_tab_right");
2246 
2247 }
2248 
2249 void
2251 {
2252  bool have_tabs = _tab_widget->count () > 0;
2253 
2254  _edit_cmd_menu->setEnabled (have_tabs);
2255  _edit_fmt_menu->setEnabled (have_tabs);
2256  _edit_nav_menu->setEnabled (have_tabs);
2257 
2258  _comment_selection_action->setEnabled (have_tabs);
2259  _uncomment_selection_action->setEnabled (have_tabs);
2260  _indent_selection_action->setEnabled (have_tabs);
2261  _unindent_selection_action->setEnabled (have_tabs);
2262 
2263  _context_help_action->setEnabled (have_tabs);
2264  _context_doc_action->setEnabled (have_tabs);
2265 
2266  _view_editor_menu->setEnabled (have_tabs);
2267  _zoom_in_action->setEnabled (have_tabs);
2268  _zoom_out_action->setEnabled (have_tabs);
2269  _zoom_normal_action->setEnabled (have_tabs);
2270 
2271  _find_action->setEnabled (have_tabs);
2272  _find_next_action->setEnabled (have_tabs);
2273  _find_previous_action->setEnabled (have_tabs);
2274  _print_action->setEnabled (have_tabs);
2275  _run_action->setEnabled (have_tabs);
2276 
2277  _edit_function_action->setEnabled (have_tabs);
2278  _save_action->setEnabled (have_tabs);
2279  _save_as_action->setEnabled (have_tabs);
2280  _close_action->setEnabled (have_tabs);
2281  _close_all_action->setEnabled (have_tabs);
2282  _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1);
2283 }
2284 
2285 // empty_script determines whether we have to create an empty script
2286 // 1. At startup, when the editor has to be (really) visible
2287 // (Here we can not use the visibility changed signal)
2288 // 2. When the editor becomes visible when octave is running
2289 void
2290 file_editor::empty_script (bool startup, bool visible)
2291 {
2292  QSettings *settings = resource_manager::get_settings ();
2293  if (settings->value ("useCustomFileEditor",false).toBool ())
2294  return; // do not open an empty script in the external editor
2295 
2296  bool real_visible;
2297 
2298  if (startup)
2299  real_visible = isVisible ();
2300  else
2301  real_visible = visible;
2302 
2303  if (! real_visible || _tab_widget->count () > 0)
2304  return;
2305 
2306  if (startup && ! isFloating ())
2307  {
2308  // check is editor is really visible or hidden between tabbed widgets
2309  QList<QTabBar *> tab_list = main_win ()->findChildren<QTabBar *>();
2310 
2311  bool in_tab = false;
2312  int i = 0;
2313  while ((i < tab_list.count ()) && (! in_tab))
2314  {
2315  QTabBar *tab = tab_list.at (i);
2316  i++;
2317 
2318  int j = 0;
2319  while ((j < tab->count ()) && (! in_tab))
2320  {
2321  // check all tabs for the editor
2322  if (tab->tabText (j) == windowTitle ())
2323  {
2324  // editor is in this tab widget
2325  in_tab = true;
2326  int top = tab->currentIndex ();
2327  if (top > -1 && tab->tabText (top) == windowTitle ())
2328  real_visible = true; // and is the current tab
2329  else
2330  return; // not current tab -> not visible
2331  }
2332  j++;
2333  }
2334  }
2335  }
2336 
2337  request_new_file ("");
2338 }
2339 
2340 // This slot is a reimplementation of the virtual slot in octave_dock_widget.
2341 // We need this for creating an empty script when the editor has no open files
2342 // and is made visible
2343 void
2345 {
2346  empty_script (false, visible);
2347 
2348  if (visible && ! isFloating ())
2349  focus ();
2350 }
2351 
2352 void
2353 file_editor::dragEnterEvent (QDragEnterEvent *e)
2354 {
2355  if (e->mimeData ()->hasUrls ())
2356  {
2357  e->acceptProposedAction();
2358  }
2359 }
2360 
2361 void
2363 {
2364  if (e->mimeData ()->hasUrls ())
2365  {
2366  foreach (QUrl url, e->mimeData ()->urls ())
2367  {
2368  request_open_file (url.toLocalFile ());
2369  }
2370  }
2371 }
2372 
2373 // slots for tab navigation
2374 void
2376 {
2377  switch_tab (-1);
2378 }
2379 void
2381 {
2382  switch_tab (1);
2383 }
2384 void
2386 {
2387 #if defined (HAVE_QTABWIDGET_SETMOVABLE)
2388  switch_tab (-1, true);
2389 #endif
2390 }
2391 void
2393 {
2394 #if defined (HAVE_QTABWIDGET_SETMOVABLE)
2395  switch_tab (1, true);
2396 #endif
2397 }
2398 void
2399 file_editor::switch_tab (int direction, bool movetab)
2400 {
2401  int tabs = _tab_widget->count ();
2402 
2403  if (tabs < 2)
2404  return;
2405 
2406  int old_pos = _tab_widget->currentIndex ();
2407  int new_pos = _tab_widget->currentIndex () + direction;
2408 
2409  if (new_pos < 0 || new_pos >= tabs)
2410  new_pos = new_pos - direction*tabs;
2411 
2412  if (movetab)
2413  {
2414 #if defined (HAVE_QTABWIDGET_SETMOVABLE)
2415  _tab_widget->tabBar ()->moveTab (old_pos, new_pos);
2416  _tab_widget->setCurrentIndex (old_pos);
2417  _tab_widget->setCurrentIndex (new_pos);
2418  focus ();
2419 #endif
2420  }
2421  else
2422  _tab_widget->setCurrentIndex (new_pos);
2423 }
2424 
2425 #endif
QAction * _delete_end_line_action
Definition: file-editor.h:372
std::map< QString, tab_info >::const_iterator editor_tab_map_const_iterator
Definition: file-editor.h:66
void fetab_save_file(const QWidget *ID, const QString &fileName, bool remove_on_success)
void fetab_set_focus(const QWidget *ID)
void request_save_file(bool)
Definition: file-editor.cc:864
void dragEnterEvent(QDragEnterEvent *event)
QList< QAction * > _fetab_actions
Definition: file-editor.h:428
QMenu * _edit_nav_menu
Definition: file-editor.h:424
QAction * _redo_action
Definition: file-editor.h:405
void request_close_file(bool)
const Cell & contents(const_iterator p) const
Definition: oct-map.h:313
QMenu * m_add_menu(QMenuBar *p, QString text)
tab_widget * _tab_widget
Definition: file-editor.h:430
void request_delete_start_word(bool)
Definition: file-editor.cc:944
void update_window_title(bool modified)
QMenuBar * _menu_bar
Definition: file-editor.h:332
QAction * _print_action
Definition: file-editor.h:393
For example cd octave end example noindent changes the current working directory to file
Definition: dirfns.cc:120
void request_save_file_as(bool)
Definition: file-editor.cc:870
QAction * _toggle_bookmark_action
Definition: file-editor.h:390
~file_editor(void)
Definition: file-editor.cc:78
bool same_file(const std::string &f, const std::string &g)
Definition: utils.cc:130
void request_delete_start_line(bool)
Definition: file-editor.cc:956
void fetab_context_run(const QWidget *ID)
void set_shortcuts()
QAction * _show_eol_action
Definition: file-editor.h:359
fname
Definition: load-save.cc:754
QAction * _delete_start_word_action
Definition: file-editor.h:369
QAction * _remove_all_breakpoints_action
Definition: file-editor.h:419
void fetab_run_file(const QWidget *ID)
QAction * _goto_line_action
Definition: file-editor.h:383
void request_uncomment_selected_text(bool)
QAction * _find_next_action
Definition: file-editor.h:380
QAction * _next_bookmark_action
Definition: file-editor.h:388
QAction * _sel_to_matching_brace
Definition: file-editor.h:387
void switch_left_tab()
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).is_integer_type())
QAction * _delete_line_action
Definition: file-editor.h:373
void request_delete_line(bool)
Definition: file-editor.cc:968
void show_white_space(bool)
void fetab_context_edit(const QWidget *ID)
void do_undo()
Definition: file-editor.cc:801
void restore_create_file_setting()
Definition: file-editor.cc:251
bool is_editor_console_tabbed()
Definition: file-editor.cc:387
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
void request_new_file(const QString &commands)
Definition: file-editor.cc:198
QMenu * debug_menu(void)
Definition: file-editor.cc:172
void handle_edit_file_request(const QString &file)
Definition: file-editor.cc:795
void handle_enter_debug_mode(void)
Definition: file-editor.cc:184
void fetab_change_request(const QWidget *ID)
void show_hscrollbar(bool)
void request_duplicate_selection(bool)
Definition: file-editor.cc:986
void zoom_out(bool)
QAction * _move_tab_right_action
Definition: file-editor.h:414
void fetab_completion(const QWidget *)
void request_indent_selected_text(bool)
void pasteClipboard()
Definition: file-editor.cc:831
void request_unindent_selected_text(bool)
void fetab_unindent_selected_text(const QWidget *ID)
octave_value arg(void) const
Definition: ov.h:1350
QAction * _copy_action
Definition: file-editor.h:350
void update_octave_directory(const QString &dir)
Definition: file-editor.cc:165
QAction * _conv_eol_windows_action
Definition: file-editor.h:346
bool editor_tab_has_focus()
QAction * _conv_eol_unix_action
Definition: file-editor.h:347
QAction * _delete_start_line_action
Definition: file-editor.h:371
QAction * _context_doc_action
Definition: file-editor.h:355
QAction * _delete_end_word_action
Definition: file-editor.h:370
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a number
Definition: input.cc:871
void show_toolbar(bool)
QAction * _switch_right_tab_action
Definition: file-editor.h:412
void set_title(const QString &)
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member)
QAction * _move_tab_left_action
Definition: file-editor.h:413
QAction * _undo_action
Definition: file-editor.h:406
void request_new_function(bool triggered=true)
Definition: file-editor.cc:225
void handle_mru_add_file(const QString &file_name, const QString &encoding)
QString fromStdString(const std::string &s)
QToolBar * _tool_bar
Definition: file-editor.h:333
void request_delete_end_word(bool)
Definition: file-editor.cc:950
void fetab_do_breakpoint_marker(bool insert, const QWidget *ID, int line=-1, const QString &="")
void request_preferences(bool)
void fetab_delete_debugger_pointer(const QWidget *ID, int line=-1)
void fetab_scintilla_command(const QWidget *ID, unsigned int sci_msg)
void request_find(bool)
std::string filename
Definition: urlwrite.cc:340
QAction * _show_toolbar_action
Definition: file-editor.h:362
static void combo_encoding(QComboBox *combo, QString current=QString())
void fetab_toggle_bookmark(const QWidget *ID)
QAction * _previous_bookmark_action
Definition: file-editor.h:389
void request_comment_selected_text(bool)
Definition: file-editor.cc:998
void request_conv_eol_unix(bool)
QAction * _save_action
Definition: file-editor.h:399
QTabBar * tabBar() const
Definition: file-editor.h:50
void request_find_previous(bool)
void request_completion(bool)
void fetab_zoom_in(const QWidget *ID)
void request_next_breakpoint(bool)
Definition: file-editor.cc:925
void focus(void)
Definition: file-editor.cc:154
QAction * _conv_eol_mac_action
Definition: file-editor.h:348
void move_tab_left()
QMenu * _fileMenu
Definition: file-editor.h:425
QAction * _show_whitespace_action
Definition: file-editor.h:358
i e
Definition: data.cc:2724
bool call_custom_editor(const QString &file_name=QString(), int line=-1)
Definition: file-editor.cc:346
void show_indent_guides(bool)
QAction * _selectall_action
Definition: file-editor.h:353
octave_value arg
Definition: pr-output.cc:3440
QAction * _close_all_action
Definition: file-editor.h:402
void fetab_move_match_brace(const QWidget *ID, bool select)
QAction * _indent_selection_action
Definition: file-editor.h:344
void fetab_uncomment_selected_text(const QWidget *ID)
void check_actions(void)
void request_upper_case(bool)
QAction * _paste_action
Definition: file-editor.h:352
QAction * _close_others_action
Definition: file-editor.h:403
void empty_script(bool startup, bool visible)
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
Definition: cellfun.cc:398
QAction * _show_linenum_action
Definition: file-editor.h:357
QAction * _cut_action
Definition: file-editor.h:351
QAction * _move_to_matching_brace
Definition: file-editor.h:386
void fetab_context_help(const QWidget *ID, bool)
QMenu * _edit_cmd_menu
Definition: file-editor.h:422
void fetab_remove_bookmark(const QWidget *ID)
void handle_insert_debugger_pointer_request(const QString &file, int line)
Definition: file-editor.cc:754
void message(const char *name, const char *fmt,...)
Definition: error.cc:430
QAction * _show_longline_action
Definition: file-editor.h:361
QAction * _edit_function_action
Definition: file-editor.h:397
void fetab_save_file_as(const QWidget *ID)
void execute_command_in_terminal_signal(const QString &)
void request_remove_breakpoint(bool)
Definition: file-editor.cc:937
void request_mru_open_file(QAction *action)
Definition: file-editor.cc:593
OCTAVE_EXPORT octave_value_list any number nd example oindent prints the prompt xample Pick a any number!nd example oindent and waits for the user to enter a value The string entered by the user is evaluated as an so it may be a literal a variable name
Definition: input.cc:871
QString _file_encoding
Definition: file-editor.h:434
QAction * _run_action
Definition: file-editor.h:394
void fetab_zoom_out(const QWidget *ID)
void show_statusbar(bool)
void fetab_convert_eol(const QWidget *ID, QsciScintilla::EolMode eol_mode)
QAction * _cut_line_action
Definition: file-editor.h:375
void fetab_indent_selected_text(const QWidget *ID)
octave_qscintilla * qsci_edit_area()
QAction * _previous_breakpoint_action
Definition: file-editor.h:418
void enable_menu_shortcuts(bool)
QString ced
Definition: file-editor.h:330
QAction * _find_files_action
Definition: file-editor.h:382
void request_styles_preferences(bool)
std::string string_value(bool force=false) const
Definition: ov.h:908
void handle_edit_mfile_request(const QString &name, const QString &file, const QString &curr_dir, int line)
Definition: file-editor.cc:668
QAction * _show_indguide_action
Definition: file-editor.h:360
void fetab_next_breakpoint(const QWidget *ID)
void request_delete_end_line(bool)
Definition: file-editor.cc:962
void request_context_doc(bool)
Definition: file-editor.cc:852
void copyClipboard()
Definition: file-editor.cc:816
QMainWindow * main_win()
std::complex< double > w(std::complex< double > z, double relerr=0)
void request_context_edit(bool)
Definition: file-editor.cc:858
void request_cut(bool)
Definition: file-editor.cc:824
QMenu * _edit_menu
Definition: file-editor.h:421
QAction * _context_help_action
Definition: file-editor.h:354
QAction * _lower_case_action
Definition: file-editor.h:341
const T * data(void) const
Definition: Array.h:582
void fetab_find_previous(const QWidget *ID)
QAction * _styles_preferences_action
Definition: file-editor.h:409
QAction * _preferences_action
Definition: file-editor.h:408
void request_next_bookmark(bool)
Definition: file-editor.cc:900
QAction * _duplicate_selection_action
Definition: file-editor.h:376
bool check_closing(void)
Definition: file-editor.cc:85
void file_loaded_signal()
void restore_session(QSettings *settings)
QAction * _zoom_normal_action
Definition: file-editor.h:367
octave_value retval
Definition: data.cc:6294
QAction * _uncomment_selection_action
Definition: file-editor.h:343
void fetab_zoom_normal(const QWidget *ID)
void switch_tab(int direction, bool movetab=false)
void check_conflict_save(const QString &fileName, bool remove_on_success)
Definition: file-editor.cc:603
void request_goto_line(bool)
void show_long_line(bool)
void selectAll()
Definition: file-editor.cc:839
QAction * _completion_action
Definition: file-editor.h:384
void handle_tab_remove_request(void)
void request_open_files(const QStringList &)
Definition: file-editor.cc:407
QHash< QMenu *, QStringList > _hash_menu_text
Definition: file-editor.h:328
QAction * _popdown_mru_action
Definition: file-editor.h:398
QAction * _transpose_line_action
Definition: file-editor.h:377
void toggle_preference(const QString &preference, bool def)
void fetab_next_bookmark(const QWidget *ID)
QAction * _unindent_selection_action
Definition: file-editor.h:345
idx type
Definition: ov.cc:3129
void fetab_recover_from_exit(void)
void request_conv_eol_windows(bool)
QAction * _switch_left_tab_action
Definition: file-editor.h:411
void fetab_check_modified_file(void)
void handle_editor_state_changed(bool enableCopy, bool is_octave_file)
QAction * _close_action
Definition: file-editor.h:401
void request_settings_dialog(const QString &)
static QSettings * get_settings(void)
QStringList _mru_files_encodings
Definition: file-editor.h:440
void request_context_run(bool)
Definition: file-editor.cc:888
void fetab_settings_changed(const QSettings *settings)
QAction * _next_breakpoint_action
Definition: file-editor.h:417
void handle_exit_debug_mode(void)
Definition: file-editor.cc:191
QMenu * _mru_file_menu
Definition: file-editor.h:437
With real return the complex result
Definition: data.cc:3375
std::string url
Definition: urlwrite.cc:337
void mru_menu_update(void)
void handle_add_filename_to_list(const QString &fileName, const QString &encoding, QWidget *ID)
void fetab_file_name_query(const QWidget *ID)
void show_eol_chars(bool)
void handle_tab_close_request(int index)
void notice_settings(const QSettings *settings)
QAction * _save_as_action
Definition: file-editor.h:400
void request_cut_line(bool)
Definition: file-editor.cc:980
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
Definition: colamd.cc:112
void request_previous_breakpoint(bool)
Definition: file-editor.cc:931
void handle_delete_debugger_pointer_request(const QString &file, int line)
Definition: file-editor.cc:761
void request_context_help(bool)
Definition: file-editor.cc:847
void switch_right_tab()
void request_toggle_breakpoint(bool)
Definition: file-editor.cc:919
void request_remove_bookmark(bool)
Definition: file-editor.cc:912
void request_sel_match_brace(bool)
void request_run_file(bool)
Definition: file-editor.cc:882
QStringList _mru_files
Definition: file-editor.h:439
static bool was_cancelled(void)
void handle_combo_enc_current_index(QString new_encoding)
Definition: file-editor.cc:318
void fetab_print_file(const QWidget *ID)
QAction * _show_statusbar_action
Definition: file-editor.h:363
QToolBar * toolbar(void)
Definition: file-editor.cc:178
QMenu * _edit_fmt_menu
Definition: file-editor.h:423
=val(i)}if ode{val(i)}occurs in table i
Definition: lookup.cc:239
void request_conv_eol_mac(bool)
void request_open_file(void)
Definition: file-editor.cc:261
void request_new_script(const QString &commands)
Definition: file-editor.cc:219
p
Definition: lu.cc:138
QAction * _show_hscrollbar_action
Definition: file-editor.h:364
void create_context_menu(QMenu *)
void request_move_match_brace(bool)
void insert_global_actions(QList< QAction * >)
void move_tab_right()
octave_map map(dims)
QAction * _find_action
Definition: file-editor.h:379
void request_close_other_files(bool)
void zoom_normal(bool)
void request_find_next(bool)
void zoom_in(bool)
void fetab_comment_selected_text(const QWidget *ID)
void edit_status_update(bool, bool)
void request_redo(bool)
Definition: file-editor.cc:809
void fetab_set_directory(const QString &dir)
QList< octave_dock_widget * > get_dock_widget_list()
Definition: main-window.h:226
OCTINTERP_API octave_value_list F__which__(const octave_value_list &=octave_value_list(), int=0)
static QIcon icon(const QString &icon_name, bool fallback=true)
bool conditional_close(void)
void fetab_goto_line(const QWidget *ID, int line=-1)
void request_print_file(bool)
Definition: file-editor.cc:876
QAction * _mru_file_actions[MaxMRUFiles]
Definition: file-editor.h:438
QAction * _upper_case_action
Definition: file-editor.h:340
QAction * _toggle_breakpoint_action
Definition: file-editor.h:416
void handle_visibility(bool visible)
void request_copy_line(bool)
Definition: file-editor.cc:974
QString load_file(const QString &fileName)
QMenu * _debug_menu
Definition: file-editor.h:334
QAction * _run_selection_action
Definition: file-editor.h:395
void active_tab_changed(int index)
void fetab_remove_all_breakpoints(const QWidget *ID)
void fetab_toggle_breakpoint(const QWidget *ID)
QAction * _zoom_in_action
Definition: file-editor.h:365
void handle_file_name_changed(const QString &fileName, const QString &toolTip)
static void reset_cancel(void)
void request_previous_bookmark(bool)
Definition: file-editor.cc:906
void request_close_all_files(bool)
QAction * _copy_line_action
Definition: file-editor.h:374
void fetab_previous_breakpoint(const QWidget *ID)
void fetab_insert_debugger_pointer(const QWidget *ID, int line=-1)
void add_file_editor_tab(file_editor_tab *f, const QString &fn)
void construct(void)
QAction * _remove_bookmark_action
Definition: file-editor.h:391
QAction * _comment_selection_action
Definition: file-editor.h:342
QAction * _zoom_out_action
Definition: file-editor.h:366
QWidget * find_tab_widget(const QString &openFileName) const
Definition: file-editor.cc:325
void save_file_as(QWidget *fetabID=0)
void dropEvent(QDropEvent *event)
std::map< QString, tab_info > editor_tab_map
Definition: file-editor.h:327
void request_lower_case(bool)
virtual void focus(void)
QAction * _find_previous_action
Definition: file-editor.h:381
file_editor(QWidget *p)
Definition: file-editor.cc:52
void fetab_find_next(const QWidget *ID)
void request_toggle_bookmark(bool)
Definition: file-editor.cc:894
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line, const QString &cond)
Definition: file-editor.cc:786
static void set_shortcut(QAction *action, const QString &key)
void fetab_find(const QWidget *ID, QList< QAction * >)
void request_transpose_line(bool)
Definition: file-editor.cc:992
void new_file(const QString &commands=QString())
QMenu * _view_editor_menu
Definition: file-editor.h:426
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
Definition: oct-hist.cc:587
void fetab_previous_bookmark(const QWidget *ID)
void set_encoding(const QString &new_encoding)
void show_line_numbers(bool)