GNU Octave  4.0.0
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-2015 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 #ifdef HAVE_CONFIG_H
24 #include <config.h>
25 #endif
26 
27 #ifdef HAVE_QSCINTILLA
28 
29 #include "file-editor.h"
30 #include "resource-manager.h"
31 #include "shortcut-manager.h"
32 
33 #include <QVBoxLayout>
34 #include <QApplication>
35 #include <QFile>
36 #include <QFont>
37 #include <QFileDialog>
38 #include <QMessageBox>
39 #include <QStyle>
40 #include <QTextStream>
41 #include <QTabBar>
42 #include <QProcess>
43 #include <QInputDialog>
44 #include <Qsci/qscicommandset.h>
45 
46 #include "octave-link.h"
47 #include "utils.h"
48 #include "main-window.h"
49 
52 {
53  // Set current editing directory before construct because loaded
54  // files will change ced accordingly.
55  ced = QDir::currentPath ();
56 
57  construct ();
58 
59  setVisible (false);
60 
61  setAcceptDrops(true);
62 }
63 
65 {
66  if (_mru_file_menu)
67  delete _mru_file_menu;
68 }
69 
70 bool
72 {
73  // Save open files for restoring in next session; this only is possible
74  QSettings *settings = resource_manager::get_settings ();
75 
76  // Have all file editor tabs signal what their file names are.
77  editor_tab_map.clear ();
78  emit fetab_file_name_query (0);
79 
80  // save file names (even if last session will not be restored next time)
81  QStringList fetFileNames;
83  p != editor_tab_map.end (); p++)
84  {
85  QString file_name = p->first;
86  if (!file_name.isEmpty ())
87  fetFileNames.append (p->first); // do not append unnamed files
88  }
89 
90  settings->setValue ("editor/savedSessionTabs", fetFileNames);
91  settings->sync ();
92 
93  // Save all tabs with confirmation.
96 
97  // Close all tabs if there was no cancellation.
99  return false;
100 
101  for (int i = 0; i < _tab_widget->count (); i++)
102  {
103  delete _tab_widget->widget (i);
104  _tab_widget->removeTab (i);
105  }
106 
107  return true;
108 }
109 
110 void
111 file_editor::focus (void)
112 {
114 
115  // set focus to current tab
116  QWidget *fileEditorTab = _tab_widget->currentWidget ();
117  if (fileEditorTab)
118  emit fetab_set_focus (fileEditorTab);
119 }
120 
121 void
122 file_editor::update_octave_directory (const QString& dir)
123 {
124  ced = dir;
125  emit fetab_set_directory (ced); // for save dialog
126 }
127 
128 QMenu *
130 {
131  return _debug_menu;
132 }
133 
134 QToolBar *
136 {
137  return _tool_bar;
138 }
139 
140 void
142 {
143  _run_action->setEnabled (false);
144  _run_action->setShortcut (QKeySequence ());
145 }
146 
147 void
149 {
150  _run_action->setEnabled (true);
151  shortcut_manager::set_shortcut (_run_action, "editor_run:run_file");
152 }
153 
154 void
155 file_editor::request_new_file (const QString& commands)
156 {
157  // Custom editor? If yes, we can only call the editor without passing
158  // some initial contents and even without being sure a new file is opened
159  if (call_custom_editor ())
160  return;
161 
162  // New file isn't a file_editor_tab function since the file
163  // editor tab has yet to be created and there is no object to
164  // pass a signal to. Hence, functionality is here.
165 
166  file_editor_tab *fileEditorTab = new file_editor_tab (ced);
167  if (fileEditorTab)
168  {
169  add_file_editor_tab (fileEditorTab, ""); // new tab with empty title
170  fileEditorTab->new_file (commands); // title is updated here
171  focus (); // focus editor and new tab
172  }
173 }
174 
175 void
176 file_editor::request_new_script (const QString& commands)
177 {
178  request_new_file (commands);
179 }
180 
181 void
183 {
184  bool ok;
185  // get the name of the new function
186  QString new_name = QInputDialog::getText (this, tr ("New Function"),
187  tr ("New function name:\n"), QLineEdit::Normal, "", &ok);
188  if (ok && new_name.length () > 0)
189  {
190  // append suffix if it not already exists
191  if (new_name.rightRef (2) != ".m")
192  new_name.append (".m");
193  // check whether new files are created without prompt
194  QSettings *settings = resource_manager::get_settings ();
195  if (! settings->value ("editor/create_new_file",false).toBool ())
196  {
197  // no, so enable this settings and wait for end of new file loading
198  settings->setValue ("editor/create_new_file",true);
199  connect (this, SIGNAL (file_loaded_signal ()),
200  this, SLOT (restore_create_file_setting ()));
201  }
202  // start the edit command
203  emit execute_command_in_terminal_signal ("edit " + new_name);
204  }
205 }
206 
207 void
209 {
210  // restore the new files creation setting
211  QSettings *settings = resource_manager::get_settings ();
212  settings->setValue ("editor/create_new_file",false);
213  disconnect (this, SIGNAL (file_loaded_signal ()),
214  this, SLOT (restore_create_file_setting ()));
215 }
216 
217 void
219 {
220  // Open file isn't a file_editor_tab function since the file
221  // editor tab has yet to be created and there is no object to
222  // pass a signal to. Hence, functionality is here.
223 
224  // Create a NonModal message.
225  QFileDialog *fileDialog = new QFileDialog (this);
226  fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
227 
228  // Giving trouble under KDE (problem is related to Qt signal handling on unix,
229  // see https://bugs.kde.org/show_bug.cgi?id=260719 ,
230  // it had/has no effect on Windows, though)
231  fileDialog->setOption(QFileDialog::DontUseNativeDialog, true);
232 
233  fileDialog->setAcceptMode (QFileDialog::AcceptOpen);
234  fileDialog->setViewMode (QFileDialog::Detail);
235  fileDialog->setFileMode (QFileDialog::ExistingFiles);
236  fileDialog->setDirectory (ced);
237 
238  connect (fileDialog, SIGNAL (filesSelected (const QStringList&)),
239  this, SLOT (request_open_files (const QStringList&)));
240 
241  fileDialog->setWindowModality (Qt::NonModal);
242  fileDialog->setAttribute (Qt::WA_DeleteOnClose);
243  fileDialog->show ();
244 }
245 
246 // Check whether this file is already open in the editor.
247 QWidget *
248 file_editor::find_tab_widget (const QString& file) const
249 {
250  QWidget *retval = 0;
251 
253  p != editor_tab_map.end (); p++)
254  {
255  QString tab_file = p->first;
256 
257  if (same_file (file.toStdString (), tab_file.toStdString ()))
258  {
259  retval = p->second;
260  break;
261  }
262  }
263 
264  return retval;
265 }
266 
267 bool
268 file_editor::call_custom_editor (const QString& file_name, int line)
269 {
270  // Check if the user wants to use a custom file editor.
271  QSettings *settings = resource_manager::get_settings ();
272 
273  if (settings->value ("useCustomFileEditor",false).toBool ())
274  {
275  if (line > -1) // check for a specific line (debugging)
276  return true; // yes: do ont open a file in external editor
277 
278  QString editor = settings->value ("customFileEditor").toString ();
279  editor.replace ("%f", file_name);
280  editor.replace ("%l", QString::number (line));
281 
282  bool started_ok = QProcess::startDetached (editor);
283 
284  if (started_ok != true)
285  {
286  QMessageBox *msgBox
287  = new QMessageBox (QMessageBox::Critical,
288  tr ("Octave Editor"),
289  tr ("Could not start custom file editor\n%1").
290  arg (editor),
291  QMessageBox::Ok, this);
292 
293  msgBox->setWindowModality (Qt::NonModal);
294  msgBox->setAttribute (Qt::WA_DeleteOnClose);
295  msgBox->show ();
296  }
297 
298  if (line < 0 && ! file_name.isEmpty ())
299  handle_mru_add_file (QFileInfo (file_name).canonicalFilePath ());
300 
301  return true;
302  }
303 
304  return false;
305 }
306 
307 bool
309 {
310  main_window *w = static_cast<main_window *>(main_win ());
311  QList<QDockWidget *> w_list = w->tabifiedDockWidgets (this);
312  QDockWidget *console =
313  static_cast<QDockWidget *> (w->get_dock_widget_list ().at (0));
314 
315  for (int i = 0; i < w_list.count (); i++)
316  {
317  if (w_list.at (i) == console)
318  return true;
319  }
320 
321  return false;
322 }
323 
324 void
325 file_editor::request_open_files (const QStringList& open_file_names)
326 {
327  for (int i = 0; i < open_file_names.count (); i++)
328  request_open_file (open_file_names.at (i));
329 }
330 
331 void
332 file_editor::request_open_file (const QString& openFileName, int line,
333  bool debug_pointer,
334  bool breakpoint_marker, bool insert)
335 {
336  if (call_custom_editor (openFileName, line))
337  return; // custom editor called
338 
339  if (openFileName.isEmpty ())
340  {
341  // This happens if edit is calles without an argument
342  // Open eitor with empty edit area instead (as new file would do)
343  request_new_file ("");
344  }
345  else
346  {
347  // Have all file editor tabs signal what their file names are.
348  editor_tab_map.clear ();
349  emit fetab_file_name_query (0);
350 
351  // Check whether this file is already open in the editor.
352  QWidget *tab = find_tab_widget (openFileName);
353 
354  if (tab)
355  {
356  _tab_widget->setCurrentWidget (tab);
357 
358  if (line > 0)
359  {
360  emit fetab_goto_line (tab, line);
361 
362  if (debug_pointer)
363  emit fetab_insert_debugger_pointer (tab, line);
364 
365  if (breakpoint_marker)
366  emit fetab_do_breakpoint_marker (insert, tab, line);
367  }
368 
369  if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ()))
370  {
371  emit fetab_set_focus (tab);
372  focus ();
373  }
374  }
375  else
376  {
377  file_editor_tab *fileEditorTab = new file_editor_tab ();
378  if (fileEditorTab)
379  {
380  QString result = fileEditorTab->load_file (openFileName);
381  if (result == "")
382  {
383  // Supply empty title then have the file_editor_tab update
384  // with full or short name.
385  add_file_editor_tab (fileEditorTab, "");
386  fileEditorTab->update_window_title (false);
387  // file already loaded, add file to mru list here
388  QFileInfo file_info = QFileInfo (openFileName);
389  handle_mru_add_file (file_info.canonicalFilePath ());
390 
391  if (line > 0)
392  {
393  emit fetab_goto_line (fileEditorTab, line);
394 
395  if (debug_pointer)
396  emit fetab_insert_debugger_pointer (fileEditorTab,
397  line);
398  if (breakpoint_marker)
399  emit fetab_do_breakpoint_marker (insert, fileEditorTab,
400  line);
401  }
402  }
403  else
404  {
405  delete fileEditorTab;
406 
407  if (QFile::exists (openFileName))
408  {
409  // File not readable:
410  // create a NonModal message about error.
411  QMessageBox *msgBox
412  = new QMessageBox (QMessageBox::Critical,
413  tr ("Octave Editor"),
414  tr ("Could not open file\n%1\nfor read: %2.").
415  arg (openFileName).arg (result),
416  QMessageBox::Ok, this);
417 
418  msgBox->setWindowModality (Qt::NonModal);
419  msgBox->setAttribute (Qt::WA_DeleteOnClose);
420  msgBox->show ();
421  }
422  else
423  {
424  // File does not exist, should it be created?
425  bool create_file = true;
426  QMessageBox *msgBox;
427  QSettings *settings = resource_manager::get_settings ();
428 
429  if (!settings->value ("editor/create_new_file", false).toBool ())
430  {
431  msgBox = new QMessageBox (QMessageBox::Question,
432  tr ("Octave Editor"),
433  tr ("File\n%1\ndoes not exist. "
434  "Do you want to create it?").arg (openFileName),
435  QMessageBox::NoButton,0);
436  QPushButton *create_button =
437  msgBox->addButton (tr ("Create"), QMessageBox::YesRole);
438  msgBox->addButton (tr ("Cancel"), QMessageBox::RejectRole);
439  msgBox->setDefaultButton (create_button);
440  msgBox->exec ();
441 
442  QAbstractButton *clicked_button = msgBox->clickedButton ();
443  if (clicked_button != create_button)
444  create_file = false;
445 
446  delete msgBox;
447  }
448 
449  if (create_file)
450  {
451  // create the file and call the editor again
452  QFile file (openFileName);
453  if (!file.open (QIODevice::WriteOnly))
454  {
455  // error opening the file
456  msgBox = new QMessageBox (QMessageBox::Critical,
457  tr ("Octave Editor"),
458  tr ("Could not open file\n%1\nfor write: %2.").
459  arg (openFileName).arg (file.errorString ()),
460  QMessageBox::Ok, this);
461 
462  msgBox->setWindowModality (Qt::NonModal);
463  msgBox->setAttribute (Qt::WA_DeleteOnClose);
464  msgBox->show ();
465  }
466  else
467  {
468  file.close ();
469  request_open_file (openFileName);
470  }
471  }
472  }
473  }
474  }
475 
476  if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ()))
477  {
478  // really show editor and the current editor tab
479  focus ();
480  emit file_loaded_signal ();
481  }
482  }
483  }
484 }
485 
486 // open a file from the mru list
487 void
488 file_editor::request_mru_open_file (QAction *action)
489 {
490  if (action)
491  {
492  request_open_file (action->data ().toString ());
493  }
494 }
495 
496 
497 void
498 file_editor::check_conflict_save (const QString& saveFileName,
499  bool remove_on_success)
500 {
501  // Have all file editor tabs signal what their file names are.
502  editor_tab_map.clear ();
503  emit fetab_file_name_query (0);
504 
505  // Check whether this file is already open in the editor.
506  QWidget *tab = find_tab_widget (saveFileName);
507 
508  if (tab)
509  {
510  // Note: to overwrite the contents of some other file editor tab
511  // with the same name requires identifying which file editor tab
512  // that is (not too difficult) then close that tab. Of course,
513  // that could trigger another dialog box if the file editor tab
514  // with the same name has modifications in it. This could become
515  // somewhat confusing to the user. For now, opt to do nothing.
516 
517  // Create a NonModal message about error.
518  QMessageBox *msgBox
519  = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"),
520  tr ("File not saved! A file with the selected name\n%1\n"
521  "is already open in the editor").
522  arg (saveFileName),
523  QMessageBox::Ok, 0);
524 
525  msgBox->setWindowModality (Qt::NonModal);
526  msgBox->setAttribute (Qt::WA_DeleteOnClose);
527  msgBox->show ();
528 
529  return;
530  }
531 
532  QObject *saveFileObject = sender ();
533  QWidget *saveFileWidget = 0;
534 
535  for (int i = 0; i < _tab_widget->count (); i++)
536  {
537  if (_tab_widget->widget (i) == saveFileObject)
538  {
539  saveFileWidget = _tab_widget->widget (i);
540  break;
541  }
542  }
543  if (!saveFileWidget)
544  {
545  // Create a NonModal message about error.
546  QMessageBox *msgBox
547  = new QMessageBox (QMessageBox::Critical, tr ("Octave Editor"),
548  tr ("The associated file editor tab has disappeared."),
549  QMessageBox::Ok, 0);
550 
551  msgBox->setWindowModality (Qt::NonModal);
552  msgBox->setAttribute (Qt::WA_DeleteOnClose);
553  msgBox->show ();
554 
555  return;
556  }
557 
558  // Can save without conflict, have the file editor tab do so.
559  emit fetab_save_file (saveFileWidget, saveFileName, remove_on_success);
560 }
561 
562 void
564  int line)
565 {
566  request_open_file (file, line, true);
567 }
568 
569 void
571  int line)
572 {
573  if (! file.isEmpty ())
574  {
575  // Have all file editor tabs signal what their file names are.
576  editor_tab_map.clear ();
577  emit fetab_file_name_query (0);
578 
579  // Check whether this file is already open in the editor.
580  QWidget *tab = find_tab_widget (file);
581 
582  if (tab)
583  {
584  _tab_widget->setCurrentWidget (tab);
585 
586  if (line > 0)
587  emit fetab_delete_debugger_pointer (tab, line);
588 
589  emit fetab_set_focus (tab);
590  }
591  }
592 }
593 
594 void
596  const QString& file,
597  int line)
598 {
599  request_open_file (file, line, false, true, insert);
600 }
601 
602 void
603 file_editor::handle_edit_file_request (const QString& file)
604 {
605  request_open_file (file);
606 }
607 
608 void
610 {
611  emit fetab_scintilla_command (_tab_widget->currentWidget (),
612  QsciScintillaBase::SCI_UNDO);
613 }
614 
615 void
617 {
618  emit fetab_scintilla_command (_tab_widget->currentWidget (),
619  QsciScintillaBase::SCI_REDO);
620 }
621 
622 void
624 {
625  emit fetab_scintilla_command (_tab_widget->currentWidget (),
626  QsciScintillaBase::SCI_COPY);
627 }
628 
629 void
631 {
632  emit fetab_scintilla_command (_tab_widget->currentWidget (),
633  QsciScintillaBase::SCI_CUT);
634 }
635 
636 void
638 {
639  emit fetab_scintilla_command (_tab_widget->currentWidget (),
640  QsciScintillaBase::SCI_PASTE);
641 }
642 
643 void
645 {
646  emit fetab_scintilla_command (_tab_widget->currentWidget (),
647  QsciScintillaBase::SCI_SELECTALL);
648 }
649 
650 void
652 {
653  emit fetab_context_help (_tab_widget->currentWidget (), false);
654 }
655 void
657 {
658  emit fetab_context_help (_tab_widget->currentWidget (), true);
659 }
660 
661 void
663 {
664  emit fetab_context_edit (_tab_widget->currentWidget ());
665 }
666 
667 void
669 {
670  emit fetab_save_file (_tab_widget->currentWidget ());
671 }
672 
673 void
675 {
676  emit fetab_save_file_as (_tab_widget->currentWidget ());
677 }
678 
679 void
681 {
682  emit fetab_print_file (_tab_widget->currentWidget ());
683 }
684 
685 
686 void
688 {
689  emit fetab_run_file (_tab_widget->currentWidget ());
690 }
691 
692 void
694 {
695  emit fetab_context_run (_tab_widget->currentWidget ());
696 }
697 
698 void
700 {
701  emit fetab_toggle_bookmark (_tab_widget->currentWidget ());
702 }
703 
704 void
706 {
707  emit fetab_next_bookmark (_tab_widget->currentWidget ());
708 }
709 
710 void
712 {
713  emit fetab_previous_bookmark (_tab_widget->currentWidget ());
714 }
715 
716 void
718 {
719  emit fetab_remove_bookmark (_tab_widget->currentWidget ());
720 }
721 
722 void
724 {
725  emit fetab_toggle_breakpoint (_tab_widget->currentWidget ());
726 }
727 
728 void
730 {
731  emit fetab_next_breakpoint (_tab_widget->currentWidget ());
732 }
733 
734 void
736 {
737  emit fetab_previous_breakpoint (_tab_widget->currentWidget ());
738 }
739 
740 void
742 {
743  emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ());
744 }
745 
746 // slots for Edit->Commands actions
747 void
749 {
750  emit fetab_scintilla_command (_tab_widget->currentWidget (),
751  QsciScintillaBase::SCI_DELWORDLEFT);
752 }
753 void
755 {
756  emit fetab_scintilla_command (_tab_widget->currentWidget (),
757  QsciScintillaBase::SCI_DELWORDRIGHT);
758 }
759 void
761 {
762  emit fetab_scintilla_command (_tab_widget->currentWidget (),
763  QsciScintillaBase::SCI_DELLINELEFT);
764 }
765 void
767 {
768  emit fetab_scintilla_command (_tab_widget->currentWidget (),
769  QsciScintillaBase::SCI_DELLINERIGHT);
770 }
771 void
773 {
774  emit fetab_scintilla_command (_tab_widget->currentWidget (),
775  QsciScintillaBase::SCI_LINEDELETE);
776 }
777 void
779 {
780  emit fetab_scintilla_command (_tab_widget->currentWidget (),
781  QsciScintillaBase::SCI_LINECOPY);
782 }
783 void
785 {
786  emit fetab_scintilla_command (_tab_widget->currentWidget (),
787  QsciScintillaBase::SCI_LINECUT);
788 }
789 void
791 {
792  emit fetab_scintilla_command (_tab_widget->currentWidget (),
793  QsciScintillaBase::SCI_SELECTIONDUPLICATE);
794 }
795 void
797 {
798  emit fetab_scintilla_command (_tab_widget->currentWidget (),
799  QsciScintillaBase::SCI_LINETRANSPOSE);
800 }
801 void
803 {
804  emit fetab_comment_selected_text (_tab_widget->currentWidget ());
805 }
806 void
808 {
809  emit fetab_uncomment_selected_text (_tab_widget->currentWidget ());
810 }
811 
812 // slots for Edit->Format actions
813 void
815 {
816  emit fetab_scintilla_command (_tab_widget->currentWidget (),
817  QsciScintillaBase::SCI_UPPERCASE);
818 }
819 void
821 {
822  emit fetab_scintilla_command (_tab_widget->currentWidget (),
823  QsciScintillaBase::SCI_LOWERCASE);
824 }
825 void
827 {
828  emit fetab_indent_selected_text (_tab_widget->currentWidget ());
829 }
830 
831 void
833 {
834  emit fetab_unindent_selected_text (_tab_widget->currentWidget ());
835 }
836 
837 void
839 {
840  emit fetab_convert_eol (_tab_widget->currentWidget (),
841  QsciScintilla::EolWindows);
842 }
843 void
845 {
846  emit fetab_convert_eol (_tab_widget->currentWidget (),
847  QsciScintilla::EolUnix);
848 }
849 void
851 {
852  emit fetab_convert_eol (_tab_widget->currentWidget (),
853  QsciScintilla::EolMac);
854 }
855 
856 
857 void
859 {
860  emit fetab_find (_tab_widget->currentWidget ());
861 }
862 
863 void
865 {
866  emit fetab_goto_line (_tab_widget->currentWidget ());
867 }
868 
869 void
871 {
872  emit fetab_move_match_brace (_tab_widget->currentWidget (), false);
873 }
874 
875 void
877 {
878  emit fetab_move_match_brace (_tab_widget->currentWidget (), true);
879 }
880 
881 void
883 {
884  emit fetab_completion (_tab_widget->currentWidget ());
885 }
886 
887 void
888 file_editor::handle_mru_add_file (const QString& file_name)
889 {
890  if (_mru_files.count () && _mru_files.at (0) == file_name)
891  return; // the first entry is already the actual file name
892 
893  _mru_files.removeAll (file_name);
894  _mru_files.prepend (file_name);
895 
896  mru_menu_update ();
897 }
898 
899 void
901 {
902  int num_files = qMin (_mru_files.size (), int (MaxMRUFiles));
903 
904  // configure and show active actions of mru-menu
905  for (int i = 0; i < num_files; ++i)
906  {
907  QString text = tr ("&%1 %2").
908  arg ((i+1) % int (MaxMRUFiles)).arg (_mru_files.at (i));
909  _mru_file_actions[i]->setText (text);
910  _mru_file_actions[i]->setData (_mru_files.at (i));
911  _mru_file_actions[i]->setVisible (true);
912  }
913 
914  // hide unused mru-menu entries
915  for (int j = num_files; j < MaxMRUFiles; ++j)
916  _mru_file_actions[j]->setVisible (false);
917 
918  // delete entries in string-list beyond MaxMRUFiles
919  while (_mru_files.size () > MaxMRUFiles)
920  _mru_files.removeLast ();
921 
922  // save actual mru-list in settings
923  QSettings *settings = resource_manager::get_settings ();
924 
925  // FIXME: what should happen if settings is 0?
926  settings->setValue ("editor/mru_file_list", _mru_files);
927  settings->sync ();
928 }
929 
930 void
931 file_editor::handle_file_name_changed (const QString& fname,
932  const QString& tip)
933 {
934  QObject *fileEditorTab = sender ();
935  if (fileEditorTab)
936  {
937  for (int i = 0; i < _tab_widget->count (); i++)
938  {
939  if (_tab_widget->widget (i) == fileEditorTab)
940  {
941  _tab_widget->setTabText (i, fname);
942  _tab_widget->setTabToolTip (i, tip);
943  }
944  }
945  }
946 }
947 
948 void
950 {
951  file_editor_tab *editor_tab =
952  static_cast<file_editor_tab *> (_tab_widget->currentWidget ());
953  editor_tab->conditional_close ();
954 }
955 
956 void
958 {
959  file_editor_tab *editor_tab;
960 
961  // loop over all tabs starting from last one otherwise deletion changes index
962  for (int index = _tab_widget->count ()-1; index >= 0; index--)
963  {
964  editor_tab = static_cast<file_editor_tab *> (_tab_widget->widget (index));
965  editor_tab->conditional_close ();
966  }
967 }
968 
969 void
971 {
972  file_editor_tab *editor_tab;
973  QWidget *tabID = _tab_widget->currentWidget ();
974 
975  // loop over all tabs starting from last one otherwise deletion changes index
976  for (int index = _tab_widget->count ()-1; index >= 0; index--)
977  {
978  if (tabID != _tab_widget->widget (index))
979  {
980  editor_tab =
981  static_cast<file_editor_tab *> (_tab_widget->widget (index));
982  editor_tab->conditional_close ();
983  }
984  }
985 }
986 
987 
988 void
990 {
991  file_editor_tab *editor_tab =
992  static_cast<file_editor_tab *> (_tab_widget->widget (index));
993  editor_tab->conditional_close ();
994 }
995 
996 void
998 {
999  QObject *fileEditorTab = sender ();
1000  if (fileEditorTab)
1001  {
1002  for (int i = 0; i < _tab_widget->count (); i++)
1003  {
1004  if (_tab_widget->widget (i) == fileEditorTab)
1005  {
1006  _tab_widget->removeTab (i);
1007  // Deleting sender is dodgy, but works because the signal
1008  // is the last item in the sender's routines.
1009  delete fileEditorTab;
1010  break;
1011  }
1012  }
1013  }
1014  check_actions ();
1015 }
1016 
1017 void
1018 file_editor::handle_add_filename_to_list (const QString& fileName, QWidget *ID)
1019 {
1020  // Should we allow multiple tabs for a single file?
1021 
1022  editor_tab_map[fileName] = ID;
1023 }
1024 
1025 // context menu of edit area
1026 void
1028 {
1029  emit fetab_change_request (_tab_widget->widget (index));
1030 }
1031 
1032 void file_editor::create_context_menu (QMenu *menu)
1033 {
1034  // remove all standard actions from scintilla
1035  QList<QAction *> all_actions = menu->actions ();
1036  QAction* a;
1037 
1038  foreach (a, all_actions)
1039  menu->removeAction (a);
1040 
1041  // add editor's actions with icons and customized shortcuts
1042  menu->addAction (_undo_action);
1043  menu->addAction (_redo_action);
1044  menu->addSeparator ();
1045  menu->addAction (_cut_action);
1046  menu->addAction (_copy_action);
1047  menu->addAction (_paste_action);
1048  menu->addSeparator ();
1049  menu->addAction (_selectall_action);
1050  menu->addSeparator ();
1051  menu->addAction (_run_selection_action);
1052 }
1053 
1054 void
1055 file_editor::toggle_preference (const QString& preference, bool def)
1056 {
1057  QSettings *settings = resource_manager::get_settings ();
1058  bool old = settings->value (preference,def).toBool ();
1059  settings->setValue (preference,!old);
1060  notice_settings (settings);
1061 }
1062 
1063 void
1065 {
1066  toggle_preference ("editor/showLineNumbers",true);
1067 }
1068 void
1070 {
1071  toggle_preference ("editor/show_white_space",false);
1072 }
1073 void
1075 {
1076  toggle_preference ("editor/show_eol_chars",false);
1077 }
1078 void
1080 {
1081  toggle_preference ("editor/show_indent_guides",false);
1082 }
1083 void
1085 {
1086  toggle_preference ("editor/long_line_marker",true);
1087 }
1088 
1089 void
1090 file_editor::zoom_in (bool)
1091 {
1092  emit fetab_zoom_in (_tab_widget->currentWidget ());
1093 }
1094 
1095 void
1096 file_editor::zoom_out (bool)
1097 {
1098  emit fetab_zoom_out (_tab_widget->currentWidget ());
1099 }
1100 
1101 void
1103 {
1104  emit fetab_zoom_normal (_tab_widget->currentWidget ());
1105 }
1106 
1107 void
1108 file_editor::edit_status_update (bool undo, bool redo)
1109 {
1110  _undo_action->setEnabled (undo);
1111  _redo_action->setEnabled (redo);
1112 }
1113 
1114 void
1115 file_editor::handle_editor_state_changed (bool copy_available,
1116  bool is_octave_file)
1117 {
1118  // In case there is some scenario where traffic could be coming from
1119  // all the file editor tabs, just process info from the current active tab.
1120  if (sender () == _tab_widget->currentWidget ())
1121  {
1122  _copy_action->setEnabled (copy_available);
1123  _cut_action->setEnabled (copy_available);
1124  _run_selection_action->setEnabled (copy_available);
1125  _run_action->setEnabled (is_octave_file);
1126 
1127  setFocusProxy (_tab_widget->currentWidget ());
1128  }
1129 }
1130 
1131 void
1132 file_editor::notice_settings (const QSettings *settings)
1133 {
1134  int icon_size_settings = settings->value ("toolbar_icon_size",0).toInt ();
1135  QStyle *st = style ();
1136  int icon_size = st->pixelMetric (QStyle::PM_ToolBarIconSize);
1137 
1138  if (icon_size_settings == 1)
1139  icon_size = st->pixelMetric (QStyle::PM_LargeIconSize);
1140  else if (icon_size_settings == -1)
1141  icon_size = st->pixelMetric (QStyle::PM_SmallIconSize);
1142 
1143  _tool_bar->setIconSize (QSize (icon_size,icon_size));
1144 
1145  int tab_width_min = settings->value ("editor/notebook_tab_width_min", 160)
1146  .toInt ();
1147  int tab_width_max = settings->value ("editor/notebook_tab_width_max", 300)
1148  .toInt ();
1149 
1150  if (settings->value ("editor/longWindowTitle", false).toBool ())
1151  {
1152  QString style_sheet = QString ("QTabBar::tab "
1153  "{min-width: %1px; max-width: %2px;}")
1154  .arg (tab_width_min).arg (tab_width_max);
1155  _tab_widget->setElideMode (Qt::ElideLeft);
1156  _tab_widget->setStyleSheet (style_sheet);
1157  }
1158  else
1159  _tab_widget->setElideMode (Qt::ElideNone);
1160 
1161  _tab_widget->setUsesScrollButtons (true);
1162 
1163  bool show_it;
1164  show_it = settings->value ("editor/showLineNumbers",true).toBool ();
1165  _show_linenum_action->setChecked (show_it);
1166  show_it = settings->value ("editor/show_white_space",false).toBool ();
1167  _show_whitespace_action->setChecked (show_it);
1168  show_it = settings->value ("editor/show_eol_chars",false).toBool ();
1169  _show_eol_action->setChecked (show_it);
1170  show_it = settings->value ("editor/show_indent_guides",false).toBool ();
1171  _show_indguide_action->setChecked (show_it);
1172  show_it = settings->value ("editor/long_line_marker",true).toBool ();
1173  _show_longline_action->setChecked (show_it);
1174 
1175  set_shortcuts ();
1176 
1177  // Relay signal to file editor tabs.
1178  emit fetab_settings_changed (settings);
1179 }
1180 
1181 void
1183 {
1184  emit request_settings_dialog ("editor");
1185 }
1186 
1187 void
1189 {
1190  emit request_settings_dialog ("editor_styles");
1191 }
1192 
1193 void
1194 file_editor::insert_new_open_actions (QAction *new_action,
1195  QAction *new_fcn_action,
1196  QAction *open_action)
1197 {
1198  _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action);
1199  _fileMenu->insertAction (open_action, new_fcn_action);
1200  _fileMenu->insertAction (new_fcn_action, new_action);
1201  _tool_bar->insertAction (_save_action, open_action);
1202  _tool_bar->insertAction (open_action, new_action);
1203 }
1204 
1205 QAction*
1206 file_editor::add_action (QMenu *menu, const QIcon &icon, const QString &text,
1207  const char *member)
1208 {
1209  QAction *a = menu->addAction (icon, text, this, member);
1210  addAction (a); // important for shortcut context
1211  a->setShortcutContext (Qt::WidgetWithChildrenShortcut);
1212  return a;
1213 }
1214 
1215 void
1217 {
1218  QHash<QMenu*, QStringList>::const_iterator i = _hash_menu_text.constBegin();
1219 
1220  while (i != _hash_menu_text.constEnd())
1221  {
1222  i.key ()->setTitle (i.value ().at (! enable));
1223  ++i;
1224  }
1225 }
1226 
1227 QMenu*
1228 file_editor::m_add_menu (QMenuBar *p, QString name)
1229 {
1230  QMenu *menu = p->addMenu (name);
1231 
1232  QString base_name = name; // get a copy
1233  // replace intended '&' ("&&") by a temp. string
1234  base_name.replace ("&&","___octave_amp_replacement___");
1235  // remove single '&' (shortcut)
1236  base_name.remove ("&");
1237  // restore intended '&'
1238  base_name.replace ("___octave_amp_replacement___","&&");
1239 
1240  // remember names with and without shortcut
1241  _hash_menu_text[menu] = QStringList () << name << base_name;
1242 
1243  return menu;
1244 }
1245 
1246 void
1248 {
1249  QWidget *editor_widget = new QWidget (this);
1250 
1251  // FIXME: what was the intended purpose of this unused variable?
1252  // QStyle *editor_style = QApplication::style ();
1253  _menu_bar = new QMenuBar (editor_widget);
1254 #if defined (Q_OS_MAC)
1255  _menu_bar->setNativeMenuBar (false);
1256 #endif
1257  _tool_bar = new QToolBar (editor_widget);
1258  _tool_bar->setMovable (true);
1259  _tab_widget = new QTabWidget (editor_widget);
1260  _tab_widget->setTabsClosable (true);
1261 #ifdef HAVE_QTABWIDGET_SETMOVABLE
1262  _tab_widget->setMovable (true);
1263 #endif
1264 
1265 
1266  // the mru-list and an empty array of actions
1267  QSettings *settings = resource_manager::get_settings ();
1268  _mru_files = settings->value ("editor/mru_file_list").toStringList ();
1269  for (int i = 0; i < MaxMRUFiles; ++i)
1270  {
1271  _mru_file_actions[i] = new QAction (this);
1272  _mru_file_actions[i]->setVisible (false);
1273  }
1274 
1275  // menu bar
1276 
1277  // file menu
1278 
1279  _fileMenu = m_add_menu (_menu_bar, tr ("&File"));
1280 
1281  // new and open menus are inserted later by the main window
1282  _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), _fileMenu);
1283  for (int i = 0; i < MaxMRUFiles; ++i)
1284  _mru_file_menu->addAction (_mru_file_actions[i]);
1285  _fileMenu->addMenu (_mru_file_menu);
1286 
1287  _fileMenu->addSeparator ();
1288 
1290  tr ("&Edit Function"), SLOT (request_context_edit (bool)));
1291 
1292  _fileMenu->addSeparator ();
1293 
1295  tr ("&Save File"), SLOT (request_save_file (bool)));
1297  tr ("Save File &As..."), SLOT (request_save_file_as (bool)));
1298 
1299  _fileMenu->addSeparator ();
1300 
1301  _close_action = add_action (_fileMenu, resource_manager::icon ("window-close",false),
1302  tr ("&Close"), SLOT (request_close_file (bool)));
1303  _close_all_action = add_action (_fileMenu, resource_manager::icon ("window-close",false),
1304  tr ("Close All"), SLOT (request_close_all_files (bool)));
1306  tr ("Close Other Files"), SLOT (request_close_other_files (bool)));
1307 
1308  _fileMenu->addSeparator ();
1309 
1311  tr ("Print..."), SLOT (request_print_file (bool)));
1312 
1313  // edit menu
1314 
1315  QMenu *editMenu = m_add_menu (_menu_bar, tr ("&Edit"));
1316 
1317  _undo_action = add_action (editMenu, resource_manager::icon ("edit-undo"),
1318  tr ("&Undo"), SLOT (request_undo (bool)));
1319  _undo_action->setEnabled (false);
1320  _redo_action = add_action (editMenu, resource_manager::icon ("edit-redo"),
1321  tr ("&Redo"), SLOT (request_redo (bool)));
1322  _redo_action->setEnabled (false);
1323 
1324  editMenu->addSeparator ();
1325 
1326  _copy_action = add_action (editMenu, resource_manager::icon ("edit-copy"),
1327  tr ("&Copy"), SLOT (request_copy (bool)));
1328  _copy_action->setEnabled (false);
1329  _cut_action = add_action (editMenu, resource_manager::icon ("edit-cut"),
1330  tr ("Cu&t"), SLOT (request_cut (bool)));
1331  _cut_action->setEnabled (false);
1332  _paste_action = add_action (editMenu, resource_manager::icon ("edit-paste"),
1333  tr ("Paste"), SLOT (request_paste (bool)));
1334 
1335  editMenu->addSeparator ();
1336 
1337  _selectall_action = add_action (editMenu, QIcon (), tr ("Select All"),
1338  SLOT (request_selectall (bool)));
1339 
1340  editMenu->addSeparator ();
1341 
1342  _find_action = add_action (editMenu, resource_manager::icon ("edit-find-replace"),
1343  tr ("&Find and Replace..."), SLOT (request_find (bool)));
1344 
1345  editMenu->addSeparator ();
1346 
1347  _edit_cmd_menu = editMenu->addMenu (tr ("&Commands"));
1348 
1350  tr ("Delete Line"), SLOT (request_delete_line (bool)));
1352  tr ("Copy Line"), SLOT (request_copy_line (bool)));
1354  tr ("Cut Line"), SLOT (request_cut_line (bool)));
1355 
1356  _edit_cmd_menu->addSeparator ();
1357 
1359  tr ("Delete to Start of Word"), SLOT (request_delete_start_word (bool)));
1361  tr ("Delete to End of Word"), SLOT (request_delete_end_word (bool)));
1363  tr ("Delete to Start of Line"), SLOT (request_delete_start_line (bool)));
1365  tr ("Delete to End of Line"), SLOT (request_delete_end_line (bool)));
1366 
1367  _edit_cmd_menu->addSeparator ();
1368 
1370  tr ("Duplicate Selection/Line"), SLOT (request_duplicate_selection (bool)));
1372  tr ("Transpose Line"), SLOT (request_transpose_line (bool)));
1373 
1374  _edit_cmd_menu->addSeparator ();
1375 
1377  tr ("&Show Completion List"), SLOT (request_completion (bool)));
1378 
1379  _edit_fmt_menu = editMenu->addMenu (tr ("&Format"));
1380 
1382  tr ("&Uppercase Selection"), SLOT (request_upper_case (bool)));
1384  tr ("&Lowercase Selection"), SLOT (request_lower_case (bool)));
1385 
1386  _edit_fmt_menu->addSeparator ();
1387 
1389  tr ("&Comment"), SLOT (request_comment_selected_text (bool)));
1391  tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool)));
1392 
1393  _edit_fmt_menu->addSeparator ();
1394 
1396  tr ("&Indent"), SLOT (request_indent_selected_text (bool)));
1398  tr ("&Unindent"), SLOT (request_unindent_selected_text (bool)));
1399 
1400  _edit_fmt_menu->addSeparator ();
1401 
1403  tr ("Convert Line Endings to &Windows (CRLF)"),
1404  SLOT (request_conv_eol_windows (bool)));
1406  tr ("Convert Line Endings to &Unix (LF)"),
1407  SLOT (request_conv_eol_unix (bool)));
1409  tr ("Convert Line Endings to &Mac (CR)"),
1410  SLOT (request_conv_eol_mac (bool)));
1411 
1412  _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation"));
1413 
1415  tr ("Go &to Line..."), SLOT (request_goto_line (bool)));
1416 
1417  _edit_cmd_menu->addSeparator ();
1418 
1420  tr ("Move to Matching Brace"), SLOT (request_move_match_brace (bool)));
1422  tr ("Select to Matching Brace"), SLOT (request_sel_match_brace (bool)));
1423 
1424  _edit_nav_menu->addSeparator ();
1425 
1427  tr ("Pre&vious Bookmark"), SLOT (request_previous_bookmark (bool)));
1429  tr ("&Next Bookmark"), SLOT (request_next_bookmark (bool)));
1431  tr ("Toggle &Bookmark"), SLOT (request_toggle_bookmark (bool)));
1433  tr ("&Remove All Bookmarks"), SLOT (request_remove_bookmark (bool)));
1434 
1435  editMenu->addSeparator ();
1436 
1437  _preferences_action = add_action (editMenu, resource_manager::icon ("preferences-system"),
1438  tr ("&Preferences..."), SLOT (request_preferences (bool)));
1439  _styles_preferences_action = add_action (editMenu, resource_manager::icon ("preferences-system"),
1440  tr ("&Styles Preferences..."), SLOT (request_styles_preferences (bool)));
1441 
1442  // view menu
1443 
1444  QMenu *view_menu = m_add_menu (_menu_bar, tr ("&View"));
1445 
1446  _view_editor_menu = view_menu->addMenu (tr ("&Editor"));
1447 
1449  tr ("Show &Line Numbers"), SLOT (show_line_numbers (bool)));
1450  _show_linenum_action->setCheckable (true);
1451 
1453  tr ("Show &Whitespace Characters"), SLOT (show_white_space (bool)));
1454  _show_whitespace_action->setCheckable (true);
1455 
1457  tr ("Show Line &Endings"), SLOT (show_eol_chars (bool)));
1458  _show_eol_action->setCheckable (true);
1459 
1461  tr ("Show &Indentation Guides"), SLOT (show_indent_guides (bool)));
1462  _show_indguide_action->setCheckable (true);
1463 
1465  tr ("Show Long Line &Marker"), SLOT (show_long_line (bool)));
1466  _show_longline_action->setCheckable (true);
1467 
1468  view_menu->addSeparator ();
1469 
1470  _zoom_in_action = add_action (view_menu, resource_manager::icon ("zoom-in"),
1471  tr ("Zoom &In"), SLOT (zoom_in (bool)));
1472  _zoom_out_action = add_action (view_menu, resource_manager::icon ("zoom-out"),
1473  tr ("Zoom &Out"), SLOT (zoom_out (bool)));
1474  _zoom_normal_action = add_action (view_menu, QIcon (),
1475  tr ("&Normal Size"), SLOT (zoom_normal (bool)));
1476 
1477  _menu_bar->addMenu (view_menu);
1478 
1479  // debug menu
1480 
1481  _debug_menu = m_add_menu (_menu_bar, tr ("&Debug"));
1482 
1484  resource_manager::icon ("bp-toggle"), tr ("Toggle &Breakpoint"),
1485  SLOT (request_toggle_breakpoint (bool)));
1487  resource_manager::icon ("bp-next"), tr ("&Next Breakpoint"),
1488  SLOT (request_next_breakpoint (bool)));
1490  resource_manager::icon ("bp-prev"), tr ("Pre&vious Breakpoint"),
1491  SLOT (request_previous_breakpoint (bool)));
1493  resource_manager::icon ("bp-rm-all"), tr ("&Remove All Breakpoints"),
1494  SLOT (request_remove_breakpoint (bool)));
1495 
1496  _debug_menu->addSeparator ();
1497 
1498  // The other debug actions will be added by the main window.
1499 
1500  // run menu
1501 
1502  QMenu *_run_menu = m_add_menu (_menu_bar, tr ("&Run"));
1503 
1504  _run_action = add_action (_run_menu, resource_manager::icon ("system-run"),
1505  tr ("Save File and Run"), SLOT (request_run_file (bool)));
1506  _run_selection_action = add_action (_run_menu, QIcon (),
1507  tr ("Run &Selection"), SLOT (request_context_run (bool)));
1508  _run_selection_action->setEnabled (false);
1509 
1510  // help menu
1511 
1512  QMenu *_help_menu = m_add_menu (_menu_bar, tr ("&Help"));
1513 
1514  _context_help_action = add_action (_help_menu, QIcon (),
1515  tr ("&Help on Keyword"), SLOT (request_context_help (bool)));
1516  _context_doc_action = add_action (_help_menu, QIcon (),
1517  tr ("&Documentation on Keyword"), SLOT (request_context_doc (bool)));
1518 
1519  // toolbar
1520 
1521  // new and open actions are inserted later from main window
1522  _tool_bar->addAction (_save_action);
1523  _tool_bar->addAction (_save_as_action);
1524  _tool_bar->addSeparator ();
1525  _tool_bar->addAction (_print_action);
1526  _tool_bar->addSeparator ();
1527  _tool_bar->addAction (_undo_action);
1528  _tool_bar->addAction (_redo_action);
1529  _tool_bar->addAction (_copy_action);
1530  _tool_bar->addAction (_cut_action);
1531  _tool_bar->addAction (_paste_action);
1532  _tool_bar->addSeparator ();
1533  _tool_bar->addAction (_find_action);
1534  _tool_bar->addAction (_run_action);
1535  _tool_bar->addSeparator ();
1536  _tool_bar->addAction (_toggle_breakpoint_action);
1538  _tool_bar->addAction (_next_breakpoint_action);
1540 
1541  // layout
1542  QVBoxLayout *vbox_layout = new QVBoxLayout ();
1543  vbox_layout->addWidget (_menu_bar);
1544  vbox_layout->addWidget (_tool_bar);
1545  vbox_layout->addWidget (_tab_widget);
1546  vbox_layout->setMargin (0);
1547  editor_widget->setLayout (vbox_layout);
1548  setWidget (editor_widget);
1549 
1550  // signals
1551  connect (this, SIGNAL (request_settings_dialog (const QString&)),
1552  main_win (),
1553  SLOT (process_settings_dialog_request (const QString&)));
1554 
1555  connect (main_win (), SIGNAL (new_file_signal (const QString&)),
1556  this, SLOT (request_new_file (const QString&)));
1557 
1558  connect (main_win (), SIGNAL (open_file_signal (const QString&)),
1559  this, SLOT (request_open_file (const QString&)));
1560 
1561  connect (_mru_file_menu, SIGNAL (triggered (QAction *)),
1562  this, SLOT (request_mru_open_file (QAction *)));
1563 
1564  mru_menu_update ();
1565 
1566  connect (_tab_widget, SIGNAL (tabCloseRequested (int)),
1567  this, SLOT (handle_tab_close_request (int)));
1568 
1569  connect (_tab_widget, SIGNAL (currentChanged (int)),
1570  this, SLOT (active_tab_changed (int)));
1571 
1572  connect (this, SIGNAL (execute_command_in_terminal_signal (const QString&)),
1573  main_win (), SLOT (execute_command_in_terminal (const QString&)));
1574 
1575  resize (500, 400);
1576  setWindowIcon (QIcon (":/actions/icons/logo.png"));
1577  set_title (tr ("Editor"));
1578 
1579  //restore previous session
1580  if (settings->value ("editor/restoreSession", true).toBool ())
1581  {
1582  QStringList sessionFileNames
1583  = settings->value ("editor/savedSessionTabs",
1584  QStringList ()).toStringList ();
1585 
1586  for (int n = 0; n < sessionFileNames.count (); ++n)
1587  {
1588  QFileInfo file = QFileInfo (sessionFileNames.at (n));
1589  if (file.exists ())
1590  request_open_file (sessionFileNames.at (n));
1591  }
1592  }
1593 
1594  check_actions ();
1595 }
1596 
1597 void
1599 {
1600  _tab_widget->addTab (f, fn);
1601 
1602  // signals from the qscintilla edit area
1603  connect (f->qsci_edit_area (), SIGNAL (status_update (bool, bool)),
1604  this, SLOT (edit_status_update (bool, bool)));
1605 
1606  connect (f->qsci_edit_area (), SIGNAL (show_doc_signal (const QString&)),
1607  main_win (), SLOT (handle_show_doc (const QString&)));
1608 
1609  connect (f->qsci_edit_area (), SIGNAL (create_context_menu_signal (QMenu *)),
1610  this, SLOT (create_context_menu (QMenu *)));
1611 
1612  connect (f->qsci_edit_area (), SIGNAL (execute_command_in_terminal_signal (const QString&)),
1613  main_win (), SLOT (execute_command_in_terminal (const QString&)));
1614 
1615  // Signals from the file editor_tab
1616  connect (f, SIGNAL (file_name_changed (const QString&, const QString&)),
1617  this, SLOT (handle_file_name_changed (const QString&,
1618  const QString&)));
1619 
1620  connect (f, SIGNAL (editor_state_changed (bool, bool)),
1621  this, SLOT (handle_editor_state_changed (bool, bool)));
1622 
1623  connect (f, SIGNAL (tab_remove_request ()),
1624  this, SLOT (handle_tab_remove_request ()));
1625 
1626  connect (f, SIGNAL (add_filename_to_list (const QString&, QWidget*)),
1627  this, SLOT (handle_add_filename_to_list (const QString&, QWidget*)));
1628 
1629  connect (f, SIGNAL (editor_check_conflict_save (const QString&, bool)),
1630  this, SLOT (check_conflict_save (const QString&, bool)));
1631 
1632  connect (f, SIGNAL (mru_add_file (const QString&)),
1633  this, SLOT (handle_mru_add_file (const QString&)));
1634 
1635  connect (f, SIGNAL (run_file_signal (const QFileInfo&)),
1636  main_win (), SLOT (run_file_in_terminal (const QFileInfo&)));
1637 
1638  connect (f, SIGNAL (request_open_file (const QString&)),
1639  this, SLOT (request_open_file (const QString&)));
1640 
1641  connect (f, SIGNAL (set_global_edit_shortcuts_signal (bool)),
1642  main_win (), SLOT (set_global_edit_shortcuts (bool)));
1643 
1644  // Signals from the file_editor non-trivial operations
1645  connect (this, SIGNAL (fetab_settings_changed (const QSettings *)),
1646  f, SLOT (notice_settings (const QSettings *)));
1647 
1648  connect (this, SIGNAL (fetab_change_request (const QWidget*)),
1649  f, SLOT (change_editor_state (const QWidget*)));
1650 
1651  connect (this, SIGNAL (fetab_file_name_query (const QWidget*)),
1652  f, SLOT (file_name_query (const QWidget*)));
1653 
1654  connect (this, SIGNAL (fetab_save_file (const QWidget*, const QString&,
1655  bool)),
1656  f, SLOT (save_file (const QWidget*, const QString&, bool)));
1657 
1658  connect (this, SIGNAL (fetab_check_modified_file (void)),
1659  f, SLOT (check_modified_file (void)));
1660 
1661  // Signals from the file_editor trivial operations
1662  connect (this, SIGNAL (fetab_set_directory (const QString&)),
1663  f, SLOT (set_current_directory (const QString&)));
1664 
1665  connect (this, SIGNAL (fetab_zoom_in (const QWidget*)),
1666  f, SLOT (zoom_in (const QWidget*)));
1667  connect (this, SIGNAL (fetab_zoom_out (const QWidget*)),
1668  f, SLOT (zoom_out (const QWidget*)));
1669  connect (this, SIGNAL (fetab_zoom_normal (const QWidget*)),
1670  f, SLOT (zoom_normal (const QWidget*)));
1671 
1672  connect (this, SIGNAL (fetab_context_help (const QWidget*, bool)),
1673  f, SLOT (context_help (const QWidget*, bool)));
1674 
1675  connect (this, SIGNAL (fetab_context_edit (const QWidget*)),
1676  f, SLOT (context_edit (const QWidget*)));
1677 
1678  connect (this, SIGNAL (fetab_save_file (const QWidget*)),
1679  f, SLOT (save_file (const QWidget*)));
1680 
1681  connect (this, SIGNAL (fetab_save_file_as (const QWidget*)),
1682  f, SLOT (save_file_as (const QWidget*)));
1683 
1684  connect (this, SIGNAL (fetab_print_file (const QWidget*)),
1685  f, SLOT (print_file (const QWidget*)));
1686 
1687  connect (this, SIGNAL (fetab_run_file (const QWidget*)),
1688  f, SLOT (run_file (const QWidget*)));
1689 
1690  connect (this, SIGNAL (fetab_context_run (const QWidget*)),
1691  f, SLOT (context_run (const QWidget*)));
1692 
1693  connect (this, SIGNAL (fetab_toggle_bookmark (const QWidget*)),
1694  f, SLOT (toggle_bookmark (const QWidget*)));
1695 
1696  connect (this, SIGNAL (fetab_next_bookmark (const QWidget*)),
1697  f, SLOT (next_bookmark (const QWidget*)));
1698 
1699  connect (this, SIGNAL (fetab_previous_bookmark (const QWidget*)),
1700  f, SLOT (previous_bookmark (const QWidget*)));
1701 
1702  connect (this, SIGNAL (fetab_remove_bookmark (const QWidget*)),
1703  f, SLOT (remove_bookmark (const QWidget*)));
1704 
1705  connect (this, SIGNAL (fetab_toggle_breakpoint (const QWidget*)),
1706  f, SLOT (toggle_breakpoint (const QWidget*)));
1707 
1708  connect (this, SIGNAL (fetab_next_breakpoint (const QWidget*)),
1709  f, SLOT (next_breakpoint (const QWidget*)));
1710 
1711  connect (this, SIGNAL (fetab_previous_breakpoint (const QWidget*)),
1712  f, SLOT (previous_breakpoint (const QWidget*)));
1713 
1714  connect (this, SIGNAL (fetab_remove_all_breakpoints (const QWidget*)),
1715  f, SLOT (remove_all_breakpoints (const QWidget*)));
1716 
1717  connect (this, SIGNAL (fetab_scintilla_command (const QWidget *, unsigned int)),
1718  f, SLOT (scintilla_command (const QWidget *, unsigned int)));
1719 
1720  connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*)),
1721  f, SLOT (comment_selected_text (const QWidget*)));
1722 
1723  connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*)),
1724  f, SLOT (uncomment_selected_text (const QWidget*)));
1725 
1726  connect (this, SIGNAL (fetab_indent_selected_text (const QWidget*)),
1727  f, SLOT (indent_selected_text (const QWidget*)));
1728 
1729  connect (this, SIGNAL (fetab_unindent_selected_text (const QWidget*)),
1730  f, SLOT (unindent_selected_text (const QWidget*)));
1731 
1732  connect (this, SIGNAL (fetab_convert_eol (const QWidget*, QsciScintilla::EolMode)),
1733  f, SLOT (convert_eol (const QWidget*, QsciScintilla::EolMode)));
1734 
1735  connect (this, SIGNAL (fetab_find (const QWidget*)),
1736  f, SLOT (find (const QWidget*)));
1737 
1738  connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)),
1739  f, SLOT (goto_line (const QWidget*, int)));
1740 
1741  connect (this, SIGNAL (fetab_move_match_brace (const QWidget*, bool)),
1742  f, SLOT (move_match_brace (const QWidget*, bool)));
1743 
1744  connect (this, SIGNAL (fetab_completion (const QWidget*)),
1745  f, SLOT (show_auto_completion (const QWidget*)));
1746 
1747  connect (this, SIGNAL (fetab_set_focus (const QWidget*)),
1748  f, SLOT (set_focus (const QWidget*)));
1749 
1750  connect (this, SIGNAL (fetab_insert_debugger_pointer (const QWidget*, int)),
1751  f, SLOT (insert_debugger_pointer (const QWidget*, int)));
1752 
1753  connect (this, SIGNAL (fetab_delete_debugger_pointer (const QWidget*, int)),
1754  f, SLOT (delete_debugger_pointer (const QWidget*, int)));
1755 
1756  connect (this, SIGNAL (fetab_do_breakpoint_marker (bool, const QWidget*,
1757  int)),
1758  f, SLOT (do_breakpoint_marker (bool, const QWidget*, int)));
1759 
1760  _tab_widget->setCurrentWidget (f);
1761 
1762  check_actions ();
1763 }
1764 
1765 bool
1767 {
1768  QWidget * foc_w = focusWidget ();
1769  if (foc_w && foc_w->inherits ("octave_qscintilla"))
1770  return true;
1771  return false;
1772 }
1773 
1774 void
1776 {
1777  if (editor_tab_has_focus ())
1778  request_copy (true);
1779 }
1780 void
1782 {
1783  if (editor_tab_has_focus ())
1784  request_paste (true);
1785 }
1786 void
1788 {
1789  if (editor_tab_has_focus ())
1790  request_selectall (true);
1791 }
1792 
1793 void
1795 {
1796  if (editor_tab_has_focus ())
1797  request_undo (true);
1798 }
1799 
1800 void
1802 {
1803  // File menu
1804  shortcut_manager::set_shortcut (_edit_function_action, "editor_file:edit_function");
1805  shortcut_manager::set_shortcut (_save_action, "editor_file:save");
1806  shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as");
1807  shortcut_manager::set_shortcut (_close_action, "editor_file:close");
1808  shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all");
1809  shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other");
1810  shortcut_manager::set_shortcut (_print_action, "editor_file:print");
1811 
1812  // Edit menu
1813  shortcut_manager::set_shortcut (_undo_action, "editor_edit:undo");
1814  shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo");
1815  shortcut_manager::set_shortcut (_copy_action, "editor_edit:copy");
1816  shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut");
1817  shortcut_manager::set_shortcut (_paste_action, "editor_edit:paste");
1818  shortcut_manager::set_shortcut (_selectall_action, "editor_edit:select_all");
1819  shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace");
1820 
1821  shortcut_manager::set_shortcut (_delete_start_word_action, "editor_edit:delete_start_word");
1822  shortcut_manager::set_shortcut (_delete_end_word_action, "editor_edit:delete_end_word");
1823  shortcut_manager::set_shortcut (_delete_start_line_action, "editor_edit:delete_start_line");
1824  shortcut_manager::set_shortcut (_delete_end_line_action, "editor_edit:delete_end_line");
1825  shortcut_manager::set_shortcut (_delete_line_action, "editor_edit:delete_line");
1826  shortcut_manager::set_shortcut (_copy_line_action, "editor_edit:copy_line");
1827  shortcut_manager::set_shortcut (_cut_line_action, "editor_edit:cut_line");
1828  shortcut_manager::set_shortcut (_duplicate_selection_action, "editor_edit:duplicate_selection");
1829  shortcut_manager::set_shortcut (_transpose_line_action, "editor_edit:transpose_line");
1830  shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection");
1831  shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection");
1832 
1833  shortcut_manager::set_shortcut (_upper_case_action, "editor_edit:upper_case");
1834  shortcut_manager::set_shortcut (_lower_case_action, "editor_edit:lower_case");
1835  shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection");
1836  shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection");
1837  shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list");
1838  shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line");
1839  shortcut_manager::set_shortcut (_move_to_matching_brace, "editor_edit:move_to_brace");
1840  shortcut_manager::set_shortcut (_sel_to_matching_brace, "editor_edit:select_to_brace");
1841  shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark");
1842  shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark");
1843  shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark");
1844  shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark");
1845  shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences");
1846  shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences");
1847 
1848  shortcut_manager::set_shortcut (_conv_eol_windows_action, "editor_edit:conv_eol_winows");
1849  shortcut_manager::set_shortcut (_conv_eol_unix_action, "editor_edit:conv_eol_unix");
1850  shortcut_manager::set_shortcut (_conv_eol_mac_action, "editor_edit:conv_eol_mac");
1851 
1852  // View menu
1853  shortcut_manager::set_shortcut (_show_linenum_action, "editor_view:show_line_numbers");
1854  shortcut_manager::set_shortcut (_show_whitespace_action, "editor_view:show_white_spaces");
1855  shortcut_manager::set_shortcut (_show_eol_action, "editor_view:show_eol_chars");
1856  shortcut_manager::set_shortcut (_show_indguide_action, "editor_view:show_ind_guides");
1857  shortcut_manager::set_shortcut (_show_longline_action, "editor_view:show_long_line");
1858  shortcut_manager::set_shortcut (_zoom_in_action, "editor_view:zoom_in");
1859  shortcut_manager::set_shortcut (_zoom_out_action, "editor_view:zoom_out");
1860  shortcut_manager::set_shortcut (_zoom_normal_action, "editor_view:zoom_normal");
1861 
1862  // Debug menu
1863  shortcut_manager::set_shortcut (_toggle_breakpoint_action, "editor_debug:toggle_breakpoint");
1864  shortcut_manager::set_shortcut (_next_breakpoint_action, "editor_debug:next_breakpoint");
1865  shortcut_manager::set_shortcut (_previous_breakpoint_action, "editor_debug:previous_breakpoint");
1866  shortcut_manager::set_shortcut (_remove_all_breakpoints_action, "editor_debug:remove_breakpoints");
1867 
1868  // Run menu
1869  shortcut_manager::set_shortcut (_run_action, "editor_run:run_file");
1870  shortcut_manager::set_shortcut (_run_selection_action, "editor_run:run_selection");
1871 
1872  // Help menu
1873  shortcut_manager::set_shortcut (_context_help_action, "editor_help:help_keyword");
1874  shortcut_manager::set_shortcut (_context_doc_action, "editor_help:doc_keyword");
1875 
1876 }
1877 
1878 void
1880 {
1881  bool have_tabs = _tab_widget->count () > 0;
1882 
1883  _edit_cmd_menu->setEnabled (have_tabs);
1884  _edit_fmt_menu->setEnabled (have_tabs);
1885  _edit_nav_menu->setEnabled (have_tabs);
1886 
1887  _comment_selection_action->setEnabled (have_tabs);
1888  _uncomment_selection_action->setEnabled (have_tabs);
1889  _indent_selection_action->setEnabled (have_tabs);
1890  _unindent_selection_action->setEnabled (have_tabs);
1891 
1892  _paste_action->setEnabled (have_tabs);
1893  _context_help_action->setEnabled (have_tabs);
1894  _context_doc_action->setEnabled (have_tabs);
1895 
1896  _view_editor_menu->setEnabled (have_tabs);
1897  _zoom_in_action->setEnabled (have_tabs);
1898  _zoom_out_action->setEnabled (have_tabs);
1899  _zoom_normal_action->setEnabled (have_tabs);
1900 
1901  _find_action->setEnabled (have_tabs);
1902  _print_action->setEnabled (have_tabs);
1903  _run_action->setEnabled (have_tabs);
1904 
1905  _edit_function_action->setEnabled (have_tabs);
1906  _save_action->setEnabled (have_tabs);
1907  _save_as_action->setEnabled (have_tabs);
1908  _close_action->setEnabled (have_tabs);
1909  _close_all_action->setEnabled (have_tabs);
1910  _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1);
1911 
1912  _selectall_action->setEnabled (have_tabs);
1913 }
1914 
1915 // empty_script determines whether we have to create an empty script
1916 // 1. At startup, when the editor has to be (really) visible
1917 // (Here we can not use the visibility changed signal)
1918 // 2. When the editor becomes visible when octave is running
1919 void
1920 file_editor::empty_script (bool startup, bool visible)
1921 {
1922  QSettings *settings = resource_manager::get_settings ();
1923  if (settings->value ("useCustomFileEditor",false).toBool ())
1924  return; // do not open an empty script in the external editor
1925 
1926  bool real_visible;
1927 
1928  if (startup)
1929  real_visible = isVisible ();
1930  else
1931  real_visible = visible;
1932 
1933  if (! real_visible || _tab_widget->count () > 0)
1934  return;
1935 
1936  if (startup && ! isFloating ())
1937  {
1938  // check is editor is really visible or hidden between tabbed widgets
1939  QList<QTabBar *> tab_list = main_win ()->findChildren<QTabBar *>();
1940 
1941  bool in_tab = false;
1942  int i = 0;
1943  while ((i < tab_list.count ()) && (! in_tab))
1944  {
1945  QTabBar *tab = tab_list.at (i);
1946  i++;
1947 
1948  int j = 0;
1949  while ((j < tab->count ()) && (! in_tab))
1950  {
1951  // check all tabs for the editor
1952  if (tab->tabText (j) == windowTitle ())
1953  {
1954  // editor is in this tab widget
1955  in_tab = true;
1956  int top = tab->currentIndex ();
1957  if (top > -1 && tab->tabText (top) == windowTitle ())
1958  real_visible = true; // and is the current tab
1959  else
1960  return; // not current tab -> not visible
1961  }
1962  j++;
1963  }
1964  }
1965  }
1966 
1967  request_new_file ("");
1968 }
1969 
1970 // This slot is a reimplementation of the virtual slot in octave_dock_widget.
1971 // We need this for creating an empty script when the editor has no open files
1972 // and is made visible
1973 void
1974 file_editor::handle_visibility (bool visible)
1975  {
1976  empty_script (false, visible);
1977 
1978  if (visible && ! isFloating ())
1979  focus ();
1980  }
1981 
1982 void
1983 file_editor::dragEnterEvent (QDragEnterEvent *e)
1984  {
1985  if (e->mimeData ()->hasUrls ())
1986  {
1987  e->acceptProposedAction();
1988  }
1989  }
1990 
1991 void
1992 file_editor::dropEvent (QDropEvent *e)
1993  {
1994  if (e->mimeData ()->hasUrls ())
1995  {
1996  foreach (QUrl url, e->mimeData ()->urls ())
1997  {
1998  request_open_file (url.toLocalFile ());
1999  }
2000  }
2001  }
2002 
2003 #endif
QAction * _delete_end_line_action
Definition: file-editor.h:306
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)
void dragEnterEvent(QDragEnterEvent *event)
QMenu * _edit_nav_menu
Definition: file-editor.h:348
QAction * _redo_action
Definition: file-editor.h:335
void request_close_file(bool)
void request_delete_start_word(bool)
void update_window_title(bool modified)
QMenuBar * _menu_bar
Definition: file-editor.h:269
QAction * _print_action
Definition: file-editor.h:324
void request_save_file_as(bool)
QAction * _toggle_bookmark_action
Definition: file-editor.h:321
~file_editor(void)
bool same_file(const std::string &f, const std::string &g)
Definition: utils.cc:133
void request_delete_start_line(bool)
void fetab_context_run(const QWidget *ID)
void set_shortcuts()
QAction * _show_eol_action
Definition: file-editor.h:296
QAction * _delete_start_word_action
Definition: file-editor.h:303
QAction * _remove_all_breakpoints_action
Definition: file-editor.h:344
void fetab_run_file(const QWidget *ID)
QAction * _goto_line_action
Definition: file-editor.h:314
void request_uncomment_selected_text(bool)
QAction * _next_bookmark_action
Definition: file-editor.h:319
QAction * _sel_to_matching_brace
Definition: file-editor.h:318
void request_selectall(bool)
QAction * _delete_line_action
Definition: file-editor.h:307
void request_delete_line(bool)
void show_white_space(bool)
void fetab_context_edit(const QWidget *ID)
void do_undo()
void fetab_find(const QWidget *ID)
void restore_create_file_setting()
bool is_editor_console_tabbed()
void request_new_file(const QString &commands)
void handle_edit_file_request(const QString &file)
void handle_enter_debug_mode(void)
void fetab_change_request(const QWidget *ID)
void request_duplicate_selection(bool)
void zoom_out(bool)
void fetab_completion(const QWidget *)
void request_indent_selected_text(bool)
void pasteClipboard()
void request_unindent_selected_text(bool)
void fetab_unindent_selected_text(const QWidget *ID)
QAction * _copy_action
Definition: file-editor.h:287
void update_octave_directory(const QString &dir)
QAction * _conv_eol_windows_action
Definition: file-editor.h:283
bool editor_tab_has_focus()
QAction * _conv_eol_unix_action
Definition: file-editor.h:284
QAction * _delete_start_line_action
Definition: file-editor.h:305
QAction * _context_doc_action
Definition: file-editor.h:292
QAction * _delete_end_word_action
Definition: file-editor.h:304
void set_title(const QString &)
QAction * _undo_action
Definition: file-editor.h:336
void request_new_function(bool triggered=true)
QToolBar * _tool_bar
Definition: file-editor.h:270
void request_delete_end_word(bool)
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)
void handle_add_filename_to_list(const QString &fileName, QWidget *ID)
void fetab_toggle_bookmark(const QWidget *ID)
QAction * _previous_bookmark_action
Definition: file-editor.h:320
void request_comment_selected_text(bool)
void request_conv_eol_unix(bool)
QAction * _save_action
Definition: file-editor.h:329
void request_completion(bool)
void fetab_zoom_in(const QWidget *ID)
void request_next_breakpoint(bool)
void focus(void)
QAction * _conv_eol_mac_action
Definition: file-editor.h:285
QMenu * _fileMenu
Definition: file-editor.h:349
QAction * _show_whitespace_action
Definition: file-editor.h:295
bool call_custom_editor(const QString &file_name=QString(), int line=-1)
void show_indent_guides(bool)
QAction * _selectall_action
Definition: file-editor.h:290
QAction * _close_all_action
Definition: file-editor.h:332
void fetab_move_match_brace(const QWidget *ID, bool select)
QAction * _indent_selection_action
Definition: file-editor.h:281
void fetab_uncomment_selected_text(const QWidget *ID)
void check_actions(void)
void request_upper_case(bool)
QAction * _paste_action
Definition: file-editor.h:289
std::map< QString, QWidget * >::const_iterator editor_tab_map_const_iterator
Definition: file-editor.h:49
QAction * _close_others_action
Definition: file-editor.h:333
void empty_script(bool startup, bool visible)
QAction * _show_linenum_action
Definition: file-editor.h:294
QAction * _cut_action
Definition: file-editor.h:288
void handle_update_breakpoint_marker_request(bool insert, const QString &file, int line)
QAction * _move_to_matching_brace
Definition: file-editor.h:317
QAction * add_action(QMenu *menu, const QIcon &icon, const QString &text, const char *member)
void fetab_context_help(const QWidget *ID, bool)
QMenu * _edit_cmd_menu
Definition: file-editor.h:346
void fetab_remove_bookmark(const QWidget *ID)
void handle_insert_debugger_pointer_request(const QString &file, int line)
QAction * _show_longline_action
Definition: file-editor.h:298
QAction * _edit_function_action
Definition: file-editor.h:328
void fetab_save_file_as(const QWidget *ID)
void execute_command_in_terminal_signal(const QString &)
void request_remove_breakpoint(bool)
void request_mru_open_file(QAction *action)
QAction * _run_action
Definition: file-editor.h:325
void fetab_zoom_out(const QWidget *ID)
F77_RET_T const double const double * f
void fetab_convert_eol(const QWidget *ID, QsciScintilla::EolMode eol_mode)
QAction * _cut_line_action
Definition: file-editor.h:309
void fetab_indent_selected_text(const QWidget *ID)
octave_qscintilla * qsci_edit_area()
QAction * _previous_breakpoint_action
Definition: file-editor.h:343
void enable_menu_shortcuts(bool)
QString ced
Definition: file-editor.h:267
void request_styles_preferences(bool)
QAction * _show_indguide_action
Definition: file-editor.h:297
void fetab_next_breakpoint(const QWidget *ID)
void request_delete_end_line(bool)
void request_context_doc(bool)
void copyClipboard()
QMainWindow * main_win()
std::complex< double > w(std::complex< double > z, double relerr=0)
void request_context_edit(bool)
void request_cut(bool)
QAction * _context_help_action
Definition: file-editor.h:291
QAction * _lower_case_action
Definition: file-editor.h:278
QAction * _styles_preferences_action
Definition: file-editor.h:339
QAction * _preferences_action
Definition: file-editor.h:338
void request_next_bookmark(bool)
QAction * _duplicate_selection_action
Definition: file-editor.h:310
bool check_closing(void)
void file_loaded_signal()
QAction * _zoom_normal_action
Definition: file-editor.h:301
QAction * _uncomment_selection_action
Definition: file-editor.h:280
void fetab_zoom_normal(const QWidget *ID)
void check_conflict_save(const QString &fileName, bool remove_on_success)
void request_goto_line(bool)
void show_long_line(bool)
void insert_new_open_actions(QAction *, QAction *, QAction *)
void selectAll()
QAction * _completion_action
Definition: file-editor.h:315
void handle_tab_remove_request(void)
void request_open_files(const QStringList &)
QHash< QMenu *, QStringList > _hash_menu_text
Definition: file-editor.h:265
QAction * _transpose_line_action
Definition: file-editor.h:311
void toggle_preference(const QString &preference, bool def)
void fetab_next_bookmark(const QWidget *ID)
QAction * _unindent_selection_action
Definition: file-editor.h:282
void request_copy(bool)
void request_conv_eol_windows(bool)
QToolBar * toolbar(void)
void request_paste(bool)
void fetab_check_modified_file(void)
void handle_editor_state_changed(bool enableCopy, bool is_octave_file)
QAction * _close_action
Definition: file-editor.h:331
void request_settings_dialog(const QString &)
static QSettings * get_settings(void)
void request_context_run(bool)
void fetab_settings_changed(const QSettings *settings)
QAction * _next_breakpoint_action
Definition: file-editor.h:342
void handle_exit_debug_mode(void)
QMenu * _mru_file_menu
Definition: file-editor.h:357
void mru_menu_update(void)
void fetab_file_name_query(const QWidget *ID)
void show_eol_chars(bool)
QMenu * debug_menu(void)
void handle_tab_close_request(int index)
double arg(double x)
Definition: lo-mappers.h:37
void notice_settings(const QSettings *settings)
QAction * _save_as_action
Definition: file-editor.h:330
void request_cut_line(bool)
static octave_idx_type find(octave_idx_type i, octave_idx_type *pp)
Definition: colamd.cc:111
void request_previous_breakpoint(bool)
void handle_delete_debugger_pointer_request(const QString &file, int line)
void request_context_help(bool)
void request_toggle_breakpoint(bool)
void request_remove_bookmark(bool)
void request_sel_match_brace(bool)
void request_run_file(bool)
QStringList _mru_files
Definition: file-editor.h:359
static bool was_cancelled(void)
void fetab_print_file(const QWidget *ID)
QMenu * _edit_fmt_menu
Definition: file-editor.h:347
QTabWidget * _tab_widget
Definition: file-editor.h:352
void handle_mru_add_file(const QString &file_name)
void request_conv_eol_mac(bool)
void request_open_file(void)
void request_new_script(const QString &commands)
QMenu * m_add_menu(QMenuBar *p, QString text)
void create_context_menu(QMenu *)
void request_move_match_brace(bool)
QAction * _find_action
Definition: file-editor.h:313
void request_close_other_files(bool)
void zoom_normal(bool)
void zoom_in(bool)
void fetab_comment_selected_text(const QWidget *ID)
QWidget * find_tab_widget(const QString &openFileName) const
void edit_status_update(bool, bool)
void request_redo(bool)
void fetab_set_directory(const QString &dir)
QList< octave_dock_widget * > get_dock_widget_list()
Definition: main-window.h:224
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)
QAction * _mru_file_actions[MaxMRUFiles]
Definition: file-editor.h:358
QAction * _upper_case_action
Definition: file-editor.h:277
QAction * _toggle_breakpoint_action
Definition: file-editor.h:341
void handle_visibility(bool visible)
void request_copy_line(bool)
QString load_file(const QString &fileName)
QMenu * _debug_menu
Definition: file-editor.h:271
QAction * _run_selection_action
Definition: file-editor.h:326
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:299
void handle_file_name_changed(const QString &fileName, const QString &toolTip)
static void reset_cancel(void)
void request_previous_bookmark(bool)
void request_close_all_files(bool)
QAction * _copy_line_action
Definition: file-editor.h:308
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)
void fetab_do_breakpoint_marker(bool insert, const QWidget *ID, int line=-1)
QAction * _remove_bookmark_action
Definition: file-editor.h:322
QAction * _comment_selection_action
Definition: file-editor.h:279
QAction * _zoom_out_action
Definition: file-editor.h:300
void save_file_as(QWidget *fetabID=0)
void dropEvent(QDropEvent *event)
std::map< QString, QWidget * > editor_tab_map
Definition: file-editor.h:264
void request_lower_case(bool)
virtual void focus(void)
file_editor(QWidget *p)
void request_toggle_bookmark(bool)
static void set_shortcut(QAction *action, const QString &key)
void request_transpose_line(bool)
void new_file(const QString &commands=QString())
void request_undo(bool)
QMenu * _view_editor_menu
Definition: file-editor.h:350
void fetab_previous_bookmark(const QWidget *ID)
void show_line_numbers(bool)