Mercurial > hg > octave-nkf
changeset 19270:dbe9a11f5dcb
maint: Periodic merge of gui-release to default.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 10 Sep 2014 14:19:58 -0400 |
parents | 429ed2f2e8c6 (current diff) 9254ff4036b2 (diff) |
children | ba442cd7f7c3 |
files | doc/interpreter/plot.txi libgui/src/m-editor/octave-qscintilla.cc libgui/src/settings-dialog.cc liboctave/array/Sparse.cc scripts/plot/util/print.m |
diffstat | 11 files changed, 197 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/interpreter/plot.txi +++ b/doc/interpreter/plot.txi @@ -594,20 +594,26 @@ @subsection Use of the @code{interpreter} Property All text objects---such as titles, labels, legends, and text---include -the property @qcode{"interpreter"}, this property determines the manner in -which special control sequences in the text are rendered. If the interpreter -is set to @qcode{"none"}, then no rendering occurs. Currently the -@qcode{"latex"} interpreter is not implemented and is equivalent to -@qcode{"none"}. +the property @qcode{"interpreter"} that determines the manner in +which special control sequences in the text are rendered. + +The interpreter property can take three values: @qcode{"none"}, @qcode{"tex"}, +@qcode{"latex"}. If the interpreter is set to @qcode{"none"} then no special +rendering occurs---the displayed text is a verbatim copy of the specified text. +Currently, the @qcode{"latex"} interpreter is not implemented and is equivalent +to @qcode{"none"}. The @qcode{"tex"} option implements a subset of @TeX{} functionality when rendering text. This allows the insertion of special glyphs such as Greek -characters or mathematical symbols. The special characters are inserted with -a code following a backslash (\) character, as in the table -@ref{tab:extended}. - -In addition, the formatting of the text can be changed within the string -by using the codes +characters or mathematical symbols. The special characters are inserted with a +code following a backslash (\) character, as shown in @ref{tab:extended}. + +Note that for on-screen display the interpreter property is honored by all +graphics toolkits. However for printing, @strong{only} the @qcode{"gnuplot"} +toolkit renders @TeX{} instructions. + +Besides special glyphs, the formatting of text can be changed within the +string by using the codes @multitable @columnfractions .2 .2 .6 .2 @item @tab \bf @tab Bold font @tab @@ -616,8 +622,8 @@ @item @tab \rm @tab Normal font @tab @end multitable -These may be used in conjunction with the @{ and @} characters to limit -the change in the font to part of the string. For example, +These codes may be used in conjunction with the @{ and @} characters to limit +the change to just a part of the string. For example, @example xlabel ('@{\bf H@} = a @{\bf V@}') @@ -931,6 +937,13 @@ saves the current figure to an encapsulated PostScript file called @file{foo.eps}. +The different graphic toolkits have different print capabilities. In +particular, the OpenGL based toolkits such as @code{fltk} do not support +the @qcode{"interpreter"} property of text objects. This means special +symbols drawn with the @qcode{"tex"} interpreter will appear correctly +on-screen but will be rendered with interpreter @qcode{"none"} when printing. +Switch graphics toolkits for printing if this is a concern. + @DOCSTRING(print) @DOCSTRING(saveas)
--- a/libgui/src/m-editor/file-editor-tab.cc +++ b/libgui/src/m-editor/file-editor-tab.cc @@ -60,6 +60,7 @@ #include "version.h" #include "utils.h" #include "defaults.h" +#include <oct-map.h> // Make parent null for the file editor tab so that warning // WindowModal messages don't affect grandparents. @@ -95,6 +96,8 @@ connect (_edit_area, SIGNAL (create_context_menu_signal (QMenu*)), this, SLOT (create_context_menu (QMenu*))); + connect (_edit_area, SIGNAL (context_menu_edit_signal (const QString&)), + this, SLOT (handle_context_menu_edit (const QString&))); // create statusbar for row/col indicator _status_bar = new QStatusBar (this); @@ -205,6 +208,108 @@ } void +file_editor_tab::handle_context_menu_edit (const QString& word_at_cursor) +{ + // search for a subfunction in actual file (this is done at first because + // octave finds this function before other with same name in the search path + QRegExp rxfun1 ("^[\t ]*function[^=]+=[\t ]*" + + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$"); + QRegExp rxfun2 ("^[\t ]*function[\t ]+" + + word_at_cursor + "[\t ]*\\([^\\)]*\\)[\t ]*$"); + QRegExp rxfun3 ("^[\t ]*function[\t ]+" + + word_at_cursor + "[\t ]*$"); + QRegExp rxfun4 ("^[\t ]*function[^=]+=[\t ]*" + + word_at_cursor + "[\t ]*$"); + + int pos_fct = -1; + QStringList lines = _edit_area->text ().split ("\n"); + + int line; + for (line = 0; line < lines.count (); line++) + { + if ((pos_fct = rxfun1.indexIn (lines.at (line))) != -1) + break; + if ((pos_fct = rxfun2.indexIn (lines.at (line))) != -1) + break; + if ((pos_fct = rxfun3.indexIn (lines.at (line))) != -1) + break; + if ((pos_fct = rxfun4.indexIn (lines.at (line))) != -1) + break; + } + + if (pos_fct > -1) + { // reg expr. found: it is an internal function + _edit_area->setCursorPosition (line, pos_fct); + _edit_area->SendScintilla (2613, line); // SCI_SETFIRSTVISIBLELINE + return; + } + + // Is it a regular function within the search path? (Call __which__) + octave_value_list fct = F__which__ (ovl (word_at_cursor.toStdString ()),0); + octave_map map = fct(0).map_value (); + + QString type = QString::fromStdString ( + map.contents ("type").data ()[0].string_value ()); + QString name = QString::fromStdString ( + map.contents ("name").data ()[0].string_value ()); + + QString message = QString (); + QString filename = QString (); + + if (type == QString("built-in function")) + { // built in function: can't edit + message = tr ("%1 is a built-in function"); + } + else if (type.isEmpty ()) + { + // function not known to octave -> try directory of edited file + QFileInfo file = QFileInfo (_file_name); + file = QFileInfo (QDir (file.canonicalPath ()), word_at_cursor + ".m"); + + if (file.exists ()) + { + filename = file.canonicalFilePath (); // local file exists + } + else + { // local file does not exist -> try private directory + file = QFileInfo (_file_name); + file = QFileInfo (QDir (file.canonicalPath () + "/private"), + word_at_cursor + ".m"); + + if (file.exists ()) + { + filename = file.canonicalFilePath (); // private function exists + } + else + { + message = tr ("Can not find function %1"); // no file found + } + } + } + + if (! message.isEmpty ()) + { + QMessageBox *msgBox + = new QMessageBox (QMessageBox::Critical, + tr ("Octave Editor"), + message.arg (name), + QMessageBox::Ok, this); + + msgBox->setWindowModality (Qt::NonModal); + msgBox->setAttribute (Qt::WA_DeleteOnClose); + msgBox->show (); + return; + } + + if ( filename.isEmpty ()) + filename = QString::fromStdString ( + map.contents ("file").data ()[0].string_value ()); + + emit execute_command_in_terminal_signal (QString("edit ") + + "\""+filename+"\""); +} + +void file_editor_tab::set_file_name (const QString& fileName) { // update tracked file if we really have a file on disk @@ -1762,20 +1867,23 @@ QString file_editor_tab::get_function_name () { - QRegExp rxfun1 ("^([\t ]*)function([^=]+)=([^\\(]+)\\(([^\\)]*)\\)"); - QRegExp rxfun2 ("^([\t ]*)function([^\\(]+)\\(([^\\)]*)\\)"); - QRegExp rxfun3 ("^([\t ]*)function([\t ]*)([^\t ]+)"); + QRegExp rxfun1 ("^[\t ]*function[^=]+=([^\\(]+)\\([^\\)]*\\)[\t ]*$"); + QRegExp rxfun2 ("^[\t ]*function[\t ]+([^\\(]+)\\([^\\)]*\\)[\t ]*$"); + QRegExp rxfun3 ("^[\t ]*function[^=]+=[\t ]*([^\\s]+)[\t ]*$"); + QRegExp rxfun4 ("^[\t ]*function[\t ]+([^\\s]+)[\t ]*$"); QStringList lines = _edit_area->text ().split ("\n"); for (int i = 0; i < lines.count (); i++) { if (rxfun1.indexIn (lines.at (i)) != -1) - return rxfun1.cap (3).remove (QRegExp("[ \t]*")); + return rxfun1.cap (1).remove (QRegExp("[ \t]*")); else if (rxfun2.indexIn (lines.at (i)) != -1) - return rxfun2.cap (2).remove (QRegExp("[ \t]*")); + return rxfun2.cap (1).remove (QRegExp("[ \t]*")); else if (rxfun3.indexIn (lines.at (i)) != -1) - return rxfun3.cap (3).remove (QRegExp("[ \t]*")); + return rxfun3.cap (1).remove (QRegExp("[ \t]*")); + else if (rxfun4.indexIn (lines.at (i)) != -1) + return rxfun4.cap (1).remove (QRegExp("[ \t]*")); } return QString ();
--- a/libgui/src/m-editor/file-editor-tab.h +++ b/libgui/src/m-editor/file-editor-tab.h @@ -120,6 +120,7 @@ void execute_command_in_terminal (const QString& command); void edit_area_has_focus (bool foucs); void create_context_menu (QMenu *); + void handle_context_menu_edit (const QString&); signals:
--- a/libgui/src/m-editor/file-editor.cc +++ b/libgui/src/m-editor/file-editor.cc @@ -835,7 +835,7 @@ void file_editor::handle_mru_add_file (const QString& file_name) { - if (_mru_files.at (0) == file_name) + if (_mru_files.count () && _mru_files.at (0) == file_name) return; // the first entry is already the actual file name _mru_files.removeAll (file_name);
--- a/libgui/src/m-editor/octave-qscintilla.cc +++ b/libgui/src/m-editor/octave-qscintilla.cc @@ -31,6 +31,7 @@ #include <Qsci/qscilexer.h> #include <Qsci/qscicommandset.h> #include <QShortcut> +#include <QMessageBox> #include "octave-qscintilla.h" #include "file-editor-tab.h" @@ -265,7 +266,7 @@ void octave_qscintilla::contextmenu_edit (bool) { - emit execute_command_in_terminal_signal (QString("edit ") + _word_at_cursor); + emit context_menu_edit_signal (_word_at_cursor); } void
--- a/libgui/src/m-editor/octave-qscintilla.h +++ b/libgui/src/m-editor/octave-qscintilla.h @@ -51,6 +51,7 @@ void execute_command_in_terminal_signal (const QString&); void create_context_menu_signal (QMenu*); + void context_menu_edit_signal (const QString&); void qsci_has_focus_signal (bool); void status_update (bool,bool);
--- a/libgui/src/settings-dialog.cc +++ b/libgui/src/settings-dialog.cc @@ -281,8 +281,12 @@ ui->proxyUserName->setText (settings->value ("proxyUserName").toString ()); ui->proxyPassword->setText (settings->value ("proxyPassword").toString ()); - // qorkspace colors + // Workspace + // colors read_workspace_colors (settings); + // hide tool tips + ui->cb_hide_tool_tips->setChecked ( + settings->value ("workspaceview/hide_tool_tips",false).toBool ()); // terminal colors read_terminal_colors (settings); @@ -731,8 +735,13 @@ delete lexer; #endif + // Workspace write_workspace_colors (settings); + // hide tool tips + settings->setValue ("workspaceview/hide_tool_tips", + ui->cb_hide_tool_tips->isChecked ()); + // Terminal write_terminal_colors (settings); // shortcuts
--- a/libgui/src/settings-dialog.ui +++ b/libgui/src/settings-dialog.ui @@ -32,7 +32,7 @@ </size> </property> <property name="currentIndex"> - <number>1</number> + <number>5</number> </property> <widget class="QWidget" name="tab_general"> <property name="enabled"> @@ -404,7 +404,7 @@ <property name="geometry"> <rect> <x>0</x> - <y>-175</y> + <y>0</y> <width>662</width> <height>580</height> </rect> @@ -1659,8 +1659,11 @@ </property> <layout class="QVBoxLayout" name="verticalLayout_19"> <item> - <layout class="QVBoxLayout" name="verticalLayout_13"> - <item> + <layout class="QGridLayout" name="gridLayout_14"> + <property name="topMargin"> + <number>0</number> + </property> + <item row="0" column="0"> <widget class="QGroupBox" name="workspace_colors_box"> <property name="enabled"> <bool>true</bool> @@ -1682,16 +1685,10 @@ </property> </widget> </item> - <item> - <widget class="Line" name="line_8"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>1</height> - </size> - </property> - <property name="orientation"> - <enum>Qt::Horizontal</enum> + <item row="1" column="0"> + <widget class="QCheckBox" name="cb_hide_tool_tips"> + <property name="text"> + <string>Hide tool tip</string> </property> </widget> </item>
--- a/libgui/src/workspace-view.cc +++ b/libgui/src/workspace-view.cc @@ -257,16 +257,22 @@ _model->notice_settings (settings); // update colors of model first QString tool_tip; - tool_tip = QString (tr ("View the variables in the active workspace.<br>")); - tool_tip += QString (tr ("Colors for variable attributes:")); - for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) + + if (!settings->value ("workspaceview/hide_tool_tips",false).toBool ()) { - tool_tip += - QString ("<div style=\"background-color:%1;color:#000000\">%2</div>") - .arg (_model->storage_class_color (i).name ()) - .arg (resource_manager::storage_class_names ().at (i)); + tool_tip = QString (tr ("View the variables in the active workspace.<br>")); + tool_tip += QString (tr ("Colors for variable attributes:")); + for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) + { + tool_tip += + QString ("<div style=\"background-color:%1;color:#000000\">%2</div>") + .arg (_model->storage_class_color (i).name ()) + .arg (resource_manager::storage_class_names ().at (i)); + } } + setToolTip (tool_tip); + } void
--- a/liboctave/array/Sparse.cc +++ b/liboctave/array/Sparse.cc @@ -845,6 +845,10 @@ for (octave_idx_type j = cidx (i); j < cidx (i+1); j++) { octave_idx_type tmp = i * old_nr + ridx (j); + if (tmp < 0) + (*current_liboctave_error_handler) + ("reshape: overflow in octave_idx_type prevents reshaping array"); + octave_idx_type ii = tmp % new_nr; octave_idx_type jj = (tmp - ii) / new_nr; for (octave_idx_type k = kk; k < jj; k++)
--- a/scripts/time/datenum.m +++ b/scripts/time/datenum.m @@ -23,6 +23,7 @@ ## @deftypefnx {Function File} {@var{days} =} datenum (@var{year}, @var{month}, @var{day}, @var{hour}, @var{minute}) ## @deftypefnx {Function File} {@var{days} =} datenum (@var{year}, @var{month}, @var{day}, @var{hour}, @var{minute}, @var{second}) ## @deftypefnx {Function File} {@var{days} =} datenum ("datestr") +## @deftypefnx {Function File} {@var{days} =} datenum ("datestr", @var{f}) ## @deftypefnx {Function File} {@var{days} =} datenum ("datestr", @var{p}) ## @deftypefnx {Function File} {[@var{days}, @var{secs}] =} datenum (@dots{}) ## Return the date/time input as a serial day number, with Jan 1, 0000 @@ -37,9 +38,17 @@ ## The input may be a date vector (see @code{datevec}), ## datestr (see @code{datestr}), or directly specified as input. ## -## When processing input datestrings, @var{p} is the year at the start of the -## century to which two-digit years will be referenced. If not specified, it -## defaults to the current year minus 50. +## When processing input datestrings, @var{f} is the format string used to +## interpret date strings (see @code{datestr}). If no format @var{f} is +## specified, then a relatively slow search is performed through various +## formats. It is always preferable to specify the format string @var{f} if +## it is known. Formats which do not specify a particular time component +## will have the value set to zero. Formats which do not specify a date +## will default to January 1st of the current year. +## +## @var{p} is the year at the start of the century to which two-digit years +## will be referenced. If not specified, it defaults to the current year +## minus 50. ## ## The optional output @var{secs} holds the time on the specified day with ## greater precision than @var{days}. @@ -196,6 +205,8 @@ %!assert (datenum ({"5/19/2001"}), 730990) %!assert (datenum (char ("5/19/2001", "6/6/1944")), [730990; 710189]) %!assert (datenum ({"5/19/2001", "6/6/1944"}), [730990; 710189]) +## Test string input with format string +%!assert (datenum ("5-19, 2001", "mm-dd, yyyy"), 730990) %% Test input validation %!error datenum ()