changeset 19479:86f50893acd8

maint: Periodic merge of gui-release to default.
author John W. Eaton <jwe@octave.org>
date Tue, 28 Oct 2014 13:58:01 -0400
parents e1713e281ac5 (current diff) 0e077a29854f (diff)
children 93a33123fcfe
files libinterp/parse-tree/lex.ll
diffstat 4 files changed, 34 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc
+++ b/libgui/src/m-editor/file-editor-tab.cc
@@ -1577,10 +1577,22 @@
   // and add the extra grid layout to the dialog's layout
   dialog_layout->addLayout (extra,rows,0,1,dialog_layout->columnCount ());
 
+  // add the possible filters and the default suffix
+  QStringList filters;
+  filters << tr ("Octave Files (*.m)")
+          << tr ("All Files (*)");
+  fileDialog->setNameFilters (filters);
+  fileDialog->setDefaultSuffix ("m");
 
   if (valid_file_name ())
     {
       fileDialog->selectFile (_file_name);
+      QFileInfo file_info (_file_name);
+      if (file_info.suffix () != "m")
+        { // it is not an octave file
+          fileDialog->selectNameFilter (filters.at (1));  // "All Files"
+          fileDialog->setDefaultSuffix ("");              // no default suffix
+        }
     }
   else
     {
@@ -1601,11 +1613,12 @@
         fileDialog->selectFile (fname + ".m");
     }
 
-  fileDialog->setNameFilter (tr ("Octave Files (*.m);;All Files (*)"));
-  fileDialog->setDefaultSuffix ("m");
   fileDialog->setAcceptMode (QFileDialog::AcceptSave);
   fileDialog->setViewMode (QFileDialog::Detail);
 
+  connect (fileDialog, SIGNAL (filterSelected (const QString&)),
+           this, SLOT (handle_save_as_filter_selected (const QString&)));
+
   if (remove_on_success)
     {
       connect (fileDialog, SIGNAL (fileSelected (const QString&)),
@@ -1629,6 +1642,20 @@
   _save_as_desired_eol = static_cast<QsciScintilla::EolMode> (index);
 }
 
+void
+file_editor_tab::handle_save_as_filter_selected (const QString& filter)
+{
+  QFileDialog *file_dialog = qobject_cast<QFileDialog *> (sender ());
+
+  QRegExp rx ("\\*\\.([^ ^\\)]*)[ \\)]");   // regexp for suffix in filter
+  int index = rx.indexIn (filter,0);        // get first suffix in filter
+
+  if (index > -1)
+    file_dialog->setDefaultSuffix (rx.cap (1)); // found a suffix, set default
+  else
+    file_dialog->setDefaultSuffix ("");         // not found, clear default
+}
+
 bool
 file_editor_tab::check_valid_identifier (QString file_name)
 {
--- a/libgui/src/m-editor/file-editor-tab.h
+++ b/libgui/src/m-editor/file-editor-tab.h
@@ -162,6 +162,7 @@
   void handle_save_file_as_answer (const QString& fileName);
   void handle_save_file_as_answer_close (const QString& fileName);
   void handle_save_file_as_answer_cancel ();
+  void handle_save_as_filter_selected (const QString& filter);
   void handle_combo_eol_current_index (int index);
 
   // When apis preparation has finished and is ready to save
--- a/libinterp/parse-tree/lex.ll
+++ b/libinterp/parse-tree/lex.ll
@@ -169,7 +169,8 @@
     { \
       curr_lexer->lexer_debug (PATTERN); \
  \
-      if (curr_lexer->previous_token_may_be_command ()) \
+      if (curr_lexer->previous_token_may_be_command () \
+          && curr_lexer->space_follows_previous_token ()) \
         { \
           yyless (0); \
           curr_lexer->push_start_state (COMMAND_START); \
--- a/scripts/plot/draw/private/__bar__.m
+++ b/scripts/plot/draw/private/__bar__.m
@@ -437,6 +437,8 @@
       ydat = get (hlist, "ydata");
       if (iscell (ydat))
         y = cell2mat (ydat.');
+      elseif (isvector (ydat))
+        y = ydat(:);
       else
         y = ydat;
       endif