diff libgui/src/m-editor/file-editor-tab.cc @ 18949:095fdef3d67c gui-release

use editors run selection action for the context menu * file-editor-tab.cc (constructor): initialize flag for octave file; (update_lexer): set flag for octave file; (set_file_name, handle_copy_available, change_editor_state): editor_state_changed signal uses flag for octave file; * file-editor-tab.h: flag for octave file, also used in editor_state_changed * file-editor.cc (create_context_menu): add action for running selection; (handle_editor_state_changed): gets flag whether file is an octave script, enable run action and run selection action depending on selection and file type; (add_file_editor_tab): connect editor_state_changed to handle_editor_state_changedwith new third parameter; * file-editor.h: handle_editor_state_changed has a new third parameter * octave-qscintilla.cc (contextMenuEvent): run selection is added by the edtior
author Torsten <ttl@justmail.de>
date Fri, 16 May 2014 20:01:27 +0200
parents f6f1f27026bb
children 6504a1932637
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc
+++ b/libgui/src/m-editor/file-editor-tab.cc
@@ -66,6 +66,7 @@
   QString directory = directory_arg;
   _lexer_apis = 0;
   _app_closing = false;
+  _is_octave_file = true;
 
   // Make sure there is a slash at the end of the directory name
   // for identification when saved later.
@@ -84,7 +85,7 @@
            this,
            SLOT (execute_command_in_terminal (const QString&)));
 
-  connect (_edit_area, 
+  connect (_edit_area,
            SIGNAL (cursorPositionChanged (int, int)),
            this,
            SLOT (handle_cursor_moved (int,int)));
@@ -215,9 +216,9 @@
   update_lexer ();
 
   // update the file editor with current editing directory
-  emit editor_state_changed (_copy_available, _file_name);
+  emit editor_state_changed (_copy_available, _file_name, _is_octave_file);
+
   // add the new file to the mru list
-
   emit mru_add_file (_file_name);
 }
 
@@ -270,6 +271,8 @@
   delete lexer;
   lexer = 0;
 
+  _is_octave_file = false;
+
   if (_file_name.endsWith (".m")
       || _file_name.endsWith ("octaverc"))
     {
@@ -278,6 +281,7 @@
 #elif defined (HAVE_LEXER_MATLAB)
       lexer = new QsciLexerMatlab ();
 #endif
+      _is_octave_file = true;
     }
 
   if (! lexer)
@@ -311,8 +315,10 @@
           // new, no yet named file: let us assume it is octave
 #if defined (HAVE_LEXER_OCTAVE)
           lexer = new QsciLexerOctave ();
+          _is_octave_file = true;
 #elif defined (HAVE_LEXER_MATLAB)
           lexer = new QsciLexerMatlab ();
+          _is_octave_file = true;
 #else
           lexer = new QsciLexerBash ();
 #endif
@@ -975,7 +981,8 @@
 file_editor_tab::handle_copy_available (bool enableCopy)
 {
   _copy_available = enableCopy;
-  emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name));
+  emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name),
+                             _is_octave_file);
 }
 
 // show_dialog: shows a modal or non modal dialog depeding on the closing
@@ -1510,7 +1517,8 @@
       _find_dialog->show ();
     }
 
-  emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name));
+  emit editor_state_changed (_copy_available, QDir::cleanPath (_file_name),
+                             _is_octave_file);
 }
 
 void