# HG changeset patch # User John W. Eaton # Date 1422044589 18000 # Node ID 844448ae53f3cd21653d6b56dfeb08a6ea9eba32 # Parent 709f3a77685d96d1264ca0e9a01d53d8398fa6f9# Parent 75a671fcdd734eca88b4ca90a940bed45263924c maint: Periodic merge of stable to gui-release. diff -r 75a671fcdd73 -r 844448ae53f3 NEWS --- a/NEWS Fri Jan 23 15:21:25 2015 -0500 +++ b/NEWS Fri Jan 23 15:23:09 2015 -0500 @@ -1,1520 +1,57 @@ -Summary of important user-visible changes for version 3.8: +Summary of important user-visible changes for version 4.0: --------------------------------------------------------- - ** One of the biggest new features for Octave 3.8 is a graphical user - interface. It is the one thing that users have requested most - often over the last few years and now it is almost ready. But - because it is not quite as polished as we would like, we have - decided to wait until the 4.0.x release series before making the - GUI the default interface (until then, you can use the --force-gui - option to start the GUI). - - Given the length of time and the number of bug fixes and - improvements since the last major release Octave, we also decided - against delaying the release of all these new improvements any - longer just to perfect the GUI. So please enjoy the 3.8 release of - Octave and the preview of the new GUI. We believe it is working - reasonably well, but we also know that there are some obvious rough - spots and many things that could be improved. - - WE NEED YOUR HELP. There are many ways that you can help us fix - the remaining problems, complete the GUI, and improve the overall - user experience for both novices and experts alike: - - * If you are a skilled software developer, you can help by - contributing your time to help with Octave's development. See - http://octave.org/get-involved.html for more information. - - * If Octave does not work properly, you are encouraged - report the problems you find. See http://octave.org/bugs.html - for more information about how to report problems. - - * Whether you are a user or developer, you can help to fund the - project. Octave development takes a lot of time and expertise. - Your contributions help to ensure that Octave will continue to - improve. See http://octave.org/donate.html for more details. - - We hope you find Octave to be useful. Please help us make it even - better for the future! - - ** Octave now uses OpenGL graphics by default with FLTK widgets. If - OpenGL libraries or FLTK widgets are not available when Octave is - built, gnuplot is used. You may also choose to use gnuplot for - graphics by executing the command - - graphics_toolkit ("gnuplot") - - Adding this command to your ~/.octaverc file will set the default - for each session. - - ** Printing or saving figures with OpenGL graphics requires the - gl2ps library which is no longer distributed with Octave. The - software is widely available in most package managers. If a - pre-compiled package does not exist for your system, you can find - the current sources at http://www.geuz.org/gl2ps/. + ** For compatibility with Matlab, the "backtrace" warning option is now + enabled by default. - ** Octave now supports nested functions with scoping rules that are - compatible with Matlab. A nested function is one declared and defined - within the body of another function. The nested function is only - accessible from within the enclosing function which makes it one - method for making private functions whose names do not conflict with those - in the global namespace (See also subfunctions and private functions). - In addition, variables in the enclosing function are visible within the - nested function. This makes it possible to have a pseudo-global variable - which can be seen by a group of functions, but which is not visible in - the global namespace. - - Example: - function outerfunc (...) - ... - function nested1 (...) - ... - function nested2 (...) - ... - endfunction - endfunction - - function nested3 (...) - ... - endfunction - endfunction - - ** Line continuations inside character strings have changed. - - The sequence '...' is no longer recognized as a line continuation - inside a character string. A backslash '\' followed by a newline - character is no longer recognized as a line continuation inside - single-quoted character strings. Inside double-quoted character - strings, a backslash followed by a newline character is still - recognized as a line continuation, but the backslash character must - be followed *immediately* by the newline character. No whitespace or - end-of-line comment may appear between them. - - ** Backslash as a continuation marker outside of double-quoted strings - is now deprecated. - - Using '\' as a continuation marker outside of double quoted strings - is now deprecated and will be removed from a future version of - Octave. When that is done, the behavior of - - (a \ - b) - - will be consistent with other binary operators. - - ** Redundant terminal comma accepted by parser - - A redundant terminal comma is now accepted in matrix - definitions which allows writing code such as - - [a,... - b,... - c,... - ] = deal (1,2,3) - - ** Octave now has limited support for named exceptions - - The following syntax is now accepted: - - try - statements - catch exception-id - statements - end - - The exception-id is a structure with the fields "message" and - "identifier". For example + ** The preference - try - error ("Octave:error-id", "error message"); - catch myerr - printf ("identifier: %s\n", myerr.identifier); - printf ("message: %s\n", myerr.message); - end_try_catch - - When classdef-style classes are added to Octave, the exception-id - will become an MException object. - - ** Warning states may now be set temporarily, until the end of the - current function, using the syntax - - warning STATE ID "local" - - in which STATE may be "on", "off", or "error". Changes to warning - states that are set locally affect the current function and all - functions called from the current scope. The previous warning state - is restored on return from the current function. The "local" - option is ignored if used in the top-level workspace. - - ** Warning IDs renamed: - - Octave:array-as-scalar => Octave:array-to-scalar - Octave:array-as-vector => Octave:array-to-vector - - ** 'emptymatch', 'noemptymatch' options added to regular expressions. - - With this addition Octave now accepts the entire set of Matlab options - for regular expressions. 'noemptymatch' is the default, but 'emptymatch' - has certain uses where you need to match an assertion rather than actual - characters. For example, - - regexprep ('World', '^', 'Hello ', 'emptymatch') - => Hello World - - where the pattern is actually the assertion '^' or start-of-line. - - ** For compatibility with Matlab, the regexp, regexpi, and regexprep - functions now process backslash escape sequences in single-quoted pattern - strings. In addition, the regexprep function now processes backslash - escapes in single-quoted replacement strings. For example, - - regexprep (str, '\t', '\n') - - would search the variable str for a TAB character (escape sequence \t) - and replace it with a NEWLINE (escape sequence \n). Previously the - expression would have searched for a literal '\' followed by 't' and - replaced the two characters with the sequence '\', 'n'. - - ** A TeX parser has been implemented for the FLTK toolkit and is the default - for any text object including titles and axis labels. The TeX parser is - supported only for display on a monitor, not for printing. - - A quick summary of features: + do_braindead_shortcircuit_evaluation - Code Feature Example Comment - ----------------------------------------------------------------- - _ subscript H_2O formula for water - ^ exponent y=x^2 formula for parabola - \char symbol \beta Greek symbol beta - \fontname font \fontname{Arial} set Arial font - \fontsize fontsize \fontsize{16} set fontsize 16 - \color[rgb] fontcolor \color[rgb]{1 0 1} set magenta color - \bf bold \bfBold Text bold font - \it italic \itItalic Text italic font - \sl slanted \slOblique Text slanted font - \rm normal \bfBold\rmNormal normal font - {} group {\bf Bold}Normal group objects - e^{i*\pi} = -1 group objects - - ** The m-files in the plot directory have been overhauled. - - The plot functions now produce output that is nearly visually compatible - with Matlab. Plot performance has also increased, dramatically for some - functions such as comet and waitbar. Finally, the documentation for most - functions has been updated so it should be clearer both how to use a - function and when a function is appropriate. - - ** The m-files in the image directory have been overhauled. - - The principal benefit is that Octave will now no longer automatically - convert images stored with integers to doubles. Storing images as uint8 - or uint16 requires only 1/8 or 1/4 the memory of an image stored using - doubles. For certain operations, such as fft2, the image must still be - converted to double in order to work. - - Other changes include fixes to the way indexed images are read from a - colormap depending on the image class (integer images have a -1 offset to - the colormap row number). - - ** The imread and imwrite functions have been completely rewritten. + is now enabled by default. - The main changes relate to the alpha channel, support for reading and - writing of floating point images, implemented writing of indexed images, - and appending images to multipage image files. - - The issues that may arise due to backwards incompatibility are: - - * imwrite no longer interprets a length of 2 or 4 in the third dimension - as grayscale or RGB with alpha channel (a length of 4 will be saved - as a CMYK image). Alpha channel must be passed as separate argument. - - * imread will always return the colormap indexes when reading an indexed - image, even if the colormap is not requested as output. - - * transparency values are now inverted from previous Octave versions - (0 is for completely transparent instead of completely opaque). - - In addition, the function imformats has been implemented to expand - reading and writing of images of different formats through imread - and imwrite. - - ** The colormap function now provides new options--"list", "register", - and "unregister"--to list all available colormap functions, and to - add or remove a function name from the list of known colormap - functions. Packages that implement extra colormaps should use these - commands with PKG_ADD and PKG_DEL statements. - - ** strsplit has been modified to be compatible with Matlab. There - are two instances where backward compatibility is broken. - - (1) Delimiters are now string vectors, not scalars. - - Octave's legacy behavior - - strsplit ("1 2, 3", ", ") - ans = - { - [1,1] = 1 - [1,2] = 2 - [1,3] = - [1,4] = 3 - } + ** The preference - Matlab compatible behavior - - strsplit ("1 2, 3", ", ") - ans = - { - [1,1] = 1 2 - [1,2] = 3 - } - - (2) By default, Matlab treats consecutive delimiters as a single - delimiter. By default, Octave's legacy behavior was to return an - empty string for the part between the delmiters. - - Where legacy behavior is desired, the call to strsplit() may be - replaced by ostrsplit(), which is Octave's original implementation of - strsplit(). - - ** The datevec function has been extended for better Matlab compatibility. - It now accepts string inputs in the following numerical formats: 12, 21, - 22, 26, 29, 31. This is undocumented, but verifiable, Matlab behavior. - In addition, the default for formats which do not specify a date is - January 1st of the current year. The previous default was the current day, - month, and year. This may produce changes in existing scripts. - - ** The error function and its derivatives has been extended to accept complex - arguments. The following functions now accept complex inputs: - - erf erfc erfcx - - In addition two new error functions erfi (imaginary error function) and - dawson (scaled imaginary error function) have been added. - - ** The glpk function has been modified to reflect changes in the GLPK - library. The "round" and "itcnt" options have been removed. The - "relax" option has been replaced by the "rtest" option. The numeric - values of error codes and of some options have also changed. - - ** The kurtosis function has changed definition to be compatible with - Matlab. It now returns the base kurtosis instead of the "excess kurtosis". - The old behavior can be had by changing scripts to normalize with -3. - - "excess kurtosis" = kurtosis (x) - 3 - - ** The moment function has changed definition to be compatible with - Matlab. It now returns the central moment instead of the raw moment. - The old behavior can be had by passing the type argument "r" for raw. - - ** The default name of the Octave crash dump file is now - "octave-workspace" instead of "octave-core". The exact name can - always be customized with the octave_core_file_name function. - - ** A citation command has been added to display information on how to - cite Octave and packages in publications. The package system will - look for and install CITATION files from packages. - - ** The java package from Octave Forge is now part of core Octave. The - following new functions are available for interacting with Java - directly from Octave: + allow_noninteger_range_as_index - debug_java java_matrix_autoconversion - isjava java_set - java2mat java_unsigned_autoconversion - javaArray javaaddpath - javaMethod javaclasspath - javaObject javamem - java_get javarmpath - usejava - - In addition, the following functions that use the Java interface - are now available (provided that Octave is compiled with support for - Java enabled): - - helpdlg listdlg questdlg - inputdlg msgbox warndlg - - ** Other new functions added in 3.8.0: - - atan2d erfi lines - base64_decode expint linsolve - base64_encode findfigs missing_component_hook - betaincinv flintmax polyeig - built_in_docstrings_file fminsearch prefdir - cmpermute gallery preferences - cmunique gco readline_re_read_init_file - colorcube hdl2struct readline_read_init_file - copyobj history_save rgbplot - dawson imformats save_default_options - dblist importdata shrinkfaces - desktop isaxes splinefit - doc_cache_create iscolormap stemleaf - ellipj isequaln strjoin - ellipke jit_debug struct2hdl - erfcinv jit_enable tetramesh - jit_startcnt waterfall + is now enabled by default and the warning ID - ** Deprecated functions. - - The following functions were deprecated in Octave 3.4 and have been - removed from Octave 3.8. - - autocor dispatch is_global setstr - autocov fstat krylovb strerror - betai gammai perror values - cellidx glpkmex replot - cquad is_duplicate_entry saveimage - - The following functions have been deprecated in Octave 3.8 and will - be removed from Octave 3.12 (or whatever version is the second major - release after 3.8): - - default_save_options java_new - gen_doc_cache java_unsigned_conversion - interp1q javafields - isequalwithequalnans javamethods - java_convert_matrix re_read_readline_init_file - java_debug read_readline_init_file - java_invoke saving_history - - The following keywords have been deprecated in Octave 3.8 and will - be removed from Octave 3.12 (or whatever version is the second major - release after 3.8): - - static - - The following configuration variables have been deprecated in Octave - 3.8 and will be removed from Octave 3.12 (or whatever version is the - second major release after 3.8): - - CC_VERSION (now GCC_VERSION) - CXX_VERSION (now GXX_VERSION) + Octave:noninteger-range-as-index - The internal class has been deprecated in Octave 3.8 and will - be removed from Octave 3.12 (or whatever version is the second major - release after 3.8). Replacement classes are (struct array) - or for a single structure. - -Summary of important user-visible changes for version 3.6: ---------------------------------------------------------- - - ** The PCRE library is now required to build Octave. If a pre-compiled - package does not exist for your system, you can find PCRE sources - at http://www.pcre.org - - ** The ARPACK library is no longer distributed with Octave. - If you need the eigs or svds functions you must provide an - external ARPACK through a package manager or by compiling it - yourself. If a pre-compiled package does not exist for your system, - you can find the current ARPACK sources at - http://forge.scilab.org/index.php/p/arpack-ng - - ** Many of Octave's binary operators (.*, .^, +, -, ...) now perform - automatic broadcasting for array operations which allows you to use - operator notation instead of calling bsxfun or expanding arrays (and - unnecessarily wasting memory) with repmat or similar idioms. For - example, to scale the columns of a matrix by the elements of a row - vector, you may now write - - rv .* M - - In this expression, the number of elements of rv must match the - number of columns of M. The following operators are affected: - - plus + .+ - minus - .- - times .* - rdivide ./ - ldivide .\ - power .^ .** - lt < - le <= - eq == - gt > - ge >= - ne != ~= - and & - or | - atan2 - hypot - max - min - mod - rem - xor - - additionally, since the A op= B assignment operators are equivalent - to A = A op B, the following operators are also affected: - - += -= .+= .-= .*= ./= .\= .^= .**= &= |= - - See the "Broadcasting" section in the new "Vectorization and Faster - Code Execution" chapter of the manual for more details. + is now set to "on" by default instead of "error" by default and "on" + for --traditional. - ** Octave now features a profiler, thanks to the work of Daniel Kraft - under the Google Summer of Code mentorship program. The manual has - been updated to reflect this addition. The new user-visible - functions are profile, profshow, and profexplore. - - ** Overhaul of statistical distribution functions - - Functions now return "single" outputs for inputs of class "single". - - 75% reduction in memory usage through use of logical indexing. - - Random sample functions now use the same syntax as rand and accept - a comma separated list of dimensions or a dimension vector. - - Functions have been made Matlab-compatible with regard to special - cases (probability on boundaries, probabilities for values outside - distribution, etc.). This may cause subtle changes to existing - scripts. - - negative binomial function has been extended to real, non-integer - inputs. The discrete_inv function now returns v(1) for 0 instead of - NaN. The nbincdf function has been recoded to use a closed form - solution with betainc. - - ** strread, textscan, and textread have been completely revamped. - - They now support nearly all Matlab functionality including: - - * Matlab-compatible whitespace and delimiter defaults - - * Matlab-compatible options: 'whitespace', treatasempty', format - string repeat count, user-specified comment style, uneven-length - output arrays, %n and %u conversion specifiers (provisionally) - - ** All .m string functions have been modified for better performance or - greater Matlab compatibility. Performance gains of 15X-30X have - been demonstrated. Operations on cell array of strings no longer pay - quite as high a penalty as those on 2-D character arrays. - - deblank: Now requires character or cellstr input. - - strtrim: Now requires character or cellstr input. - No longer trims nulls ("\0") from string for Matlab - compatibility. - - strmatch: Follows documentation precisely and ignores trailing spaces - in pattern and in string. Note that this is documented - Matlab behavior but the implementation apparently does - not always follow it. - - substr: Now possible to specify a negative LEN option which - extracts to within LEN of the end of the string. - - strtok: Now accepts cellstr input. - - base2dec, bin2dec, hex2dec: - Now accept cellstr inputs. - - dec2base, dec2bin, dec2hex: - Now accept cellstr inputs. - - index, rindex: - Now accept 2-D character array input. - - strsplit: Now accepts 2-D character array input. - - ** Geometry functions derived from Qhull (convhull, delaunay, voronoi) - have been revamped. The options passed to the underlying qhull - command have been changed for better results or for Matlab + ** polyeig now returns a row vector of eigenvalues rather than a matrix + with the eigenvalues on the diagonal. This change was made for Matlab compatibility. - convhull: Default options are "Qt" for 2D, 3D, 4D inputs - Default options are "Qt Qx" for 5D and higher - - delaunay: Default options are "Qt Qbb Qc Qz" for 2D and 3D inputs - Default options are "Qt Qbb Qc Qx" for 4D and higher - - voronoi: No default arguments - - ** Date/Time functions updated. Millisecond support with FFF format - string now supported. - - datestr: Numerical formats 21, 22, 29 changed to match Matlab. - Now accepts cellstr input. - - ** The following warning IDs have been removed: - - Octave:associativity-change - Octave:complex-cmp-ops - Octave:empty-list-elements - Octave:fortran-indexing - Octave:precedence-change - - ** The warning ID Octave:string-concat has been renamed to - Octave:mixed-string-concat. - - ** Octave now includes the following Matlab-compatible preference - functions: + ** Other new functions added in 4.0.0: - addpref getpref ispref rmpref setpref - - ** The following Matlab-compatible handle graphics functions have been - added: - - guidata uipanel uitoolbar - guihandles uipushtool uiwait - uicontextmenu uiresume waitfor - uicontrol uitoggletool - - The uiXXX functions above are experimental. - - Except for uiwait and uiresume, the uiXXX functions are not - supported with the FLTK+OpenGL graphics toolkit. - - The gnuplot graphics toolkit does not support any of the uiXXX - functions nor the waitfor function. - - ** New keyword parfor (parallel for loop) is now recognized as a valid - keyword. Implementation, however, is still mapped to an ordinary - for loop. - - ** Other new functions added in 3.6.0: - - bicg nthargout usejava - is_dq_string narginchk waitbar - is_sq_string python zscore - is_function_handle register_graphics_toolkit - loaded_graphics_toolkits recycle + validateattributes ** Deprecated functions. - The following functions were deprecated in Octave 3.2 and have been - removed from Octave 3.6. - - create_set spcholinv splu - dmult spcumprod spmax - iscommand spcumsum spmin - israwcommand spdet spprod - lchol spdiag spqr - loadimage spfind spsum - mark_as_command sphcat spsumsq - mark_as_rawcommand spinv spvcat - spatan2 spkron str2mat - spchol splchol unmark_command - spchol2inv split unmark_rawcommand - - The following functions have been deprecated in Octave 3.6 and will - be removed from Octave 3.10 (or whatever version is the second major - release after 3.6): + The following functions were deprecated in Octave 3.6 and have been + removed from Octave 4.0. - cut is_duplicate_entry - cor polyderiv - corrcoef shell_cmd - __error_text__ studentize - error_text sylvester_matrix - - ** The following functions have been modified for Matlab compatibility: - - randperm - -Summary of important user-visible changes for version 3.4.3: ------------------------------------------------------------ - - ** Octave 3.4.3 is a bug fixing release. - -Summary of important user-visible changes for version 3.4.2: ------------------------------------------------------------ - - ** Octave 3.4.2 fixes some minor installation problems that affected - version 3.4.1. - -Summary of important user-visible changes for version 3.4.1: ------------------------------------------------------------ - - ** Octave 3.4.1 is primarily a bug fixing release. + cut polyderiv + cor shell_cmd + corrcoef studentize + __error_text__ sylvester_matrix + error_text - ** IMPORTANT note about binary incompatibility in this release: - - Binary compatibility for all 3.4.x releases was originally planned, - but this is impossible for the 3.4.1 release due to a bug in the way - shared libraries were built in Octave 3.4.0. Because of this bug, - .oct files built for Octave 3.4.0 must be recompiled before they - will work with Octave 3.4.1. - - Given that there would be binary incompatibilities with shared - libraries going from Octave 3.4.0 to 3.4.1, the following - incompatible changes were also made in this release: - - * The Perl Compatible Regular Expression (PCRE) library is now - required to build Octave. - - * Octave's libraries and .oct files are now installed in - subdirectories of $libdir instead of $libexecdir. - - Any future Octave 3.4.x release versions should remain binary - compatible with Octave 3.4.1 as proper library versioning is now - being used as recommended by the libtool manual. + The following functions have been deprecated in Octave 4.0 and will + be removed from Octave 4.4 (or whatever version is the second major + release after 4.0): - ** The following functions have been deprecated in Octave 3.4.1 and will - be removed from Octave 3.8 (or whatever version is the second major - release after 3.4): - - cquad is_duplicate_entry perror strerror - - ** The following functions are new in 3.4.1: - - colstyle gmres iscolumn isrow mgorth nproc rectangle - - ** The get_forge_pkg function is now private. + allow_noninteger_range_as_index + do_braindead_shortcircuit_evaluation - ** The rectangle_lw, rectangle_sw, triangle_lw, and triangle_sw - functions are now private. - - ** The logistic_regression_derivatives and logistic_regression_likelihood - functions are now private. + The internal function atan2 of the sparse matrix class has been deprecated + in Octave 4.0 and will be removed from Octave 4.4 (or whatever version is + the second major release after 4.0). Use the Fatan2 function with sparse + inputs as a replacement. - ** ChangeLog files in the Octave sources are no longer maintained - by hand. Instead, there is a single ChangeLog file generated from - the Mercurial version control commit messages. Older ChangeLog - information can be found in the etc/OLD-ChangeLogs directory in the - source distribution. - -Summary of important user-visible changes for version 3.4: --------------------------------------------------------- - ** BLAS and LAPACK libraries are now required to build Octave. The - subset of the reference BLAS and LAPACK libraries has been removed - from the Octave sources. - - ** The ARPACK library is now distributed with Octave so it no longer - needs to be available as an external dependency when building - Octave. - - ** The `lookup' function was extended to be more useful for - general-purpose binary searching. Using this improvement, the - ismember function was rewritten for significantly better - performance. - - ** Real, integer and logical matrices, when used in indexing, will now - cache the internal index_vector value (zero-based indices) when - successfully used as indices, eliminating the conversion penalty for - subsequent indexing by the same matrix. In particular, this means it - is no longer needed to avoid repeated indexing by logical arrays - using find for performance reasons. - - ** Logical matrices are now treated more efficiently when used as - indices. Octave will keep the index as a logical mask unless the - ratio of true elements is small enough, using a specialized - code. Previously, all logical matrices were always first converted - to index vectors. This results in savings in both memory and - computing time. - - ** The `sub2ind' and `ind2sub' functions were reimplemented as compiled - functions for better performance. These functions are now faster, - can deliver more economized results for ranges, and can reuse the - index cache mechanism described in previous paragraph. - - ** The built-in function equivalents to associative operators (`plus', - `times', `mtimes', `and', and `or') have been extended to accept - multiple arguments. This is especially useful for summing - (multiplying, etc.) lists of objects (of possibly distinct types): - - matrix_sum = plus (matrix_list{:}); - - ** An FTP object type based on libcurl has been implemented. These - objects allow ftp connections, downloads and uploads to be - managed. For example, - - fp = ftp ("ftp.octave.org); - cd (fp, "gnu/octave"); - mget (fp, "octave-3.2.3.tar.bz2"); - close (fp); - - ** The default behavior of `assert (observed, expected)' has been - relaxed to employ less strict checking that does not require the - internals of the values to match. This avoids previously valid - tests from breaking due to new internal classes introduced in future - Octave versions. - - For instance, all of these assertions were true in Octave 3.0.x - but false in 3.2.x due to new optimizations and improvements: - - assert (2*linspace (1, 5, 5), 2*(1:5)) - assert (zeros (0, 0), []) - assert (2*ones (1, 5), (2) (ones (1,5))) - - ** The behavior of library functions `ismatrix', `issquare', and - `issymmetric' has been changed for better consistency. - - * The `ismatrix' function now returns true for all numeric, - logical and character 2-D or N-D matrices. Previously, `ismatrix' - returned false if the first or second dimension was zero. - Hence, `ismatrix ([])' was false, - while `ismatrix (zeros (1,2,0))' was true. - - * The `issquare' function now returns a logical scalar, and is - equivalent to the expression - - ismatrix (x) && ndims (x) == 2 && rows (x) == columns (x) - - The dimension is no longer returned. As a result, `issquare ([])' - now yields true. - - * The `issymmetric' function now checks for symmetry instead of - Hermitianness. For the latter, ishermitian was created. Also, - logical scalar is returned rather than the dimension, so - `issymmetric ([])' is now true. - - ** Function handles are now aware of overloaded functions. If a - function is overloaded, the handle determines at the time of its - reference which function to call. A non-overloaded version does not - need to exist. - - ** Overloading functions for built-in classes (double, int8, cell, - etc.) is now compatible with Matlab. - - ** Function handles can now be compared with the == and != operators, - as well as the `isequal' function. - - ** Performance of concatenation (using []) and the functions `cat', - `horzcat', and `vertcat' has been improved for multidimensional - arrays. - - ** The operation-assignment operators +=, -=, *= and /= now behave more - efficiently in certain cases. For instance, if M is a matrix and S a - scalar, then the statement - - M += S; - - will operate on M's data in-place if it is not shared by another - variable, usually increasing both time and memory efficiency. - - Only selected common combinations are affected, namely: - - matrix += matrix - matrix -= matrix - matrix .*= matrix - matrix ./= matrix - - matrix += scalar - matrix -= scalar - matrix *= scalar - matrix /= scalar - - logical matrix |= logical matrix - logical matrix &= logical matrix - - where matrix and scalar belong to the same class. The left-hand - side must be a simple variable reference. - - Moreover, when unary operators occur in expressions, Octave will - also try to do the operation in-place if it's argument is a - temporary expression. - - ** The effect of comparison operators (<, >, <=, and >=) applied to - complex numbers has changed to be consistent with the strict - ordering defined by the `max', `min', and `sort' functions. More - specifically, complex numbers are compared by lexicographical - comparison of the pairs `[abs(z), arg(z)]'. Previously, only real - parts were compared; this can be trivially achieved by converting - the operands to real values with the `real' function. - - ** The automatic simplification of complex computation results has - changed. Octave will now simplify any complex number with a zero - imaginary part or any complex matrix with all elements having zero - imaginary part to a real value. Previously, this was done only for - positive zeros. Note that the behavior of the complex function is - unchanged and it still produces a complex value even if the - imaginary part is zero. - - ** As a side effect of code refactoring in liboctave, the binary - logical operations are now more easily amenable to compiler - optimizations and are thus significantly faster. - - ** Octave now allows user-defined `subsasgn' methods to optimize out - redundant copies. For more information, see the manual. - - ** More efficient matrix division handling. Octave is now able to - handle the expressions - - M' \ V - M.' \ V - V / M - - (M is a matrix and V is a vector) more efficiently in certain cases. - In particular, if M is triangular, all three expressions will be - handled by a single call to xTRTRS (from LAPACK), with appropriate - flags. Previously, all three expressions required a physical - transpose of M. - - ** More efficient handling of certain mixed real-complex matrix - operations. For instance, if RM is a real matrix and CM a complex - matrix, - - RM * CM - - can now be evaluated either as - - complex (RM * real (CM), RM * imag (CM)) - - or as - - complex (RM) * CM, - - depending on the dimensions. The first form requires more - temporaries and copying, but halves the FLOP count, which normally - brings better performance if RM has enough rows. Previously, the - second form was always used. - - Matrix division is similarly affected. - - ** More efficient handling of triangular matrix factors returned from - factorizations. The functions for computing QR, LU and Cholesky - factorizations will now automatically return the triangular matrix - factors with proper internal matrix_type set, so that it won't need - to be computed when the matrix is used for division. - - ** The built-in `sum' function now handles the non-native summation - (i.e., double precision sum of single or integer inputs) more - efficiently, avoiding a temporary conversion of the whole input - array to doubles. Further, `sum' can now accept an extra option - argument, using a compensated summation algorithm rather than a - straightforward sum, which significantly improves precision if lots - of cancellation occurs in the summation. - - ** The built-in `bsxfun' function now uses optimized code for certain - cases where built-in operator handles are passed in. Namely, the - optimizations concern the operators `plus', `minus', `times', - `ldivide', `rdivide', `power', `and', `or' (for logical arrays), - the relational operators `eq', `ne', `lt', `le', `gt', `ge', and the - functions `min' and `max'. Optimizations only apply when both - operands are of the same built-in class. Mixed real/complex and - single/double operations will first convert both operands to a - common type. - - ** The `strfind' and `strrep' functions now have compiled - implementations, facilitating significantly more efficient searching - and replacing in strings, especially with longer patterns. The code - of `strcat' has been vectorized and is now much more efficient when - many strings are concatenated. The `strcmpi' and `strncmpi' - functions are now built-in functions, providing better performance. - - ** 'str2double' now has a compiled implementation and the API conforms - to Matlab. The additional Octave-specific features of returning a - boolean matrix indicating which elements were successfully converted - has been removed. - - ** Matlab-style ignoring input and output function arguments using - tilde (~) is now supported. Ignored output arguments may be - detected from a function using the built-in function `isargout'. - For more details, consult the manual. - - ** The list datatype, deprecated since the introduction of cells, has - been removed. - - ** The accumarray function has been optimized and is now significantly - faster in certain important cases. - - ** The behavior of isreal and isnumeric functions was changed to be more - Matlab-compatible. - - ** The integer math & conversion warnings (Octave:int-convert-nan, - Octave:int-convert-non-int-val, Octave:int-convert-overflow, - Octave:int-math-overflow) have been removed. - - ** rem and mod are now built-in functions. They also handle integer - types efficiently using integer arithmetic. - - ** Sparse indexing and indexed assignment has been mostly rewritten. - Since Octave uses compressed column storage for sparse matrices, - major attention is devoted to operations manipulating whole columns. - Such operations are now significantly faster, as well as some other - important cases. - - Further, it is now possible to pre-allocate a sparse matrix and - subsequently fill it by assignments, provided they meet certain - conditions. For more information, consult the `spalloc' function, - which is no longer a mere dummy. Consequently, nzmax and nnz are no - longer always equal in Octave. Octave may also produce a matrix - with nnz < nzmax as a result of other operations, so you should - consistently use nnz unless you really want to use nzmax (i.e., the - space allocated for nonzero elements). - - Sparse concatenation is also affected, and concatenating sparse - matrices, especially larger collections, is now significantly more - efficient. This applies to both the [] operator and the - cat/vertcat/horzcat functions. - - ** It is now possible to optionally employ the xGESDD LAPACK drivers - for computing the singular value decomposition using svd, instead - of the default xGESVD, using the configuration pseudo-variable - svd_driver. The xGESDD driver can be up to 6x times faster when - singular vectors are requested, but is reported to be somewhat less - robust on highly ill-conditioned matrices. - - ** Configuration pseudo-variables, such as page_screen_output or - confirm_recursive_rmdir (or the above mentioned svd_driver), now - accept a "local" option as second argument, requesting the change - to be undone when the current function returns: - - function [status, msg] = rm_rf (dir) - confirm_recursive_rmdir (false, "local"); - [status, msg] = rmdir (dir, "s"); - ... - endfunction - - Upon return, confirm_recursive_rmdir will be restored to the value - it had on entry to the function, even if there were subsequent - changes to the variable in function rm_rf or any of the functions - it calls. - - ** pkg now accepts a -forge option for downloading and installing - packages from Octave Forge automatically. For example, - - pkg install -forge general - - will automatically download the latest release of the general - package and attempt to install it. No automatic resolving of - dependencies is provided. Further, - - pkg list -forge - - can be used to list all available packages. - - ** The internal data representation of structs has been completely - rewritten to make certain optimizations feasible. The field data - can now be shared between structs with equal keys but different - dimensions or values, making operations that preserve the fields - faster. Economized storage is now used for scalar structs (just - like most other scalars), making their usage more - memory-efficient. Certain array-like operations on structs - (concatenation, uniform cellfun, num2cell) have gained a - significant speed-up. Additionally, the octave_scalar_map class - now provides a simpler interface to work with scalar structs within - a C++ DLD function. - - ** Two new formats are available for displaying numbers: - - format short eng - format long eng - - Both display numbers in engineering notation, i.e., mantissa + - exponent where the exponent is a multiple of 3. - - ** The following functions are new in Octave 3.4: - accumdim erfcx nfields pqpnonneg uigetdir - bitpack fileread nth_element quadcc uigetfile - bitunpack fminbnd onCleanup randi uiputfile - blkmm fskipl pbaspect repelems uimenu - cbrt ifelse pie3 reset whitebg - curl ishermitian powerset rsf2csf - chop isindex ppder saveas - daspect luupdate ppint strread - divergence merge ppjumps textread - - ** Using the image function to view images with external programs such - as display, xv, and xloadimage is no longer supported. The - image_viewer function has also been removed. - - ** The behavior of struct assignments to non-struct values has been - changed. Previously, it was possible to overwrite an arbitrary - value: - - a = 1; - a.x = 2; - - This is no longer possible unless a is an empty matrix or cell - array. - - ** The dlmread function has been extended to allow specifying a custom - value for empty fields. - - ** The dlmread and dlmwrite functions have been modified to accept - file IDs (as returned by fopen) in addition to file names. - - ** Octave can now optimize away the interpreter overhead of an - anonymous function handle, if the function simply calls another - function or handle with some of its parameters bound to certain - values. Example: - - f = @(x) sum (x, 1); - - When f is called, the call is forwarded to @sum with the constant 1 - appended, and the anonymous function call does not occur on the - call stack. - - ** For compatibility with Matlab, mu2lin (x) is now equivalent to - mu2lin (x, 0). - - ** The new function `history_control' may be used to control the way - command lines are added to the history list when Octave is using - readline for command-line editing. For example - - history_control ("ignoredups") - - tells Octave to avoid adding duplicate lines to the history list. - - ** Octave now uses the gnulib library for improved portability and to - avoid bugs in operating system functions. - - ** Deprecated functions. - - The following functions were deprecated in Octave 3.0 and have been - removed from Octave 3.4. - - beta_cdf geometric_pdf pascal_pdf - beta_inv geometric_rnd pascal_rnd - beta_pdf hypergeometric_cdf poisson_cdf - beta_rnd hypergeometric_inv poisson_inv - binomial_cdf hypergeometric_pdf poisson_pdf - binomial_inv hypergeometric_rnd poisson_rnd - binomial_pdf intersection polyinteg - binomial_rnd is_bool setstr - chisquare_cdf is_complex struct_contains - chisquare_inv is_list struct_elements - chisquare_pdf is_matrix t_cdf - chisquare_rnd is_scalar t_inv - clearplot is_square t_pdf - clg is_stream t_rnd - com2str is_struct uniform_cdf - exponential_cdf is_symmetric uniform_inv - exponential_inv is_vector uniform_pdf - exponential_pdf isstr uniform_rnd - exponential_rnd lognormal_cdf weibcdf - f_cdf lognormal_inv weibinv - f_inv lognormal_pdf weibpdf - f_pdf lognormal_rnd weibrnd - f_rnd meshdom weibull_cdf - gamma_cdf normal_cdf weibull_inv - gamma_inv normal_inv weibull_pdf - gamma_pdf normal_pdf weibull_rnd - gamma_rnd normal_rnd wiener_rnd - geometric_cdf pascal_cdf - geometric_inv pascal_inv - - The following functions were deprecated in Octave 3.2 and will - be removed from Octave 3.6 (or whatever version is the second major - release after 3.2): - - create_set spcholinv splu - dmult spcumprod spmax - iscommand spcumsum spmin - israwcommand spdet spprod - lchol spdiag spqr - loadimage spfind spsum - mark_as_command sphcat spsumsq - mark_as_rawcommand spinv spvcat - spatan2 spkron str2mat - spchol splchol unmark_command - spchol2inv split unmark_rawcommand - - The following functions have been deprecated in Octave 3.4 and will - be removed from Octave 3.8 (or whatever version is the second major - release after 3.4): - - autocor cellidx gammai is_global replot values - autocov dispatch glpkmex krylovb saveimage - betai fstat intwarning perror strerror - -Summary of important user-visible changes for version 3.2: ---------------------------------------------------------- - - ** Compatibility with Matlab graphics has been improved. - - The hggroup object and associated listener callback functions have - been added allowing the inclusion of group objects. Data sources - have been added to these group objects such that - - x = 0:0.1:10; - y = sin (x); - plot (x, y, "ydatasource", "y"); - for i = 1 : 100 - pause(0.1) - y = sin (x + 0.1 * i); - refreshdata (); - endfor - - works as expected. This capability has be used to introduce - stem-series, bar-series, etc., objects for better Matlab - compatibility. - - ** New graphics functions: - - addlistener ezcontour gcbo refresh - addproperty ezcontourf ginput refreshdata - allchild ezmesh gtext specular - available_graphics_toolkits ezmeshc intwarning surfl - graphics_toolkit ezplot ishghandle trisurf - cla ezplot3 isocolors waitforbuttonpress - clabel ezpolar isonormals - comet ezsurf isosurface - dellistener findall linkprop - diffuse gcbf plotmatrix - - ** New experimental OpenGL/FLTK based plotting system. - - An experimental plotting system based on OpenGL and the FLTK - toolkit is now part of Octave. This graphics toolkit is disabled by - default. You can switch to using it with the command - - graphics_toolkit ("fltk") - - for all future figures or for a particular figure with the command - - graphics_toolkit (h, "fltk") - - where "h" is a valid figure handle. - - ** Functions providing direct access to gnuplot have been removed. - - The functions __gnuplot_plot__, __gnuplot_set__, __gnuplot_raw__, - __gnuplot_show__, __gnuplot_replot__, __gnuplot_splot__, - __gnuplot_save_data__ and __gnuplot_send_inline_data__ have been - removed from Octave. These function were incompatible with the - high level graphics handle code. - - ** The Control, Finance and Quaternion functions have been removed. - - These functions are now available as separate packages from - - http://octave.sourceforge.net/packages.html - - and can be reinstalled using the Octave package manager (see - the pkg function). - - ** Specific sparse matrix functions removed. - - The following functions, which handled only sparse matrices have - been removed. Instead of calling these functions directly, you - should use the corresponding function without the "sp" prefix. - - spatan2 spcumsum spkron spprod - spchol spdet splchol spqr - spchol2inv spdiag splu spsum - spcholinv spfind spmax spsumsqk - spcumprod spinv spmin - - ** Improvements to the debugger. - - The interactive debugging features have been improved. Stopping - on statements with dbstop should work correctly now. Stepping - into and over functions, and stepping one statement at a time - (with dbstep) now works. Moving up and down the call stack with - dbup and dbdown now works. The dbstack function is now available - to print the current function call stack. The new dbquit function - is available to exit the debugging mode. - - ** Improved traceback error messages. - - Traceback error messages are much more concise and easier to - understand. They now display information about the function call - stack instead of the stack of all statements that were active at - the point of the error. - - ** Object Oriented Programming. - - Octave now includes OOP features and the user can create their own - class objects and overloaded functions and operators. For - example, all methods of a class called "myclass" will be found in - a directory "@myclass" on the users path. The class specific - versions of functions and operators take precedence over the - generic versions of these functions. - - New functions related to OOP include - - class inferiorto isobject loadobj methods superiorto - - See the Octave manual for more details. - - ** Parsing of Command-style Functions. - - Octave now parses command-style functions without needing to first - declare them with "mark_as_command". The rules for recognizing a - command-style function calls are - - * A command must appear as the first word in a statement, - followed by a space. - - * The first character after the space must not be '=' or '(' - - * The next token after the space must not look like a binary - operator. - - These rules should be mostly compatible with the way Matlab parses - command-style function calls and allow users to define commands in - .m files without having to mark them as commands. - - Note that previous versions of Octave allowed expressions like - - x = load -text foo.dat - - but an expression like this will now generate a parse error. In - order to assign the value returned by a function to a variable, - you must use the normal function call syntax: - - x = load ("-text", "foo.dat"); - - ** Block comments. - - Commented code can be between matching "#{" and "#}" or "%{" and - "%}" markers, even if the commented code spans several line. This - allows blocks code to be commented, without needing to comment - each line. For example, - - function [s, t] = func (x, y) - s = 2 * x; - #{ - s *= y; - t = y + x; - #} - endfunction - - the lines "s *= y;" and "t = y + x" will not be executed. - - ** If any subfunction in a file ends with "end" or "endfunction", then - they all must end that way. Previously, Octave accepted - - function main () - ... - # no endfunction here. - function sub () - ... - endfunction - - but this is no longer allowed. - - ** Special treatment in the parser of expressions like "a' * b". - - In these cases the transpose is no longer explicitly formed and - BLAS libraries are called with the transpose flagged, - significantly improving performance for these kinds of - operations. - - ** Single Precision data type. - - Octave now includes a single precision data type. Single - precision variables can be created with the "single" command, or - from functions like ones, eye, etc. For example, - - single (1) - ones (2, 2, "single") - zeros (2, 2, "single") - eye (2, 2, "single") - Inf (2, 2, "single") - NaN (2, 2, "single") - NA (2, 2, "single") - - all create single precision variables. For compatibility with - Matlab, mixed double/single precision operators and functions - return single precision types. - - As a consequence of this addition to Octave the internal - representation of the double precision NA value has changed, and - so users that make use of data generated by Octave with R or - visa-versa are warned that compatibility might not be assured. - - ** Improved array indexing. - - The underlying code used for indexing of arrays has been - completely rewritten and indexing is now significantly faster. - - ** Improved memory management. - - Octave will now attempt to share data in some cases where previously - a copy would be made, such as certain array slicing operations or - conversions between cells, structs and cs-lists. This usually reduces - both time and memory consumption. - Also, Octave will now attempt to detect and optimize usage of a vector - as a stack, when elements are being repeatedly inserted at/removed from - the end of the vector. - - ** Improved performance for reduction operations. - - The performance of the sum, prod, sumsq, cumsum, cumprod, any, all, - max and min functions has been significantly improved. - - ** Sorting and searching. - - The performance of sort has been improved, especially when sorting - indices are requested. An efficient built-in issorted - implementation was added. The sortrows function now uses a more - efficient algorithm, especially in the homogeneous case. The lookup - function is now a built-in function performing a binary search, - optimized for long runs of close elements. Lookup also works with - cell arrays of strings. - - ** Range arithmetics - - For some operations on ranges, Octave will attempt to keep the - result as a range. These include negation, adding a scalar, - subtracting a scalar, and multiplying by a scalar. Ranges with zero - increment are allowed and can be constructed using the built-in - function `ones'. - - ** Various performance improvements. - - Performance of a number of other built-in operations and functions - was improved, including: - - * logical operations - * comparison operators - * element-wise power - * accumarray - * cellfun - * isnan - * isinf - * isfinite - * nchoosek - * repmat - * strcmp - - ** 64-bit integer arithmetic. - - Arithmetic with 64-bit integers (int64 and uint64 types) is fully - supported, with saturation semantics like the other integer types. - Performance of most integer arithmetic operations has been - improved by using integer arithmetic directly. Previously, Octave - performed integer math with saturation semantics by converting the - operands to double precision, performing the operation, and then - converting the result back to an integer value, truncating if - necessary. - - ** Diagonal and permutation matrices. - - The interpreter can now treat diagonal and permutation matrices as - special objects that store only the non-zero elements, rather than - general full matrices. Therefore, it is now possible to construct - and use these matrices in linear algebra without suffering a - performance penalty due to storing large numbers of zero elements. - - ** Improvements to fsolve. - - The fsolve function now accepts an option structure argument (see - also the optimset function). The INFO values returned from fsolve - have changed to be compatible with Matlab's fsolve function. - Additionally, fsolve is now able to solve overdetermined systems, - complex-differentiable complex systems, systems with a sparse - jacobian and can work in single precision if given single precision - inputs. It can also be called recursively. - - ** Improvements to the norm function. - - The norm function is now able to compute row or column norms of a - matrix in a single call, as well as general matrix p-norms. - - ** New functions for computing some eigenvalues or singular values. - - The eigs and svds functions have been included in Octave. These - functions require the ARPACK library (now distributed under a - GPL-compatible license). - - ** New QR and Cholesky factorization updating functions. - - choldelete cholshift qrdelete qrshift - cholinsert cholupdate qrinsert qrupdate - - ** New quadrature functions. - - dblquad quadgk quadv triplequad - - ** New functions for reading and writing images. - - The imwrite and imread functions have been included in Octave. - These functions require the GraphicsMagick library. The new - function imfinfo provides information about an image file (size, - type, colors, etc.) - - ** The input_event_hook function has been replaced by the pair of - functions add_input_event_hook and remove_input_event_hook so that - more than one hook function may be installed at a time. - - ** Other miscellaneous new functions. - - addtodate hypot reallog - bicgstab idivide realpow - cellslices info realsqrt - cgs interp1q rectint - command_line_path isdebugmode regexptranslate - contrast isfloat restoredefaultpath - convn isstrprop roundb - cummin log1p rundemos - cummax lsqnonneg runlength - datetick matlabroot saveobj - display namelengthmax spaugment - expm1 nargoutchk strchr - filemarker pathdef strvcat - fstat perl subspace - full prctile symvar - fzero quantile treelayout - genvarname re_read_readline_init_file validatestring - histc - - ** Changes to strcat. - - The strcat function is now compatible with Matlab's strcat - function, which removes trailing whitespace when concatenating - character strings. For example - - strcat ('foo ', 'bar') - ==> 'foobar' - - The new function cstrcat provides the previous behavior of - Octave's strcat. - - ** Improvements to the help functions. - - The help system has been mostly re-implemented in .m files to make - it easier to modify. Performance of the lookfor function has been - greatly improved by caching the help text from all functions that - are distributed with Octave. The pkg function has been modified - to generate cache files for external packages when they are - installed. - - ** Deprecated functions. - - The following functions were deprecated in Octave 3.0 and will be - removed from Octave 3.4 (or whatever version is the second major - release after 3.0): - - beta_cdf geometric_pdf pascal_pdf - beta_inv geometric_rnd pascal_rnd - beta_pdf hypergeometric_cdf poisson_cdf - beta_rnd hypergeometric_inv poisson_inv - binomial_cdf hypergeometric_pdf poisson_pdf - binomial_inv hypergeometric_rnd poisson_rnd - binomial_pdf intersection polyinteg - binomial_rnd is_bool setstr - chisquare_cdf is_complex struct_contains - chisquare_inv is_list struct_elements - chisquare_pdf is_matrix t_cdf - chisquare_rnd is_scalar t_inv - clearplot is_square t_pdf - clg is_stream t_rnd - com2str is_struct uniform_cdf - exponential_cdf is_symmetric uniform_inv - exponential_inv is_vector uniform_pdf - exponential_pdf isstr uniform_rnd - exponential_rnd lognormal_cdf weibcdf - f_cdf lognormal_inv weibinv - f_inv lognormal_pdf weibpdf - f_pdf lognormal_rnd weibrnd - f_rnd meshdom weibull_cdf - gamma_cdf normal_cdf weibull_inv - gamma_inv normal_inv weibull_pdf - gamma_pdf normal_pdf weibull_rnd - gamma_rnd normal_rnd wiener_rnd - geometric_cdf pascal_cdf - geometric_inv pascal_inv - - The following functions are now deprecated in Octave 3.2 and will - be removed from Octave 3.6 (or whatever version is the second major - release after 3.2): - - create_set spcholinv spmax - dmult spcumprod spmin - iscommand spcumsum spprod - israwcommand spdet spqr - lchol spdiag spsum - loadimage spfind spsumsq - mark_as_command spinv str2mat - mark_as_rawcommand spkron unmark_command - spatan2 splchol unmark_rawcommand - spchol split - spchol2inv splu - See NEWS.3 for old news. diff -r 75a671fcdd73 -r 844448ae53f3 bootstrap.conf --- a/bootstrap.conf Fri Jan 23 15:21:25 2015 -0500 +++ b/bootstrap.conf Fri Jan 23 15:23:09 2015 -0500 @@ -188,19 +188,3 @@ (cd libinterp/dldfcn; ./config-module.sh) } -bootstrap_epilogue () -{ - ## G77 is obsolete, but it is still the first option in the autoconf - ## Fortran macros. We should avoid it, because mixing old versions of - ## g77 with modern gcc and g++ causes trouble. The following will - ## make it harder (but not impossible) for users to make this mistake. - ## - ## FIXME -- we should really work to fix autoconf so that it prefers - ## gfortran over g77 even when searching for a Fortran 77 compiler. - - echo "replacing all occurrences of g77 with gfortran in configure script..." - - sed 's/g77/gfortran/g' configure > configure.t - mv configure.t configure - chmod 755 configure -} diff -r 75a671fcdd73 -r 844448ae53f3 build-aux/common.mk --- a/build-aux/common.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/build-aux/common.mk Fri Jan 23 15:23:09 2015 -0500 @@ -91,7 +91,6 @@ # Fortran compiler flags. -FC = @FC@ F77 = @F77@ AM_FFLAGS = @FFLAGS@ FPICFLAG = @FPICFLAG@ @@ -557,7 +556,6 @@ -e "s|%OCTAVE_CONF_F77%|\"${F77}\"|" \ -e "s|%OCTAVE_CONF_F77_FLOAT_STORE_FLAG%|\"${F77_FLOAT_STORE_FLAG}\"|" \ -e "s|%OCTAVE_CONF_F77_INTEGER_8_FLAG%|\"${F77_INTEGER_8_FLAG}\"|" \ - -e "s|%OCTAVE_CONF_FC%|\"${FC}\"|" \ -e "s|%OCTAVE_CONF_FFLAGS%|\"${FFLAGS}\"|" \ -e "s|%OCTAVE_CONF_FFTW3_CPPFLAGS%|\"${FFTW3_CPPFLAGS}\"|" \ -e "s|%OCTAVE_CONF_FFTW3_LDFLAGS%|\"${FFTW3_LDFLAGS}\"|" \ diff -r 75a671fcdd73 -r 844448ae53f3 configure.ac --- a/configure.ac Fri Jan 23 15:21:25 2015 -0500 +++ b/configure.ac Fri Jan 23 15:23:09 2015 -0500 @@ -19,21 +19,21 @@ ### . AC_PREREQ([2.62]) -AC_INIT([GNU Octave], [3.8.2], [http://octave.org/bugs.html], [octave]) +AC_INIT([GNU Octave], [3.9.0+], [http://octave.org/bugs.html], [octave]) dnl Note that the version number is duplicated here and in AC_INIT dnl because AC_INIT requires it to be static, not computed from dnl shell variables. OCTAVE_MAJOR_VERSION=3 -OCTAVE_MINOR_VERSION=8 -OCTAVE_PATCH_VERSION=2 +OCTAVE_MINOR_VERSION=9 +OCTAVE_PATCH_VERSION=0+ dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg OCTAVE_VERSION="$PACKAGE_VERSION" -OCTAVE_COPYRIGHT="Copyright (C) 2014 John W. Eaton and others." - -OCTAVE_RELEASE_DATE="2014-08-06" +OCTAVE_COPYRIGHT="Copyright (C) 2013 John W. Eaton and others." + +OCTAVE_RELEASE_DATE="2014-07-01" ## The "API version" is used as a way of checking that interfaces in the ## liboctave and libinterp libraries haven't changed in a backwardly @@ -245,14 +245,14 @@ fi ### Use atomic operations for internal reference counting. This is required -### for thread-safe behavior but incurs a significant slowdown, and is thus -### disabled by default. - -USE_ATOMIC_REFCOUNT=no +### for thread-safe behavior (Qt Handles) but incurs a significant slowdown. +### Enabled by default until a higher performing solution can be found. + +USE_ATOMIC_REFCOUNT=yes AC_ARG_ENABLE([atomic-refcount], - [AS_HELP_STRING([--enable-atomic-refcount], - [use atomic operations for internal reference counting. This is required for thread-safe behavior but does not by itself make Octave internals thread safe.])], - [if test "$enableval" = yes; then USE_ATOMIC_REFCOUNT=yes; fi], []) + [AS_HELP_STRING([--disable-atomic-refcount], + [Do not use atomic operations for internal reference counting. This option is required for thread-safe behavior as used in the GUI's Qt plotting toolkit. Performance for CLI-only builds is improved by disabling this feature.])], + [if test "$enableval" = no; then USE_ATOMIC_REFCOUNT=no; fi], []) if test $USE_ATOMIC_REFCOUNT = yes; then AC_DEFINE(USE_ATOMIC_REFCOUNT, 1, [Define to 1 to use atomic operations for reference counting.]) @@ -613,8 +613,17 @@ FFLAGS="-O" fi -## the F77 variable, if set, overrides AC_PROG_F77 automatically -AC_PROG_F77 +## Prefer gfortran, but the user's F77 environment variable will override. +AC_PROG_F77([gfortran]) +if test -z "$F77"; then + ## No gfortran found, search for any other installed compiler. + AC_PROG_F77 +fi +if test "$F77" = g77; then + AC_MSG_ERROR([g77 is not a supported Fortran compiler. Select another compiler by setting the environment variable F77 and re-running configure.]) +fi + +## Determine calling conventions for Fortran compiler AC_F77_LIBRARY_LDFLAGS AC_F77_DUMMY_MAIN AC_F77_WRAPPERS @@ -710,10 +719,6 @@ fi AC_SUBST(F77_INTEGER_8_FLAG) -## FIXME: Is this really used? Makefile seems to use $F77 for compiler -FC=$F77 -AC_SUBST(FC) - OCTAVE_F77_FLAG([-ffloat-store], [ AC_MSG_RESULT([setting F77_FLOAT_STORE_FLAG to -ffloat-store]) F77_FLOAT_STORE_FLAG=-ffloat-store @@ -723,7 +728,7 @@ ### Check for the Qhull library OCTAVE_CHECK_LIB(qhull, QHull, - [Qhull library not found -- this will result in loss of functionality of some geometry functions.], + [Qhull library not found. This will result in loss of functionality of some geometry functions.], [libqhull/libqhull.h qhull/libqhull.h libqhull.h qhull/qhull.h qhull.h], [qh_qhull], [], [], [warn_qhull= @@ -731,7 +736,7 @@ OCTAVE_CHECK_LIB_QHULL_OK( [TEXINFO_QHULL="@set HAVE_QHULL" AC_DEFINE(HAVE_QHULL, 1, [Define to 1 if Qhull is available.])], - [warn_qhull="Qhull library found, but does not seem to work properly -- this will result in loss of functionality of some geometry functions. Please try recompiling the library with -fno-strict-aliasing."])]) + [warn_qhull="Qhull library found, but does not seem to work properly. This will result in loss of functionality of some geometry functions. Please try recompiling the library with -fno-strict-aliasing."])]) ### Check for PCRE regex library. @@ -2183,7 +2188,7 @@ dnl These checks define/undefine HAVE_FUNCNAME in config.h. dnl Code tests HAVE_FUNCNAME and either uses function or provides workaround. dnl Use multiple AC_CHECKs to avoid line continuations '\' in list -AC_CHECK_FUNCS([canonicalize_file_name ctermid dup2]) +AC_CHECK_FUNCS([ctermid dup2]) AC_CHECK_FUNCS([endgrent endpwent execvp expm1 expm1f fork]) AC_CHECK_FUNCS([getegid geteuid getgid getgrent getgrgid getgrnam]) AC_CHECK_FUNCS([getpgrp getpid getppid getpwent getpwuid getuid]) @@ -2228,6 +2233,7 @@ OCTAVE_CHECK_FUNC_CMATH(isnan) OCTAVE_CHECK_FUNC_CMATH(isinf) OCTAVE_CHECK_FUNC_CMATH(isfinite) +OCTAVE_CHECK_FUNC_CMATH(signbit) ## Check for Inf and NaN functions @@ -2714,27 +2720,38 @@ [AS_HELP_STRING([--disable-gui], [don't build the GUI])], [if test "$enableval" = no; then build_gui=no; fi], []) +if test -z "$OPENGL_LIBS"; then + build_gui=no + if test $check_opengl = yes; then + warn_gui="OpenGL libs (GL and GLU) not found -- disabling GUI" + else + warn_gui="--without-opengl was specified -- disabling GUI" + fi + OCTAVE_CONFIGURE_WARNING([warn_gui]) +fi + if test $build_gui = yes; then warn_gui="" ## Check for Qt libraries - PKG_CHECK_MODULES(QT, [QtCore, QtGui, QtNetwork], + QT_MODULES="QtCore QtGui QtNetwork QtOpenGL" + PKG_CHECK_MODULES(QT, [$QT_MODULES], [], [warn_gui="Qt libraries not found -- disabling GUI" build_gui=no]) if test $build_gui = yes; then ## Retrieve Qt compilation and linker flags - QT_CPPFLAGS="`$PKG_CONFIG --cflags-only-I QtCore QtGui QtNetwork`" - QT_LDFLAGS="`$PKG_CONFIG --libs-only-L QtCore QtGui QtNetwork`" - QT_LIBS="`$PKG_CONFIG --libs-only-l QtCore QtGui QtNetwork`" + QT_CPPFLAGS="`$PKG_CONFIG --cflags-only-I $QT_MODULES`" + QT_LDFLAGS="`$PKG_CONFIG --libs-only-L $QT_MODULES`" + QT_LIBS="`$PKG_CONFIG --libs-only-l $QT_MODULES`" case $host_os in *darwin*) ## Qt might be installed in framework if test -z "$QT_LIBS"; then - QT_LDFLAGS="`$PKG_CONFIG --libs-only-other QtCore QtGui QtNetwork | tr ' ' '\n' | $GREP -e '-F' | uniq | tr '\n' ' '`" - QT_LIBS="`$PKG_CONFIG --libs-only-other QtCore QtGui QtNetwork | tr ' ' '\n' | $GREP -v -e '-F' | uniq | tr '\n' ' '`" + QT_LDFLAGS="`$PKG_CONFIG --libs-only-other $QT_MODULES | tr ' ' '\n' | $GREP -e '-F' | uniq | tr '\n' ' '`" + QT_LIBS="`$PKG_CONFIG --libs-only-other $QT_MODULES | tr ' ' '\n' | $GREP -v -e '-F' | uniq | tr '\n' ' '`" ## Enabling link_all_deps works around libtool's imperfect handling ## of the -F flag AM_CONDITIONAL([AMCOND_LINK_ALL_DEPS], @@ -2776,6 +2793,8 @@ OCTAVE_CHECK_QFONT_MONOSPACE OCTAVE_CHECK_QFONT_FORCE_INTEGER_METRICS OCTAVE_CHECK_FUNC_SETPLACEHOLDERTEXT + OCTAVE_CHECK_FUNC_QTABWIDGET_SETMOVABLE + OCTAVE_CHECK_FUNC_QSCI_FINDSELECTION fi if test $build_gui = yes; then @@ -3085,17 +3104,19 @@ warn_msg_printed=true fi -if test $USE_ATOMIC_REFCOUNT = yes; then +if test $USE_ATOMIC_REFCOUNT = no; then AC_MSG_WARN([]) - AC_MSG_WARN([Using atomic reference counting.]) + AC_MSG_WARN([atomic reference counting disabled.]) AC_MSG_WARN([This feature allows access to Octave data safely from]) - AC_MSG_WARN([another thread, for instance from a GUI. However this]) - AC_MSG_WARN([results in a small performance penalty in the Octave]) - AC_MSG_WARN([interpreter.]) + AC_MSG_WARN([another thread, and is required when using the GUI's Qt toolkit]) + AC_MSG_WARN([for plotting.]) AC_MSG_WARN([]) +fi +if test $USE_ATOMIC_REFCOUNT = yes; then if test $USE_OCTAVE_ALLOCATOR = yes; then - AC_MSG_WARN([Thread-safe behavior is not guaranteed unless you also]) - AC_MSG_WARN([disable the use of the octave_allocator class.]) + AC_MSG_WARN([Using atomic reference counting.]) + AC_MSG_WARN([Thread-safe behavior is not guaranteed unless the]) + AC_MSG_WARN([octave_allocator class is also disabled.]) AC_MSG_WARN([]) fi warn_msg_printed=true diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/basics.txi --- a/doc/interpreter/basics.txi Fri Jan 23 15:21:25 2015 -0500 +++ b/doc/interpreter/basics.txi Fri Jan 23 15:23:09 2015 -0500 @@ -244,16 +244,15 @@ @group PS1 = ">> " PS2 = "" -allow_noninteger_range_as_index = true beep_on_error = true confirm_recursive_rmdir = false crash_dumps_octave_core = false save_default_options = "-mat-binary" -do_braindead_shortcircuit_evaluation = true fixed_point_format = true history_timestamp_format_string = "%%-- %D %I:%M %p --%%" page_screen_output = false print_empty_dimensions = false +struct_levels_to_print = 0 @end group @end example @@ -266,6 +265,7 @@ Octave:fopen-file-in-path Octave:function-name-clash Octave:load-file-in-path +Octave:possible-matlab-short-circuit-operator @end group @end example diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/contributors.in --- a/doc/interpreter/contributors.in Fri Jan 23 15:21:25 2015 -0500 +++ b/doc/interpreter/contributors.in Fri Jan 23 15:23:09 2015 -0500 @@ -72,6 +72,7 @@ Stephen Fegan Ramon Garcia Fernandez Torsten Finke +Colin Foster Jose Daniel Munoz Frias Brad Froehle Castor Fu @@ -225,6 +226,7 @@ Elias Pipping Robert Platt Hans Ekkehard Plesser +Sergey Plotnikov Tom Poage Orion Poplawski Ondrej Popp diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/func.txi --- a/doc/interpreter/func.txi Fri Jan 23 15:21:25 2015 -0500 +++ b/doc/interpreter/func.txi Fri Jan 23 15:23:09 2015 -0500 @@ -393,6 +393,8 @@ which stops the function execution and prints a message about the correct way to call the function whenever the number of inputs is wrong. +@DOCSTRING(validateattributes) + For compatibility with @sc{matlab}, @code{nargchk}, @code{narginchk} and @code{nargoutchk} are available which provide similar error checking. diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/grammar.txi diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/macros.texi --- a/doc/interpreter/macros.texi Fri Jan 23 15:21:25 2015 -0500 +++ b/doc/interpreter/macros.texi Fri Jan 23 15:23:09 2015 -0500 @@ -28,14 +28,14 @@ @c which is `XXX'. This looks particularly bad when the macro body is @c single or double-quoted text, such as a property value `"position"' @ifinfo -@macro qcode{arg} +@rmacro qcode{arg} \arg\ -@end macro +@end rmacro @end ifinfo @ifnotinfo -@macro qcode{arg} +@rmacro qcode{arg} @code{\arg\} -@end macro +@end rmacro @end ifnotinfo @c The following macro is used for the on-line help system, but we don't diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/plot.txi --- a/doc/interpreter/plot.txi Fri Jan 23 15:21:25 2015 -0500 +++ b/doc/interpreter/plot.txi Fri Jan 23 15:23:09 2015 -0500 @@ -2652,17 +2652,23 @@ @item linestyle May be one of -@table @code -@item "-" +@table @asis +@item @qcode{"-"} Solid line. [default] -@item "--" +@c Special handling required to avoid '--' becoming single en-dash in Info +@ifnottex +@item @verb{|"--"|} +@end ifnottex +@iftex +@item @code{"--"} +@end iftex Dashed line. -@item ":" +@item @qcode{":"} Dotted line. -@item "-." +@item @qcode{"-."} A dash-dot line. @item @qcode{"none"} diff -r 75a671fcdd73 -r 844448ae53f3 doc/interpreter/var.txi diff -r 75a671fcdd73 -r 844448ae53f3 etc/NEWS.3 --- a/etc/NEWS.3 Fri Jan 23 15:21:25 2015 -0500 +++ b/etc/NEWS.3 Fri Jan 23 15:23:09 2015 -0500 @@ -1,3 +1,1523 @@ +Summary of important user-visible changes for version 3.8: +--------------------------------------------------------- + + ** One of the biggest new features for Octave 3.8 is a graphical user + interface. It is the one thing that users have requested most + often over the last few years and now it is almost ready. But + because it is not quite as polished as we would like, we have + decided to wait until the 4.0.x release series before making the + GUI the default interface (until then, you can use the --force-gui + option to start the GUI). + + Given the length of time and the number of bug fixes and + improvements since the last major release Octave, we also decided + against delaying the release of all these new improvements any + longer just to perfect the GUI. So please enjoy the 3.8 release of + Octave and the preview of the new GUI. We believe it is working + reasonably well, but we also know that there are some obvious rough + spots and many things that could be improved. + + WE NEED YOUR HELP. There are many ways that you can help us fix + the remaining problems, complete the GUI, and improve the overall + user experience for both novices and experts alike: + + * If you are a skilled software developer, you can help by + contributing your time to help with Octave's development. See + http://octave.org/get-involved.html for more information. + + * If Octave does not work properly, you are encouraged + report the problems you find. See http://octave.org/bugs.html + for more information about how to report problems. + + * Whether you are a user or developer, you can help to fund the + project. Octave development takes a lot of time and expertise. + Your contributions help to ensure that Octave will continue to + improve. See http://octave.org/donate.html for more details. + + We hope you find Octave to be useful. Please help us make it even + better for the future! + + ** Octave now uses OpenGL graphics by default with FLTK widgets. If + OpenGL libraries or FLTK widgets are not available when Octave is + built, gnuplot is used. You may also choose to use gnuplot for + graphics by executing the command + + graphics_toolkit ("gnuplot") + + Adding this command to your ~/.octaverc file will set the default + for each session. + + ** Printing or saving figures with OpenGL graphics requires the + gl2ps library which is no longer distributed with Octave. The + software is widely available in most package managers. If a + pre-compiled package does not exist for your system, you can find + the current sources at http://www.geuz.org/gl2ps/. + + ** Octave now supports nested functions with scoping rules that are + compatible with Matlab. A nested function is one declared and defined + within the body of another function. The nested function is only + accessible from within the enclosing function which makes it one + method for making private functions whose names do not conflict with those + in the global namespace (See also subfunctions and private functions). + In addition, variables in the enclosing function are visible within the + nested function. This makes it possible to have a pseudo-global variable + which can be seen by a group of functions, but which is not visible in + the global namespace. + + Example: + function outerfunc (...) + ... + function nested1 (...) + ... + function nested2 (...) + ... + endfunction + endfunction + + function nested3 (...) + ... + endfunction + endfunction + + ** Line continuations inside character strings have changed. + + The sequence '...' is no longer recognized as a line continuation + inside a character string. A backslash '\' followed by a newline + character is no longer recognized as a line continuation inside + single-quoted character strings. Inside double-quoted character + strings, a backslash followed by a newline character is still + recognized as a line continuation, but the backslash character must + be followed *immediately* by the newline character. No whitespace or + end-of-line comment may appear between them. + + ** Backslash as a continuation marker outside of double-quoted strings + is now deprecated. + + Using '\' as a continuation marker outside of double quoted strings + is now deprecated and will be removed from a future version of + Octave. When that is done, the behavior of + + (a \ + b) + + will be consistent with other binary operators. + + ** Redundant terminal comma accepted by parser + + A redundant terminal comma is now accepted in matrix + definitions which allows writing code such as + + [a,... + b,... + c,... + ] = deal (1,2,3) + + ** Octave now has limited support for named exceptions + + The following syntax is now accepted: + + try + statements + catch exception-id + statements + end + + The exception-id is a structure with the fields "message" and + "identifier". For example + + try + error ("Octave:error-id", "error message"); + catch myerr + printf ("identifier: %s\n", myerr.identifier); + printf ("message: %s\n", myerr.message); + end_try_catch + + When classdef-style classes are added to Octave, the exception-id + will become an MException object. + + ** Warning states may now be set temporarily, until the end of the + current function, using the syntax + + warning STATE ID "local" + + in which STATE may be "on", "off", or "error". Changes to warning + states that are set locally affect the current function and all + functions called from the current scope. The previous warning state + is restored on return from the current function. The "local" + option is ignored if used in the top-level workspace. + + ** Warning IDs renamed: + + Octave:array-as-scalar => Octave:array-to-scalar + Octave:array-as-vector => Octave:array-to-vector + + ** 'emptymatch', 'noemptymatch' options added to regular expressions. + + With this addition Octave now accepts the entire set of Matlab options + for regular expressions. 'noemptymatch' is the default, but 'emptymatch' + has certain uses where you need to match an assertion rather than actual + characters. For example, + + regexprep ('World', '^', 'Hello ', 'emptymatch') + => Hello World + + where the pattern is actually the assertion '^' or start-of-line. + + ** For compatibility with Matlab, the regexp, regexpi, and regexprep + functions now process backslash escape sequences in single-quoted pattern + strings. In addition, the regexprep function now processes backslash + escapes in single-quoted replacement strings. For example, + + regexprep (str, '\t', '\n') + + would search the variable str for a TAB character (escape sequence \t) + and replace it with a NEWLINE (escape sequence \n). Previously the + expression would have searched for a literal '\' followed by 't' and + replaced the two characters with the sequence '\', 'n'. + + ** A TeX parser has been implemented for the FLTK toolkit and is the default + for any text object including titles and axis labels. The TeX parser is + supported only for display on a monitor, not for printing. + + A quick summary of features: + + Code Feature Example Comment + ----------------------------------------------------------------- + _ subscript H_2O formula for water + ^ exponent y=x^2 formula for parabola + \char symbol \beta Greek symbol beta + \fontname font \fontname{Arial} set Arial font + \fontsize fontsize \fontsize{16} set fontsize 16 + \color[rgb] fontcolor \color[rgb]{1 0 1} set magenta color + \bf bold \bfBold Text bold font + \it italic \itItalic Text italic font + \sl slanted \slOblique Text slanted font + \rm normal \bfBold\rmNormal normal font + {} group {\bf Bold}Normal group objects + e^{i*\pi} = -1 group objects + + ** The m-files in the plot directory have been overhauled. + + The plot functions now produce output that is nearly visually compatible + with Matlab. Plot performance has also increased, dramatically for some + functions such as comet and waitbar. Finally, the documentation for most + functions has been updated so it should be clearer both how to use a + function and when a function is appropriate. + + ** The m-files in the image directory have been overhauled. + + The principal benefit is that Octave will now no longer automatically + convert images stored with integers to doubles. Storing images as uint8 + or uint16 requires only 1/8 or 1/4 the memory of an image stored using + doubles. For certain operations, such as fft2, the image must still be + converted to double in order to work. + + Other changes include fixes to the way indexed images are read from a + colormap depending on the image class (integer images have a -1 offset to + the colormap row number). + + ** The imread and imwrite functions have been completely rewritten. + + The main changes relate to the alpha channel, support for reading and + writing of floating point images, implemented writing of indexed images, + and appending images to multipage image files. + + The issues that may arise due to backwards incompatibility are: + + * imwrite no longer interprets a length of 2 or 4 in the third dimension + as grayscale or RGB with alpha channel (a length of 4 will be saved + as a CMYK image). Alpha channel must be passed as separate argument. + + * imread will always return the colormap indexes when reading an indexed + image, even if the colormap is not requested as output. + + * transparency values are now inverted from previous Octave versions + (0 is for completely transparent instead of completely opaque). + + In addition, the function imformats has been implemented to expand + reading and writing of images of different formats through imread + and imwrite. + + ** The colormap function now provides new options--"list", "register", + and "unregister"--to list all available colormap functions, and to + add or remove a function name from the list of known colormap + functions. Packages that implement extra colormaps should use these + commands with PKG_ADD and PKG_DEL statements. + + ** strsplit has been modified to be compatible with Matlab. There + are two instances where backward compatibility is broken. + + (1) Delimiters are now string vectors, not scalars. + + Octave's legacy behavior + + strsplit ("1 2, 3", ", ") + ans = + { + [1,1] = 1 + [1,2] = 2 + [1,3] = + [1,4] = 3 + } + + Matlab compatible behavior + + strsplit ("1 2, 3", ", ") + ans = + { + [1,1] = 1 2 + [1,2] = 3 + } + + (2) By default, Matlab treats consecutive delimiters as a single + delimiter. By default, Octave's legacy behavior was to return an + empty string for the part between the delmiters. + + Where legacy behavior is desired, the call to strsplit() may be + replaced by ostrsplit(), which is Octave's original implementation of + strsplit(). + + ** The datevec function has been extended for better Matlab compatibility. + It now accepts string inputs in the following numerical formats: 12, 21, + 22, 26, 29, 31. This is undocumented, but verifiable, Matlab behavior. + In addition, the default for formats which do not specify a date is + January 1st of the current year. The previous default was the current day, + month, and year. This may produce changes in existing scripts. + + ** The error function and its derivatives has been extended to accept complex + arguments. The following functions now accept complex inputs: + + erf erfc erfcx + + In addition two new error functions erfi (imaginary error function) and + dawson (scaled imaginary error function) have been added. + + ** The glpk function has been modified to reflect changes in the GLPK + library. The "round" and "itcnt" options have been removed. The + "relax" option has been replaced by the "rtest" option. The numeric + values of error codes and of some options have also changed. + + ** The kurtosis function has changed definition to be compatible with + Matlab. It now returns the base kurtosis instead of the "excess kurtosis". + The old behavior can be had by changing scripts to normalize with -3. + + "excess kurtosis" = kurtosis (x) - 3 + + ** The moment function has changed definition to be compatible with + Matlab. It now returns the central moment instead of the raw moment. + The old behavior can be had by passing the type argument "r" for raw. + + ** The default name of the Octave crash dump file is now + "octave-workspace" instead of "octave-core". The exact name can + always be customized with the octave_core_file_name function. + + ** A citation command has been added to display information on how to + cite Octave and packages in publications. The package system will + look for and install CITATION files from packages. + + ** The java package from Octave Forge is now part of core Octave. The + following new functions are available for interacting with Java + directly from Octave: + + debug_java java_matrix_autoconversion + isjava java_unsigned_autoconversion + java2mat javaaddpath + javaArray javaclasspath + javaMethod javamem + javaObject javarmpath + usejava + + In addition, the following functions that use the Java interface + are now available (provided that Octave is compiled with support for + Java enabled): + + helpdlg listdlg questdlg + inputdlg msgbox warndlg + + ** Other new functions added in 3.8.0: + + atan2d erfi lines + base64_decode expint linsolve + base64_encode findfigs missing_component_hook + betaincinv flintmax polyeig + built_in_docstrings_file fminsearch prefdir + cmpermute gallery preferences + cmunique gco readline_re_read_init_file + colorcube hdl2struct readline_read_init_file + copyobj history_save rgbplot + dawson imformats save_default_options + dblist importdata shrinkfaces + desktop isaxes splinefit + doc_cache_create iscolormap stemleaf + ellipj isequaln strjoin + ellipke jit_debug struct2hdl + erfcinv jit_enable tetramesh + jit_startcnt waterfall + + ** Deprecated functions. + + The following functions were deprecated in Octave 3.4 and have been + removed from Octave 3.8. + + autocor dispatch is_global setstr + autocov fstat krylovb strerror + betai gammai perror values + cellidx glpkmex replot + cquad is_duplicate_entry saveimage + + The following functions have been deprecated in Octave 3.8 and will + be removed from Octave 3.12 (or whatever version is the second major + release after 3.8): + + default_save_options java_new + gen_doc_cache java_set + interp1q java_unsigned_conversion + isequalwithequalnans javafields + java_convert_matrix javamethods + java_debug re_read_readline_init_file + java_get read_readline_init_file + java_invoke saving_history + + + The following keywords have been deprecated in Octave 3.8 and will + be removed from Octave 3.12 (or whatever version is the second major + release after 3.8): + + static + + The following configuration variables have been deprecated in Octave + 3.8 and will be removed from Octave 3.12 (or whatever version is the + second major release after 3.8): + + CC_VERSION (now GCC_VERSION) + CXX_VERSION (now GXX_VERSION) + + The internal class has been deprecated in Octave 3.8 and will + be removed from Octave 3.12 (or whatever version is the second major + release after 3.8). Replacement classes are (struct array) + or for a single structure. + +Summary of important user-visible changes for version 3.6: +--------------------------------------------------------- + + ** The PCRE library is now required to build Octave. If a pre-compiled + package does not exist for your system, you can find PCRE sources + at http://www.pcre.org + + ** The ARPACK library is no longer distributed with Octave. + If you need the eigs or svds functions you must provide an + external ARPACK through a package manager or by compiling it + yourself. If a pre-compiled package does not exist for your system, + you can find the current ARPACK sources at + http://forge.scilab.org/index.php/p/arpack-ng + + ** Many of Octave's binary operators (.*, .^, +, -, ...) now perform + automatic broadcasting for array operations which allows you to use + operator notation instead of calling bsxfun or expanding arrays (and + unnecessarily wasting memory) with repmat or similar idioms. For + example, to scale the columns of a matrix by the elements of a row + vector, you may now write + + rv .* M + + In this expression, the number of elements of rv must match the + number of columns of M. The following operators are affected: + + plus + .+ + minus - .- + times .* + rdivide ./ + ldivide .\ + power .^ .** + lt < + le <= + eq == + gt > + ge >= + ne != ~= + and & + or | + atan2 + hypot + max + min + mod + rem + xor + + additionally, since the A op= B assignment operators are equivalent + to A = A op B, the following operators are also affected: + + += -= .+= .-= .*= ./= .\= .^= .**= &= |= + + See the "Broadcasting" section in the new "Vectorization and Faster + Code Execution" chapter of the manual for more details. + + ** Octave now features a profiler, thanks to the work of Daniel Kraft + under the Google Summer of Code mentorship program. The manual has + been updated to reflect this addition. The new user-visible + functions are profile, profshow, and profexplore. + + ** Overhaul of statistical distribution functions + + Functions now return "single" outputs for inputs of class "single". + + 75% reduction in memory usage through use of logical indexing. + + Random sample functions now use the same syntax as rand and accept + a comma separated list of dimensions or a dimension vector. + + Functions have been made Matlab-compatible with regard to special + cases (probability on boundaries, probabilities for values outside + distribution, etc.). This may cause subtle changes to existing + scripts. + + negative binomial function has been extended to real, non-integer + inputs. The discrete_inv function now returns v(1) for 0 instead of + NaN. The nbincdf function has been recoded to use a closed form + solution with betainc. + + ** strread, textscan, and textread have been completely revamped. + + They now support nearly all Matlab functionality including: + + * Matlab-compatible whitespace and delimiter defaults + + * Matlab-compatible options: 'whitespace', treatasempty', format + string repeat count, user-specified comment style, uneven-length + output arrays, %n and %u conversion specifiers (provisionally) + + ** All .m string functions have been modified for better performance or + greater Matlab compatibility. Performance gains of 15X-30X have + been demonstrated. Operations on cell array of strings no longer pay + quite as high a penalty as those on 2-D character arrays. + + deblank: Now requires character or cellstr input. + + strtrim: Now requires character or cellstr input. + No longer trims nulls ("\0") from string for Matlab + compatibility. + + strmatch: Follows documentation precisely and ignores trailing spaces + in pattern and in string. Note that this is documented + Matlab behavior but the implementation apparently does + not always follow it. + + substr: Now possible to specify a negative LEN option which + extracts to within LEN of the end of the string. + + strtok: Now accepts cellstr input. + + base2dec, bin2dec, hex2dec: + Now accept cellstr inputs. + + dec2base, dec2bin, dec2hex: + Now accept cellstr inputs. + + index, rindex: + Now accept 2-D character array input. + + strsplit: Now accepts 2-D character array input. + + ** Geometry functions derived from Qhull (convhull, delaunay, voronoi) + have been revamped. The options passed to the underlying qhull + command have been changed for better results or for Matlab + compatibility. + + convhull: Default options are "Qt" for 2D, 3D, 4D inputs + Default options are "Qt Qx" for 5D and higher + + delaunay: Default options are "Qt Qbb Qc Qz" for 2D and 3D inputs + Default options are "Qt Qbb Qc Qx" for 4D and higher + + voronoi: No default arguments + + ** Date/Time functions updated. Millisecond support with FFF format + string now supported. + + datestr: Numerical formats 21, 22, 29 changed to match Matlab. + Now accepts cellstr input. + + ** The following warning IDs have been removed: + + Octave:associativity-change + Octave:complex-cmp-ops + Octave:empty-list-elements + Octave:fortran-indexing + Octave:precedence-change + + ** The warning ID Octave:string-concat has been renamed to + Octave:mixed-string-concat. + + ** Octave now includes the following Matlab-compatible preference + functions: + + addpref getpref ispref rmpref setpref + + ** The following Matlab-compatible handle graphics functions have been + added: + + guidata uipanel uitoolbar + guihandles uipushtool uiwait + uicontextmenu uiresume waitfor + uicontrol uitoggletool + + The uiXXX functions above are experimental. + + Except for uiwait and uiresume, the uiXXX functions are not + supported with the FLTK+OpenGL graphics toolkit. + + The gnuplot graphics toolkit does not support any of the uiXXX + functions nor the waitfor function. + + ** New keyword parfor (parallel for loop) is now recognized as a valid + keyword. Implementation, however, is still mapped to an ordinary + for loop. + + ** Other new functions added in 3.6.0: + + bicg nthargout usejava + is_dq_string narginchk waitbar + is_sq_string python zscore + is_function_handle register_graphics_toolkit + loaded_graphics_toolkits recycle + + ** Deprecated functions. + + The following functions were deprecated in Octave 3.2 and have been + removed from Octave 3.6. + + create_set spcholinv splu + dmult spcumprod spmax + iscommand spcumsum spmin + israwcommand spdet spprod + lchol spdiag spqr + loadimage spfind spsum + mark_as_command sphcat spsumsq + mark_as_rawcommand spinv spvcat + spatan2 spkron str2mat + spchol splchol unmark_command + spchol2inv split unmark_rawcommand + + The following functions have been deprecated in Octave 3.6 and will + be removed from Octave 3.10 (or whatever version is the second major + release after 3.6): + + cut polyderiv + cor shell_cmd + corrcoef studentize + __error_text__ sylvester_matrix + error_text + + ** The following functions have been modified for Matlab compatibility: + + randperm + +Summary of important user-visible changes for version 3.4.3: +----------------------------------------------------------- + + ** Octave 3.4.3 is a bug fixing release. + +Summary of important user-visible changes for version 3.4.2: +----------------------------------------------------------- + + ** Octave 3.4.2 fixes some minor installation problems that affected + version 3.4.1. + +Summary of important user-visible changes for version 3.4.1: +----------------------------------------------------------- + + ** Octave 3.4.1 is primarily a bug fixing release. + + ** IMPORTANT note about binary incompatibility in this release: + + Binary compatibility for all 3.4.x releases was originally planned, + but this is impossible for the 3.4.1 release due to a bug in the way + shared libraries were built in Octave 3.4.0. Because of this bug, + .oct files built for Octave 3.4.0 must be recompiled before they + will work with Octave 3.4.1. + + Given that there would be binary incompatibilities with shared + libraries going from Octave 3.4.0 to 3.4.1, the following + incompatible changes were also made in this release: + + * The Perl Compatible Regular Expression (PCRE) library is now + required to build Octave. + + * Octave's libraries and .oct files are now installed in + subdirectories of $libdir instead of $libexecdir. + + Any future Octave 3.4.x release versions should remain binary + compatible with Octave 3.4.1 as proper library versioning is now + being used as recommended by the libtool manual. + + ** The following functions have been deprecated in Octave 3.4.1 and will + be removed from Octave 3.8 (or whatever version is the second major + release after 3.4): + + cquad is_duplicate_entry perror strerror + + ** The following functions are new in 3.4.1: + + colstyle gmres iscolumn isrow mgorth nproc rectangle + + ** The get_forge_pkg function is now private. + + ** The rectangle_lw, rectangle_sw, triangle_lw, and triangle_sw + functions are now private. + + ** The logistic_regression_derivatives and logistic_regression_likelihood + functions are now private. + + ** ChangeLog files in the Octave sources are no longer maintained + by hand. Instead, there is a single ChangeLog file generated from + the Mercurial version control commit messages. Older ChangeLog + information can be found in the etc/OLD-ChangeLogs directory in the + source distribution. + +Summary of important user-visible changes for version 3.4: +--------------------------------------------------------- + + ** BLAS and LAPACK libraries are now required to build Octave. The + subset of the reference BLAS and LAPACK libraries has been removed + from the Octave sources. + + ** The ARPACK library is now distributed with Octave so it no longer + needs to be available as an external dependency when building + Octave. + + ** The `lookup' function was extended to be more useful for + general-purpose binary searching. Using this improvement, the + ismember function was rewritten for significantly better + performance. + + ** Real, integer and logical matrices, when used in indexing, will now + cache the internal index_vector value (zero-based indices) when + successfully used as indices, eliminating the conversion penalty for + subsequent indexing by the same matrix. In particular, this means it + is no longer needed to avoid repeated indexing by logical arrays + using find for performance reasons. + + ** Logical matrices are now treated more efficiently when used as + indices. Octave will keep the index as a logical mask unless the + ratio of true elements is small enough, using a specialized + code. Previously, all logical matrices were always first converted + to index vectors. This results in savings in both memory and + computing time. + + ** The `sub2ind' and `ind2sub' functions were reimplemented as compiled + functions for better performance. These functions are now faster, + can deliver more economized results for ranges, and can reuse the + index cache mechanism described in previous paragraph. + + ** The built-in function equivalents to associative operators (`plus', + `times', `mtimes', `and', and `or') have been extended to accept + multiple arguments. This is especially useful for summing + (multiplying, etc.) lists of objects (of possibly distinct types): + + matrix_sum = plus (matrix_list{:}); + + ** An FTP object type based on libcurl has been implemented. These + objects allow ftp connections, downloads and uploads to be + managed. For example, + + fp = ftp ("ftp.octave.org); + cd (fp, "gnu/octave"); + mget (fp, "octave-3.2.3.tar.bz2"); + close (fp); + + ** The default behavior of `assert (observed, expected)' has been + relaxed to employ less strict checking that does not require the + internals of the values to match. This avoids previously valid + tests from breaking due to new internal classes introduced in future + Octave versions. + + For instance, all of these assertions were true in Octave 3.0.x + but false in 3.2.x due to new optimizations and improvements: + + assert (2*linspace (1, 5, 5), 2*(1:5)) + assert (zeros (0, 0), []) + assert (2*ones (1, 5), (2) (ones (1,5))) + + ** The behavior of library functions `ismatrix', `issquare', and + `issymmetric' has been changed for better consistency. + + * The `ismatrix' function now returns true for all numeric, + logical and character 2-D or N-D matrices. Previously, `ismatrix' + returned false if the first or second dimension was zero. + Hence, `ismatrix ([])' was false, + while `ismatrix (zeros (1,2,0))' was true. + + * The `issquare' function now returns a logical scalar, and is + equivalent to the expression + + ismatrix (x) && ndims (x) == 2 && rows (x) == columns (x) + + The dimension is no longer returned. As a result, `issquare ([])' + now yields true. + + * The `issymmetric' function now checks for symmetry instead of + Hermitianness. For the latter, ishermitian was created. Also, + logical scalar is returned rather than the dimension, so + `issymmetric ([])' is now true. + + ** Function handles are now aware of overloaded functions. If a + function is overloaded, the handle determines at the time of its + reference which function to call. A non-overloaded version does not + need to exist. + + ** Overloading functions for built-in classes (double, int8, cell, + etc.) is now compatible with Matlab. + + ** Function handles can now be compared with the == and != operators, + as well as the `isequal' function. + + ** Performance of concatenation (using []) and the functions `cat', + `horzcat', and `vertcat' has been improved for multidimensional + arrays. + + ** The operation-assignment operators +=, -=, *= and /= now behave more + efficiently in certain cases. For instance, if M is a matrix and S a + scalar, then the statement + + M += S; + + will operate on M's data in-place if it is not shared by another + variable, usually increasing both time and memory efficiency. + + Only selected common combinations are affected, namely: + + matrix += matrix + matrix -= matrix + matrix .*= matrix + matrix ./= matrix + + matrix += scalar + matrix -= scalar + matrix *= scalar + matrix /= scalar + + logical matrix |= logical matrix + logical matrix &= logical matrix + + where matrix and scalar belong to the same class. The left-hand + side must be a simple variable reference. + + Moreover, when unary operators occur in expressions, Octave will + also try to do the operation in-place if it's argument is a + temporary expression. + + ** The effect of comparison operators (<, >, <=, and >=) applied to + complex numbers has changed to be consistent with the strict + ordering defined by the `max', `min', and `sort' functions. More + specifically, complex numbers are compared by lexicographical + comparison of the pairs `[abs(z), arg(z)]'. Previously, only real + parts were compared; this can be trivially achieved by converting + the operands to real values with the `real' function. + + ** The automatic simplification of complex computation results has + changed. Octave will now simplify any complex number with a zero + imaginary part or any complex matrix with all elements having zero + imaginary part to a real value. Previously, this was done only for + positive zeros. Note that the behavior of the complex function is + unchanged and it still produces a complex value even if the + imaginary part is zero. + + ** As a side effect of code refactoring in liboctave, the binary + logical operations are now more easily amenable to compiler + optimizations and are thus significantly faster. + + ** Octave now allows user-defined `subsasgn' methods to optimize out + redundant copies. For more information, see the manual. + + ** More efficient matrix division handling. Octave is now able to + handle the expressions + + M' \ V + M.' \ V + V / M + + (M is a matrix and V is a vector) more efficiently in certain cases. + In particular, if M is triangular, all three expressions will be + handled by a single call to xTRTRS (from LAPACK), with appropriate + flags. Previously, all three expressions required a physical + transpose of M. + + ** More efficient handling of certain mixed real-complex matrix + operations. For instance, if RM is a real matrix and CM a complex + matrix, + + RM * CM + + can now be evaluated either as + + complex (RM * real (CM), RM * imag (CM)) + + or as + + complex (RM) * CM, + + depending on the dimensions. The first form requires more + temporaries and copying, but halves the FLOP count, which normally + brings better performance if RM has enough rows. Previously, the + second form was always used. + + Matrix division is similarly affected. + + ** More efficient handling of triangular matrix factors returned from + factorizations. The functions for computing QR, LU and Cholesky + factorizations will now automatically return the triangular matrix + factors with proper internal matrix_type set, so that it won't need + to be computed when the matrix is used for division. + + ** The built-in `sum' function now handles the non-native summation + (i.e., double precision sum of single or integer inputs) more + efficiently, avoiding a temporary conversion of the whole input + array to doubles. Further, `sum' can now accept an extra option + argument, using a compensated summation algorithm rather than a + straightforward sum, which significantly improves precision if lots + of cancellation occurs in the summation. + + ** The built-in `bsxfun' function now uses optimized code for certain + cases where built-in operator handles are passed in. Namely, the + optimizations concern the operators `plus', `minus', `times', + `ldivide', `rdivide', `power', `and', `or' (for logical arrays), + the relational operators `eq', `ne', `lt', `le', `gt', `ge', and the + functions `min' and `max'. Optimizations only apply when both + operands are of the same built-in class. Mixed real/complex and + single/double operations will first convert both operands to a + common type. + + ** The `strfind' and `strrep' functions now have compiled + implementations, facilitating significantly more efficient searching + and replacing in strings, especially with longer patterns. The code + of `strcat' has been vectorized and is now much more efficient when + many strings are concatenated. The `strcmpi' and `strncmpi' + functions are now built-in functions, providing better performance. + + ** 'str2double' now has a compiled implementation and the API conforms + to Matlab. The additional Octave-specific features of returning a + boolean matrix indicating which elements were successfully converted + has been removed. + + ** Matlab-style ignoring input and output function arguments using + tilde (~) is now supported. Ignored output arguments may be + detected from a function using the built-in function `isargout'. + For more details, consult the manual. + + ** The list datatype, deprecated since the introduction of cells, has + been removed. + + ** The accumarray function has been optimized and is now significantly + faster in certain important cases. + + ** The behavior of isreal and isnumeric functions was changed to be more + Matlab-compatible. + + ** The integer math & conversion warnings (Octave:int-convert-nan, + Octave:int-convert-non-int-val, Octave:int-convert-overflow, + Octave:int-math-overflow) have been removed. + + ** rem and mod are now built-in functions. They also handle integer + types efficiently using integer arithmetic. + + ** Sparse indexing and indexed assignment has been mostly rewritten. + Since Octave uses compressed column storage for sparse matrices, + major attention is devoted to operations manipulating whole columns. + Such operations are now significantly faster, as well as some other + important cases. + + Further, it is now possible to pre-allocate a sparse matrix and + subsequently fill it by assignments, provided they meet certain + conditions. For more information, consult the `spalloc' function, + which is no longer a mere dummy. Consequently, nzmax and nnz are no + longer always equal in Octave. Octave may also produce a matrix + with nnz < nzmax as a result of other operations, so you should + consistently use nnz unless you really want to use nzmax (i.e., the + space allocated for nonzero elements). + + Sparse concatenation is also affected, and concatenating sparse + matrices, especially larger collections, is now significantly more + efficient. This applies to both the [] operator and the + cat/vertcat/horzcat functions. + + ** It is now possible to optionally employ the xGESDD LAPACK drivers + for computing the singular value decomposition using svd, instead + of the default xGESVD, using the configuration pseudo-variable + svd_driver. The xGESDD driver can be up to 6x times faster when + singular vectors are requested, but is reported to be somewhat less + robust on highly ill-conditioned matrices. + + ** Configuration pseudo-variables, such as page_screen_output or + confirm_recursive_rmdir (or the above mentioned svd_driver), now + accept a "local" option as second argument, requesting the change + to be undone when the current function returns: + + function [status, msg] = rm_rf (dir) + confirm_recursive_rmdir (false, "local"); + [status, msg] = rmdir (dir, "s"); + ... + endfunction + + Upon return, confirm_recursive_rmdir will be restored to the value + it had on entry to the function, even if there were subsequent + changes to the variable in function rm_rf or any of the functions + it calls. + + ** pkg now accepts a -forge option for downloading and installing + packages from Octave Forge automatically. For example, + + pkg install -forge general + + will automatically download the latest release of the general + package and attempt to install it. No automatic resolving of + dependencies is provided. Further, + + pkg list -forge + + can be used to list all available packages. + + ** The internal data representation of structs has been completely + rewritten to make certain optimizations feasible. The field data + can now be shared between structs with equal keys but different + dimensions or values, making operations that preserve the fields + faster. Economized storage is now used for scalar structs (just + like most other scalars), making their usage more + memory-efficient. Certain array-like operations on structs + (concatenation, uniform cellfun, num2cell) have gained a + significant speed-up. Additionally, the octave_scalar_map class + now provides a simpler interface to work with scalar structs within + a C++ DLD function. + + ** Two new formats are available for displaying numbers: + + format short eng + format long eng + + Both display numbers in engineering notation, i.e., mantissa + + exponent where the exponent is a multiple of 3. + + ** The following functions are new in Octave 3.4: + accumdim erfcx nfields pqpnonneg uigetdir + bitpack fileread nth_element quadcc uigetfile + bitunpack fminbnd onCleanup randi uiputfile + blkmm fskipl pbaspect repelems uimenu + cbrt ifelse pie3 reset whitebg + curl ishermitian powerset rsf2csf + chop isindex ppder saveas + daspect luupdate ppint strread + divergence merge ppjumps textread + + ** Using the image function to view images with external programs such + as display, xv, and xloadimage is no longer supported. The + image_viewer function has also been removed. + + ** The behavior of struct assignments to non-struct values has been + changed. Previously, it was possible to overwrite an arbitrary + value: + + a = 1; + a.x = 2; + + This is no longer possible unless a is an empty matrix or cell + array. + + ** The dlmread function has been extended to allow specifying a custom + value for empty fields. + + ** The dlmread and dlmwrite functions have been modified to accept + file IDs (as returned by fopen) in addition to file names. + + ** Octave can now optimize away the interpreter overhead of an + anonymous function handle, if the function simply calls another + function or handle with some of its parameters bound to certain + values. Example: + + f = @(x) sum (x, 1); + + When f is called, the call is forwarded to @sum with the constant 1 + appended, and the anonymous function call does not occur on the + call stack. + + ** For compatibility with Matlab, mu2lin (x) is now equivalent to + mu2lin (x, 0). + + ** The new function `history_control' may be used to control the way + command lines are added to the history list when Octave is using + readline for command-line editing. For example + + history_control ("ignoredups") + + tells Octave to avoid adding duplicate lines to the history list. + + ** Octave now uses the gnulib library for improved portability and to + avoid bugs in operating system functions. + + ** Deprecated functions. + + The following functions were deprecated in Octave 3.0 and have been + removed from Octave 3.4. + + beta_cdf geometric_pdf pascal_pdf + beta_inv geometric_rnd pascal_rnd + beta_pdf hypergeometric_cdf poisson_cdf + beta_rnd hypergeometric_inv poisson_inv + binomial_cdf hypergeometric_pdf poisson_pdf + binomial_inv hypergeometric_rnd poisson_rnd + binomial_pdf intersection polyinteg + binomial_rnd is_bool setstr + chisquare_cdf is_complex struct_contains + chisquare_inv is_list struct_elements + chisquare_pdf is_matrix t_cdf + chisquare_rnd is_scalar t_inv + clearplot is_square t_pdf + clg is_stream t_rnd + com2str is_struct uniform_cdf + exponential_cdf is_symmetric uniform_inv + exponential_inv is_vector uniform_pdf + exponential_pdf isstr uniform_rnd + exponential_rnd lognormal_cdf weibcdf + f_cdf lognormal_inv weibinv + f_inv lognormal_pdf weibpdf + f_pdf lognormal_rnd weibrnd + f_rnd meshdom weibull_cdf + gamma_cdf normal_cdf weibull_inv + gamma_inv normal_inv weibull_pdf + gamma_pdf normal_pdf weibull_rnd + gamma_rnd normal_rnd wiener_rnd + geometric_cdf pascal_cdf + geometric_inv pascal_inv + + The following functions were deprecated in Octave 3.2 and will + be removed from Octave 3.6 (or whatever version is the second major + release after 3.2): + + create_set spcholinv splu + dmult spcumprod spmax + iscommand spcumsum spmin + israwcommand spdet spprod + lchol spdiag spqr + loadimage spfind spsum + mark_as_command sphcat spsumsq + mark_as_rawcommand spinv spvcat + spatan2 spkron str2mat + spchol splchol unmark_command + spchol2inv split unmark_rawcommand + + The following functions have been deprecated in Octave 3.4 and will + be removed from Octave 3.8 (or whatever version is the second major + release after 3.4): + + autocor cellidx gammai is_global replot values + autocov dispatch glpkmex krylovb saveimage + betai fstat intwarning perror strerror + +Summary of important user-visible changes for version 3.2: +--------------------------------------------------------- + + ** Compatibility with Matlab graphics has been improved. + + The hggroup object and associated listener callback functions have + been added allowing the inclusion of group objects. Data sources + have been added to these group objects such that + + x = 0:0.1:10; + y = sin (x); + plot (x, y, "ydatasource", "y"); + for i = 1 : 100 + pause(0.1) + y = sin (x + 0.1 * i); + refreshdata (); + endfor + + works as expected. This capability has be used to introduce + stem-series, bar-series, etc., objects for better Matlab + compatibility. + + ** New graphics functions: + + addlistener ezcontour gcbo refresh + addproperty ezcontourf ginput refreshdata + allchild ezmesh gtext specular + available_graphics_toolkits ezmeshc intwarning surfl + graphics_toolkit ezplot ishghandle trisurf + cla ezplot3 isocolors waitforbuttonpress + clabel ezpolar isonormals + comet ezsurf isosurface + dellistener findall linkprop + diffuse gcbf plotmatrix + + ** New experimental OpenGL/FLTK based plotting system. + + An experimental plotting system based on OpenGL and the FLTK + toolkit is now part of Octave. This graphics toolkit is disabled by + default. You can switch to using it with the command + + graphics_toolkit ("fltk") + + for all future figures or for a particular figure with the command + + graphics_toolkit (h, "fltk") + + where "h" is a valid figure handle. + + ** Functions providing direct access to gnuplot have been removed. + + The functions __gnuplot_plot__, __gnuplot_set__, __gnuplot_raw__, + __gnuplot_show__, __gnuplot_replot__, __gnuplot_splot__, + __gnuplot_save_data__ and __gnuplot_send_inline_data__ have been + removed from Octave. These function were incompatible with the + high level graphics handle code. + + ** The Control, Finance and Quaternion functions have been removed. + + These functions are now available as separate packages from + + http://octave.sourceforge.net/packages.html + + and can be reinstalled using the Octave package manager (see + the pkg function). + + ** Specific sparse matrix functions removed. + + The following functions, which handled only sparse matrices have + been removed. Instead of calling these functions directly, you + should use the corresponding function without the "sp" prefix. + + spatan2 spcumsum spkron spprod + spchol spdet splchol spqr + spchol2inv spdiag splu spsum + spcholinv spfind spmax spsumsqk + spcumprod spinv spmin + + ** Improvements to the debugger. + + The interactive debugging features have been improved. Stopping + on statements with dbstop should work correctly now. Stepping + into and over functions, and stepping one statement at a time + (with dbstep) now works. Moving up and down the call stack with + dbup and dbdown now works. The dbstack function is now available + to print the current function call stack. The new dbquit function + is available to exit the debugging mode. + + ** Improved traceback error messages. + + Traceback error messages are much more concise and easier to + understand. They now display information about the function call + stack instead of the stack of all statements that were active at + the point of the error. + + ** Object Oriented Programming. + + Octave now includes OOP features and the user can create their own + class objects and overloaded functions and operators. For + example, all methods of a class called "myclass" will be found in + a directory "@myclass" on the users path. The class specific + versions of functions and operators take precedence over the + generic versions of these functions. + + New functions related to OOP include + + class inferiorto isobject loadobj methods superiorto + + See the Octave manual for more details. + + ** Parsing of Command-style Functions. + + Octave now parses command-style functions without needing to first + declare them with "mark_as_command". The rules for recognizing a + command-style function calls are + + * A command must appear as the first word in a statement, + followed by a space. + + * The first character after the space must not be '=' or '(' + + * The next token after the space must not look like a binary + operator. + + These rules should be mostly compatible with the way Matlab parses + command-style function calls and allow users to define commands in + .m files without having to mark them as commands. + + Note that previous versions of Octave allowed expressions like + + x = load -text foo.dat + + but an expression like this will now generate a parse error. In + order to assign the value returned by a function to a variable, + you must use the normal function call syntax: + + x = load ("-text", "foo.dat"); + + ** Block comments. + + Commented code can be between matching "#{" and "#}" or "%{" and + "%}" markers, even if the commented code spans several line. This + allows blocks code to be commented, without needing to comment + each line. For example, + + function [s, t] = func (x, y) + s = 2 * x; + #{ + s *= y; + t = y + x; + #} + endfunction + + the lines "s *= y;" and "t = y + x" will not be executed. + + ** If any subfunction in a file ends with "end" or "endfunction", then + they all must end that way. Previously, Octave accepted + + function main () + ... + # no endfunction here. + function sub () + ... + endfunction + + but this is no longer allowed. + + ** Special treatment in the parser of expressions like "a' * b". + + In these cases the transpose is no longer explicitly formed and + BLAS libraries are called with the transpose flagged, + significantly improving performance for these kinds of + operations. + + ** Single Precision data type. + + Octave now includes a single precision data type. Single + precision variables can be created with the "single" command, or + from functions like ones, eye, etc. For example, + + single (1) + ones (2, 2, "single") + zeros (2, 2, "single") + eye (2, 2, "single") + Inf (2, 2, "single") + NaN (2, 2, "single") + NA (2, 2, "single") + + all create single precision variables. For compatibility with + Matlab, mixed double/single precision operators and functions + return single precision types. + + As a consequence of this addition to Octave the internal + representation of the double precision NA value has changed, and + so users that make use of data generated by Octave with R or + visa-versa are warned that compatibility might not be assured. + + ** Improved array indexing. + + The underlying code used for indexing of arrays has been + completely rewritten and indexing is now significantly faster. + + ** Improved memory management. + + Octave will now attempt to share data in some cases where previously + a copy would be made, such as certain array slicing operations or + conversions between cells, structs and cs-lists. This usually reduces + both time and memory consumption. + Also, Octave will now attempt to detect and optimize usage of a vector + as a stack, when elements are being repeatedly inserted at/removed from + the end of the vector. + + ** Improved performance for reduction operations. + + The performance of the sum, prod, sumsq, cumsum, cumprod, any, all, + max and min functions has been significantly improved. + + ** Sorting and searching. + + The performance of sort has been improved, especially when sorting + indices are requested. An efficient built-in issorted + implementation was added. The sortrows function now uses a more + efficient algorithm, especially in the homogeneous case. The lookup + function is now a built-in function performing a binary search, + optimized for long runs of close elements. Lookup also works with + cell arrays of strings. + + ** Range arithmetics + + For some operations on ranges, Octave will attempt to keep the + result as a range. These include negation, adding a scalar, + subtracting a scalar, and multiplying by a scalar. Ranges with zero + increment are allowed and can be constructed using the built-in + function `ones'. + + ** Various performance improvements. + + Performance of a number of other built-in operations and functions + was improved, including: + + * logical operations + * comparison operators + * element-wise power + * accumarray + * cellfun + * isnan + * isinf + * isfinite + * nchoosek + * repmat + * strcmp + + ** 64-bit integer arithmetic. + + Arithmetic with 64-bit integers (int64 and uint64 types) is fully + supported, with saturation semantics like the other integer types. + Performance of most integer arithmetic operations has been + improved by using integer arithmetic directly. Previously, Octave + performed integer math with saturation semantics by converting the + operands to double precision, performing the operation, and then + converting the result back to an integer value, truncating if + necessary. + + ** Diagonal and permutation matrices. + + The interpreter can now treat diagonal and permutation matrices as + special objects that store only the non-zero elements, rather than + general full matrices. Therefore, it is now possible to construct + and use these matrices in linear algebra without suffering a + performance penalty due to storing large numbers of zero elements. + + ** Improvements to fsolve. + + The fsolve function now accepts an option structure argument (see + also the optimset function). The INFO values returned from fsolve + have changed to be compatible with Matlab's fsolve function. + Additionally, fsolve is now able to solve overdetermined systems, + complex-differentiable complex systems, systems with a sparse + jacobian and can work in single precision if given single precision + inputs. It can also be called recursively. + + ** Improvements to the norm function. + + The norm function is now able to compute row or column norms of a + matrix in a single call, as well as general matrix p-norms. + + ** New functions for computing some eigenvalues or singular values. + + The eigs and svds functions have been included in Octave. These + functions require the ARPACK library (now distributed under a + GPL-compatible license). + + ** New QR and Cholesky factorization updating functions. + + choldelete cholshift qrdelete qrshift + cholinsert cholupdate qrinsert qrupdate + + ** New quadrature functions. + + dblquad quadgk quadv triplequad + + ** New functions for reading and writing images. + + The imwrite and imread functions have been included in Octave. + These functions require the GraphicsMagick library. The new + function imfinfo provides information about an image file (size, + type, colors, etc.) + + ** The input_event_hook function has been replaced by the pair of + functions add_input_event_hook and remove_input_event_hook so that + more than one hook function may be installed at a time. + + ** Other miscellaneous new functions. + + addtodate hypot reallog + bicgstab idivide realpow + cellslices info realsqrt + cgs interp1q rectint + command_line_path isdebugmode regexptranslate + contrast isfloat restoredefaultpath + convn isstrprop roundb + cummin log1p rundemos + cummax lsqnonneg runlength + datetick matlabroot saveobj + display namelengthmax spaugment + expm1 nargoutchk strchr + filemarker pathdef strvcat + fstat perl subspace + full prctile symvar + fzero quantile treelayout + genvarname re_read_readline_init_file validatestring + histc + + ** Changes to strcat. + + The strcat function is now compatible with Matlab's strcat + function, which removes trailing whitespace when concatenating + character strings. For example + + strcat ('foo ', 'bar') + ==> 'foobar' + + The new function cstrcat provides the previous behavior of + Octave's strcat. + + ** Improvements to the help functions. + + The help system has been mostly re-implemented in .m files to make + it easier to modify. Performance of the lookfor function has been + greatly improved by caching the help text from all functions that + are distributed with Octave. The pkg function has been modified + to generate cache files for external packages when they are + installed. + + ** Deprecated functions. + + The following functions were deprecated in Octave 3.0 and will be + removed from Octave 3.4 (or whatever version is the second major + release after 3.0): + + beta_cdf geometric_pdf pascal_pdf + beta_inv geometric_rnd pascal_rnd + beta_pdf hypergeometric_cdf poisson_cdf + beta_rnd hypergeometric_inv poisson_inv + binomial_cdf hypergeometric_pdf poisson_pdf + binomial_inv hypergeometric_rnd poisson_rnd + binomial_pdf intersection polyinteg + binomial_rnd is_bool setstr + chisquare_cdf is_complex struct_contains + chisquare_inv is_list struct_elements + chisquare_pdf is_matrix t_cdf + chisquare_rnd is_scalar t_inv + clearplot is_square t_pdf + clg is_stream t_rnd + com2str is_struct uniform_cdf + exponential_cdf is_symmetric uniform_inv + exponential_inv is_vector uniform_pdf + exponential_pdf isstr uniform_rnd + exponential_rnd lognormal_cdf weibcdf + f_cdf lognormal_inv weibinv + f_inv lognormal_pdf weibpdf + f_pdf lognormal_rnd weibrnd + f_rnd meshdom weibull_cdf + gamma_cdf normal_cdf weibull_inv + gamma_inv normal_inv weibull_pdf + gamma_pdf normal_pdf weibull_rnd + gamma_rnd normal_rnd wiener_rnd + geometric_cdf pascal_cdf + geometric_inv pascal_inv + + The following functions are now deprecated in Octave 3.2 and will + be removed from Octave 3.6 (or whatever version is the second major + release after 3.2): + + create_set spcholinv spmax + dmult spcumprod spmin + iscommand spcumsum spprod + israwcommand spdet spqr + lchol spdiag spsum + loadimage spfind spsumsq + mark_as_command spinv str2mat + mark_as_rawcommand spkron unmark_command + spatan2 splchol unmark_rawcommand + spchol split + spchol2inv splu + Summary of important user-visible changes for version 3.0: --------------------------------------------------------- @@ -196,5 +1716,6 @@ the distributions using the standard scale factor rather than one over the scale factor. +--------------------------------------------------------- See NEWS.2 for old news. diff -r 75a671fcdd73 -r 844448ae53f3 etc/RELEASE.PROCESS --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/etc/RELEASE.PROCESS Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,84 @@ + + +==3.8 Release Tasks== + +This page shows the tasks to be completed before the 3.8 release is finalized. + + +# File bug reports for all outstanding bugs known, but not reported +#: Completion Date: 10/16/2013 +## Put out a general call for reports on Octave-Maintainers and Octave-Help list +##: Completion Date: 10/9/2013 + +# Review patch tracker/bug list for any patches submitted that may be included before release +#: Completion Date: 10/24/2013 + +# Identify Bugs which *must* be fixed prior to release +#: Completion Date: 10/20/2013 +## Start discussion about criteria on octave-maintainers list +## Possible Criteria: +##* Severity >= 4 +##* Item Group == ("Crash" or "Regression") +##* Item Group == "Build Failure" +## Review bugs on tracker for possible inclusion in list +## Review bugs and update to correct category, such as Patch Submitted. + +# Clear all bugs identified as must-fix +#: Completion Date: 10/26/2013 +## See [[3.8 Bug Fix List]] + +# GPL License activities +## Update Copyright statements for all source controlled files +## Add any new contributors to contributors.in + +# Style-check code base +## This will produce lots of whitespace changes, but no behavior changes. +## Must occur after patches have been added since whitespace changes will often prevent patches from applying. + +# Run lint checker on code base +## cppcheck, Clang sanitize, etc. + +# Verify 'make check' is passing +## Start discussion on octave-maintainers list about which failing tests must be fixed +## Identify and fix any tests determined critical in step above + +# Run Octave test suite under Valgrind to check for memory leaks +## Done: 10/17/13 + +# Review documentation +## Grammar check documentation so that it conforms to Octave standards +## Spellcheck documentation +## Verify no functions missing from manual +## Verify deprecated functions removed from seealso links +## Verify all formats (Info, HTML, pdf) build correctly +## Review NEWS for any features which should be announced + +# Localization and Internationalization +## Submit call for translations for GUI strings. +## Completion Date: 11/1/13 + +# Verify build process and create release candidates +## Update version information in configure.ac/Makefile.am +## Verify 'make distcheck' passes +## Create release candidate +### 'make dist' +### hg tag repository with release candidate ID +### For Windows, create installer [[Windows Installer]] +### Upload release candidate +### Announce release candidate to Octave-Maintainers, Octave-Help, on web page +### Repeat release candidate cycle until clean + +# Final Release +## hg tag repository with release +## merge default onto stable to become the current stable release +## add new release version to Savannah bug tracker +## Announce final release on Octave mailing lists and web site + +# Post-Release +## Update configure.ac/Makefile.am versioning to next release cycle +## Remove all deprecated functions scheduled for deletion in 4.0 from default branch + +[[Category:Releases]] diff -r 75a671fcdd73 -r 844448ae53f3 libgui/Makefile.am --- a/libgui/Makefile.am Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/Makefile.am Fri Jan 23 15:23:09 2015 -0500 @@ -34,6 +34,7 @@ languages/en_US.ts \ languages/es_ES.ts \ languages/fr_FR.ts \ + languages/it_IT.ts \ languages/nl_NL.ts \ languages/pt_BR.ts \ languages/pt_PT.ts \ @@ -53,6 +54,7 @@ noinst_LTLIBRARIES = include src/module.mk +include graphics/module.mk include qterminal-module.mk ## liboctgui merely collects a bunch of compiled convenience libraries. @@ -67,6 +69,7 @@ liboctgui_la_LIBADD = \ qterminal/libqterminal.la \ src/libgui-src.la \ + graphics/libgui-graphics.la \ $(top_builddir)/libinterp/liboctinterp.la \ $(top_builddir)/liboctave/liboctave.la \ $(LIBOCTGUI_LINK_DEPS) @@ -103,7 +106,7 @@ ( echo '#ifdef HAVE_CONFIG_H'; \ echo '#include '; \ echo '#endif'; \ - $(RCC) $< ) > $@-t + $(RCC) -name $(@D) $< ) > $@-t mv $@-t $@ endef diff -r 75a671fcdd73 -r 844448ae53f3 libgui/default-qt-settings.in --- a/libgui/default-qt-settings.in Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/default-qt-settings.in Fri Jan 23 15:23:09 2015 -0500 @@ -550,10 +550,10 @@ Bash\style2\eolfill=false Bash\style2\font=__default_font__, __default_font_size__, 0, 0, 0 Bash\style2\paper=16777215 -Bash\style3\color=11184640 +Bash\style3\color=43647 Bash\style3\eolfill=false Bash\style3\font=__default_font__, __default_font_size__, 0, 0, 0 -Bash\style3\paper=16711680 +Bash\style0\paper=16777215 Bash\style4\color=127 Bash\style4\eolfill=false Bash\style4\font=__default_font__, __default_font_size__, 1, 0, 0 @@ -600,3 +600,11 @@ Bash\defaultpaper=16777215 Bash\defaultfont=__default_font__, __default_font_size__, 0, 0, 0 Bash\autoindentstyle=-1 +Text\style0\color=0 +Text\style0\eolfill=false +Text\style0\font=__default_font__, __default_font_size__, 0, 0, 0 +Text\style0\paper=16777215 +Text\defaultcolor=0 +Text\defaultpaper=16777215 +Text\defaultfont=__default_font__, __default_font_size__, 0, 0, 0 +Text\autoindentstyle=-1 diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Backend.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Backend.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,203 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include + +#include "Backend.h" +#include "Logger.h" +#include "Object.h" +#include "ObjectFactory.h" +#include "ObjectProxy.h" + +//#if INTPTR_MAX == INT32_MAX +//# define OCTAVE_PTR_TYPE octave_uint32 +//# define OCTAVE_INTPTR_TYPE uint32_t +//# define OCTAVE_PTR_SCALAR uint32_scalar_value +//#else +# define OCTAVE_PTR_TYPE octave_uint64 +# define OCTAVE_INTPTR_TYPE uint64_t +# define OCTAVE_PTR_SCALAR uint64_scalar_value +//#endif + +namespace QtHandles +{ + +static std::string toolkitObjectProperty (const graphics_object& go) +{ + if (go.isa ("figure")) + return std::string ("__plot_stream__"); + else if (go.isa ("uicontrol") + || go.isa ("uipanel") + || go.isa ("uimenu") + || go.isa ("uicontextmenu") + || go.isa ("uitoolbar") + || go.isa ("uipushtool") + || go.isa ("uitoggletool")) + return std::string ("__object__"); + else + qCritical ("QtHandles::Backend: no __object__ property known for object " + "of type %s", go.type ().c_str ()); + + return std::string (); +} + +Backend::Backend (void) + : QObject (), base_graphics_toolkit ("qt") +{ + ObjectFactory* factory = ObjectFactory::instance (); + + connect (this, SIGNAL (createObject (double)), + factory, SLOT (createObject (double))); +} + +Backend::~Backend (void) +{ +} + +bool Backend::initialize (const graphics_object& go) +{ + if (go.isa ("figure") + || go.isa ("uicontrol") + || go.isa ("uipanel") + || go.isa ("uimenu") + || go.isa ("uicontextmenu") + || go.isa ("uitoolbar") + || go.isa ("uipushtool") + || go.isa ("uitoggletool")) + { + Logger::debug ("Backend::initialize %s from thread %08x", + go.type ().c_str (), QThread::currentThreadId ()); + + ObjectProxy* proxy = new ObjectProxy (); + graphics_object gObj (go); + + gObj.get_properties ().set(toolkitObjectProperty (go), + OCTAVE_PTR_TYPE (reinterpret_cast (proxy))); + + emit createObject (go.get_handle ().value ()); + + return true; + } + + return false; +} + +void Backend::update (const graphics_object& go, int pId) +{ + // Rule out obvious properties we want to ignore. + if (pId == figure::properties::ID___PLOT_STREAM__ + || pId == uicontrol::properties::ID___OBJECT__ + || pId == uipanel::properties::ID___OBJECT__ + || pId == uimenu::properties::ID___OBJECT__ + || pId == uicontextmenu::properties::ID___OBJECT__ + || pId == uitoolbar::properties::ID___OBJECT__ + || pId == uipushtool::properties::ID___OBJECT__ + || pId == uitoggletool::properties::ID___OBJECT__ + || pId == base_properties::ID___MODIFIED__) + return; + + Logger::debug ("Backend::update %s(%d) from thread %08x", + go.type ().c_str (), pId, QThread::currentThreadId ()); + + ObjectProxy* proxy = toolkitObjectProxy (go); + + if (proxy) + { + if (go.isa ("uicontrol") + && pId == uicontrol::properties::ID_STYLE) + { + // Special case: we need to recreate the control widget + // associated with the octave graphics_object + + finalize (go); + initialize (go); + } + else + proxy->update (pId); + } +} + +void Backend::finalize (const graphics_object& go) +{ + Logger::debug ("Backend::finalize %s from thread %08x", + go.type ().c_str (), QThread::currentThreadId ()); + + ObjectProxy* proxy = toolkitObjectProxy (go); + + if (proxy) + { + proxy->finalize (); + delete proxy; + + graphics_object gObj (go); + + gObj.get_properties ().set (toolkitObjectProperty (go), Matrix ()); + } +} + +void Backend::redraw_figure (const graphics_object& go) const +{ + if (go.get_properties ().is_visible ()) + { + ObjectProxy* proxy = toolkitObjectProxy (go); + + if (proxy) + proxy->redraw (); + } +} + +Object* Backend::toolkitObject (const graphics_object& go) +{ + ObjectProxy* proxy = toolkitObjectProxy (go); + + if (proxy) + return proxy->object (); + + return 0; +} + +ObjectProxy* Backend::toolkitObjectProxy (const graphics_object& go) +{ + if (go) + { + octave_value ov = go.get (toolkitObjectProperty (go)); + + if (ov.is_defined () && ! ov.is_empty ()) + { + OCTAVE_INTPTR_TYPE ptr = ov.OCTAVE_PTR_SCALAR ().value (); + + if (! error_state) + return reinterpret_cast (ptr); + } + } + + return 0; +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Backend.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Backend.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,67 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Backend__ +#define __QtHandles_Backend__ 1 + +#include + +#include "graphics.h" + +namespace QtHandles +{ + +class Object; +class ObjectProxy; + +class Backend : + public QObject, + public base_graphics_toolkit +{ + Q_OBJECT + +public: + Backend (void); + + ~Backend (void); + + bool is_valid (void) const { return true; } + + void redraw_figure (const graphics_object& h) const; + + void update (const graphics_object& obj, int pId); + + bool initialize (const graphics_object& obj); + + void finalize (const graphics_object& obj); + + static Object* toolkitObject (const graphics_object& go); + + static ObjectProxy* toolkitObjectProxy (const graphics_object& go); + +signals: + void createObject (double handle); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/BaseControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/BaseControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,232 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "BaseControl.h" +#include "ContextMenu.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +static void updatePalette (const uicontrol::properties& props, QWidget* w) +{ + QPalette p = w->palette (); + + if (props.style_is ("edit") + || props.style_is ("listbox") + || props.style_is ("popupmenu")) + { + p.setColor (QPalette::Base, + Utils::fromRgb (props.get_backgroundcolor_rgb ())); + p.setColor (QPalette::Text, + Utils::fromRgb (props.get_foregroundcolor_rgb ())); + } + else if (props.style_is ("pushbutton") + || props.style_is ("togglebutton")) + { + p.setColor (QPalette::Button, + Utils::fromRgb (props.get_backgroundcolor_rgb ())); + p.setColor (QPalette::ButtonText, + Utils::fromRgb (props.get_foregroundcolor_rgb ())); + } + else + { + p.setColor (QPalette::Window, + Utils::fromRgb (props.get_backgroundcolor_rgb ())); + p.setColor (QPalette::WindowText, + Utils::fromRgb (props.get_foregroundcolor_rgb ())); + } + + w->setPalette (p); +} + +BaseControl::BaseControl (const graphics_object& go, QWidget* w) + : Object (go, w), m_normalizedFont (false), m_keyPressHandlerDefined (false) +{ + init (w); +} + +void BaseControl::init (QWidget* w, bool callBase) +{ + if (callBase) + Object::init (w, callBase); + + uicontrol::properties& up = properties (); + + Matrix bb = up.get_boundingbox (false); + w->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + w->setFont (Utils::computeFont (up, bb(3))); + updatePalette (up, w); + w->setEnabled (up.enable_is ("on")); + w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); + w->setVisible (up.is_visible ()); + m_keyPressHandlerDefined = ! up.get_keypressfcn ().is_empty (); + + w->installEventFilter (this); + + m_normalizedFont = up.fontunits_is ("normalized"); +} + +BaseControl::~BaseControl (void) +{ +} + +void BaseControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QWidget* w = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_POSITION: + { + Matrix bb = up.get_boundingbox (false); + w->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + } + break; + case uicontrol::properties::ID_FONTNAME: + case uicontrol::properties::ID_FONTSIZE: + case uicontrol::properties::ID_FONTWEIGHT: + case uicontrol::properties::ID_FONTANGLE: + w->setFont (Utils::computeFont (up)); + break; + case uicontrol::properties::ID_FONTUNITS: + // FIXME: We shouldn't have to do anything, octave should update + // the "fontsize" property automatically to the new units. + // Hence the actual font used shouldn't change. + m_normalizedFont = up.fontunits_is ("normalized"); + break; + case uicontrol::properties::ID_BACKGROUNDCOLOR: + case uicontrol::properties::ID_FOREGROUNDCOLOR: + updatePalette (up, w); + break; + case uicontrol::properties::ID_ENABLE: + w->setEnabled (up.enable_is ("on")); + break; + case uicontrol::properties::ID_TOOLTIPSTRING: + w->setToolTip (Utils::fromStdString (up.get_tooltipstring ())); + break; + case base_properties::ID_VISIBLE: + w->setVisible (up.is_visible ()); + break; + case uicontrol::properties::ID_KEYPRESSFCN: + m_keyPressHandlerDefined = ! up.get_keypressfcn ().is_empty (); + break; + default: + break; + } +} + +bool BaseControl::eventFilter (QObject* watched, QEvent* ev) +{ + switch (ev->type ()) + { + case QEvent::Resize: + if (m_normalizedFont) + { + gh_manager::auto_lock lock; + + qWidget ()->setFont (Utils::computeFont + (properties ())); + } + break; + case QEvent::MouseButtonPress: + { + gh_manager::auto_lock lock; + + QMouseEvent* m = dynamic_cast (ev); + graphics_object go = object (); + uicontrol::properties& up = Utils::properties (go); + graphics_object fig = go.get_ancestor ("figure"); + + if (m->button () != Qt::LeftButton + || ! up.enable_is ("on")) + { + gh_manager::post_set (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); + gh_manager::post_set (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), + false); + gh_manager::post_callback (fig.get_handle (), + "windowbuttondownfcn"); + gh_manager::post_callback (m_handle, "buttondownfcn"); + + if (m->button () == Qt::RightButton) + ContextMenu::executeAt (up, m->globalPos ()); + } + else + { + if (up.style_is ("listbox")) + gh_manager::post_set (fig.get_handle (), "selectiontype", + Utils::figureSelectionType (m), false); + else + gh_manager::post_set (fig.get_handle (), "selectiontype", + octave_value ("normal"), false); + } + } + break; + case QEvent::MouseMove: + if (qWidget ()->hasMouseTracking ()) + { + gh_manager::auto_lock lock; + + QMouseEvent* m = dynamic_cast (ev); + graphics_object go = object (); + graphics_object fig = go.get_ancestor ("figure"); + + gh_manager::post_set (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, m), false); + gh_manager::post_callback (fig.get_handle (), "windowbuttonmotionfcn"); + } + break; + case QEvent::KeyPress: + if (m_keyPressHandlerDefined) + { + gh_manager::auto_lock lock; + + octave_scalar_map keyData = + Utils::makeKeyEventStruct (dynamic_cast (ev)); + graphics_object fig = object ().get_ancestor ("figure"); + + gh_manager::post_set (fig.get_handle (), "currentcharacter", + keyData.getfield ("Character"), false); + gh_manager::post_callback (m_handle, "keypressfcn", keyData); + } + break; + default: break; + } + + return Object::eventFilter (watched, ev); +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/BaseControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/BaseControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,55 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_BaseControl__ +#define __QtHandles_BaseControl__ 1 + +#include "Object.h" + +class QEvent; +class QObject; + +namespace QtHandles +{ + +class BaseControl : public Object +{ +public: + BaseControl (const graphics_object& go, QWidget* w); + ~BaseControl (void); + + Container* innerContainer (void) { return 0; } + + bool eventFilter (QObject* watched, QEvent* e); + +protected: + void init (QWidget* w, bool callBase = false); + void update (int pId); + +private: + bool m_normalizedFont; + bool m_keyPressHandlerDefined; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ButtonControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ButtonControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,122 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "ButtonControl.h" +#include "Container.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +ButtonControl::ButtonControl (const graphics_object& go, QAbstractButton* btn) + : BaseControl (go, btn), m_blockCallback (false) +{ + uicontrol::properties& up = properties (); + + btn->setText (Utils::fromStdString (up.get_string_string ())); + if (btn->isCheckable () || up.style_is ("togglebutton")) + { + btn->setCheckable (true); + + Matrix value = up.get_value ().matrix_value (); + + if (value.numel () > 0 && value(0) == up.get_max ()) + btn->setChecked (true); + } + + connect (btn, SIGNAL (clicked (void)), SLOT (clicked (void))); + connect (btn, SIGNAL (toggled (bool)), SLOT (toggled (bool))); +} + +ButtonControl::~ButtonControl (void) +{ +} + +void ButtonControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QAbstractButton* btn = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + btn->setText (Utils::fromStdString (up.get_string_string ())); + break; + case uicontrol::properties::ID_VALUE: + m_blockCallback = true; + if (btn->isCheckable ()) + { + Matrix value = up.get_value ().matrix_value (); + + if (value.numel () > 0) + { + double dValue = value(0); + + if (dValue == up.get_min () && btn->isChecked ()) + btn->setChecked (false); + else if (dValue == up.get_max () && ! btn->isChecked ()) + btn->setChecked (true); + } + } + m_blockCallback = false; + break; + default: + BaseControl::update (pId); + break; + } +} + +void ButtonControl::toggled (bool checked) +{ + QAbstractButton* btn = qWidget (); + + if (! m_blockCallback && btn->isCheckable ()) + { + gh_manager::auto_lock lock; + + uicontrol::properties& up = properties (); + + Matrix oldValue = up.get_value ().matrix_value (); + double newValue = (checked ? up.get_max () : up.get_min ()); + + if (oldValue.numel() != 1 + || (newValue != oldValue(0))) + gh_manager::post_set (m_handle, "value", newValue, false); + gh_manager::post_callback (m_handle, "callback"); + } +} + +void ButtonControl::clicked (void) +{ + QAbstractButton* btn = qWidget (); + + if (! btn->isCheckable ()) + gh_manager::post_callback (m_handle, "callback"); +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ButtonControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ButtonControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,54 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ButtonControl__ +#define __QtHandles_ButtonControl__ 1 + +#include "BaseControl.h" + +class QAbstractButton; + +namespace QtHandles +{ + +class ButtonControl : public BaseControl +{ + Q_OBJECT + +public: + ButtonControl (const graphics_object& go, QAbstractButton* btn); + ~ButtonControl (void); + +protected: + void update (int pId); + +private slots: + void clicked (void); + void toggled (bool checked); + +private: + bool m_blockCallback; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Canvas.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Canvas.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,416 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "Backend.h" +#include "Canvas.h" +#include "ContextMenu.h" +#include "GLCanvas.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +void Canvas::redraw (bool sync) +{ + if (sync) + qWidget ()->repaint (); + else + qWidget ()->update (); +} + +void Canvas::blockRedraw (bool block) +{ + m_redrawBlocked = block; +} + +void Canvas::updateCurrentPoint(const graphics_object& fig, + const graphics_object& obj, QMouseEvent* event) +{ + gh_manager::post_set (fig.get_handle (), "currentpoint", + Utils::figureCurrentPoint (fig, event), false); + + Matrix children = obj.get_properties ().get_children (); + octave_idx_type num_children = children.numel (); + + for (int i = 0; i < num_children; i++) + { + graphics_object childObj (gh_manager::get_object (children(i))); + + if (childObj.isa ("axes")) + { + axes::properties& ap = Utils::properties (childObj); + Matrix x_zlim = ap.get_transform_zlim (); + graphics_xform x_form = ap.get_transform (); + + ColumnVector p1 = x_form.untransform (event->x (), event->y (), + x_zlim(0)); + ColumnVector p2 = x_form.untransform (event->x (), event->y (), + x_zlim(1)); + + Matrix cp (2, 3, 0.0); + + cp(0,0) = p1(0); cp(0,1) = p1(1); cp(0,2) = p1(2); + cp(1,0) = p2(0); cp(1,1) = p2(1); cp(1,2) = p2(2); + + gh_manager::post_set (childObj.get_handle (), "currentpoint", cp, + false); + } + } +} + +void Canvas::canvasPaintEvent (void) +{ + if (! m_redrawBlocked) + { + gh_manager::auto_lock lock; + + draw (m_handle); + + if (m_mouseMode == ZoomMode && m_mouseAxes.ok ()) + drawZoomBox (m_mouseAnchor, m_mouseCurrent); + } +} + +void Canvas::canvasMouseMoveEvent (QMouseEvent* event) +{ + gh_manager::auto_lock lock; + graphics_object ax = gh_manager::get_object (m_mouseAxes); + + if (m_mouseMode != NoMode && ax.valid_object ()) + { + axes::properties& ap = Utils::properties (ax); + + switch (m_mouseMode) + { + case RotateMode: + { + Matrix bb = ap.get_boundingbox (true); + Matrix view = ap.get_view ().matrix_value (); + + // Compute new view angles + view(0) += ((m_mouseCurrent.x () - event->x ()) + * (180.0 / bb(2))); + view(1) += ((event->y () - m_mouseCurrent.y ()) + * (180.0 / bb(3))); + + // Clipping + view(1) = std::min (view(1), 90.0); + view(1) = std::max (view(1), -90.0); + if (view(0) > 180.0) + view(0) -= 360.0; + else if (view(0) < -180.0) + view(0) += 360.0; + + // Snapping + double snapMargin = 1.0; + for (int a = -90; a <= 90; a += 90) + if ((a - snapMargin) < view(1) + && view(1) < (a + snapMargin)) + { + view(1) = a; + break; + } + for (int a = -180; a <= 180; a += 180) + if ((a - snapMargin) < view(0) + && view(0) < (a + snapMargin)) + { + if (a == 180) + view(0) = -180; + else + view(0) = a; + break; + } + + // Update axes properties + ap.set_view (view); + + // Update current mouse position + m_mouseCurrent = event->pos (); + + // Force immediate redraw + redraw (true); + } + break; + case ZoomMode: + m_mouseCurrent = event->pos(); + redraw (true); + break; + case PanMode: + break; + default: + break; + } + } + else if (m_mouseMode == NoMode) + { + graphics_object obj = gh_manager::get_object (m_handle); + + if (obj.valid_object ()) + { + graphics_object figObj (obj.get_ancestor ("figure")); + + updateCurrentPoint (figObj, obj, event); + gh_manager::post_callback (figObj.get_handle (), + "windowbuttonmotionfcn"); + } + } +} + +void Canvas::canvasMousePressEvent (QMouseEvent* event) +{ + gh_manager::auto_lock lock; + graphics_object obj = gh_manager::get_object (m_handle); + + if (obj.valid_object ()) + { + graphics_object figObj (obj.get_ancestor ("figure")); + graphics_object currentObj, axesObj; + QList axesList; + + Matrix children = obj.get_properties ().get_children (); + octave_idx_type num_children = children.numel (); + + for (int i = 0; i < num_children; i++) + { + graphics_object childObj (gh_manager::get_object (children(i))); + + if (childObj.isa ("axes")) + axesList.append (childObj); + else if (childObj.isa ("uicontrol") || childObj.isa ("uipanel")) + { + Matrix bb = childObj.get_properties ().get_boundingbox (false); + QRectF r (bb(0), bb(1), bb(2), bb(3)); + + r.adjust (-5, -5, 5, 5); + if (r.contains (event->posF ())) + { + currentObj = childObj; + break; + } + } + } + + if (! currentObj) + { + for (QList::ConstIterator it = axesList.begin (); + it != axesList.end (); ++it) + { + graphics_object go = selectFromAxes (*it, event->pos ()); + + if (go) + { + currentObj = go; + axesObj = *it; + } + // FIXME: is this really necessary? the axes object should + // have been selected through selectFromAxes anyway + else if (it->get_properties ().is_hittest ()) + { + Matrix bb = it->get_properties ().get_boundingbox (true); + QRectF r (bb(0), bb(1), bb(2), bb(3)); + + if (r.contains (event->posF ())) + axesObj = *it; + } + + if (axesObj) + break; + } + + if (axesObj) + { + if (axesObj.get_properties ().handlevisibility_is ("on")) + Utils::properties
(figObj) + .set_currentaxes (axesObj.get_handle ().as_octave_value ()); + if (! currentObj) + currentObj = axesObj; + } + } + + if (! currentObj) + currentObj = obj; + + if (currentObj.get_properties ().handlevisibility_is ("on")) + Utils::properties
(figObj) + .set_currentobject (currentObj.get_handle ().as_octave_value ()); + else + Utils::properties
(figObj).set_currentobject (octave_NaN); + + Figure* fig = dynamic_cast (Backend::toolkitObject (figObj)); + + MouseMode newMouseMode = NoMode; + + if (fig) + newMouseMode = fig->mouseMode (); + + switch (newMouseMode) + { + case NoMode: + gh_manager::post_set (figObj.get_handle (), "selectiontype", + Utils::figureSelectionType (event), false); + updateCurrentPoint (figObj, obj, event); + gh_manager::post_callback (figObj.get_handle (), + "windowbuttondownfcn"); + gh_manager::post_callback (currentObj.get_handle (), + "buttondownfcn"); + if (event->button () == Qt::RightButton) + ContextMenu::executeAt (currentObj.get_properties (), + event->globalPos ()); + break; + case RotateMode: + case ZoomMode: + case PanMode: + if (axesObj) + { + if (event->buttons () == Qt::LeftButton + && event->modifiers () == Qt::NoModifier) + { + m_mouseAnchor = m_mouseCurrent = event->pos (); + m_mouseAxes = axesObj.get_handle (); + m_mouseMode = newMouseMode; + } + else if (newMouseMode == ZoomMode + && event->modifiers () == Qt::NoModifier) + { + switch (event->buttons ()) + { + case Qt::RightButton: + Utils::properties (axesObj).unzoom (); + break; + case Qt::MidButton: + { + axes::properties& ap = + Utils::properties (axesObj); + + ap.clear_zoom_stack (); + ap.set_xlimmode ("auto"); + ap.set_ylimmode ("auto"); + ap.set_zlimmode ("auto"); + } + break; + } + redraw (false); + } + } + break; + default: + break; + } + } +} + +void Canvas::canvasMouseReleaseEvent (QMouseEvent* event) +{ + if (m_mouseMode == ZoomMode + && m_mouseAxes.ok () + && m_mouseAnchor != event->pos ()) + { + gh_manager::auto_lock lock; + graphics_object ax = gh_manager::get_object (m_mouseAxes); + + if (ax.valid_object ()) + { + axes::properties& ap = Utils::properties (ax); + + ColumnVector p0 = ap.pixel2coord (m_mouseAnchor.x (), + m_mouseAnchor.y ()); + ColumnVector p1 = ap.pixel2coord (event->x (), + event->y ()); + + Matrix xl (1, 2, 0.0); + Matrix yl (1, 2, 0.0); + + xl(0) = std::min (p0(0), p1(0)); + xl(1) = std::max (p0(0), p1(0)); + yl(0) = std::min (p0(1), p1(1)); + yl(1) = std::max (p0(1), p1(1)); + + ap.zoom (xl, yl); + + redraw (false); + } + } + else if (m_mouseMode == NoMode) + { + gh_manager::auto_lock lock; + graphics_object obj = gh_manager::get_object (m_handle); + + if (obj.valid_object ()) + { + graphics_object figObj (obj.get_ancestor ("figure")); + + updateCurrentPoint (figObj, obj, event); + gh_manager::post_callback (figObj.get_handle (), + "windowbuttonupfcn"); + } + } + + m_mouseAxes = graphics_handle (); + m_mouseMode = NoMode; +} + +bool Canvas::canvasKeyPressEvent (QKeyEvent* event) +{ + if (m_eventMask & KeyPress) + { + octave_scalar_map eventData = Utils::makeKeyEventStruct (event); + + gh_manager::post_set (m_handle, "currentcharacter", + eventData.getfield ("Character"), false); + gh_manager::post_callback (m_handle, "keypressfcn", eventData); + + return true; + } + + return false; +} + +bool Canvas::canvasKeyReleaseEvent (QKeyEvent* event) +{ + if (! event->isAutoRepeat () && (m_eventMask & KeyRelease)) + { + gh_manager::post_callback (m_handle, "keyreleasefcn", + Utils::makeKeyEventStruct (event)); + + return true; + } + + return false; +} + +Canvas* Canvas::create (const std::string& /* name */, QWidget* parent, + const graphics_handle& handle) +{ + // Only OpenGL + return new GLCanvas (parent, handle); +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Canvas.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Canvas.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,100 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Canvas__ +#define __QtHandles_Canvas__ 1 + +#include + +#include "graphics.h" + +#include "Figure.h" + +class QKeyEvent; +class QMouseEvent; +class QWidget; + +namespace QtHandles +{ + +class Canvas +{ +public: + enum EventMask + { + KeyPress = 0x01, + KeyRelease = 0x02 + }; + +public: + virtual ~Canvas (void) { } + + void redraw (bool sync = false); + void blockRedraw (bool block = true); + + void addEventMask (int m) { m_eventMask |= m; } + void clearEventMask (int m) { m_eventMask &= (~m); } + void setEventMask (int m) { m_eventMask = m; } + + virtual QWidget* qWidget (void) = 0; + + static Canvas* create (const std::string& name, QWidget* parent, + const graphics_handle& handle); + +protected: + virtual void draw (const graphics_handle& handle) = 0; + virtual void drawZoomBox (const QPoint& p1, const QPoint& p2) = 0; + virtual void resize (int x, int y, int width, int height) = 0; + virtual graphics_object selectFromAxes (const graphics_object& ax, + const QPoint& pt) = 0; + +protected: + Canvas (const graphics_handle& handle) + : m_handle (handle), + m_redrawBlocked (false), + m_mouseMode (NoMode), + m_eventMask (0) + { } + + void canvasPaintEvent (void); + void canvasMouseMoveEvent (QMouseEvent* event); + void canvasMousePressEvent (QMouseEvent* event); + void canvasMouseReleaseEvent (QMouseEvent* event); + bool canvasKeyPressEvent (QKeyEvent* event); + bool canvasKeyReleaseEvent (QKeyEvent* event); + + void updateCurrentPoint (const graphics_object& fig, + const graphics_object& obj, QMouseEvent *event); + +private: + graphics_handle m_handle; + bool m_redrawBlocked; + MouseMode m_mouseMode; + QPoint m_mouseAnchor; + QPoint m_mouseCurrent; + graphics_handle m_mouseAxes; + int m_eventMask; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/CheckBoxControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/CheckBoxControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,60 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "CheckBoxControl.h" +#include "Container.h" + +namespace QtHandles +{ + +CheckBoxControl* CheckBoxControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new CheckBoxControl (go, new QCheckBox (container)); + } + + return 0; +} + +CheckBoxControl::CheckBoxControl (const graphics_object& go, QCheckBox* box) + : ButtonControl (go, box) +{ + box->setAutoFillBackground (true); +} + +CheckBoxControl::~CheckBoxControl (void) +{ +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/CheckBoxControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/CheckBoxControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,44 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_CheckBoxControl__ +#define __QtHandles_CheckBoxControl__ 1 + +#include "ButtonControl.h" + +class QCheckBox; + +namespace QtHandles +{ + +class CheckBoxControl : public ButtonControl +{ +public: + CheckBoxControl (const graphics_object& go, QCheckBox* box); + ~CheckBoxControl (void); + + static CheckBoxControl* create (const graphics_object& go); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Container.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Container.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,107 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "graphics.h" + +#include "Canvas.h" +#include "Container.h" +#include "Object.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +Container::Container (QWidget* xparent) + : ContainerBase (xparent), m_canvas (0) +{ + setFocusPolicy (Qt::ClickFocus); +} + +Container::~Container (void) +{ +} + +Canvas* Container::canvas (const graphics_handle& gh, bool xcreate) +{ + if (! m_canvas && xcreate) + { + graphics_object go = gh_manager::get_object (gh); + + if (go) + { + graphics_object fig = go.get_ancestor ("figure"); + + m_canvas = Canvas::create (fig.get("renderer").string_value (), + this, gh); + + QWidget* canvasWidget = m_canvas->qWidget (); + + canvasWidget->lower (); + canvasWidget->show (); + canvasWidget->setGeometry (0, 0, width (), height ()); + } + } + + return m_canvas; +} + +void Container::resizeEvent (QResizeEvent* /* event */) +{ + if (m_canvas) + m_canvas->qWidget ()->setGeometry (0, 0, width (), height ()); + + gh_manager::auto_lock lock; + + foreach (QObject* qObj, children ()) + { + if (qObj->isWidgetType ()) + { + Object* obj = Object::fromQObject (qObj); + + if (obj) + { + Matrix bb = obj->properties ().get_boundingbox (false); + + obj->qWidget () + ->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + } + } + } +} + +void Container::childEvent (QChildEvent* ev) +{ + if (ev->child ()->isWidgetType ()) + { + qobject_cast (ev->child ())->setMouseTracking (hasMouseTracking ()); + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Container.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Container.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,57 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Container__ +#define __QtHandles_Container__ 1 + +#include + +#include "GenericEventNotify.h" + +#include "graphics.h" + +namespace QtHandles +{ + +DECLARE_GENERICEVENTNOTIFY_SENDER(ContainerBase, QWidget); + +class Canvas; + +class Container : public ContainerBase +{ +public: + Container (QWidget* parent); + ~Container (void); + + Canvas* canvas (const graphics_handle& handle, bool create = true); + +protected: + void childEvent (QChildEvent* event); + void resizeEvent (QResizeEvent* event); + +private: + Canvas* m_canvas; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ContextMenu.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ContextMenu.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,132 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Backend.h" +#include "ContextMenu.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +ContextMenu* ContextMenu::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + QWidget* w = parent->qWidget (); + + return new ContextMenu (go, new QMenu (w)); + } + + return 0; +} + +ContextMenu::ContextMenu (const graphics_object& go, QMenu* xmenu) + : Object (go, xmenu) +{ + xmenu->setAutoFillBackground (true); + + connect (xmenu, SIGNAL (aboutToShow (void)), SLOT (aboutToShow (void))); + connect (xmenu, SIGNAL (aboutToHide (void)), SLOT (aboutToHide (void))); +} + +ContextMenu::~ContextMenu (void) +{ +} + +void ContextMenu::update (int pId) +{ + uicontextmenu::properties& up = properties (); + QMenu* xmenu = qWidget (); + + switch (pId) + { + case base_properties::ID_VISIBLE: + if (up.is_visible ()) + { + Matrix pos = up.get_position ().matrix_value (); + QWidget* parentW = xmenu->parentWidget (); + QPoint pt; + + pt.rx () = xround (pos(0)); + pt.ry () = parentW->height () - xround (pos(1)); + pt = parentW->mapToGlobal (pt); + + xmenu->popup (pt); + } + else + xmenu->hide (); + break; + default: + Object::update (pId); + break; + } +} + +void ContextMenu::aboutToShow (void) +{ + gh_manager::post_callback (m_handle, "callback"); + gh_manager::post_set (m_handle, "visible", "on", false); +} + +void ContextMenu::aboutToHide (void) +{ + gh_manager::post_set (m_handle, "visible", "off", false); +} + +QWidget* ContextMenu::menu (void) +{ + return qWidget (); +} + +void ContextMenu::executeAt (const base_properties& props, const QPoint& pt) +{ + graphics_handle h = props.get_uicontextmenu (); + + if (h.ok ()) + { + graphics_object go = gh_manager::get_object (h); + + if (go.valid_object ()) + { + ContextMenu* cMenu = + dynamic_cast (Backend::toolkitObject (go)); + + if (cMenu) + { + QMenu* menu = cMenu->qWidget (); + + if (menu) + menu->popup (pt); + } + } + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ContextMenu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ContextMenu.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,61 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ContextMenu__ +#define __QtHandles_ContextMenu__ 1 + +#include + +#include "MenuContainer.h" +#include "Object.h" + +class QMenu; + +namespace QtHandles +{ + +class ContextMenu : public Object, public MenuContainer +{ + Q_OBJECT + +public: + ContextMenu (const graphics_object& go, QMenu* menu); + ~ContextMenu (void); + + static ContextMenu* create (const graphics_object& go); + static void executeAt (const base_properties& props, const QPoint& pt); + + Container* innerContainer (void) { return 0; } + + QWidget* menu (void); + +protected: + void update (int pId); + +private slots: + void aboutToShow (void); + void aboutToHide (void); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/EditControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/EditControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,220 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Container.h" +#include "EditControl.h" +#include "TextEdit.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +EditControl* EditControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + { + uicontrol::properties& up = Utils::properties (go); + + if ((up.get_max () - up.get_min ()) > 1) + return new EditControl (go, new TextEdit (container)); + else + return new EditControl (go, new QLineEdit (container)); + } + } + + return 0; +} + +EditControl::EditControl (const graphics_object& go, QLineEdit* edit) + : BaseControl (go, edit), m_multiLine (false), m_textChanged (false) +{ + init (edit); +} + +void EditControl::init (QLineEdit* edit, bool callBase) +{ + if (callBase) + BaseControl::init (edit, callBase); + + m_multiLine = false; + initCommon (edit); + + uicontrol::properties& up = properties (); + + edit->setText (Utils::fromStdString (up.get_string_string ())); + edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), + up.get_verticalalignment ())); + + connect (edit, SIGNAL (textEdited (const QString&)), + SLOT (textChanged (void))); + connect (edit, SIGNAL (editingFinished (void)), + SLOT (editingFinished (void))); +} + +EditControl::EditControl (const graphics_object& go, TextEdit* edit) + : BaseControl (go, edit), m_multiLine (true), m_textChanged (false) +{ + init (edit); +} + +void EditControl::init (TextEdit* edit, bool callBase) +{ + if (callBase) + BaseControl::init (edit, callBase); + + m_multiLine = true; + initCommon (edit); + + uicontrol::properties& up = properties (); + + edit->setAcceptRichText (false); + // FIXME: support string_vector + edit->setPlainText (Utils::fromStdString (up.get_string_string ())); + + connect (edit, SIGNAL (textChanged (void)), + SLOT (textChanged (void))); + connect (edit, SIGNAL (editingFinished (void)), + SLOT (editingFinished (void))); +} + +EditControl::~EditControl (void) +{ +} + +void EditControl::initCommon (QWidget*) +{ + m_textChanged = false; +} + +void EditControl::update (int pId) +{ + bool handled = false; + + if (m_multiLine) + handled = updateMultiLine (pId); + else + handled = updateSingleLine (pId); + + if (! handled) + { + switch (pId) + { + default: + BaseControl::update (pId); + break; + } + } +} + +bool EditControl::updateSingleLine (int pId) +{ + uicontrol::properties& up = properties (); + QLineEdit* edit = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + edit->setText (Utils::fromStdString (up.get_string_string ())); + return true; + case uicontrol::properties::ID_HORIZONTALALIGNMENT: + case uicontrol::properties::ID_VERTICALALIGNMENT: + edit->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), + up.get_verticalalignment ())); + return true; + case uicontrol::properties::ID_MIN: + case uicontrol::properties::ID_MAX: + if ((up.get_max () - up.get_min ()) > 1) + { + QWidget* container = edit->parentWidget (); + + delete edit; + init (new TextEdit (container), true); + } + return true; + default: + break; + } + + return false; +} + +bool EditControl::updateMultiLine (int pId) +{ + uicontrol::properties& up = properties (); + TextEdit* edit = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + edit->setPlainText (Utils::fromStdString (up.get_string_string ())); + return true; + case uicontrol::properties::ID_MIN: + case uicontrol::properties::ID_MAX: + if ((up.get_max () - up.get_min ()) <= 1) + { + QWidget* container = edit->parentWidget (); + + delete edit; + init (new QLineEdit (container), true); + } + return true; + default: + break; + } + + return false; +} + +void EditControl::textChanged (void) +{ + m_textChanged = true; +} + +void EditControl::editingFinished (void) +{ + if (m_textChanged) + { + QString txt = (m_multiLine + ? qWidget ()->toPlainText () + : qWidget ()->text ()); + + gh_manager::post_set (m_handle, "string", Utils::toStdString (txt), false); + gh_manager::post_callback (m_handle, "callback"); + + m_textChanged = false; + } +} + +}; // namespace QtHandles + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/EditControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/EditControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,68 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_EditControl__ +#define __QtHandles_EditControl__ 1 + +#include "BaseControl.h" + +class QLineEdit; +class QWidget; + +namespace QtHandles +{ + +class TextEdit; + +class EditControl : public BaseControl +{ + Q_OBJECT + +public: + EditControl (const graphics_object& go, QLineEdit* edit); + EditControl (const graphics_object& go, TextEdit* edit); + ~EditControl (void); + + static EditControl* create (const graphics_object& go); + +protected: + void update (int pId); + +private: + void init (QLineEdit* edit, bool callBase = false); + void init (TextEdit* edit, bool callBase = false); + void initCommon (QWidget* widget); + bool updateSingleLine (int pId); + bool updateMultiLine (int pId); + +private slots: + void textChanged (void); + void editingFinished (void); + +private: + bool m_multiLine; + bool m_textChanged; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Figure.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Figure.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,677 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Canvas.h" +#include "Container.h" +#include "Figure.h" +#include "FigureWindow.h" +#include "MouseModeActionGroup.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +#define ABOUT_TEXT "QtHandles - a Qt-based toolkit for Octave.

Copyright (C) 2011-2014 Michael Goffioul" + +DECLARE_GENERICEVENTNOTIFY_SENDER(MenuBar, QMenuBar); + +static bool hasUiControlChildren (const figure::properties& fp) +{ + Matrix kids = fp.get_all_children (); + + for (int i = 0; i < kids.numel (); i++) + { + graphics_object go (gh_manager::get_object (kids(i))); + + if (go && (go.isa ("uicontrol") || go.isa ("uipanel") + || go.isa ("uibuttongroup"))) + return true; + } + + return false; +} + +static bool hasUiMenuChildren (const figure::properties& fp) +{ + Matrix kids = fp.get_all_children (); + + for (int i = 0; i < kids.numel (); i++) + { + graphics_object go (gh_manager::get_object (kids(i))); + + if (go && go.isa ("uimenu")) + return true; + } + + return false; +} + +static QRect boundingBoxToRect (const Matrix& bb) +{ + QRect r; + + if (bb.numel () == 4) + { + r = QRect (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + if (! r.isValid ()) + r = QRect (); + } + + return r; +} + +Figure* Figure::create (const graphics_object& go) +{ + return new Figure (go, new FigureWindow ()); +} + +Figure::Figure (const graphics_object& go, FigureWindow* win) + : Object (go, win), m_blockUpdates (false), m_mouseMode (NoMode), + m_lastMouseMode (NoMode), m_figureToolBar (0), m_menuBar (0), + m_innerRect (), m_outerRect () +{ + m_container = new Container (win); + win->setCentralWidget (m_container); + + figure::properties& fp = properties
(); + + createFigureToolBarAndMenuBar (); + + int offset = 0; + if (fp.toolbar_is ("figure") + || (fp.toolbar_is ("auto") && ! hasUiControlChildren (fp))) + offset += m_figureToolBar->sizeHint ().height (); + else + m_figureToolBar->hide (); + if (fp.menubar_is ("figure") || hasUiMenuChildren (fp)) + offset += m_menuBar->sizeHint ().height () + 1; + else + m_menuBar->hide (); + + m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); + m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); + + //qDebug () << "Figure::Figure:" << m_innerRect; + win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0)); + //qDebug () << "Figure::Figure(adjusted)" << m_innerRect.adjusted (0, -offset, 0, 0); + win->setWindowTitle (Utils::fromStdString (fp.get_title ())); + + int eventMask = 0; + if (! fp.get_keypressfcn ().is_empty ()) + eventMask |= Canvas::KeyPress; + if (! fp.get_keyreleasefcn ().is_empty ()) + eventMask |= Canvas::KeyRelease; + m_container->canvas (m_handle)->setEventMask (eventMask); + + if (! fp.get_windowbuttonmotionfcn ().is_empty ()) + { + m_container->setMouseTracking (true); + m_container->canvas (m_handle)->qWidget ()->setMouseTracking (true); + } + + connect (this, SIGNAL (asyncUpdate (void)), + this, SLOT (updateContainer (void))); + + if (fp.is_visible ()) + QTimer::singleShot (0, win, SLOT (show ())); + else + win->hide (); + + win->addReceiver (this); + m_container->addReceiver (this); +} + +Figure::~Figure (void) +{ +} + +void Figure::createFigureToolBarAndMenuBar (void) +{ + QMainWindow* win = qWidget (); + + m_figureToolBar = win->addToolBar (tr ("Figure ToolBar")); + m_figureToolBar->setMovable (false); + m_figureToolBar->setFloatable (false); + + MouseModeActionGroup* mouseModeGroup = new MouseModeActionGroup (win); + connect (mouseModeGroup, SIGNAL (modeChanged (MouseMode)), + SLOT (setMouseMode (MouseMode))); + m_figureToolBar->addActions (mouseModeGroup->actions ()); + + m_menuBar = new MenuBar (win); + win->setMenuBar (m_menuBar); + + QMenu* fileMenu = m_menuBar->addMenu (tr ("&File")); + fileMenu->menuAction ()->setObjectName ("builtinMenu"); + fileMenu->addAction (tr ("&New Figure"), this, SLOT (fileNewFigure (void))); + fileMenu->addAction (tr ("&Open..."))->setEnabled (false); + fileMenu->addSeparator (); + fileMenu->addAction (tr ("&Save"))->setEnabled (false); + fileMenu->addAction (tr ("Save &As"))->setEnabled (false); + fileMenu->addSeparator (); + fileMenu->addAction (tr ("&Close Figure"), this, + SLOT (fileCloseFigure (void)), Qt::CTRL|Qt::Key_W); + + QMenu* editMenu = m_menuBar->addMenu (tr ("&Edit")); + editMenu->menuAction ()->setObjectName ("builtinMenu"); + editMenu->addAction (tr ("Cop&y"), this, SLOT (editCopy (void)), + Qt::CTRL|Qt::Key_C)->setEnabled (false); + editMenu->addAction (tr ("Cu&t"), this, SLOT (editCut (void)), + Qt::CTRL|Qt::Key_X)->setEnabled (false); + editMenu->addAction (tr ("&Paste"), this, SLOT (editPaste(void)), + Qt::CTRL|Qt::Key_V)->setEnabled (false); + editMenu->addSeparator (); + editMenu->addActions (mouseModeGroup->actions ()); + + QMenu* helpMenu = m_menuBar->addMenu (tr ("&Help")); + helpMenu->menuAction ()->setObjectName ("builtinMenu"); + helpMenu->addAction (tr ("&About QtHandles"), this, + SLOT (helpAboutQtHandles (void))); + helpMenu->addAction (tr ("About &Qt"), qApp, SLOT (aboutQt (void))); + + m_menuBar->addReceiver (this); +} + +Container* Figure::innerContainer (void) +{ + return m_container; +} + +void Figure::redraw (void) +{ + Canvas* canvas = m_container->canvas (m_handle); + + if (canvas) + { + canvas->redraw (); + //canvas->setMouseMode (RotateMode); + } + + foreach (QFrame* frame, + qWidget ()->findChildren ("UIPanel")) + { + Object* obj = Object::fromQObject (frame); + + if (obj) + obj->slotRedraw (); + } +} + +void Figure::beingDeleted (void) +{ + Canvas* canvas = m_container->canvas (m_handle.value (), false); + + if (canvas) + canvas->blockRedraw (true); + + m_menuBar->removeReceiver (this); + m_container->removeReceiver (this); + qWidget ()->removeReceiver (this); +} + +void Figure::update (int pId) +{ + if (m_blockUpdates) + return; + + figure::properties& fp = properties
(); + QMainWindow* win = qWidget (); + + m_blockUpdates = true; + + switch (pId) + { + case figure::properties::ID_POSITION: + { + m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); + //qDebug () << "Figure::update(position):" << m_innerRect; + int offset = 0; + + foreach (QToolBar* tb, win->findChildren ()) + if (! tb->isHidden ()) + offset += tb->sizeHint ().height (); + if (! m_menuBar->isHidden ()) + offset += m_menuBar->sizeHint ().height () + 1; + //qDebug () << "Figure::update(position)(adjusted):" << m_innerRect.adjusted (0, -offset, 0, 0); + win->setGeometry (m_innerRect.adjusted (0, -offset, 0, 0)); + //qDebug () << "Figure::update(position): done"; + } + break; + case figure::properties::ID_NAME: + case figure::properties::ID_NUMBERTITLE: + win->setWindowTitle (Utils::fromStdString (fp.get_title ())); + break; + case figure::properties::ID_VISIBLE: + if (fp.is_visible ()) + QTimer::singleShot (0, win, SLOT (show ())); + else + win->hide (); + break; + case figure::properties::ID_TOOLBAR: + if (fp.toolbar_is ("none")) + showFigureToolBar (false); + else if (fp.toolbar_is ("figure")) + showFigureToolBar (true); + else // "auto" + showFigureToolBar (! hasUiControlChildren (fp)); + break; + case figure::properties::ID_MENUBAR: + showMenuBar (fp.menubar_is ("figure")); + break; + case figure::properties::ID_KEYPRESSFCN: + if (fp.get_keypressfcn ().is_empty ()) + m_container->canvas (m_handle)->clearEventMask (Canvas::KeyPress); + else + m_container->canvas (m_handle)->addEventMask (Canvas::KeyPress); + break; + case figure::properties::ID_KEYRELEASEFCN: + if (fp.get_keyreleasefcn ().is_empty ()) + m_container->canvas (m_handle)->clearEventMask (Canvas::KeyRelease); + else + m_container->canvas (m_handle)->addEventMask (Canvas::KeyRelease); + break; + case figure::properties::ID_WINDOWBUTTONMOTIONFCN: + { + bool hasCallback = ! fp.get_windowbuttonmotionfcn ().is_empty (); + + m_container->setMouseTracking (hasCallback); + foreach (QWidget* w, m_container->findChildren ()) + { w->setMouseTracking (hasCallback); } + } + break; + default: + break; + } + + m_blockUpdates = false; +} + +void Figure::showFigureToolBar (bool visible) +{ + if ((! m_figureToolBar->isHidden ()) != visible) + { + int dy = m_figureToolBar->sizeHint ().height (); + QRect r = qWidget ()->geometry (); + + if (! visible) + r.adjust (0, dy, 0, 0); + else + r.adjust (0, -dy, 0, 0); + + m_blockUpdates = true; + qWidget ()->setGeometry (r); + m_figureToolBar->setVisible (visible); + m_blockUpdates = false; + + updateBoundingBox (false); + + if (visible) + m_mouseMode = m_lastMouseMode; + else + { + m_lastMouseMode = m_mouseMode; + m_mouseMode = NoMode; + } + } +} + +void Figure::showMenuBar (bool visible) +{ + int h1 = m_menuBar->sizeHint ().height (); + + foreach (QAction* a, m_menuBar->actions ()) + if (a->objectName () == "builtinMenu") + a->setVisible (visible); + + int h2 = m_menuBar->sizeHint ().height (); + + if (! visible) + visible = hasUiMenuChildren (properties
()); + + if ((! m_menuBar->isHidden ()) != visible) + { + int dy = qMax (h1, h2) + 1; + QRect r = qWidget ()->geometry (); + + //qDebug () << "Figure::showMenuBar:" << r; + if (! visible) + r.adjust (0, dy, 0, 0); + else + r.adjust (0, -dy, 0, 0); + //qDebug () << "Figure::showMenuBar(adjusted):" << r; + + m_blockUpdates = true; + qWidget ()->setGeometry (r); + m_menuBar->setVisible (visible); + m_blockUpdates = false; + + updateBoundingBox (false); + } +} + +void Figure::updateMenuBar (void) +{ + gh_manager::auto_lock lock; + graphics_object go = object (); + + if (go.valid_object ()) + showMenuBar (Utils::properties
(go).menubar_is ("figure")); +} + +QWidget* Figure::menu (void) +{ + return qWidget ()->menuBar (); +} + +struct UpdateBoundingBoxData +{ + Matrix m_bbox; + bool m_internal; + graphics_handle m_handle; + Figure* m_figure; +}; + +void Figure::updateBoundingBoxHelper (void* data) +{ + gh_manager::auto_lock lock; + + UpdateBoundingBoxData* d = reinterpret_cast (data); + graphics_object go = gh_manager::get_object (d->m_handle); + + if (go.valid_object ()) + { + figure::properties& fp = Utils::properties
(go); + + //qDebug ("Figure::updateBoundingBoxHelper: internal=%d, bbox=[%g %g %g %g]", + // d->m_internal, d->m_bbox(0), d->m_bbox(1), d->m_bbox(2), d->m_bbox(3)); + fp.set_boundingbox (d->m_bbox, d->m_internal, false); + + if (d->m_internal) + emit d->m_figure->asyncUpdate (); + } + + delete d; +} + +void Figure::updateBoundingBox (bool internal, int flags) +{ + QWidget* win = qWidget (); + Matrix bb (1, 4); + + if (internal) + { + QRect r = m_innerRect; + + if (flags & UpdateBoundingBoxPosition) + r.moveTopLeft (win->mapToGlobal (m_container->pos ())); + if (flags & UpdateBoundingBoxSize) + r.setSize (m_container->size ()); + + if (r.isValid () && r != m_innerRect) + { + //qDebug() << "inner rect changed:" << m_innerRect << "->>" << r; + m_innerRect = r; + + bb(0) = r.x (); + bb(1) = r.y (); + bb(2) = r.width (); + bb(3) = r.height (); + } + else + return; + } + else + { + QRect r = m_outerRect; + + if (flags & UpdateBoundingBoxPosition) + r.moveTopLeft (win->pos ()); + if (flags & UpdateBoundingBoxSize) + r.setSize (win->frameGeometry ().size ()); + + if (r.isValid () && r != m_outerRect ) + { + //qDebug() << "outer rect changed:" << m_outerRect << "->>" << r; + m_outerRect = r; + + bb(0) = r.x (); + bb(1) = r.y (); + bb(2) = r.width (); + bb(3) = r.height (); + } + else + return; + } + + UpdateBoundingBoxData* d = new UpdateBoundingBoxData (); + + d->m_bbox = bb; + d->m_internal = internal; + d->m_handle = m_handle; + d->m_figure = this; + + //qDebug ("Figure::updateBoundingBox: internal=%d, bbox=[%g %g %g %g]", + // d->m_internal, d->m_bbox(0), d->m_bbox(1), d->m_bbox(2), d->m_bbox(3)); + gh_manager::post_function (Figure::updateBoundingBoxHelper, d); +} + +bool Figure::eventNotifyBefore (QObject* obj, QEvent* ev) +{ + if (! m_blockUpdates) + { + if (obj == m_container) + { + // Do nothing... + } + else if (obj == m_menuBar) + { + switch (ev->type ()) + { + case QEvent::ActionRemoved: + { + QAction* a = dynamic_cast (ev)->action (); + + if (! a->isSeparator () + && a->objectName () != "builtinMenu") + updateMenuBar (); + } + break; + default: + break; + } + } + else + { + switch (ev->type ()) + { + case QEvent::Close: + ev->ignore (); + gh_manager::post_callback (m_handle, "closerequestfcn"); + return true; + default: + break; + } + } + } + + return false; +} + +void Figure::eventNotifyAfter (QObject* watched, QEvent* ev) +{ + if (! m_blockUpdates) + { + if (watched == m_container) + { + switch (ev->type ()) + { + case QEvent::Resize: + updateBoundingBox (true, UpdateBoundingBoxSize); + break; + case QEvent::ChildAdded: + if (dynamic_cast (ev)->child + ()->isWidgetType()) + { + gh_manager::auto_lock lock; + const figure::properties& fp = properties
(); + + showFigureToolBar (! hasUiControlChildren (fp)); + } + default: + break; + } + } + else if (watched == m_menuBar) + { + switch (ev->type ()) + { + case QEvent::ActionAdded: + { + QAction* a = dynamic_cast (ev)->action (); + + if (! a->isSeparator () + && a->objectName () != "builtinMenu") + updateMenuBar (); + } + break; + default: + break; + } + } + else + { + switch (ev->type ()) + { + case QEvent::Move: + updateBoundingBox (false, UpdateBoundingBoxPosition); + updateBoundingBox (true, UpdateBoundingBoxPosition); + break; + case QEvent::Resize: + updateBoundingBox (false, UpdateBoundingBoxSize); + break; + default: + break; + } + } + } +} + +void Figure::helpAboutQtHandles (void) +{ + QMessageBox::about (qWidget (), tr ("About QtHandles"), + ABOUT_TEXT); +} + +void Figure::fileNewFigure (void) +{ +} + +void Figure::fileCloseFigure (void) +{ + qWidget ()->close (); +} + +void Figure::editCopy (void) +{ +} + +void Figure::editCut (void) +{ +} + +void Figure::editPaste (void) +{ +} + +void Figure::addCustomToolBar (QToolBar* bar, bool visible) +{ + QMainWindow* win = qWidget (); + + if (! visible) + win->addToolBar (bar); + else + { + QSize sz = bar->sizeHint (); + QRect r = win->geometry (); + //qDebug () << "Figure::addCustomToolBar:" << r; + + r.adjust (0, -sz.height (), 0, 0); + + m_blockUpdates = true; + win->setGeometry (r); + win->addToolBarBreak (); + win->addToolBar (bar); + m_blockUpdates = false; + + //qDebug () << "Figure::addCustomToolBar:" << win->geometry (); + updateBoundingBox (false); + } +} + +void Figure::showCustomToolBar (QToolBar* bar, bool visible) +{ + QMainWindow* win = qWidget (); + + if ((! bar->isHidden ()) != visible) + { + QSize sz = bar->sizeHint (); + QRect r = win->geometry (); + + if (visible) + r.adjust (0, -sz.height (), 0, 0); + else + r.adjust (0, sz.height (), 0, 0); + + m_blockUpdates = true; + win->setGeometry (r); + bar->setVisible (visible); + m_blockUpdates = false; + + updateBoundingBox (false); + } +} + +void Figure::updateContainer (void) +{ + redraw (); +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Figure.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Figure.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,124 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Figure__ +#define __QtHandles_Figure__ 1 + +#include + +#include "GenericEventNotify.h" +#include "MenuContainer.h" +#include "Object.h" + +class QMainWindow; +class QToolBar; + +namespace QtHandles +{ + +enum MouseMode +{ + NoMode = 0, + RotateMode = 1, + ZoomMode = 2, + PanMode = 3, + SelectMode = 4 +}; + +class Container; +class FigureWindow; +class MenuBar; +class ToolBar; + +class Figure : + public Object, + public MenuContainer, + public GenericEventNotifyReceiver +{ + Q_OBJECT + + friend class ToolBar; + +public: + Figure (const graphics_object& go, FigureWindow* win); + ~Figure (void); + + static Figure* create (const graphics_object& go); + + MouseMode mouseMode (void) { return m_mouseMode; } + + Container* innerContainer (void); + QWidget* menu (void); + + bool eventNotifyBefore (QObject* watched, QEvent* event); + void eventNotifyAfter (QObject* watched, QEvent* event); + +protected: + enum UpdateBoundingBoxFlag + { + UpdateBoundingBoxPosition = 0x1, + UpdateBoundingBoxSize = 0x2, + UpdateBoundingBoxAll = 0x3 + }; + +protected: + void redraw (void); + void update (int pId); + void updateBoundingBox (bool internal = false, int flags = 0); + void beingDeleted (void); + +private: + void createFigureToolBarAndMenuBar (void); + void showFigureToolBar (bool visible); + void showMenuBar (bool visible); + void addCustomToolBar (QToolBar* bar, bool visible); + void showCustomToolBar (QToolBar* bar, bool visible); + + static void updateBoundingBoxHelper (void*); + +private slots: + void setMouseMode (MouseMode mode) { m_mouseMode = mode; } + void fileNewFigure (void); + void fileCloseFigure (void); + void editCopy (void); + void editCut (void); + void editPaste (void); + void helpAboutQtHandles (void); + void updateMenuBar (void); + void updateContainer (void); + +signals: + void asyncUpdate (void); + +private: + Container* m_container; + bool m_blockUpdates; + MouseMode m_mouseMode, m_lastMouseMode; + QToolBar* m_figureToolBar; + MenuBar* m_menuBar; + QRect m_innerRect; + QRect m_outerRect; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/FigureWindow.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/FigureWindow.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,49 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "FigureWindow.h" + +namespace QtHandles +{ + +FigureWindow::FigureWindow (QWidget* xparent) + : FigureWindowBase (xparent) +{ +} + +FigureWindow::~FigureWindow (void) +{ +} + +QMenu* FigureWindow::createPopupMenu (void) +{ + // For the time being, disable menubar/toolbar popup menu + return 0; +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/FigureWindow.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/FigureWindow.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,48 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_FigureWindow__ +#define __QtHandles_FigureWindow__ 1 + +#include + +#include "GenericEventNotify.h" + +namespace QtHandles +{ + +DECLARE_GENERICEVENTNOTIFY_SENDER(FigureWindowBase, QMainWindow); + +class FigureWindow : public FigureWindowBase +{ + Q_OBJECT + +public: + FigureWindow (QWidget* parent = 0); + ~FigureWindow (void); + + QMenu* createPopupMenu (void); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/GLCanvas.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/GLCanvas.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,149 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gl-render.h" +#include "graphics.h" + +#include "GLCanvas.h" +#include "gl-select.h" + +namespace QtHandles +{ + +GLCanvas::GLCanvas (QWidget* xparent, const graphics_handle& gh) + : QGLWidget (xparent), Canvas (gh) +{ + setFocusPolicy (Qt::ClickFocus); +} + +GLCanvas::~GLCanvas (void) +{ +} + +void GLCanvas::draw (const graphics_handle& gh) +{ + graphics_object go = gh_manager::get_object (gh); + + if (go) + { + opengl_renderer r; + + r.set_viewport (width (), height ()); + r.draw(go); + } +} + +graphics_object GLCanvas::selectFromAxes (const graphics_object& ax, + const QPoint& pt) +{ + makeCurrent (); + + if (ax) + { + opengl_selector s; + + s.set_viewport (width (), height ()); + return s.select (ax, pt.x (), height () - pt.y ()); + } + + return graphics_object (); +} + +inline void glDrawZoomBox (const QPoint& p1, const QPoint& p2) +{ + glVertex2d (p1.x (), p1.y ()); + glVertex2d (p2.x (), p1.y ()); + glVertex2d (p2.x (), p2.y ()); + glVertex2d (p1.x (), p2.y ()); + glVertex2d (p1.x (), p1.y ()); +} + +void GLCanvas::drawZoomBox (const QPoint& p1, const QPoint& p2) +{ + glPushMatrix (); + + glMatrixMode (GL_MODELVIEW); + glLoadIdentity (); + + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + glOrtho (0, width (), height (), 0, 1, -1); + + glPushAttrib (GL_DEPTH_BUFFER_BIT | GL_CURRENT_BIT); + glDisable (GL_DEPTH_TEST); + + glBegin (GL_POLYGON); + glColor4f (0.45, 0.62, 0.81, 0.1); + glDrawZoomBox (p1, p2); + glEnd (); + + glBegin (GL_LINE_STRIP); + glLineWidth (1.5); + glColor4f (0.45, 0.62, 0.81, 0.9); + glDrawZoomBox (p1, p2); + glEnd (); + + glPopAttrib (); + glPopMatrix (); +} + +void GLCanvas::paintGL (void) +{ + canvasPaintEvent (); +} + +void GLCanvas::mouseMoveEvent (QMouseEvent* ev) +{ + canvasMouseMoveEvent (ev); +} + +void GLCanvas::mousePressEvent (QMouseEvent* ev) +{ + canvasMousePressEvent (ev); +} + +void GLCanvas::mouseReleaseEvent (QMouseEvent* ev) +{ + canvasMouseReleaseEvent (ev); +} + +void GLCanvas::keyPressEvent (QKeyEvent* ev) +{ + if (! canvasKeyPressEvent (ev)) + QGLWidget::keyPressEvent (ev); +} + +void GLCanvas::keyReleaseEvent (QKeyEvent* ev) +{ + if (! canvasKeyReleaseEvent (ev)) + QGLWidget::keyReleaseEvent (ev); +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/GLCanvas.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/GLCanvas.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,58 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_GLCanvas__ +#define __QtHandles_GLCanvas__ 1 + +#include + +#include "Canvas.h" + +namespace QtHandles +{ + +class GLCanvas : public QGLWidget, public Canvas +{ +public: + GLCanvas (QWidget* parent, const graphics_handle& handle); + ~GLCanvas (void); + + void draw (const graphics_handle& handle); + void drawZoomBox (const QPoint& p1, const QPoint& p2); + void resize (int /* x */, int /* y */, + int /* width */, int /* height */) { } + graphics_object selectFromAxes (const graphics_object& ax, + const QPoint& pt); + QWidget* qWidget (void) { return this; } + +protected: + void paintGL (void); + void mouseMoveEvent (QMouseEvent* event); + void mousePressEvent (QMouseEvent* event); + void mouseReleaseEvent (QMouseEvent* event); + void keyPressEvent (QKeyEvent* event); + void keyReleaseEvent (QKeyEvent* event); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/GenericEventNotify.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/GenericEventNotify.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,104 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __GenericEventNotify_h__ +#define __GenericEventNotify_h__ 1 + +#include + +class QEvent; +class QObject; +class QWidget; + +namespace QtHandles +{ + +class GenericEventNotifyReceiver; + +class GenericEventNotifySender +{ +public: + GenericEventNotifySender (void) : m_receivers () { } + virtual ~GenericEventNotifySender (void) { } + + void addReceiver (GenericEventNotifyReceiver* r) + { m_receivers.insert (r); } + + void removeReceiver (GenericEventNotifyReceiver* r) + { m_receivers.remove (r); } + +protected: + bool notifyReceiversBefore (QObject* obj, QEvent* evt); + void notifyReceiversAfter (QObject* obj, QEvent* evt); + +private: + QSet m_receivers; +}; + +class GenericEventNotifyReceiver +{ +public: + GenericEventNotifyReceiver (void) { } + virtual ~GenericEventNotifyReceiver (void) { } + + virtual bool eventNotifyBefore (QObject* obj, QEvent* evt) = 0; + virtual void eventNotifyAfter (QObject* obj, QEvent* evt) = 0; +}; + +inline +bool GenericEventNotifySender::notifyReceiversBefore (QObject* obj, + QEvent* evt) +{ + foreach (GenericEventNotifyReceiver* r, m_receivers) + if (r->eventNotifyBefore (obj, evt)) + return true; + return false; +} + +inline +void GenericEventNotifySender::notifyReceiversAfter (QObject* obj, + QEvent* evt) +{ + foreach (GenericEventNotifyReceiver* r, m_receivers) + r->eventNotifyAfter (obj, evt); +} + +#define DECLARE_GENERICEVENTNOTIFY_SENDER(T,B) \ +class T : public B, public GenericEventNotifySender \ +{ \ +public: \ + T (QWidget* xparent) : B (xparent), GenericEventNotifySender () { } \ + ~ T (void) { } \ +\ + bool event (QEvent* evt) \ + { \ + bool result = true; \ + if (! notifyReceiversBefore (this, evt)) \ + result = B::event (evt); \ + notifyReceiversAfter (this, evt); \ + return result; \ + } \ +} + +}; + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/KeyMap.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/KeyMap.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,258 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "KeyMap.h" + +namespace QtHandles +{ + +namespace KeyMap +{ + +std::string qKeyToKeyString (int key) +{ + static QMap keyMapper; + + if (keyMapper.isEmpty ()) + { + keyMapper[Qt::Key_Escape] = "escape"; + keyMapper[Qt::Key_Tab] = "tab"; + keyMapper[Qt::Key_Backtab] = "backtab"; + keyMapper[Qt::Key_Backspace] = "backspace"; + keyMapper[Qt::Key_Return] = "return"; + keyMapper[Qt::Key_Enter] = "enter"; + keyMapper[Qt::Key_Insert] = "insert"; + keyMapper[Qt::Key_Delete] = "delete"; + keyMapper[Qt::Key_Pause] = "pause"; + keyMapper[Qt::Key_Print] = "print"; + keyMapper[Qt::Key_SysReq] = "sysreq"; + keyMapper[Qt::Key_Clear] = "clear"; + keyMapper[Qt::Key_Home] = "home"; + keyMapper[Qt::Key_End] = "end"; + keyMapper[Qt::Key_Left] = "left"; + keyMapper[Qt::Key_Up] = "up"; + keyMapper[Qt::Key_Right] = "right"; + keyMapper[Qt::Key_Down] = "down"; + keyMapper[Qt::Key_PageUp] = "pageup"; + keyMapper[Qt::Key_PageDown] = "pagedown"; + keyMapper[Qt::Key_Shift] = "shift"; + keyMapper[Qt::Key_Control] = "control"; + keyMapper[Qt::Key_Meta] = "meta"; + keyMapper[Qt::Key_Alt] = "alt"; + keyMapper[Qt::Key_CapsLock] = "capslock"; + keyMapper[Qt::Key_NumLock] = "numlock"; + keyMapper[Qt::Key_ScrollLock] = "scrolllock"; + keyMapper[Qt::Key_F1] = "f1"; + keyMapper[Qt::Key_F2] = "f2"; + keyMapper[Qt::Key_F3] = "f3"; + keyMapper[Qt::Key_F4] = "f4"; + keyMapper[Qt::Key_F5] = "f5"; + keyMapper[Qt::Key_F6] = "f6"; + keyMapper[Qt::Key_F7] = "f7"; + keyMapper[Qt::Key_F8] = "f8"; + keyMapper[Qt::Key_F9] = "f9"; + keyMapper[Qt::Key_F10] = "f10"; + keyMapper[Qt::Key_F11] = "f11"; + keyMapper[Qt::Key_F12] = "f12"; + keyMapper[Qt::Key_F13] = "f13"; + keyMapper[Qt::Key_F14] = "f14"; + keyMapper[Qt::Key_F15] = "f15"; + keyMapper[Qt::Key_F16] = "f16"; + keyMapper[Qt::Key_F17] = "f17"; + keyMapper[Qt::Key_F18] = "f18"; + keyMapper[Qt::Key_F19] = "f19"; + keyMapper[Qt::Key_F20] = "f20"; + keyMapper[Qt::Key_F21] = "f21"; + keyMapper[Qt::Key_F22] = "f22"; + keyMapper[Qt::Key_F23] = "f23"; + keyMapper[Qt::Key_F24] = "f24"; + keyMapper[Qt::Key_F25] = "f25"; + keyMapper[Qt::Key_F26] = "f26"; + keyMapper[Qt::Key_F27] = "f27"; + keyMapper[Qt::Key_F28] = "f28"; + keyMapper[Qt::Key_F29] = "f29"; + keyMapper[Qt::Key_F30] = "f30"; + keyMapper[Qt::Key_F31] = "f31"; + keyMapper[Qt::Key_F32] = "f32"; + keyMapper[Qt::Key_F33] = "f33"; + keyMapper[Qt::Key_F34] = "f34"; + keyMapper[Qt::Key_F35] = "f35"; + keyMapper[Qt::Key_Super_L] = "super_l"; + keyMapper[Qt::Key_Super_R] = "super_r"; + keyMapper[Qt::Key_Menu] = "menu"; + keyMapper[Qt::Key_Hyper_L] = "hyper_l"; + keyMapper[Qt::Key_Hyper_R] = "hyper_r"; + keyMapper[Qt::Key_Help] = "help"; + keyMapper[Qt::Key_Direction_L] = "direction_l"; + keyMapper[Qt::Key_Direction_R] = "direction_r"; + keyMapper[Qt::Key_Space] = "space"; + keyMapper[Qt::Key_Any] = "any"; + keyMapper[Qt::Key_Exclam] = "exclam"; + keyMapper[Qt::Key_QuoteDbl] = "quotedbl"; + keyMapper[Qt::Key_NumberSign] = "numbersign"; + keyMapper[Qt::Key_Dollar] = "dollar"; + keyMapper[Qt::Key_Percent] = "percent"; + keyMapper[Qt::Key_Ampersand] = "ampersand"; + keyMapper[Qt::Key_Apostrophe] = "apostrophe"; + keyMapper[Qt::Key_ParenLeft] = "parenleft"; + keyMapper[Qt::Key_ParenRight] = "parenright"; + keyMapper[Qt::Key_Asterisk] = "asterisk"; + keyMapper[Qt::Key_Plus] = "plus"; + keyMapper[Qt::Key_Comma] = "comma"; + keyMapper[Qt::Key_Minus] = "minus"; + keyMapper[Qt::Key_Period] = "period"; + keyMapper[Qt::Key_Slash] = "slash"; + keyMapper[Qt::Key_0] = "0"; + keyMapper[Qt::Key_1] = "1"; + keyMapper[Qt::Key_2] = "2"; + keyMapper[Qt::Key_3] = "3"; + keyMapper[Qt::Key_4] = "4"; + keyMapper[Qt::Key_5] = "5"; + keyMapper[Qt::Key_6] = "6"; + keyMapper[Qt::Key_7] = "7"; + keyMapper[Qt::Key_8] = "8"; + keyMapper[Qt::Key_9] = "9"; + keyMapper[Qt::Key_Colon] = "colon"; + keyMapper[Qt::Key_Semicolon] = "semicolon"; + keyMapper[Qt::Key_Less] = "less"; + keyMapper[Qt::Key_Equal] = "equal"; + keyMapper[Qt::Key_Greater] = "greater"; + keyMapper[Qt::Key_Question] = "question"; + keyMapper[Qt::Key_At] = "at"; + keyMapper[Qt::Key_A] = "a"; + keyMapper[Qt::Key_B] = "b"; + keyMapper[Qt::Key_C] = "c"; + keyMapper[Qt::Key_D] = "d"; + keyMapper[Qt::Key_E] = "e"; + keyMapper[Qt::Key_F] = "f"; + keyMapper[Qt::Key_G] = "g"; + keyMapper[Qt::Key_H] = "h"; + keyMapper[Qt::Key_I] = "i"; + keyMapper[Qt::Key_J] = "j"; + keyMapper[Qt::Key_K] = "k"; + keyMapper[Qt::Key_L] = "l"; + keyMapper[Qt::Key_M] = "m"; + keyMapper[Qt::Key_N] = "n"; + keyMapper[Qt::Key_O] = "o"; + keyMapper[Qt::Key_P] = "p"; + keyMapper[Qt::Key_Q] = "q"; + keyMapper[Qt::Key_R] = "r"; + keyMapper[Qt::Key_S] = "s"; + keyMapper[Qt::Key_T] = "t"; + keyMapper[Qt::Key_U] = "u"; + keyMapper[Qt::Key_V] = "v"; + keyMapper[Qt::Key_W] = "w"; + keyMapper[Qt::Key_X] = "x"; + keyMapper[Qt::Key_Y] = "y"; + keyMapper[Qt::Key_Z] = "z"; + keyMapper[Qt::Key_BracketLeft] = "bracketleft"; + keyMapper[Qt::Key_Backslash] = "backslash"; + keyMapper[Qt::Key_BracketRight] = "bracketright"; + keyMapper[Qt::Key_AsciiCircum] = "asciicircum"; + keyMapper[Qt::Key_Underscore] = "underscore"; + keyMapper[Qt::Key_QuoteLeft] = "quoteleft"; + keyMapper[Qt::Key_BraceLeft] = "braceleft"; + keyMapper[Qt::Key_Bar] = "bar"; + keyMapper[Qt::Key_BraceRight] = "braceright"; + keyMapper[Qt::Key_AsciiTilde] = "asciitilde"; + + keyMapper[Qt::Key_nobreakspace] = "nobreakspace"; + keyMapper[Qt::Key_exclamdown] = "exclamdown"; + keyMapper[Qt::Key_cent] = "cent"; + keyMapper[Qt::Key_sterling] = "sterling"; + keyMapper[Qt::Key_currency] = "currency"; + keyMapper[Qt::Key_yen] = "yen"; + keyMapper[Qt::Key_brokenbar] = "brokenbar"; + keyMapper[Qt::Key_section] = "section"; + keyMapper[Qt::Key_diaeresis] = "diaeresis"; + keyMapper[Qt::Key_copyright] = "copyright"; + keyMapper[Qt::Key_ordfeminine] = "ordfeminine"; + keyMapper[Qt::Key_guillemotleft] = "guillemotleft"; + keyMapper[Qt::Key_notsign] = "notsign"; + keyMapper[Qt::Key_hyphen] = "hyphen"; + keyMapper[Qt::Key_registered] = "registered"; + keyMapper[Qt::Key_macron] = "macron"; + keyMapper[Qt::Key_degree] = "degree"; + keyMapper[Qt::Key_plusminus] = "plusminus"; + keyMapper[Qt::Key_twosuperior] = "twosuperior"; + keyMapper[Qt::Key_threesuperior] = "threesuperior"; + keyMapper[Qt::Key_acute] = "acute"; + keyMapper[Qt::Key_mu] = "mu"; + keyMapper[Qt::Key_paragraph] = "paragraph"; + keyMapper[Qt::Key_periodcentered] = "periodcentered"; + keyMapper[Qt::Key_cedilla] = "cedilla"; + keyMapper[Qt::Key_onesuperior] = "onesuperior"; + keyMapper[Qt::Key_masculine] = "masculine"; + keyMapper[Qt::Key_guillemotright] = "guillemotright"; + keyMapper[Qt::Key_onequarter] = "onequarter"; + keyMapper[Qt::Key_onehalf] = "onehalf"; + keyMapper[Qt::Key_threequarters] = "threequarters"; + keyMapper[Qt::Key_questiondown] = "questiondown"; + keyMapper[Qt::Key_Agrave] = "agrave"; + keyMapper[Qt::Key_Aacute] = "aacute"; + keyMapper[Qt::Key_Acircumflex] = "acircumflex"; + keyMapper[Qt::Key_Atilde] = "atilde"; + keyMapper[Qt::Key_Adiaeresis] = "adiaeresis"; + keyMapper[Qt::Key_Aring] = "aring"; + keyMapper[Qt::Key_AE] = "ae"; + keyMapper[Qt::Key_Ccedilla] = "ccedilla"; + keyMapper[Qt::Key_Egrave] = "egrave"; + keyMapper[Qt::Key_Eacute] = "eacute"; + keyMapper[Qt::Key_Ecircumflex] = "ecircumflex"; + keyMapper[Qt::Key_Ediaeresis] = "ediaeresis"; + keyMapper[Qt::Key_Igrave] = "igrave"; + keyMapper[Qt::Key_Iacute] = "iacute"; + keyMapper[Qt::Key_Icircumflex] = "icircumflex"; + keyMapper[Qt::Key_Idiaeresis] = "idiaeresis"; + keyMapper[Qt::Key_ETH] = "eth"; + keyMapper[Qt::Key_Ntilde] = "ntilde"; + keyMapper[Qt::Key_Ograve] = "ograve"; + keyMapper[Qt::Key_Oacute] = "oacute"; + keyMapper[Qt::Key_Ocircumflex] = "ocircumflex"; + keyMapper[Qt::Key_Otilde] = "otilde"; + keyMapper[Qt::Key_Odiaeresis] = "odiaeresis"; + keyMapper[Qt::Key_multiply] = "multiply"; + keyMapper[Qt::Key_Ooblique] = "ooblique"; + keyMapper[Qt::Key_Ugrave] = "ugrave"; + keyMapper[Qt::Key_Uacute] = "uacute"; + keyMapper[Qt::Key_Ucircumflex] = "ucircumflex"; + keyMapper[Qt::Key_Udiaeresis] = "udiaeresis"; + keyMapper[Qt::Key_Yacute] = "yacute"; + keyMapper[Qt::Key_THORN] = "thorn"; + keyMapper[Qt::Key_ssharp] = "ssharp"; + keyMapper[Qt::Key_division] = "division"; + keyMapper[Qt::Key_ydiaeresis] = "ydiaeresis"; + } + + return keyMapper.value (key, std::string ("")); +} + +}; //namespace KeyMap + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/KeyMap.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/KeyMap.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,40 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles__KeyMap__ +#define __QtHandles__KeyMap__ 1 + +#include + +namespace QtHandles +{ + +namespace KeyMap +{ + +std::string qKeyToKeyString (int key); + +}; // namespace KeyMap + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ListBoxControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ListBoxControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,170 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Container.h" +#include "ListBoxControl.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +static void updateSelection (QListWidget* list, const Matrix& value) +{ + octave_idx_type n = value.numel (); + int lc = list->count (); + + list->clearSelection (); + + for (octave_idx_type i = 0; i < n; i++) + { + int idx = xround (value(i)); + + if (1 <= idx && idx <= lc) + { + list->item (idx-1)->setSelected (true); + if (i == 0 + && list->selectionMode () == QAbstractItemView::SingleSelection) + break; + } + else + { + // Invalid selection. + list->clearSelection (); + break; + } + } +} + +ListBoxControl* ListBoxControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new ListBoxControl (go, new QListWidget (container)); + } + + return 0; +} + +ListBoxControl::ListBoxControl (const graphics_object& go, QListWidget* list) + : BaseControl (go, list), m_blockCallback (false) +{ + uicontrol::properties& up = properties (); + + list->addItems (Utils::fromStringVector (up.get_string_vector ())); + if ((up.get_max () - up.get_min ()) > 1) + list->setSelectionMode (QAbstractItemView::ExtendedSelection); + else + list->setSelectionMode (QAbstractItemView::SingleSelection); + Matrix value = up.get_value ().matrix_value (); + if (value.numel () > 0) + { + octave_idx_type n = value.numel (); + int lc = list->count (); + + for (octave_idx_type i = 0; i < n; i++) + { + int idx = xround (value(i)); + + if (1 <= idx && idx <= lc) + { + list->item (idx-1)->setSelected (true); + if (i == 0 + && list->selectionMode () == + QAbstractItemView::SingleSelection) + break; + } + } + } + + list->removeEventFilter (this); + list->viewport ()->installEventFilter (this); + + connect (list, SIGNAL (itemSelectionChanged (void)), + SLOT (itemSelectionChanged (void))); +} + +ListBoxControl::~ListBoxControl (void) +{ +} + +void ListBoxControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QListWidget* list = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + m_blockCallback = true; + list->clear (); + list->addItems (Utils::fromStringVector (up.get_string_vector ())); + updateSelection (list, up.get_value ().matrix_value ()); + m_blockCallback = false; + break; + case uicontrol::properties::ID_MIN: + case uicontrol::properties::ID_MAX: + if ((up.get_max () - up.get_min ()) > 1) + list->setSelectionMode (QAbstractItemView::ExtendedSelection); + else + list->setSelectionMode (QAbstractItemView::SingleSelection); + break; + case uicontrol::properties::ID_VALUE: + m_blockCallback = true; + updateSelection (list, up.get_value ().matrix_value ()); + m_blockCallback = false; + break; + default: + BaseControl::update (pId); + break; + } +} + +void ListBoxControl::itemSelectionChanged (void) +{ + if (! m_blockCallback) + { + QListWidget* list = qWidget (); + + QModelIndexList l = list->selectionModel ()->selectedIndexes (); + Matrix value (dim_vector (1, l.size ())); + int i = 0; + + foreach (const QModelIndex& idx, l) + value(i++) = (idx.row () + 1); + + gh_manager::post_set (m_handle, "value", octave_value (value), false); + gh_manager::post_callback (m_handle, "callback"); + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ListBoxControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ListBoxControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,55 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ListBoxControl__ +#define __QtHandles_ListBoxControl__ 1 + +#include "BaseControl.h" + +class QListWidget; + +namespace QtHandles +{ + +class ListBoxControl : public BaseControl +{ + Q_OBJECT + +public: + ListBoxControl (const graphics_object& go, QListWidget* list); + ~ListBoxControl (void); + + static ListBoxControl* create (const graphics_object& go); + +protected: + void update (int pId); + +private slots: + void itemSelectionChanged (void); + +private: + bool m_blockCallback; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Logger.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Logger.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,86 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include "Logger.h" + +namespace QtHandles +{ + +Logger* Logger::s_instance = 0; +QMutex* Logger::s_mutex = 0; + +Logger::Logger (void) + : m_debugEnabled (false) +{ + QProcessEnvironment pe (QProcessEnvironment::systemEnvironment ()); + + if (pe.value ("QTHANDLES_DEBUG", "0") != "0") + m_debugEnabled = true; +} + +Logger::~Logger (void) +{ +} + +Logger* Logger::instance (void) +{ + if (! s_instance) + { + s_instance = new Logger (); + s_mutex = new QMutex (); + } + + return s_instance; +} + +#define STATIC_LOGGER(fun) \ +void Logger::fun (const char* fmt, ...) \ +{ \ + QMutexLocker lock (s_mutex); \ + va_list vl; \ + va_start (vl, fmt); \ + instance ()->fun ## V (fmt, vl); \ + va_end (vl); \ +} + +STATIC_LOGGER (debug) + +void Logger::debugV (const char* fmt, va_list arg) +{ + if (m_debugEnabled) + { + vfprintf (stderr, fmt, arg); + fprintf (stderr, "\n"); + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Logger.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Logger.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,55 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Logger__ +#define __QtHandles_Logger__ 1 + +#include + +class QMutex; + +namespace QtHandles +{ + +class Logger +{ +public: + static void debug (const char* fmt, ...); + +private: + bool m_debugEnabled; + + static Logger* s_instance; + static QMutex* s_mutex; + +private: + Logger (void); + ~Logger (void); + + static Logger* instance (void); + + void debugV (const char* fmt, va_list arg); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Menu.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Menu.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,307 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include + +#include "Figure.h" +#include "Menu.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +static QKeySequence accelSequence (const uimenu::properties& up) +{ + std::string s (up.get_accelerator ()); + + if (! s.empty ()) + { + char c = s[0]; + int keyMod = Qt::CTRL; + + if (c >= 'A' && c <= 'Z') + keyMod |= Qt::SHIFT; + if (c >= 'a' && c <= 'z') + c -= ('a' - 'A'); + if (c >= 'A' && c <= 'Z') + return QKeySequence (keyMod | static_cast (c)); + } + + return QKeySequence (); +} + +Menu* Menu::create (const graphics_object& go) +{ + Object* parent_obj = Object::parentObject (go); + + if (parent_obj) + { + QObject* qObj = parent_obj->qObject (); + + if (qObj) + return new Menu (go, new QAction (qObj), parent_obj); + } + + return 0; +} + +Menu::Menu (const graphics_object& go, QAction* action, Object* xparent) + : Object (go, action), m_parent (0), m_separator (0) +{ + uimenu::properties& up = properties (); + + action->setText (Utils::fromStdString (up.get_label ())); + if (up.is_checked ()) + { + action->setCheckable (true); + action->setChecked (up.is_checked ()); + } + action->setEnabled (up.is_enable ()); + action->setShortcut (accelSequence (up)); + action->setVisible (up.is_visible ()); + if (up.is_separator ()) + { + m_separator = new QAction (action); + m_separator->setSeparator (true); + m_separator->setVisible (up.is_visible ()); + } + + MenuContainer* menuContainer = dynamic_cast (xparent); + + if (menuContainer) + m_parent = menuContainer->menu (); + + if (m_parent) + { + int pos = static_cast (up.get_position ()); + + if (pos <= 0) + { + if (m_separator) + m_parent->insertAction (0, m_separator); + m_parent->insertAction (0, action); + + int count = 0; + + foreach (QAction* a, m_parent->actions ()) + if (! a->isSeparator () && a->objectName () != "builtinMenu") + count++; + up.get_property ("position").set + (octave_value (static_cast (count)), true, false); + } + else + { + + int count = 0; + QAction* before = 0; + + foreach (QAction* a, m_parent->actions ()) + if (! a->isSeparator () && a->objectName () != "builtinMenu") + { + count++; + if (pos <= count) + { + before = a; + break; + } + } + + if (m_separator) + m_parent->insertAction (before, m_separator); + m_parent->insertAction (before, action); + + if (before) + updateSiblingPositions (); + else + up.get_property ("position").set + (octave_value (static_cast (count+1)), true, false); + } + } + + connect (action, SIGNAL (triggered (bool)), SLOT (actionTriggered (void))); +} + +Menu::~Menu (void) +{ +} + +void Menu::update (int pId) +{ + uimenu::properties& up = properties (); + QAction* action = qWidget (); + + switch (pId) + { + case uimenu::properties::ID_LABEL: + action->setText (Utils::fromStdString (up.get_label ())); + break; + case uimenu::properties::ID_CHECKED: + if (up.is_checked ()) + { + action->setCheckable (true); + action->setChecked (up.is_checked ()); + } + else + { + action->setChecked (false); + action->setCheckable (false); + } + break; + case uimenu::properties::ID_ENABLE: + action->setEnabled (up.is_enable ()); + break; + case uimenu::properties::ID_ACCELERATOR: + if (! action->menu ()) + action->setShortcut (accelSequence (up)); + break; + case uimenu::properties::ID_SEPARATOR: + if (up.is_separator ()) + { + if (! m_separator) + { + m_separator = new QAction (action); + m_separator->setSeparator (true); + m_separator->setVisible (up.is_visible ()); + if (m_parent) + m_parent->insertAction (action, m_separator); + } + } + else + { + if (m_separator) + delete m_separator; + m_separator = 0; + } + break; + case uimenu::properties::ID_VISIBLE: + action->setVisible (up.is_visible ()); + if (m_separator) + m_separator->setVisible (up.is_visible ()); + break; + case uimenu::properties::ID_POSITION: + if (m_separator) + m_parent->removeAction (m_separator); + m_parent->removeAction (action); + { + int pos = static_cast (up.get_position ()); + QAction* before = 0; + + if (pos > 0) + { + int count = 0; + + foreach (QAction* a, m_parent->actions ()) + if (! a->isSeparator () && a->objectName () != "builtinMenu") + { + count++; + if (pos <= count) + { + before = a; + break; + } + } + } + + if (m_separator) + m_parent->insertAction (before, m_separator); + m_parent->insertAction (before, action); + updateSiblingPositions (); + } + break; + default: + Object::update (pId); + break; + } +} + +QWidget* Menu::menu (void) +{ + QAction* action = qWidget (); + QMenu* _menu = action->menu (); + + if (! _menu) + { + _menu = new QMenu (action->parentWidget ()); + action->setMenu (_menu); + action->setShortcut (QKeySequence ()); + connect (_menu, SIGNAL (aboutToShow (void)), + this, SLOT (actionHovered (void))); + } + + return _menu; +} + +void Menu::actionTriggered (void) +{ + QAction* action = qWidget (); + + if (action->isCheckable ()) + action->setChecked (! action->isChecked ()); + gh_manager::post_callback (m_handle, "callback"); +} + +void Menu::actionHovered (void) +{ + gh_manager::post_callback (m_handle, "callback"); +} + +void Menu::updateSiblingPositions (void) +{ + if (m_parent) + { + double count = 1.0; + + foreach (QAction* a, m_parent->actions ()) + { + if (! a->isSeparator () && a->objectName () != "builtinMenu") + { + Object* aObj = Object::fromQObject (a); + + if (aObj) + { + graphics_object go = aObj->object (); + + // Probably overkill as a uimenu child can only be another + // uimenu object. + if (go.isa ("uimenu")) + { + uimenu::properties& up = Utils::properties (go); + + up.get_property ("position").set + (octave_value (count), true, false); + } + } + + count++; + } + } + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Menu.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Menu.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,67 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Menu__ +#define __QtHandles_Menu__ 1 + +#include "MenuContainer.h" +#include "Object.h" + +class QAction; +class QMenu; +class QWidget; + +namespace QtHandles +{ + +class Menu : public Object, public MenuContainer +{ + Q_OBJECT + +public: + Menu (const graphics_object& go, QAction* action, Object* parent); + ~Menu (void); + + static Menu* create (const graphics_object& go); + + Container* innerContainer (void) { return 0; } + + QWidget* menu (void); + +protected: + void update (int pId); + +private slots: + void actionTriggered (void); + void actionHovered (void); + +private: + void updateSiblingPositions (void); + +private: + QWidget* m_parent; + QAction* m_separator; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/MenuContainer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/MenuContainer.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,39 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_MenuContainer__ +#define __QtHandles_MenuContainer__ 1 + +class QWidget; + +namespace QtHandles +{ + +class MenuContainer +{ +public: + virtual QWidget* menu (void) = 0; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/MouseModeActionGroup.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/MouseModeActionGroup.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,93 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "Figure.h" +#include "MouseModeActionGroup.h" + +namespace QtHandles +{ + +MouseModeActionGroup::MouseModeActionGroup (QObject* xparent) + : QObject (xparent), m_current (0) +{ + m_actions.append (new QAction (QIcon (":/images/rotate.png"), + tr ("Rotate"), this)); + m_actions.append (new QAction (QIcon (":/images/zoom.png"), + tr ("Zoom"), this)); + m_actions.append (new QAction (QIcon (":/images/pan.png"), + tr ("Pan"), this)); + m_actions.append (new QAction (QIcon (":/images/select.png"), + tr ("Select"), this)); + m_actions[2]->setEnabled (false); + m_actions[3]->setEnabled (false); + + foreach (QAction* a, m_actions) + { + a->setCheckable (true); + connect (a, SIGNAL (toggled (bool)), this, SLOT (actionToggled (bool))); + } +} + +MouseModeActionGroup::~MouseModeActionGroup (void) +{ +} + +void MouseModeActionGroup::actionToggled (bool checked) +{ + if (! checked) + { + if (sender () == m_current) + { + m_current = 0; + emit modeChanged (NoMode); + } + } + else + { + int i = m_actions.indexOf (qobject_cast (sender ())); + + if (i >= 0) + { + m_current = m_actions[i]; + for (int j = 0; j < m_actions.size (); j++) + if (j != i) + m_actions[j]->setChecked (false); + emit modeChanged (static_cast (i+1)); + } + } +} + +MouseMode MouseModeActionGroup::mouseMode (void) const +{ + int i = (m_current ? -1 : m_actions.indexOf (m_current)); + + return static_cast (i+1); +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/MouseModeActionGroup.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/MouseModeActionGroup.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,60 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_MouseModeActionGroup__ +#define __QtHandles_MouseModeActionGroup__ 1 + +#include +#include + +#include "Figure.h" + +class QAction; + +namespace QtHandles +{ + +class MouseModeActionGroup : public QObject +{ + Q_OBJECT + +public: + MouseModeActionGroup (QObject* parent = 0); + ~MouseModeActionGroup (void); + + QList actions (void) const { return m_actions; } + MouseMode mouseMode (void) const; + +signals: + void modeChanged (MouseMode mode); + +private slots: + void actionToggled (bool checked); + +private: + QList m_actions; + QAction* m_current; +}; + +}; + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Object.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Object.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,162 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Backend.h" +#include "Object.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +Object::Object (const graphics_object& go, QObject* obj) + : QObject (), m_handle (go.get_handle ()), m_qobject (0) +{ + gh_manager::auto_lock lock (false); + + if (! lock) + qCritical ("QtHandles::Object::Object: " + "creating Object (h=%g) without a valid lock!!!", + m_handle.value ()); + + init (obj); +} + +void Object::init (QObject* obj, bool) +{ + if (m_qobject) + qCritical ("QtHandles::Object::init: " + "resetting QObject while in invalid state"); + + m_qobject = obj; + + if (m_qobject) + { + m_qobject->setProperty ("QtHandles::Object", + qVariantFromValue (this)); + connect (m_qobject, SIGNAL (destroyed (QObject*)), + SLOT (objectDestroyed (QObject*))); + } +} + +Object::~Object (void) +{ +} + +graphics_object Object::object (void) const +{ + gh_manager::auto_lock lock (false); + + if (! lock) + qCritical ("QtHandles::Object::object: " + "accessing graphics object (h=%g) without a valid lock!!!", + m_handle.value ()); + + return gh_manager::get_object (m_handle); +} + +void Object::slotUpdate (int pId) +{ + gh_manager::auto_lock lock; + + switch (pId) + { + // Special case for objects being deleted, as it's very likely + // that the graphics_object already has been destroyed when this + // is executed (because of the async behavior). + case base_properties::ID_BEINGDELETED: + beingDeleted (); + break; + default: + if (object ().valid_object ()) + update (pId); + break; + } +} + +void Object::slotFinalize (void) +{ + gh_manager::auto_lock lock; + + finalize (); +} + +void Object::slotRedraw (void) +{ + gh_manager::auto_lock lock; + + if (object ().valid_object ()) + redraw (); +} + +void Object::update (int /* pId */) +{ +} + +void Object::finalize (void) +{ + if (m_qobject) + { + delete m_qobject; + m_qobject = 0; + } + deleteLater (); +} + +void Object::redraw (void) +{ +} + +void Object::beingDeleted (void) +{ +} + +void Object::objectDestroyed (QObject* obj) +{ + if (obj && obj == m_qobject) + m_qobject = 0; +} + +Object* Object::parentObject (const graphics_object& go) +{ + Object* parent = Backend::toolkitObject + (gh_manager::get_object (go.get_parent ())); + + return parent; +} + +Object* Object::fromQObject (QObject* obj) +{ + QVariant v = obj->property ("QtHandles::Object"); + + if (v.isValid ()) + return reinterpret_cast (qVariantValue (v)); + + return 0; +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Object.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Object.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,103 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Object__ +#define __QtHandles_Object__ 1 + +#include + +#include "graphics.h" + +class QObject; +class QWidget; + +namespace QtHandles +{ + +class Container; +class ObjectProxy; + +class Object : public QObject +{ + Q_OBJECT + +public: + Object (const graphics_object& go, QObject* obj = 0); + + virtual ~Object (void); + + base_properties& properties (void) + { return object ().get_properties (); } + + const base_properties& properties (void) const + { return object ().get_properties (); } + + template + typename T::properties& properties (void) + { + return dynamic_cast + (object ().get_properties ()); + } + + template + const typename T::properties& properties (void) const + { + return dynamic_cast + (object ().get_properties ()); + } + + graphics_object object (void) const; + + virtual QObject* qObject (void) { return m_qobject; } + + template + T* qWidget (void) { return qobject_cast(qObject ()); } + + virtual Container* innerContainer (void) = 0; + + static Object* fromQObject (QObject* obj); + +public slots: + void slotUpdate (int pId); + void slotFinalize (void); + void slotRedraw (void); + + void objectDestroyed (QObject *obj = 0); + +protected: + static Object* parentObject (const graphics_object& go); + void init (QObject* obj, bool callBase = false); + + virtual void update (int pId); + virtual void finalize (void); + virtual void redraw (void); + + virtual void beingDeleted (void); + +protected: + graphics_handle m_handle; + QObject* m_qobject; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ObjectFactory.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ObjectFactory.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,149 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "graphics.h" + +#include "Backend.h" +#include "CheckBoxControl.h" +#include "ContextMenu.h" +#include "EditControl.h" +#include "Figure.h" +#include "ListBoxControl.h" +#include "Logger.h" +#include "Menu.h" +#include "ObjectFactory.h" +#include "ObjectProxy.h" +#include "Panel.h" +#include "PopupMenuControl.h" +#include "PushButtonControl.h" +#include "PushTool.h" +#include "RadioButtonControl.h" +#include "SliderControl.h" +#include "TextControl.h" +#include "ToggleButtonControl.h" +#include "ToggleTool.h" +#include "ToolBar.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +ObjectFactory* ObjectFactory::instance (void) +{ + static ObjectFactory s_instance; + static bool s_instanceCreated = false; + + if (! s_instanceCreated) + { + if (QThread::currentThread () != QApplication::instance ()->thread ()) + s_instance.moveToThread (QApplication::instance ()->thread ()); + s_instanceCreated = true; + } + + return &s_instance; +} + +void ObjectFactory::createObject (double handle) +{ + gh_manager::auto_lock lock; + + graphics_object go (gh_manager::get_object (graphics_handle (handle))); + + if (go.valid_object ()) + { + if (go.get_properties ().is_beingdeleted ()) + qWarning ("ObjectFactory::createObject: object is being deleted"); + else + { + ObjectProxy* proxy = Backend::toolkitObjectProxy (go); + + if (proxy) + { + Logger::debug ("ObjectFactory::createObject: " + "create %s from thread %08x", + go.type ().c_str (), QThread::currentThreadId ()); + + Object* obj = 0; + + if (go.isa ("figure")) + obj = Figure::create (go); + else if (go.isa ("uicontrol")) + { + uicontrol::properties& up = + Utils::properties (go); + + if (up.style_is ("pushbutton")) + obj = PushButtonControl::create (go); + else if (up.style_is ("edit")) + obj = EditControl::create (go); + else if (up.style_is ("checkbox")) + obj = CheckBoxControl::create (go); + else if (up.style_is ("radiobutton")) + obj = RadioButtonControl::create (go); + else if (up.style_is ("togglebutton")) + obj = ToggleButtonControl::create (go); + else if (up.style_is ("text")) + obj = TextControl::create (go); + else if (up.style_is ("popupmenu")) + obj = PopupMenuControl::create (go); + else if (up.style_is ("slider")) + obj = SliderControl::create (go); + else if (up.style_is ("listbox")) + obj = ListBoxControl::create (go); + } + else if (go.isa ("uipanel")) + obj = Panel::create (go); + else if (go.isa ("uimenu")) + obj = Menu::create (go); + else if (go.isa ("uicontextmenu")) + obj = ContextMenu::create (go); + else if (go.isa ("uitoolbar")) + obj = ToolBar::create (go); + else if (go.isa ("uipushtool")) + obj = PushTool::create (go); + else if (go.isa ("uitoggletool")) + obj = ToggleTool::create (go); + else + qWarning ("ObjectFactory::createObject: unsupported type `%s'", + go.type ().c_str ()); + + if (obj) + proxy->setObject (obj); + } + else + qWarning ("ObjectFactory::createObject: no proxy for handle %g", + handle); + } + } + else + qWarning ("ObjectFactory::createObject: invalid object for handle %g", + handle); +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ObjectFactory.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ObjectFactory.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,53 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ObjectFactory__ +#define __QtHandles_ObjectFactory__ 1 + +#include + +class graphics_object; + +namespace QtHandles +{ + +class Object; + +class ObjectFactory : public QObject +{ + Q_OBJECT + +public: + static ObjectFactory* instance (void); + +public slots: + void createObject (double handle); + +private: + ObjectFactory (void) + : QObject () + { } +}; + +}; + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ObjectProxy.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ObjectProxy.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,94 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "oct-mutex.h" + +#include "Object.h" +#include "ObjectProxy.h" + +namespace QtHandles +{ + +ObjectProxy::ObjectProxy (Object* obj) + : QObject (), m_object (0) +{ + init (obj); +} + +void ObjectProxy::init (Object* obj) +{ + if (obj != m_object) + { + if (m_object) + { + disconnect (this, SIGNAL (sendUpdate (int)), + m_object, SLOT (slotUpdate (int))); + disconnect (this, SIGNAL (sendFinalize (void)), + m_object, SLOT (slotFinalize (void))); + disconnect (this, SIGNAL (sendRedraw (void)), + m_object, SLOT (slotRedraw (void))); + } + + m_object = obj; + + if (m_object) + { + connect (this, SIGNAL (sendUpdate (int)), + m_object, SLOT (slotUpdate (int))); + connect (this, SIGNAL (sendFinalize (void)), + m_object, SLOT (slotFinalize (void))); + connect (this, SIGNAL (sendRedraw (void)), + m_object, SLOT (slotRedraw (void))); + } + } +} + +void ObjectProxy::setObject (Object* obj) +{ + emit sendFinalize (); + init (obj); +} + +void ObjectProxy::update (int pId) +{ + if (octave_thread::is_octave_thread ()) + emit sendUpdate (pId); + else + m_object->slotUpdate (pId); +} + +void ObjectProxy::finalize (void) +{ + emit sendFinalize (); + init (0); +} + +void ObjectProxy::redraw (void) +{ + emit sendRedraw (); +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ObjectProxy.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ObjectProxy.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,61 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ObjectProxy__ +#define __QtHandles_ObjectProxy__ 1 + +#include + +namespace QtHandles +{ + +class Object; + +class ObjectProxy : public QObject +{ + Q_OBJECT + +public: + ObjectProxy (Object* obj = 0); + + void update (int pId); + void finalize (void); + void redraw (void); + + Object* object (void) { return m_object; } + void setObject (Object* obj); + +signals: + void sendUpdate (int pId); + void sendFinalize (void); + void sendRedraw (void); + +private: + void init (Object* obj); + +private: + Object* m_object; +}; + +}; + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Panel.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Panel.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,358 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include "Canvas.h" +#include "Container.h" +#include "ContextMenu.h" +#include "Panel.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +static int frameStyleFromProperties (const uipanel::properties& pp) +{ + if (pp.bordertype_is ("none")) + return QFrame::NoFrame; + else if (pp.bordertype_is ("etchedin")) + return (QFrame::Box | QFrame::Sunken); + else if (pp.bordertype_is ("etchedout")) + return (QFrame::Box | QFrame::Raised); + else if (pp.bordertype_is ("beveledin")) + return (QFrame::Panel | QFrame::Sunken); + else if (pp.bordertype_is ("beveledout")) + return (QFrame::Panel | QFrame::Raised); + else + return (QFrame::Panel | QFrame::Plain); +} + +static void setupPalette (const uipanel::properties& pp, QPalette& p) +{ + p.setColor (QPalette::Window, + Utils::fromRgb (pp.get_backgroundcolor_rgb ())); + p.setColor (QPalette::WindowText, + Utils::fromRgb (pp.get_foregroundcolor_rgb ())); + p.setColor (QPalette::Light, + Utils::fromRgb (pp.get_highlightcolor_rgb ())); + p.setColor (QPalette::Dark, + Utils::fromRgb (pp.get_shadowcolor_rgb ())); +} + +static int borderWidthFromProperties (const uipanel::properties& pp) +{ + int bw = 0; + + if (! pp.bordertype_is ("none")) + { + bw = xround (pp.get_borderwidth ()); + if (pp.bordertype_is ("etchedin") || pp.bordertype_is ("etchedout")) + bw *= 2; + } + + return bw; +} + +Panel* Panel::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new Panel (go, new QFrame (container)); + } + + return 0; +} + +Panel::Panel (const graphics_object& go, QFrame* frame) + : Object (go, frame), m_container (0), m_title (0), m_blockUpdates (false) +{ + uipanel::properties& pp = properties (); + + frame->setObjectName ("UIPanel"); + frame->setAutoFillBackground (true); + Matrix bb = pp.get_boundingbox (false); + frame->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + frame->setFrameStyle (frameStyleFromProperties (pp)); + frame->setLineWidth (xround (pp.get_borderwidth ())); + QPalette pal = frame->palette (); + setupPalette (pp, pal); + frame->setPalette (pal); + + m_container = new Container (frame); + m_container->canvas (m_handle); + + if (frame->hasMouseTracking ()) + { + foreach (QWidget* w, frame->findChildren ()) + { w->setMouseTracking (true); } + } + + QString title = Utils::fromStdString (pp.get_title ()); + if (! title.isEmpty ()) + { + m_title = new QLabel (title, frame); + m_title->setAutoFillBackground (true); + m_title->setContentsMargins (4, 0, 4, 0); + m_title->setPalette (pal); + m_title->setFont (Utils::computeFont (pp, bb(3))); + } + + frame->installEventFilter (this); + m_container->installEventFilter (this); + + if (pp.is_visible ()) + QTimer::singleShot (0, frame, SLOT (show (void))); + else + frame->hide (); +} + +Panel::~Panel (void) +{ +} + +bool Panel::eventFilter (QObject* watched, QEvent* ev) +{ + if (! m_blockUpdates) + { + if (watched == qObject ()) + { + switch (ev->type ()) + { + case QEvent::Resize: + { + gh_manager::auto_lock lock; + graphics_object go = object (); + + if (go.valid_object ()) + { + if (m_title) + { + const uipanel::properties& pp = + Utils::properties (go); + + if (pp.fontunits_is ("normalized")) + { + QFrame* frame = qWidget (); + + m_title->setFont (Utils::computeFont + (pp, frame->height ())); + m_title->resize (m_title->sizeHint ()); + } + } + updateLayout (); + } + } + break; + case QEvent::MouseButtonPress: + { + QMouseEvent* m = dynamic_cast (ev); + + if (m->button () == Qt::RightButton) + { + gh_manager::auto_lock lock; + + ContextMenu::executeAt (properties (), m->globalPos ()); + } + } + break; + default: + break; + } + } + else if (watched == m_container) + { + switch (ev->type ()) + { + case QEvent::Resize: + if (qWidget ()->isVisible ()) + { + gh_manager::auto_lock lock; + + properties ().update_boundingbox (); + } + break; + default: + break; + } + } + } + + return false; +} + +void Panel::update (int pId) +{ + uipanel::properties& pp = properties (); + QFrame* frame = qWidget (); + + m_blockUpdates = true; + + switch (pId) + { + case uipanel::properties::ID_POSITION: + { + Matrix bb = pp.get_boundingbox (false); + + frame->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + updateLayout (); + } + break; + case uipanel::properties::ID_BORDERWIDTH: + frame->setLineWidth (xround (pp.get_borderwidth ())); + updateLayout (); + break; + case uipanel::properties::ID_BACKGROUNDCOLOR: + case uipanel::properties::ID_FOREGROUNDCOLOR: + case uipanel::properties::ID_HIGHLIGHTCOLOR: + case uipanel::properties::ID_SHADOWCOLOR: + { + QPalette pal = frame->palette (); + + setupPalette (pp, pal); + frame->setPalette (pal); + if (m_title) + m_title->setPalette (pal); + } + break; + case uipanel::properties::ID_TITLE: + { + QString title = Utils::fromStdString (pp.get_title ()); + + if (title.isEmpty ()) + { + if (m_title) + delete m_title; + m_title = 0; + } + else + { + if (! m_title) + { + QPalette pal = frame->palette (); + + m_title = new QLabel (title, frame); + m_title->setAutoFillBackground (true); + m_title->setContentsMargins (4, 0, 4, 0); + m_title->setPalette (pal); + m_title->setFont (Utils::computeFont (pp)); + m_title->show (); + } + else + { + m_title->setText (title); + m_title->resize (m_title->sizeHint ()); + } + } + updateLayout (); + } + case uipanel::properties::ID_TITLEPOSITION: + updateLayout (); + break; + case uipanel::properties::ID_BORDERTYPE: + frame->setFrameStyle (frameStyleFromProperties (pp)); + updateLayout (); + break; + case uipanel::properties::ID_FONTNAME: + case uipanel::properties::ID_FONTSIZE: + case uipanel::properties::ID_FONTWEIGHT: + case uipanel::properties::ID_FONTANGLE: + if (m_title) + { + m_title->setFont (Utils::computeFont (pp)); + m_title->resize (m_title->sizeHint ()); + updateLayout (); + } + break; + case uipanel::properties::ID_VISIBLE: + frame->setVisible (pp.is_visible ()); + updateLayout (); + break; + default: + break; + } + + m_blockUpdates = false; +} + +void Panel::redraw (void) +{ + Canvas* canvas = m_container->canvas (m_handle); + + if (canvas) + canvas->redraw (); +} + +void Panel::updateLayout (void) +{ + uipanel::properties& pp = properties (); + QFrame* frame = qWidget (); + + Matrix bb = pp.get_boundingbox (true); + int bw = borderWidthFromProperties (pp); + + frame->setFrameRect (QRect (xround (bb(0)) - bw, xround (bb(1)) - bw, + xround (bb(2)) + 2*bw, xround (bb(3)) + 2*bw)); + m_container->setGeometry (xround (bb(0)), xround (bb(1)), + xround (bb(2)), xround (bb(3))); + + if (m_blockUpdates) + pp.update_boundingbox (); + + if (m_title) + { + QSize sz = m_title->sizeHint (); + int offset = 5; + + if (pp.titleposition_is ("lefttop")) + m_title->move (bw+offset, 0); + else if (pp.titleposition_is ("righttop")) + m_title->move (frame->width () - bw - offset - sz.width (), 0); + else if (pp.titleposition_is ("leftbottom")) + m_title->move (bw+offset, frame->height () - sz.height ()); + else if (pp.titleposition_is ("rightbottom")) + m_title->move (frame->width () - bw - offset - sz.width (), + frame->height () - sz.height ()); + else if (pp.titleposition_is ("centertop")) + m_title->move (frame->width () / 2 - sz.width () / 2, 0); + else if (pp.titleposition_is ("centerbottom")) + m_title->move (frame->width () / 2 - sz.width () / 2, + frame->height () - sz.height ()); + } +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/Panel.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/Panel.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,63 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Panel__ +#define __QtHandles_Panel__ 1 + +#include "Object.h" + +class QFrame; +class QLabel; + +namespace QtHandles +{ + +class Container; + +class Panel : public Object +{ +public: + Panel (const graphics_object& go, QFrame* frame); + ~Panel (void); + + Container* innerContainer (void) { return m_container; } + + bool eventFilter (QObject* watched, QEvent* event); + + static Panel* create (const graphics_object& go); + +protected: + void update (int pId); + void redraw (void); + +private: + void updateLayout (void); + +private: + Container* m_container; + QLabel* m_title; + bool m_blockUpdates; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/PopupMenuControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/PopupMenuControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,130 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Container.h" +#include "PopupMenuControl.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +PopupMenuControl* PopupMenuControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new PopupMenuControl (go, new QComboBox (container)); + } + + return 0; +} + +PopupMenuControl::PopupMenuControl (const graphics_object& go, QComboBox *box) + : BaseControl (go, box), m_blockUpdate (false) +{ + uicontrol::properties& up = properties (); + + box->addItems (Utils::fromStdString (up.get_string_string ()).split ('|')); + + connect (box, SIGNAL (currentIndexChanged (int)), + SLOT (currentIndexChanged (int))); +} + +PopupMenuControl::~PopupMenuControl (void) +{ +} + +void PopupMenuControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QComboBox* box = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + m_blockUpdate = true; + { + int oldCurrent = box->currentIndex (); + + box->clear (); + box->addItems (Utils::fromStdString + (up.get_string_string ()).split ('|')); + if (box->count() > 0 + && oldCurrent >= 0 + && oldCurrent < box->count ()) + { + box->setCurrentIndex (oldCurrent); + } + else + { + gh_manager::post_set (m_handle, "value", + octave_value (box->count () > 0 + ? 1.0 : 0.0), + false); + } + } + m_blockUpdate = false; + break; + case uicontrol::properties::ID_VALUE: + { + Matrix value = up.get_value ().matrix_value (); + + if (value.numel () > 0) + { + int newIndex = int (value(0)) - 1; + + if (newIndex >= 0 && newIndex < box->count () + && newIndex != box->currentIndex ()) + { + box->setCurrentIndex (newIndex); + } + } + } + break; + default: + BaseControl::update (pId); + break; + } +} + +void PopupMenuControl::currentIndexChanged (int index) +{ + if (! m_blockUpdate) + { + gh_manager::post_set (m_handle, "value", + octave_value (double (index + 1)), + false); + gh_manager::post_callback (m_handle, "callback"); + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/PopupMenuControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/PopupMenuControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,55 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_PopupMenuControl__ +#define __QtHandles_PopupMenuControl__ 1 + +#include "BaseControl.h" + +class QComboBox; + +namespace QtHandles +{ + +class PopupMenuControl : public BaseControl +{ + Q_OBJECT + +public: + PopupMenuControl (const graphics_object& go, QComboBox* box); + ~PopupMenuControl (void); + + static PopupMenuControl* create (const graphics_object& go); + +protected: + void update (int pId); + +private slots: + void currentIndexChanged (int index); + +private: + bool m_blockUpdate; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/PushButtonControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/PushButtonControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,78 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "PushButtonControl.h" +#include "Container.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +PushButtonControl* PushButtonControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new PushButtonControl (go, new QPushButton (container)); + } + + return 0; +} + +PushButtonControl::PushButtonControl (const graphics_object& go, QPushButton* btn) + : ButtonControl (go, btn) +{ + btn->setAutoFillBackground (true); +} + +PushButtonControl::~PushButtonControl (void) +{ +} + +void PushButtonControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QPushButton* btn = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + btn->setText (Utils::fromStdString (up.get_string_string ())); + break; + default: + BaseControl::update (pId); + break; + } +} + +}; // namespave QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/PushButtonControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/PushButtonControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,47 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_PushButtonControl__ +#define __QtHandles_PushButtonControl__ 1 + +#include "ButtonControl.h" + +class QPushButton; + +namespace QtHandles +{ + +class PushButtonControl : public ButtonControl +{ +public: + PushButtonControl (const graphics_object& go, QPushButton* btn); + ~PushButtonControl (void); + + static PushButtonControl* create (const graphics_object& go); + +protected: + void update (int pId); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/PushTool.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/PushTool.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,74 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "PushTool.h" + +#include "ToolBarButton.cc" + +namespace QtHandles +{ + +PushTool* PushTool::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + QWidget* parentWidget = parent->qWidget (); + + if (parentWidget) + return new PushTool (go, new QAction (parentWidget)); + } + + return 0; +} + +PushTool::PushTool (const graphics_object& go, QAction* action) + : ToolBarButton (go, action) +{ + connect (action, SIGNAL (triggered (bool)), this, SLOT (clicked (void))); +} + +PushTool::~PushTool (void) +{ +} + +void PushTool::update (int pId) +{ + switch (pId) + { + default: + ToolBarButton::update (pId); + break; + } +} + +void PushTool::clicked (void) +{ + gh_manager::post_callback (m_handle, "clickedcallback"); +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/PushTool.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/PushTool.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,50 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_PushTool__ +#define __QtHandles_PushTool__ 1 + +#include "ToolBarButton.h" + +namespace QtHandles +{ + +class PushTool : public ToolBarButton +{ + Q_OBJECT + +public: + PushTool (const graphics_object& go, QAction* action); + ~PushTool (void); + + static PushTool* create (const graphics_object& go); + +protected: + void update (int pId); + +private slots: + void clicked (void); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/QtHandlesUtils.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/QtHandlesUtils.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,324 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include + +#include + +#include "ov.h" +#include "graphics.h" + +#include "Backend.h" +#include "Container.h" +#include "KeyMap.h" +#include "Object.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +namespace Utils +{ + +QString fromStdString (const std::string& s) +{ + return QString::fromLocal8Bit (s.c_str ()); +} + +std::string toStdString (const QString& s) +{ + return std::string (s.toLocal8Bit ().data ()); +} + +QStringList fromStringVector (const string_vector& v) +{ + QStringList l; + octave_idx_type n = v.length (); + + for (octave_idx_type i = 0; i < n; i++) + l << fromStdString (v[i]); + + return l; +} + +string_vector toStringVector (const QStringList& l) +{ + string_vector v (l.length ()); + int i = 0; + + foreach (const QString& s, l) + v[i++] = toStdString (s); + + return v; +} + +template +QFont computeFont (const typename T::properties& props, int height) +{ + QFont f (fromStdString (props.get_fontname ())); + + static std::map weightMap; + static std::map angleMap; + static bool mapsInitialized = false; + + if (! mapsInitialized) + { + weightMap[std::string ("normal")] = QFont::Normal; + weightMap[std::string ("light")] = QFont::Light; + weightMap[std::string ("demi")] = QFont::DemiBold; + weightMap[std::string ("bold")] = QFont::Normal; + + angleMap[std::string ("normal")] = QFont::StyleNormal; + angleMap[std::string ("italic")] = QFont::StyleItalic; + angleMap[std::string ("oblique")] = QFont::StyleOblique; + + mapsInitialized = true; + } + + f.setPointSizeF (props.get_fontsize_points (height)); + f.setWeight (weightMap[props.get_fontweight ()]); + f.setStyle (angleMap[props.get_fontangle ()]); + + return f; +} + +template QFont computeFont (const uicontrol::properties& props, + int height); +template QFont computeFont (const uipanel::properties& props, + int height); + +QColor fromRgb (const Matrix& rgb) +{ + QColor c; + + if (rgb.numel () == 3) + c.setRgbF (rgb(0), rgb(1), rgb(2)); + + return c; +} + +Matrix toRgb (const QColor& c) +{ + Matrix rgb (1, 3); + double* rgbData = rgb.fortran_vec (); + + c.getRgbF (rgbData, rgbData+1, rgbData+2); + + return rgb; +} + +std::string figureSelectionType (QMouseEvent* event, bool isDoubleClick) +{ + if (isDoubleClick) + return std::string ("open"); + else + { + Qt::MouseButtons buttons = event->buttons (); + Qt::KeyboardModifiers mods = event->modifiers (); + + if (mods == Qt::NoModifier) + { + if (buttons == Qt::LeftButton) + return std::string ("normal"); + else if (buttons == Qt::RightButton) + return std::string ("alt"); +#if defined (Q_WS_WIN) + else if (buttons == (Qt::LeftButton|Qt::RightButton)) + return std::string ("extend"); +#elif defined (Q_WS_X11) + else if (buttons == Qt::MidButton) + return std::string ("extend"); +#endif + } + else if (buttons == Qt::LeftButton) + { + if (mods == Qt::ShiftModifier) + return std::string ("extend"); + else if (mods == Qt::ControlModifier) + return std::string ("alt"); + } + } + + return std::string ("normal"); +} + +Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent* event) +{ + Object* tkFig = Backend::toolkitObject (fig); + + if (tkFig) + { + Container* c = tkFig->innerContainer (); + + if (c) + { + QPoint qp = c->mapFromGlobal (event->globalPos ()); + + return + tkFig->properties
().map_from_boundingbox (qp.x (), + qp.y ()); + } + } + + return Matrix (1, 2, 0.0); +} + +Qt::Alignment fromHVAlign (const caseless_str& halign, + const caseless_str& valign) +{ + Qt::Alignment flags; + + if (halign.compare ("left")) + flags |= Qt::AlignLeft; + else if (halign.compare ("center")) + flags |= Qt::AlignHCenter; + else if (halign.compare ("right")) + flags |= Qt::AlignRight; + else + flags |= Qt::AlignLeft; + + if (valign.compare ("middle")) + flags |= Qt::AlignVCenter; + else if (valign.compare ("top")) + flags |= Qt::AlignTop; + else if (valign.compare ("bottom")) + flags |= Qt::AlignBottom; + else + flags |= Qt::AlignVCenter; + + return flags; +} + +QImage makeImageFromCData (const octave_value& v, int width, int height) +{ + dim_vector dv (v.dims ()); + + if (dv.length () == 3 && dv(2) == 3) + { + int w = qMin (dv(1), static_cast (width)); + int h = qMin (dv(0), static_cast (height)); + + int x_off = (w < width ? (width - w) / 2 : 0); + int y_off = (h < height ? (height - h) / 2 : 0); + + QImage img (width, height, QImage::Format_ARGB32); + img.fill (qRgba (0, 0, 0, 0)); + + if (v.is_uint8_type ()) + { + uint8NDArray d = v.uint8_array_value (); + + for (int i = 0; i < w; i++) + for (int j = 0; j < h; j++) + { + int r = d(j, i, 0); + int g = d(j, i, 1); + int b = d(j, i, 2); + int a = 255; + + img.setPixel (x_off + i, y_off + j, qRgba (r, g, b, a)); + } + } + else if (v.is_single_type ()) + { + FloatNDArray f = v.float_array_value (); + + for (int i = 0; i < w; i++) + for (int j = 0; j < h; j++) + { + float r = f(j, i, 0); + float g = f(j, i, 1); + float b = f(j, i, 2); + int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255); + + img.setPixel (x_off + i, y_off + j, + qRgba (xround (r * 255), + xround (g * 255), + xround (b * 255), + a)); + } + } + else if (v.is_real_type ()) + { + NDArray d = v.array_value (); + + for (int i = 0; i < w; i++) + for (int j = 0; j < h; j++) + { + double r = d(j, i, 0); + double g = d(j, i, 1); + double b = d(j, i, 2); + int a = (xisnan (r) || xisnan (g) || xisnan (b) ? 0 : 255); + + img.setPixel (x_off + i, y_off + j, + qRgba (xround (r * 255), + xround (g * 255), + xround (b * 255), + a)); + } + } + + return img; + } + + return QImage (); +} + +octave_scalar_map makeKeyEventStruct (QKeyEvent* event) +{ + octave_scalar_map retval; + + retval.setfield ("Key", KeyMap::qKeyToKeyString (event->key ())); + retval.setfield ("Character", toStdString (event->text ())); + + std::list modList; + Qt::KeyboardModifiers mods = event->modifiers (); + + if (mods & Qt::ShiftModifier) + modList.push_back ("shift"); + if (mods & Qt::ControlModifier) +#ifdef Q_OS_MAC + modList.push_back ("command"); +#else + modList.push_back ("control"); +#endif + if (mods & Qt::AltModifier) + modList.push_back ("alt"); +#ifdef Q_OS_MAC + if (mods & Qt::MetaModifier) + modList.push_back ("control"); +#endif + + retval.setfield ("Modifier", Cell (modList)); + + return retval; +} + +}; // namespace Utils + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/QtHandlesUtils.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/QtHandlesUtils.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,82 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_Utils__ +#define __QtHandles_Utils__ 1 + +#include +#include +#include +#include +#include + +#include + +#include "graphics.h" + +class QKeyEvent; +class QMouseEvent; + +namespace QtHandles +{ + +namespace Utils +{ + QString fromStdString (const std::string& s); + std::string toStdString (const QString& s); + + QStringList fromStringVector (const string_vector& v); + string_vector toStringVector (const QStringList& l); + + template + QFont computeFont (const typename T::properties& props, int height = -1); + + QColor fromRgb (const Matrix& rgb); + Matrix toRgb (const QColor& c); + + Qt::Alignment fromHVAlign (const caseless_str& halign, + const caseless_str& valign); + + std::string figureSelectionType (QMouseEvent* event, + bool isDoubleClick = false); + + Matrix figureCurrentPoint (const graphics_object& fig, QMouseEvent* event); + + template + inline typename T::properties& + properties (graphics_object obj) + { return dynamic_cast (obj.get_properties ()); } + + template + inline typename T::properties& + properties (const graphics_handle& h) + { return Utils::properties (gh_manager::get_object (h)); } + + QImage makeImageFromCData (const octave_value& v, int width = -1, + int height = -1); + + octave_scalar_map makeKeyEventStruct (QKeyEvent* event); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/RadioButtonControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/RadioButtonControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,63 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "RadioButtonControl.h" +#include "Container.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +RadioButtonControl* RadioButtonControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new RadioButtonControl (go, new QRadioButton (container)); + } + + return 0; +} + +RadioButtonControl::RadioButtonControl (const graphics_object& go, + QRadioButton* radio) + : ButtonControl (go, radio) +{ + radio->setAutoFillBackground (true); + radio->setAutoExclusive (false); +} + +RadioButtonControl::~RadioButtonControl (void) +{ +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/RadioButtonControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/RadioButtonControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,44 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_RadioButton__ +#define __QtHandles_RadioButton__ 1 + +#include "ButtonControl.h" + +class QRadioButton; + +namespace QtHandles +{ + +class RadioButtonControl : public ButtonControl +{ +public: + RadioButtonControl (const graphics_object& go, QRadioButton* box); + ~RadioButtonControl (void); + + static RadioButtonControl* create (const graphics_object& go); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/SliderControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/SliderControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,150 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Container.h" +#include "SliderControl.h" +#include "QtHandlesUtils.h" + +#define RANGE_INT_MAX 1000000 + +namespace QtHandles +{ + +SliderControl* SliderControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new SliderControl (go, new QScrollBar (container)); + } + + return 0; +} + +SliderControl::SliderControl (const graphics_object& go, + QAbstractSlider* slider) + : BaseControl (go, slider), m_blockUpdates (false) +{ + uicontrol::properties& up = properties (); + + slider->setTracking (false); + Matrix bb = up.get_boundingbox (); + slider->setOrientation (bb(2) > bb(3) ? Qt::Horizontal : Qt::Vertical); + Matrix steps = up.get_sliderstep ().matrix_value (); + slider->setMinimum (0); + slider->setMaximum (RANGE_INT_MAX); + slider->setSingleStep (xround (steps(0) * RANGE_INT_MAX)); + slider->setPageStep (xround (steps(1) * RANGE_INT_MAX)); + Matrix value = up.get_value ().matrix_value (); + if (value.numel () > 0) + { + double dmin = up.get_min (), dmax = up.get_max (); + + slider->setValue (xround (((value(0) - dmin) / (dmax - dmin)) + * RANGE_INT_MAX)); + } + + connect (slider, SIGNAL (valueChanged (int)), SLOT (valueChanged (int))); +} + +SliderControl::~SliderControl (void) +{ +} + +void SliderControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QScrollBar* slider = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_SLIDERSTEP: + { + Matrix steps = up.get_sliderstep ().matrix_value (); + + slider->setSingleStep (xround (steps(0) * RANGE_INT_MAX)); + slider->setPageStep (xround (steps(1) * RANGE_INT_MAX)); + } + break; + case uicontrol::properties::ID_VALUE: + { + Matrix value = up.get_value ().matrix_value (); + double dmax = up.get_max (), dmin = up.get_min (); + + if (value.numel () > 0) + { + int ival = xround (((value(0) - dmin) / (dmax - dmin)) + * RANGE_INT_MAX); + + m_blockUpdates = true; + slider->setValue (ival); + m_blockUpdates = false; + } + } + break; + default: + BaseControl::update (pId); + break; + } +} + +void SliderControl::valueChanged (int ival) +{ + if (! m_blockUpdates) + { + gh_manager::auto_lock lock; + graphics_object go = object (); + + if (go.valid_object ()) + { + uicontrol::properties& up = Utils::properties (go); + + Matrix value = up.get_value ().matrix_value (); + double dmin = up.get_min (), dmax = up.get_max (); + + int ival_tmp = (value.numel () > 0 ? + xround (((value(0) - dmin) / (dmax - dmin)) + * RANGE_INT_MAX) : + 0); + + if (ival != ival_tmp || value.numel () > 0) + { + double dval = dmin + (ival * (dmax - dmin) / RANGE_INT_MAX); + + gh_manager::post_set (m_handle, "value", octave_value (dval)); + gh_manager::post_callback (m_handle, "callback"); + } + } + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/SliderControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/SliderControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,55 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_SliderControl__ +#define __QtHandles_SliderControl__ 1 + +#include "BaseControl.h" + +class QAbstractSlider; + +namespace QtHandles +{ + +class SliderControl : public BaseControl +{ + Q_OBJECT + +public: + SliderControl (const graphics_object& go, QAbstractSlider* slider); + ~SliderControl (void); + + static SliderControl* create (const graphics_object& go); + +protected: + void update (int pId); + +private slots: + void valueChanged (int ival); + +private: + bool m_blockUpdates; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/TextControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/TextControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,91 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "Container.h" +#include "TextControl.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +TextControl* TextControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new TextControl (go, new QLabel (container)); + } + + return 0; +} + +TextControl::TextControl (const graphics_object& go, QLabel* label) + : BaseControl (go, label) +{ + uicontrol::properties& up = properties (); + + label->setAutoFillBackground (true); + label->setTextFormat (Qt::PlainText); + label->setWordWrap (false); + label->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), + up.get_verticalalignment ())); + // FIXME: support string_vector + label->setText (Utils::fromStdString (up.get_string_string ())); +} + +TextControl::~TextControl (void) +{ +} + +void TextControl::update (int pId) +{ + uicontrol::properties& up = properties (); + QLabel* label = qWidget (); + + switch (pId) + { + case uicontrol::properties::ID_STRING: + // FIXME: support string_vector + label->setText (Utils::fromStdString (up.get_string_string ())); + break; + case uicontrol::properties::ID_HORIZONTALALIGNMENT: + case uicontrol::properties::ID_VERTICALALIGNMENT: + label->setAlignment (Utils::fromHVAlign (up.get_horizontalalignment (), + up.get_verticalalignment ())); + break; + default: + BaseControl::update (pId); + break; + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/TextControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/TextControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,47 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_TextControl__ +#define __QtHandles_TextControl__ 1 + +#include "BaseControl.h" + +class QLabel; + +namespace QtHandles +{ + +class TextControl : public BaseControl +{ +public: + TextControl (const graphics_object& go, QLabel* label); + ~TextControl (void); + + static TextControl* create (const graphics_object& go); + +protected: + void update (int pId); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/TextEdit.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/TextEdit.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,51 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "TextEdit.h" + +namespace QtHandles +{ + +void TextEdit::focusOutEvent (QFocusEvent* ev) +{ + QTextEdit::focusOutEvent (ev); + + emit editingFinished (); +} + +void TextEdit::keyPressEvent (QKeyEvent* ev) +{ + QTextEdit::keyPressEvent (ev); + + if ((ev->key () == Qt::Key_Return + || ev->key () == Qt::Key_Enter) + && ev->modifiers () == Qt::ControlModifier) + emit editingFinished (); +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/TextEdit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/TextEdit.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,49 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_TextEdit__ +#define __QtHandles_TextEdit__ 1 + +#include + +namespace QtHandles +{ + +class TextEdit : public QTextEdit +{ + Q_OBJECT + +public: + TextEdit (QWidget* xparent) : QTextEdit(xparent) { } + ~TextEdit (void) { } + +signals: + void editingFinished (void); + +protected: + void focusOutEvent (QFocusEvent* event); + void keyPressEvent (QKeyEvent* event); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToggleButtonControl.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToggleButtonControl.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,63 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include + +#include "ToggleButtonControl.h" +#include "Container.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +ToggleButtonControl* ToggleButtonControl::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + Container* container = parent->innerContainer (); + + if (container) + return new ToggleButtonControl (go, new QPushButton (container)); + } + + return 0; +} + +ToggleButtonControl::ToggleButtonControl (const graphics_object& go, + QPushButton* btn) + : ButtonControl (go, btn) +{ + btn->setCheckable (true); + btn->setAutoFillBackground (true); +} + +ToggleButtonControl::~ToggleButtonControl (void) +{ +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToggleButtonControl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToggleButtonControl.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,44 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ToggleButtonControl__ +#define __QtHandles_ToggleButtonControl__ 1 + +#include "ButtonControl.h" + +class QPushButton; + +namespace QtHandles +{ + +class ToggleButtonControl : public ButtonControl +{ +public: + ToggleButtonControl (const graphics_object& go, QPushButton* box); + ~ToggleButtonControl (void); + + static ToggleButtonControl* create (const graphics_object& go); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToggleTool.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToggleTool.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,91 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "ToggleTool.h" + +#include "ToolBarButton.cc" + +namespace QtHandles +{ + +ToggleTool* ToggleTool::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + QWidget* parentWidget = parent->qWidget (); + + if (parentWidget) + return new ToggleTool (go, new QAction (parentWidget)); + } + + return 0; +} + +ToggleTool::ToggleTool (const graphics_object& go, QAction* action) + : ToolBarButton (go, action) +{ + uitoggletool::properties& tp = properties (); + + action->setCheckable (true); + action->setChecked (tp.is_state ()); + + connect (action, SIGNAL (toggled (bool)), + this, SLOT (triggered (bool))); +} + +ToggleTool::~ToggleTool (void) +{ +} + +void ToggleTool::update (int pId) +{ + uitoggletool::properties& tp = properties (); + QAction* action = qWidget (); + + switch (pId) + { + case uitoggletool::properties::ID_STATE: + action->setChecked (tp.is_state ()); + break; + default: + ToolBarButton::update (pId); + break; + } +} + +void ToggleTool::triggered (bool checked) +{ + gh_manager::post_set (m_handle, "state", checked, false); + gh_manager::post_callback (m_handle, + checked + ? "oncallback" + : "offcallback"); + gh_manager::post_callback (m_handle, "clickedcallback"); +} + +}; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToggleTool.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToggleTool.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,50 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ToggleTool__ +#define __QtHandles_ToggleTool__ 1 + +#include "ToolBarButton.h" + +namespace QtHandles +{ + +class ToggleTool : public ToolBarButton +{ + Q_OBJECT + +public: + ToggleTool (const graphics_object& go, QAction* action); + ~ToggleTool (void); + + static ToggleTool* create (const graphics_object& go); + +protected: + void update (int pId); + +private slots: + void triggered (bool checked); +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToolBar.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToolBar.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,172 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "Figure.h" +#include "ToolBar.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +static QAction* addEmptyAction (QToolBar* bar) +{ + static QIcon _empty; + + if (_empty.isNull ()) + { + QPixmap pix (16, 16); + + pix.fill (Qt::transparent); + + _empty = QIcon (pix); + } + + QAction* a = bar->addAction (_empty, "Empty Toolbar"); + + a->setEnabled (false); + a->setToolTip (""); + + return a; +} + +ToolBar* ToolBar::create (const graphics_object& go) +{ + Object* parent = Object::parentObject (go); + + if (parent) + { + QWidget* parentWidget = parent->qWidget (); + + if (parentWidget) + return new ToolBar (go, new QToolBar (parentWidget)); + } + + return 0; +} + +ToolBar::ToolBar (const graphics_object& go, QToolBar* bar) + : Object (go, bar), m_empty (0), m_figure (0) +{ + uitoolbar::properties& tp = properties (); + + bar->setFloatable (false); + bar->setMovable (false); + bar->setVisible (tp.is_visible ()); + + m_empty = addEmptyAction (bar); + + m_figure = + dynamic_cast (Object::fromQObject (bar->parentWidget ())); + + if (m_figure) + m_figure->addCustomToolBar (bar, tp.is_visible ()); + + bar->installEventFilter (this); +} + +ToolBar::~ToolBar (void) +{ +} + +void ToolBar::update (int pId) +{ + uitoolbar::properties& tp = properties (); + QToolBar* bar = qWidget (); + + switch (pId) + { + case base_properties::ID_VISIBLE: + if (m_figure) + m_figure->showCustomToolBar (bar, tp.is_visible ()); + break; + default: + Object::update (pId); + break; + } +} + +bool ToolBar::eventFilter (QObject* watched, QEvent* ev) +{ + if (watched == qObject ()) + { + switch (ev->type ()) + { + case QEvent::ActionAdded: + case QEvent::ActionRemoved: + { + QActionEvent* ae = dynamic_cast (ev); + QToolBar* bar = qWidget (); + + if (ae->action () != m_empty) + { + if (ev->type () == QEvent::ActionAdded) + { + if (bar->actions ().size () == 2) + QTimer::singleShot (0, this, SLOT (hideEmpty (void))); + } + else + { + if (bar->actions ().size () == 1) + m_empty->setVisible (true); + } + } + } + break; + default: + break; + } + } + + return false; +} + +void ToolBar::hideEmpty (void) +{ + m_empty->setVisible (false); +} + +void ToolBar::beingDeleted (void) +{ + if (m_figure) + { + QToolBar* bar = qWidget (); + + if (bar) + m_figure->showCustomToolBar (bar, false); + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToolBar.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToolBar.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,64 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ToolBar__ +#define __QtHandles_ToolBar__ 1 + +#include "Object.h" + +class QAction; +class QToolBar; + +namespace QtHandles +{ + +class Figure; + +class ToolBar : public Object +{ + Q_OBJECT + +public: + ToolBar (const graphics_object& go, QToolBar* bar); + ~ToolBar (void); + + static ToolBar* create (const graphics_object& go); + + Container* innerContainer (void) { return 0; } + + bool eventFilter (QObject* watched, QEvent* event); + +protected: + void update (int pId); + void beingDeleted (void); + +private slots: + void hideEmpty (void); + +private: + QAction* m_empty; + Figure* m_figure; +}; + +}; // namespace QtHandles + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToolBarButton.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToolBarButton.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,119 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include + +#include "ToolBarButton.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +template +ToolBarButton::ToolBarButton (const graphics_object& go, QAction* action) + : Object (go, action), m_separator (0) +{ + typename T::properties& tp = properties (); + + action->setToolTip (Utils::fromStdString (tp.get_tooltipstring ())); + action->setVisible (tp.is_visible ()); + QImage img = Utils::makeImageFromCData (tp.get_cdata (), 16, 16); + action->setIcon (QIcon (QPixmap::fromImage (img))); + if (tp.is_separator ()) + { + m_separator = new QAction (action); + m_separator->setSeparator (true); + m_separator->setVisible (tp.is_visible ()); + } + action->setEnabled (tp.is_enable ()); + + QWidget* w = qobject_cast (action->parent ()); + + w->insertAction (w->actions ().back (), action); + if (m_separator) + w->insertAction (action, m_separator); +} + +template +ToolBarButton::~ToolBarButton (void) +{ +} + +template +void ToolBarButton::update (int pId) +{ + typename T::properties& tp = properties (); + QAction* action = qWidget (); + + switch (pId) + { + case base_properties::ID_VISIBLE: + action->setVisible (tp.is_visible ()); + if (m_separator) + m_separator->setVisible (tp.is_visible ()); + break; + case T::properties::ID_TOOLTIPSTRING: + action->setToolTip (Utils::fromStdString (tp.get_tooltipstring ())); + break; + case T::properties::ID_CDATA: + { + QImage img = Utils::makeImageFromCData (tp.get_cdata (), 16, 16); + + action->setIcon (QIcon (QPixmap::fromImage (img))); + } + break; + case T::properties::ID_SEPARATOR: + if (tp.is_separator ()) + { + if (! m_separator) + { + m_separator = new QAction (action); + m_separator->setSeparator (true); + m_separator->setVisible (tp.is_visible ()); + + QWidget* w = qobject_cast (action->parent ()); + + w->insertAction (action, m_separator); + } + } + else + { + if (m_separator) + delete m_separator; + m_separator = 0; + } + break; + case T::properties::ID_ENABLE: + action->setEnabled (tp.is_enable ()); + break; + default: + Object::update (pId); + break; + } +} + +}; // namespace QtHandles diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/ToolBarButton.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/ToolBarButton.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,53 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_ToolBarButton__ +#define __QtHandles_ToolBarButton__ 1 + +#include "Object.h" + +class QAction; + +namespace QtHandles +{ + +class Container; + +template +class ToolBarButton : public Object +{ +public: + ToolBarButton (const graphics_object& go, QAction* action); + ~ToolBarButton (void); + + Container* innerContainer (void) { return 0; } + +protected: + void update (int pId); + +private: + QAction* m_separator; +}; + +}; + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/__init_qt__.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/__init_qt__.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,332 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include + +#include "graphics.h" +#include "toplev.h" +#include "defun.h" + +#include "Backend.h" +#include "QtHandlesUtils.h" + +namespace QtHandles +{ + +static bool qtHandlesInitialized = false; + +bool __init__ (void) +{ + if (! qtHandlesInitialized) + { + if (qApp) + { + qRegisterMetaType ("graphics_object"); + + gh_manager::enable_event_processing (true); + + graphics_toolkit tk (new Backend ()); + gtk_manager::load_toolkit (tk); + + octave_add_atexit_function ("__shutdown_qt__"); + + // Change some default settings to use Qt default colors + QPalette p; + graphics_object root = gh_manager::get_object (0); + + /* + root.set ("defaultfigurecolor", + octave_value (Utils::toRgb (p.color (QPalette::Window)))); + */ + root.set ("defaultuicontrolbackgroundcolor", + octave_value (Utils::toRgb (p.color (QPalette::Window)))); + root.set ("defaultuicontrolforegroundcolor", + octave_value (Utils::toRgb + (p.color (QPalette::WindowText)))); + root.set ("defaultuipanelbackgroundcolor", + octave_value (Utils::toRgb (p.color (QPalette::Window)))); + root.set ("defaultuipanelforegroundcolor", + octave_value (Utils::toRgb + (p.color (QPalette::WindowText)))); + root.set ("defaultuipanelhighlightcolor", + octave_value (Utils::toRgb (p.color (QPalette::Light)))); + root.set ("defaultuipanelshadowcolor", + octave_value (Utils::toRgb (p.color (QPalette::Dark)))); + + qtHandlesInitialized = true; + + return true; + } + else + error ("__init_qt__: QApplication object must exist."); + } + + return false; +} + +bool __shutdown__ (void) +{ + if (qtHandlesInitialized) + { + octave_add_atexit_function ("__shutdown_qt__"); + + gtk_manager::unload_toolkit ("qt"); + + gh_manager::enable_event_processing (false); + + qtHandlesInitialized = false; + + return true; + } + + return false; +} + +}; // namespace QtHandles + +DEFUN (__init_qt__, , , "") +{ + QtHandles::__init__ (); + + return octave_value (); +} + +DEFUN (__shutdown_qt__, , , "") +{ + QtHandles::__shutdown__ (); + + return octave_value (); +} + +void +install___init_qt___functions (void) +{ + install_builtin_function (F__init_qt__, "__init_qt__", + "__init_qt__.cc", ""); + + install_builtin_function (F__shutdown_qt__, "__shutdown_qt__", + "__init_qt__.cc", ""); +} + +#if 0 + +static QStringList makeFilterSpecs (const Cell& filters) +{ + using namespace QtHandles::Utils; + + QStringList filterSpecs; + QRegExp parenRe (" ?\\(.*\\)\\s*$"); + + for (int i = 0; i < filters.rows (); i++) + { + QStringList extList = + fromStdString (filters(i, 0).string_value ()).split (";"); + QString desc = fromStdString (filters(i, 1).string_value ()).trimmed (); + QString specItem; + + if (desc.contains (parenRe)) + { + // We need to strip any existing parenthesis and recreate it. + // In case the format specified in the () section is not correct, + // the filters won't work as expected. + desc.remove (parenRe); + } + + specItem = QString ("%1 (%2)").arg (desc).arg (extList.join (" ")); + + filterSpecs.append (specItem); + } + + return filterSpecs; +} + +static QString appendDirSep (const QString& d) +{ + if (! d.endsWith ("/") && ! d.endsWith (QDir::separator ())) + return (d + "/"); + return d; +} + +DEFUN (__uigetfile_qt__, args, , "") +{ + using namespace QtHandles::Utils; + + // Expected arguments: + // args(0) : File filter as a cell array {ext1, name1; ext2, name2; ...} + // args(1) : Dialog title + // args(2) : Default file name + // args(3) : Dialog position [ignored] + // args(4) : Multiselection "on"/"off" + // args(5) : Default directory + + octave_value_list retval (3); + + QString caption = fromStdString (args(1).string_value ()); + QString defaultDirectory = fromStdString (args(5).string_value ()); + QString defaultFileName = fromStdString (args(2).string_value ()); + bool isMultiSelect = (args(4).string_value () == "on"); + + if (isMultiSelect) + retval(0) = Cell (); + else + retval(0) = ""; + retval(1) = ""; + retval(2) = static_cast (0); + + if (defaultFileName.isEmpty ()) + defaultFileName = defaultDirectory; + else + defaultFileName = defaultDirectory + "/" + defaultFileName; + + QStringList filterSpecs = makeFilterSpecs (args(0).cell_value ()); + + if (isMultiSelect) + { + QString filter; + QStringList files = + QFileDialog::getOpenFileNames (0, caption, defaultFileName, + filterSpecs.join (";;"), &filter, 0); + + if (! files.isEmpty ()) + { + Cell cFiles (1, files.length ()); + QString dirName; + int i = 0; + + foreach (const QString& s, files) + { + QFileInfo fi (s); + + if (dirName.isEmpty ()) + dirName = appendDirSep (fi.canonicalPath ()); + cFiles(i++) = toStdString (fi.fileName ()); + } + + retval(0) = cFiles; + retval(1) = toStdString (dirName); + if (! filter.isEmpty ()) + retval(2) = static_cast (filterSpecs.indexOf (filter) + 1); + } + } + else + { + QString filter; + QString fileName = + QFileDialog::getOpenFileName (0, caption, defaultFileName, + filterSpecs.join (";;"), &filter, 0); + + if (! fileName.isNull ()) + { + QFileInfo fi (fileName); + + retval(0) = toStdString (fi.fileName ()); + retval(1) = toStdString (appendDirSep (fi.canonicalPath ())); + if (! filter.isEmpty ()) + retval(2) = static_cast (filterSpecs.indexOf (filter) + 1); + } + } + + return retval; +} + +DEFUN (__uiputfile_qt__, args, , "") +{ + using namespace QtHandles::Utils; + + // Expected arguments: + // args(0) : File filter as a cell array {ext1, name1; ext2, name2; ...} + // args(1) : Dialog title + // args(2) : Default file name + // args(3) : Dialog position [ignored] + // args(4) : Tag [ignored] + // args(5) : Default directory + + octave_value_list retval (3); + + QString caption = fromStdString (args(1).string_value ()); + QString defaultDirectory = fromStdString (args(5).string_value ()); + QString defaultFileName = fromStdString (args(2).string_value ()); + + retval(0) = ""; + retval(1) = ""; + retval(2) = static_cast (0); + + if (defaultFileName.isEmpty ()) + defaultFileName = defaultDirectory; + else + defaultFileName = defaultDirectory + "/" + defaultFileName; + + QStringList filterSpecs = makeFilterSpecs (args(0).cell_value ()); + + QString filter; + QString fileName = + QFileDialog::getSaveFileName (0, caption, defaultFileName, + filterSpecs.join (";;"), &filter, 0); + + if (! fileName.isNull ()) + { + QFileInfo fi (fileName); + + retval(0) = toStdString (fi.fileName ()); + if (fi.exists ()) + retval(1) = toStdString (appendDirSep (fi.canonicalPath ())); + else + retval(1) = toStdString (appendDirSep (fi.absolutePath ())); + if (! filter.isEmpty ()) + retval(2) = static_cast (filterSpecs.indexOf (filter) + 1); + } + + return retval; +} + +DEFUN (__uigetdir_qt__, args, , "") +{ + using namespace QtHandles::Utils; + + // Expected arguments: + // args(0) : Start directory + // args(1) : Dialog title + + octave_value retval (""); + + QString caption = fromStdString (args(1).string_value ()); + QString defaultDirectory = fromStdString (args(0).string_value ()); + + QString dirName = QFileDialog::getExistingDirectory (0, caption, + defaultDirectory); + + if (! dirName.isNull ()) + retval = toStdString (dirName); + + return retval; +} + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/__init_qt__.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/__init_qt__.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,35 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_init_qt__ +#define __QtHandles_init_qt__ 1 + +namespace QtHandles +{ + +bool __init__ (void); + +}; // namespace QtHandles + +extern void install___init_qt___functions (void); + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/gl-select.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/gl-select.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,203 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include "gl-select.h" + +#include + +void +opengl_selector::apply_pick_matrix (void) +{ + GLdouble p_matrix[16]; + GLint viewport[4]; + + glGetDoublev (GL_PROJECTION_MATRIX, p_matrix); + glGetIntegerv (GL_VIEWPORT, viewport); + glMatrixMode (GL_PROJECTION); + glLoadIdentity (); + gluPickMatrix (xp, yp, size, size, viewport); + glMultMatrixd (p_matrix); + glMatrixMode (GL_MODELVIEW); +} + +void +opengl_selector::setup_opengl_transformation (const axes::properties& props) +{ + opengl_renderer::setup_opengl_transformation (props); + apply_pick_matrix (); +} + +void +opengl_selector::init_marker (const std::string& m, double sz, float width) +{ + opengl_renderer::init_marker (m, sz, width); + apply_pick_matrix (); +} + +# define BUFFER_SIZE 128 + +graphics_object +opengl_selector::select (const graphics_object& ax, int x, int y, int flags) +{ + glEnable (GL_DEPTH_TEST); + glDepthFunc (GL_LEQUAL); + + xp = x; + yp = y; + + GLuint select_buffer[BUFFER_SIZE]; + + glSelectBuffer (BUFFER_SIZE, select_buffer); + glRenderMode (GL_SELECT); + glInitNames (); + + object_map.clear (); + + draw (ax); + + int hits = glRenderMode (GL_RENDER); + graphics_object obj; + + if (hits > 0) + { + GLuint current_minZ = 0xffffffff; + GLuint current_name = 0xffffffff; + + for (int i = 0, j = 0; i < hits && j < BUFFER_SIZE-3; i++) + { + GLuint n = select_buffer[j++], + minZ = select_buffer[j++]; + + j++; // skip maxZ + if (((flags & select_last) == 0 && (minZ <= current_minZ)) || + ((flags & select_last) != 0 && (minZ >= current_minZ))) + { + bool candidate = true; + GLuint name = + select_buffer[std::min (j + n, GLuint (BUFFER_SIZE)) - 1]; + + if ((flags & select_ignore_hittest) == 0) + { + graphics_object go = object_map[name]; + + if (! go.get_properties ().is_hittest ()) + candidate = false; + } + + if (candidate) + { + current_minZ = minZ; + current_name = name; + } + + j += n; + } + else + j += n; + } + + if (current_name != 0xffffffff) + obj = object_map[current_name]; + } + else if (hits < 0) + warning ("opengl_selector::select: selection buffer overflow"); + + object_map.clear (); + + return obj; +} + +void +opengl_selector::draw (const graphics_object& go, bool toplevel) +{ + GLuint name = object_map.size (); + + object_map[name] = go; + glPushName (name); + opengl_renderer::draw (go, toplevel); + glPopName (); +} + +void +opengl_selector::fake_text (double x, double y, double z, const Matrix& bbox, + bool use_scale) +{ + ColumnVector xpos, xp1, xp2; + + xpos = get_transform ().transform (x, y, z, use_scale); + + xp1 = xp2 = xpos; + xp1(0) += bbox(0); + xp1(1) -= bbox(1); + xp2(0) += (bbox(0) + bbox(2)); + xp2(1) -= (bbox(1) + bbox(3)); + + ColumnVector p1, p2, p3, p4; + + p1 = get_transform ().untransform (xp1(0), xp1(1), xp1(2), false); + p2 = get_transform ().untransform (xp2(0), xp1(1), xp1(2), false); + p3 = get_transform ().untransform (xp2(0), xp2(1), xp1(2), false); + p4 = get_transform ().untransform (xp1(0), xp2(1), xp1(2), false); + + glBegin (GL_QUADS); + glVertex3dv (p1.data ()); + glVertex3dv (p2.data ()); + glVertex3dv (p3.data ()); + glVertex3dv (p4.data ()); + glEnd (); +} + +void +opengl_selector::draw_text (const text::properties& props) +{ + if (props.get_string ().is_empty ()) + return; + + Matrix pos = props.get_data_position (); + const Matrix bbox = props.get_extent_matrix (); + + fake_text (pos(0), pos(1), pos.numel () > 2 ? pos(2) : 0.0, bbox); +} + +Matrix +opengl_selector::render_text (const std::string& txt, + double x, double y, double z, + int halign, int valign, double rotation) +{ +#if HAVE_FREETYPE + uint8NDArray pixels; + Matrix bbox; + + // FIXME: probably more efficient to only compute bbox instead + // of doing full text rendering... + text_to_pixels (txt, pixels, bbox, halign, valign, rotation); + fake_text (x, y, z, bbox, false); + + return bbox; +#else + return Matrix (1, 4, 0.0); +#endif +} diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/gl-select.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/gl-select.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,76 @@ +/* + +Copyright (C) 2011-2014 Michael Goffioul + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef __QtHandles_gl_selector__ +#define __QtHandles_gl_selector__ 1 + +#include "gl-render.h" + +#include + +enum select_flags +{ + select_ignore_hittest = 0x01, + select_last = 0x02 +}; + +class opengl_selector : public opengl_renderer +{ +public: + opengl_selector (void) : size (5) { } + + virtual ~opengl_selector (void) { } + + graphics_object select (const graphics_object& ax, int x, int y, + int flags = 0); + + virtual void draw (const graphics_object& go, bool toplevel = true); + +protected: + virtual void draw_text (const text::properties& props); + + virtual void setup_opengl_transformation (const axes::properties& props); + + virtual void init_marker (const std::string& m, double size, float width); + + virtual Matrix render_text (const std::string& txt, + double x, double y, double z, + int halign, int valign, double rotation = 0.0); + +private: + void apply_pick_matrix (void); + + void fake_text (double x, double y, double z, const Matrix& bbox, + bool use_scale = true); + +private: + // The mouse coordinate of the selection/picking point + int xp, yp; + + // The size (in pixels) of the picking window + int size; + + // The OpenGL name mapping + std::map object_map; +}; + +#endif // __QtHandles_gl_selector__ diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/images/README --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/images/README Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,10 @@ +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +This copyright and license notice covers the images in this directory. +************************************************************************ + +TITLE: Crystal Project Icons +AUTHOR: Everaldo Coelho +SITE: http://www.everaldo.com +CONTACT: everaldo@everaldo.com + +Copyright (c) 2006-2007 Everaldo Coelho. diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/images/pan.png Binary file libgui/graphics/images/pan.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/images/rotate.png Binary file libgui/graphics/images/rotate.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/images/select.png Binary file libgui/graphics/images/select.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/images/zoom.png Binary file libgui/graphics/images/zoom.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/module.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/module.mk Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,137 @@ +EXTRA_DIST += \ + graphics/module.mk \ + graphics/qthandles.qrc \ + graphics/images/README \ + graphics/images/pan.png \ + graphics/images/rotate.png \ + graphics/images/select.png \ + graphics/images/zoom.png + +octave_gui_MOC += \ + graphics/moc-Backend.cc \ + graphics/moc-ButtonControl.cc \ + graphics/moc-ContextMenu.cc \ + graphics/moc-EditControl.cc \ + graphics/moc-Figure.cc \ + graphics/moc-FigureWindow.cc \ + graphics/moc-ListBoxControl.cc \ + graphics/moc-Menu.cc \ + graphics/moc-MouseModeActionGroup.cc \ + graphics/moc-Object.cc \ + graphics/moc-ObjectFactory.cc \ + graphics/moc-ObjectProxy.cc \ + graphics/moc-PopupMenuControl.cc \ + graphics/moc-PushTool.cc \ + graphics/moc-SliderControl.cc \ + graphics/moc-TextEdit.cc \ + graphics/moc-ToggleTool.cc \ + graphics/moc-ToolBar.cc + +octave_gui_graphics_RC = graphics/qrc-qthandles.cc + +noinst_HEADERS += \ + graphics/__init_qt__.h \ + graphics/Backend.h \ + graphics/BaseControl.h \ + graphics/ButtonControl.h \ + graphics/Canvas.h \ + graphics/CheckBoxControl.h \ + graphics/Container.h \ + graphics/ContextMenu.h \ + graphics/EditControl.h \ + graphics/Figure.h \ + graphics/FigureWindow.h \ + graphics/GenericEventNotify.h \ + graphics/GLCanvas.h \ + graphics/KeyMap.h \ + graphics/ListBoxControl.h \ + graphics/Logger.h \ + graphics/Menu.h \ + graphics/MenuContainer.h \ + graphics/MouseModeActionGroup.h \ + graphics/Object.h \ + graphics/ObjectFactory.h \ + graphics/ObjectProxy.h \ + graphics/Panel.h \ + graphics/PopupMenuControl.h \ + graphics/PushButtonControl.h \ + graphics/PushTool.h \ + graphics/QtHandlesUtils.h \ + graphics/RadioButtonControl.h \ + graphics/SliderControl.h \ + graphics/TextControl.h \ + graphics/TextEdit.h \ + graphics/ToggleButtonControl.h \ + graphics/ToggleTool.h \ + graphics/ToolBar.h \ + graphics/ToolBarButton.h \ + graphics/gl-select.h \ + $(TEMPLATE_SRC) + +graphics_libgui_graphics_la_SOURCES = \ + graphics/__init_qt__.cc \ + graphics/Backend.cc \ + graphics/BaseControl.cc \ + graphics/ButtonControl.cc \ + graphics/Canvas.cc \ + graphics/CheckBoxControl.cc \ + graphics/Container.cc \ + graphics/ContextMenu.cc \ + graphics/EditControl.cc \ + graphics/Figure.cc \ + graphics/FigureWindow.cc \ + graphics/GLCanvas.cc \ + graphics/KeyMap.cc \ + graphics/ListBoxControl.cc \ + graphics/Logger.cc \ + graphics/Menu.cc \ + graphics/MouseModeActionGroup.cc \ + graphics/Object.cc \ + graphics/ObjectFactory.cc \ + graphics/ObjectProxy.cc \ + graphics/Panel.cc \ + graphics/PopupMenuControl.cc \ + graphics/PushButtonControl.cc \ + graphics/PushTool.cc \ + graphics/QtHandlesUtils.cc \ + graphics/RadioButtonControl.cc \ + graphics/SliderControl.cc \ + graphics/TextControl.cc \ + graphics/TextEdit.cc \ + graphics/ToggleButtonControl.cc \ + graphics/ToggleTool.cc \ + graphics/ToolBar.cc \ + graphics/gl-select.cc + +TEMPLATE_SRC = \ + graphics/ToolBarButton.cc + +nodist_graphics_libgui_graphics_la_SOURCES = $(octave_gui_graphics_MOC) $(octave_gui_graphics_RC) + +graphics_libgui_graphics_la_CPPFLAGS = \ + $(AM_CPPFLAGS) \ + $(FT2_CFLAGS) \ + $(FONTCONFIG_CPPFLAGS) \ + @OCTGUI_DLL_DEFS@ \ + @QT_CPPFLAGS@ \ + -Igraphics -I$(srcdir)/graphics \ + -I$(top_srcdir)/liboctave/cruft/misc \ + -I$(top_srcdir)/liboctave/array \ + -I$(top_builddir)/liboctave/numeric -I$(top_srcdir)/liboctave/numeric \ + -I$(top_builddir)/liboctave/operators -I$(top_srcdir)/liboctave/operators \ + -I$(top_srcdir)/liboctave/system \ + -I$(top_srcdir)/liboctave/util \ + -I$(top_builddir)/libinterp -I$(top_srcdir)/libinterp \ + -I$(top_builddir)/libinterp/parse-tree -I$(top_srcdir)/libinterp/parse-tree \ + -I$(top_builddir)/libinterp/corefcn -I$(top_srcdir)/libinterp/corefcn \ + -I$(top_srcdir)/libinterp/octave-value + +graphics_libgui_graphics_la_CFLAGS = $(AM_CFLAGS) $(WARN_CFLAGS) + +graphics_libgui_graphics_la_CXXFLAGS = $(AM_CXXFLAGS) $(WARN_CXXFLAGS) + +noinst_LTLIBRARIES += graphics/libgui-graphics.la + +CLEANFILES += \ + $(octave_gui_graphics_MOC) \ + $(octave_gui_graphics_RC) diff -r 75a671fcdd73 -r 844448ae53f3 libgui/graphics/qthandles.qrc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/graphics/qthandles.qrc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,8 @@ + + + images/pan.png + images/rotate.png + images/select.png + images/zoom.png + + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/be_BY.ts --- a/libgui/languages/be_BY.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/be_BY.ts Fri Jan 23 15:23:09 2015 -0500 @@ -475,7 +475,7 @@ курсор - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> <p><strong>Нататка пра новы GUI Octave</strong></p><p>Адна з найбольшых адметнасцяў Octave 3.8 - графічны інтэрфэйс. Карыстальнікі апошнімі гадамі прасілі яго найбольш часта, і нарэшце ён амаль гатовы. Але ён пакуль не такі дасканалы, як бы мы жадалі, таму мы вырашылі пачакаць выпуску з серыі 4.0.x перад тым, як рабіць яго стандартным.</p><p>Да таго ж, улічваючы час і колькасць выпраўленняў і паляпшэнняў у параўнанні з апошнім буйным выпускам Octave, мы вырашылі затрымліваць новы выпуск толькі дзеля ўдасканалення GUI, не зважаючы на новыя магчымасці. Таму прыемнага вам карстання выпускам 3.8 і першай версіяй новага інтэрфэйсу. Нам здаецца, ён працуе даволі добра, але мы ведаем, што ёсць некаторыя відавочныя грубыя недарэчнасці і шмат чаго, што можна палепшыць.</p><p><strong>Нам патрабуецца ваша дапамога</strong></p><p>Ёсць шмат спосабаў, якімі вы можаце дапамагчы нам выправіць праблемы, што яшчэ засталіся, скончыць GUI і палепшыць агульнае уражанне як для новых карыстальнікаў, так і для экспертаў (спасылкі адкрыюцца ў знешнім браўзэры):</p><p><ul><li>Калі вы спрактыкаваны распрацоўнік праграм, то можаце выдаткаваць час, каб дапамагчы ў <a href="http://octave.org/get-involved.html">распрацоўцы Octave</a>.</li><li>Калі Octave працуе з памылкамі, вы можаце <a href="http://octave.org/bugs.html">паведаміць пра праблемы</a>, з якімі сутыкнуліся.</li><li>Няхай вы хоць карыстальнік, хоць распрацоўнік, вы можаце <a href="http://octave.org/donate.html">прафундаваць праект</a>. Распрацоўка Octave патрабуе шмат часу і навыкаў. Ваш удзел дапаможа гарантаваць, што Octave і надалей будзе ўдасканальвацца.</li></ul></p><p>Спадзяемся, вы знойдзеце Octave карыснай. Калі ласка, дапамажыце нам зрабіць яго лепшым для будучыні!</p> @@ -963,7 +963,7 @@ QWinTerminalImpl - + copied selection to clipboard вылучэнне скапіявана ў буфер абмену @@ -1684,17 +1684,12 @@ ужо адкрыты ў рэдактары - + &%1 %2 &%1 %2 - - &New File - &Новы файл - - - + &Save File &Захаваць файл @@ -1704,7 +1699,12 @@ &Адкрыць файл... - + + &New Script + + + + Save File &As... Захаваць файл &як... @@ -1790,6 +1790,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Знайсці і замяніць... @@ -1804,7 +1814,7 @@ П&ерайсці да радка... - + &Recent Editor Files &Ранейшыя файлы @@ -1829,7 +1839,7 @@ Закрыць іншыя файлы - + &Preferences... &Настаўленні... @@ -1859,7 +1869,7 @@ &Дакументацыя па ключавым слове - + Could not open file %1 for read: %2. @@ -1891,7 +1901,7 @@ Асацыяваная картка рэдактара знікла. - + &File &Файл @@ -1906,7 +1916,7 @@ &Змяніць - + &Debug &Адладка @@ -1919,7 +1929,7 @@ file_editor_tab - + Goto line Перайсці да радка @@ -1929,7 +1939,7 @@ Нумар радка - + <unnamed> <без назвы> @@ -1946,14 +1956,15 @@ - - + + + Octave Editor Рэдактар Octave - + The file %1 is about to be closed but has been modified. @@ -1964,12 +1975,12 @@ %2 - + Octave Files (*.m);;All Files (*) Файлы Octave (*.m);;Усе файлы (*) - + Warning: The contents in the editor is modified! @@ -1987,14 +1998,14 @@ быў выдалены або пераназваны. Можа, захаваць яго зараз?%2 - + Could not open file %1 for write: %2. Не выйшла адкрыць файл %1 на запіс: %2. - + Line: Радок: @@ -2004,7 +2015,18 @@ Слупок: - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Выглядае на тое, што '%1' быў зменены іншай праграмай. Перачытаць яго? @@ -2037,7 +2059,12 @@ Дзеянні з дзейным каталогам - + + Set Browser Directory... + + + + Find Files... Шукаць файлы... @@ -2048,16 +2075,17 @@ + New Directory Новы каталог - + Double-click a file to open it Двойчы пстрыкніце па файле для адкрыцця - + Show Octave directory Перайсці да каталогу Octave @@ -2082,7 +2110,7 @@ Перайсці да хатняга каталогу - + Search Directory... Шукаць каталог... @@ -2102,7 +2130,7 @@ Новы каталог... - + File size Памер файла @@ -2215,7 +2243,12 @@ - + + New File.txt + + + + Create Directory Стварыць каталог @@ -2294,7 +2327,12 @@ find_dialog - + + Find and Replace + + + + Find &what: Што &шукаць: @@ -2364,7 +2402,7 @@ Шукаць вы&лучанае - + Search from end Шукаць ад канца @@ -2374,7 +2412,7 @@ Шукаць ад пачатку - + Replace Result Вынік замены @@ -2384,7 +2422,7 @@ %1 элементаў заменена - + Find Result Вынік пошуку @@ -2407,12 +2445,7 @@ Маска назваў: - - Enter the filename expression - Задайце выраз для назваў файлаў - - - + Start in: Пачынаць з: @@ -2432,22 +2465,12 @@ Пазначыць каталог пачатку пошуку - - Recurse directories - Рэкурсіўна - - - + Search recursively through directories for matching files Шукаць ува ўсіх падкаталогах - - Include directories - Знаходзіць каталогі - - - + Include matching directories in search results Дадаваць пасавальныя каталогі ў вынікі пошуку @@ -2467,9 +2490,24 @@ Змяшчае тэкст: - - Search must match text - Улічваць файлы, што ўтрымліваюць пэўны тэкст + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -2532,7 +2570,12 @@ Ідзе пошук... - + + %1 match(es) + + + + Set search directory Пазначыць каталог пошуку @@ -2622,13 +2665,13 @@ main_window - + Load Workspace Загрузіць прастору зменных - - + + About Octave Пра Octave @@ -2643,12 +2686,7 @@ Новы - - Script - Новы сцэнар - - - + Figure Графік @@ -2688,12 +2726,23 @@ Уставіць - + Save Workspace As Захаваць прастору зменных як - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. Файл заўваг да выпуску '%1' пусты. @@ -2713,7 +2762,7 @@ Навіны супольнасці Octave - + Clear Clipboard Ачысціць буфер @@ -2778,7 +2827,12 @@ Крок наперад - + + Octave + + + + Load Workspace... Загрузіць прастору зменных... @@ -2788,7 +2842,12 @@ Захаваць прастору зменных як... - + + New Script + + + + Function... Функцыя... @@ -2879,8 +2938,8 @@ Перайсці каталогам вышэй - - + + Browse directories Агляд каталогаў @@ -2954,7 +3013,7 @@ news_reader - + <html> <body> <p> @@ -3013,18 +3072,18 @@ octave_dock_widget - - + + Undock widget Адчапіць віджэт - + Hide widget Схаваць віджэт - + Dock widget Прычапіць віджэт @@ -3055,7 +3114,7 @@ octave_qt_link - + Yes @@ -3082,13 +3141,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - Файл %1 не існуе ў дзейным шляху. Для адладкі функцыі, якую вы рэдагуеце, трэба змяніць каталог на %2 або дадаць яго да дзейнага шляху. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - Файлу %1 замінае файл з такой самай назвай у дзейным шляху. Для адладкі функцыі, якую вы рэдагуеце, змяніце каталог на %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -3139,17 +3198,17 @@ settings_dialog - + Settings Настаўленні - + General Агульныя - + Octave logo only Толькі эмблема Octave @@ -3160,17 +3219,37 @@ Літарныя значкі - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Рэдактар - + Color Колер - + Indent width Даўжыня водступу @@ -3180,7 +3259,7 @@ Табуляцыя робіць водступ - + Auto indentation Аўтаводступы @@ -3227,67 +3306,114 @@ Памятаць карткі папярэдняга сеансу - + Use custom file editor Свой файлавы рэдактар - + + emacs +%l %f + + + + Editor Styles Выгляд рэдактара - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Пазначце шрыфт, ягоны памер (як розніцу ад стандартнага памеру), стыль шрыфту (<b>т</b>оўсты, <b>к</b>урсіўны, <b>п</b>адкрэслены), колер тэксту і колер фону (для фону ружовы (255,0,255) азначае стандартны колер фону).</p></body></html> - + Terminal Colors Колеры тэрміналу - + Font Шрыфт - + Show line numbers Паказваць нумары радкоў - + Highlight current line Фарбаваць дзейны радок - + Code completion Аўтадапаўненне - + Show complete path in window title Паказваць поўны шлях у загалоўку акна - + + Interface + + + + Graphic icons Графічныя значкі - + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + Show whitespace Паказваць прагальныя знакі - + Do not show whitespace used for indentation Не паказваць прагальныя знакі ў водступах - + + Tab width min. + + + + + max. + + + + # of characters typed before completion list displayed Пасля ўводу колькі знакаў прапаноўваць дапаўненні @@ -3297,87 +3423,102 @@ Ствараць няісныя файлы без пытанняў - + command line (%f=file, %l=line): Загад (%f=файл, %l-радок): - - emacs - emacs - - - - Terminal - Тэрмінал - - - - Cursor type: - Тып курсора: - - - - Cursor blinking - Мігценне курсора - - - - Use foreground color - Выкар. колер пярэдняга плану - - + Terminal + Тэрмінал + + + + Cursor type: + Тып курсора: + + + + Cursor blinking + Мігценне курсора + + + + Use foreground color + Выкар. колер пярэдняга плану + + + Font size Памер шрыфту - + + Set focus to terminal when running a command from within another widget + + + + File Browser Файлавы агляднік - + Show file size Паказваць памеры файлаў - + Show file type Паказваць тыпы файлаў - - Show date of last modification - Паказваць дату апошняга змянення - - - - Show hidden files - Паказваць схаваныя файлы - - - - Alternating row colors - Колеры радкоў чаргуюцца - - + Show date of last modification + Паказваць дату апошняга змянення + + + + Show hidden files + Паказваць схаваныя файлы + + + + Display + + + + + Alternating row colors + Колеры радкоў чаргуюцца + + + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Прастора зменных - + Storage Class Colors Колеры класаў памяці - + Network Сетка - + Allow Octave to connect to the Octave web site to display current news and information Дазволіць Octave злучацца з вэб-сайтам Octave для адлюстравання навінаў і свежай інфармацыі @@ -3392,27 +3533,27 @@ HttpProxy - + Icon set for dock widgets Набор значкоў для віджэтаў - + Language (requires restart) Мова (патрэбны перазапуск) - + Icon size Памер значкоў - + Synchronize Octave working directory with file browser Сінхранізаваць дзейны каталог Octave з файлавым агляднікам - + Socks5Proxy Socks5Proxy @@ -3442,9 +3583,9 @@ Пароль: - + - + System setting Сістэмная @@ -3491,6 +3632,16 @@ short form for underlined п + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -3558,7 +3709,7 @@ webinfo - + Type here and press 'Return' to search Для пошуку ўвядзіце тут штосьці і націсніце Enter @@ -3567,6 +3718,16 @@ Global search Глабальны пошук + + + Error + Памылкі + + + + The info file %1 does not exist + + welcome_wizard @@ -3600,8 +3761,8 @@ - Storage Class - Клас памяці + Attribute + @@ -3649,8 +3810,8 @@ - Colors for the storage class: - Колеры для класаў памяці: + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/de_DE.ts --- a/libgui/languages/de_DE.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/de_DE.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ Cursor - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> <p><strong>Einige Hinweise zur neuen Octave GUI</strong></p><p>Eine der größten Neuerungen von Octave 3.8 ist die grafische Benutzerschnittstelle (GUI). Sie ist das, worum die Nutzer in den letzten Jahren am häufigsten gebeten haben, und nun ist sie fast fertig. Aber weil noch der Feinschliff fehlt, haben wir beschlossen, mit der GUI als Standard-Benutzerschnittstelle auf die 4.0.x Veröffentlichungen zu warten.</p><p>In Anbetracht der vergangenen Zeit, der Anzahl der behobenen Fehler und den Verbesserungen seit der letzten Veröffentlichung haben wir uns dazu entschieden, die nächste Veröffentlichung nicht weiter zu verzögern, nur um die GUI zu perfektionieren. Daher wünschen wir viel Spaß mit der Version 3.8 von Octave und der Vorschau auf die neue GUI. Wir sind der Meinung, dass sie schon ziemlich gut funktioniert, obwohl uns bewusst ist, dass es noch einige Ecken und Kanten sowie viele Dinge zu verbessern gibt.</p><p><strong>Deshalb brauchen wir Deine Mithilfe!</strong></p><p>Es gibt viele Möglichkeiten uns zu helfen die verbleibenden Probleme zu beheben, die GUI weiter zu entwickeln und die Benutzererfahrung für Neulinge und Experten gleichermaßen zu verbessern (Links öffnen im externen Browser):</p><p><ul><li>Falls Du ein geschickter Software-Entwickler bist, kannst du helfen, indem du dich an der <a href="http://octave.org/get-involved.html">Weiterentwicklung von Octave</a> beteiligst.</li><li>Sollte Octave einmal nicht wie erwartet funktionieren, solltest Du das gefundene <a href="http://octave.org/bugs.html">Problem melden</a>.</li><li>Egal, ob Du Anwender oder Entwickler bist, kannst du <a href="http://octave.org/donate.html">helfen, das Projekt zu finanzieren</a>. Die Weiterentwicklung von Octave braucht viel Zeit und Sachverstand. Dein Beitrag hilft sicherzustellen, dass Octave weiter verbessert wird.</li></ul></p><p>Wir hoffen, dass du Octave nützlich findest. Bitte hilf uns Octave zukünftig noch besser zu machen!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard Auswahl in die Zwischenablage kopiert @@ -144,17 +144,12 @@ ist im Editor bereits geöffnet - + &%1 %2 &%1 %2 - - &New File - &Neue Datei - - - + &Save File Datei &speichern @@ -164,7 +159,12 @@ Datei &Öffnen... - + + &New Script + + + + Save File &As... Datei speichern &als... @@ -250,6 +250,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Suchen und Ersetzen... @@ -264,7 +274,7 @@ &Gehe zu Zeile... - + &Recent Editor Files &Zuletzt bearbeitete Dateien @@ -289,7 +299,7 @@ Andere Dokumente schließen - + &Preferences... &Einstellungen... @@ -319,7 +329,7 @@ &Dokumentation zum Schlüsselwort - + Could not open file %1 for read: %2. @@ -353,7 +363,7 @@ Der zugehörige Editor-Reiter ist nicht mehr vorhanden. - + &File &Datei @@ -368,7 +378,7 @@ &Bearbeiten - + &Debug &Debuggen @@ -381,7 +391,7 @@ file_editor_tab - + Goto line Gehe zu Zeile @@ -391,7 +401,7 @@ Zeilennummer - + <unnamed> <unbenannt> @@ -408,14 +418,15 @@ - - + + + Octave Editor Octave Editor - + The file %1 is about to be closed but has been modified. @@ -426,12 +437,12 @@ %2 - + Octave Files (*.m);;All Files (*) Octave Dateien (*.m);;All Files (*) - + Warning: The contents in the editor is modified! @@ -447,14 +458,14 @@ wurde gelöscht oder umbenannt. Soll die Datei jetzt gespeichert werden?%2 - + Could not open file %1 for write: %2. Die Datei %1 konnte nicht zum Schreiben geöffnet werden: %2. - + Line: Zeile: @@ -464,7 +475,18 @@ Spalte: - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Die Datei %1 wurde von einer anderen Anwendung verändert. Soll der neue Inhalt geladen werden? @@ -497,7 +519,12 @@ Aktionen mit aktuellem Verzeichnis - + + Set Browser Directory... + + + + Find Files... Dateien suchen... @@ -508,16 +535,17 @@ + New Directory Neues Verzeichnis - + Double-click a file to open it Doppelklick auf eine Datei um diese zu öffnen - + Show Octave directory Aktuelles Octave Verzeichnis anzeigen @@ -542,7 +570,7 @@ Wechsle zum Heimatverzeichnis - + Search Directory... Verzeichnis suchen... @@ -563,7 +591,7 @@ Neues Verzeichnis... - + File size Dateigröße @@ -677,7 +705,12 @@ - + + New File.txt + + + + Create Directory Neues Verzeichnis @@ -756,7 +789,12 @@ find_dialog - + + Find and Replace + + + + Find &what: &Suche: @@ -826,7 +864,7 @@ In Auswah&l suchen - + Search from end Vom Ende suchen @@ -836,7 +874,7 @@ Suche vom Beginn - + Replace Result Ergebins der Ersetzungen @@ -846,7 +884,7 @@ %1 Vorkommnisse ersetzt - + Find Result Suchergebnis @@ -869,12 +907,7 @@ Name: - - Enter the filename expression - Eingabe eines Ausdrucks für den Dateinamen - - - + Start in: Beginne in: @@ -894,22 +927,12 @@ Suche Startverzeichnis - - Recurse directories - Unterverzeichnisse durchsuchen - - - + Search recursively through directories for matching files Rekursive Dateisuche durch Unterverzeichnisse - - Include directories - Verzeichnisse einbeziehen - - - + Include matching directories in search results Auch Verzeichnisse berücksichtigen, die die Suchanfrage erfüllen @@ -929,9 +952,24 @@ In Datei vorkommender Text: - - Search must match text - Suche Dateien mit übereinstimmendem Text + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -994,7 +1032,12 @@ Suche... - + + %1 match(es) + + + + Set search directory Suchverzeichnis setzen @@ -1084,13 +1127,13 @@ main_window - + Load Workspace Lade Arbeitsumgebung - - + + About Octave Über Octave @@ -1105,12 +1148,7 @@ Neu - - Script - Skript - - - + Figure Abbildung @@ -1150,12 +1188,23 @@ Einfügen - + Save Workspace As Arbeitsumgebung speichern als - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. Die Datei '%1' mit Versionshinweisen ist leer. @@ -1175,7 +1224,7 @@ Neuigkeiten aus der Octave Community - + Clear Clipboard Zwischenablage leeren @@ -1240,7 +1289,12 @@ Hineinspringen - + + Octave + + + + Load Workspace... Lade Arbeitsumgebung... @@ -1250,7 +1304,12 @@ Arbeitsumgebung speichern als... - + + New Script + + + + Function... Funktion... @@ -1341,8 +1400,8 @@ Ein Verzeichnis höher - - + + Browse directories Verzeichnis suchen @@ -1416,7 +1475,7 @@ news_reader - + <html> <body> <p> @@ -1475,18 +1534,18 @@ octave_dock_widget - - + + Undock widget Fenster lösen - + Hide widget Fenster verbergen - + Dock widget Fenster andocken @@ -1517,7 +1576,7 @@ octave_qt_link - + Yes @@ -1544,13 +1603,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - Die Datei %1 exisitiert nicht im Suchpfad. Um die editierte Funktion zu debuggen, muss entweder in das Verzeichnis %2 gewechselt werden oder dieses Verzeichnis dem Suchpfad hinzugefügt werden. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - Die Datei %1 wird von einer gleichnamigen Datei im Suchpfad überdeckt. Um die editierte Funktion zu debuggen, muss in das Verzeichnis %2 gewechselt werden. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -1601,17 +1660,17 @@ settings_dialog - + Settings Einstellungen - + General Allgemein - + Octave logo only Nur Octave Logo @@ -1621,17 +1680,37 @@ Icons mit Buchstaben - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Editor - + Color Farbe - + Indent width Einrücken um @@ -1641,7 +1720,7 @@ Tabulator rückt ein - + Auto indentation Auto Einrückung @@ -1686,67 +1765,114 @@ Editor Dateien der letzten Sitzung wiederherstellen - + Use custom file editor Externen Editor verwenden - + + emacs +%l %f + + + + Editor Styles Editor Stile - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Auswahl von Schrift, Schriftgröße (als Differenz von der Standardgröße), Schriftstil (<b>f</b>ett, <b>k</b>ursiv, <b>u</b>nterstrichen), Text- und Hintergrundfarbe (für den Hintergrund ist die Farbe Pink (255,0,255) ein Platzhalter für die Standardfarbe)</p></body></html> - + Terminal Colors Farben des Befehlsfensters - + Font Schriftart - + Show line numbers Zeilennummern anzeigen - + Highlight current line Aktuelle Zeile hervorheben - + Code completion Vervollständigung - + Show complete path in window title Kompletten Pfad im Reiter anzeigen - + + Interface + + + + Graphic icons Grafische Icons - + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + Show whitespace Leerzeichen anzeigen - + Do not show whitespace used for indentation Leerzeichen der Einrückung nicht anzeigen - + + Tab width min. + + + + + max. + + + + # of characters typed before completion list displayed Anzahl der eingegebenen Zeichen bis Vervollständigungsliste @@ -1756,87 +1882,102 @@ Nicht existierende Dateien ohne Nachfrage anlegen - + command line (%f=file, %l=line): Kommandozeile (%f=Datei, %l=Zeile): - - emacs - emacs - - - + Terminal Befehlsfenster - + Cursor type: Cursortyp: - + Cursor blinking Blinkender Cursor - + Use foreground color Vordergrundfarbe verwenden - + Font size Schriftgröße - + + Set focus to terminal when running a command from within another widget + + + + File Browser Dateibrowser - + Show file size Dateigröße anzeigen - + Show file type Dateityp anzeigen - + Show date of last modification Datum der letzten Änderung anzeigen - + Show hidden files Versteckte Dateien anzeigen - + + Display + + + + Alternating row colors Alternierende Farben für die Zeilen verwenden - + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Arbeitsumgebung - + Storage Class Colors Farben der Speicherklassen festlegen - + Network Netzwerk - + Allow Octave to connect to the Octave web site to display current news and information Octave erlauben Neuigkeiten und Informationen von der Octave Webseite anzuzeigen @@ -1851,27 +1992,27 @@ HTTP Proxy - + Icon set for dock widgets Icons der Unterfenster - + Language (requires restart) Sprache (Neustart erforderlich) - + Icon size Icongröße - + Synchronize Octave working directory with file browser Octave Arbeitsverzeichnis und Dateibrowser synchronisieren - + Socks5Proxy Socks5Proxy @@ -1901,9 +2042,9 @@ Passwort: - + - + System setting Systemeinstellung @@ -1950,6 +2091,16 @@ short form for underlined u + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -2017,7 +2168,7 @@ webinfo - + Type here and press 'Return' to search Suchbegriff eingeben und mit 'Enter' die Suche starten @@ -2026,6 +2177,16 @@ Global search Globale Suche + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -2059,8 +2220,8 @@ - Storage Class - Speicherklasse + Attribute + @@ -2108,8 +2269,8 @@ - Colors for the storage class: - Farben der Speicherklassen: + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/en_US.ts --- a/libgui/languages/en_US.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/en_US.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard @@ -141,17 +141,12 @@ - + &%1 %2 - - &New File - - - - + &Save File @@ -161,7 +156,12 @@ - + + &New Script + + + + Save File &As... @@ -247,6 +247,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... @@ -261,7 +271,7 @@ - + &Recent Editor Files @@ -286,7 +296,7 @@ - + &Preferences... @@ -316,7 +326,7 @@ - + Could not open file %1 for read: %2. @@ -342,7 +352,7 @@ - + &File @@ -357,7 +367,7 @@ - + &Debug @@ -370,7 +380,7 @@ file_editor_tab - + Goto line @@ -380,7 +390,7 @@ - + <unnamed> @@ -397,14 +407,15 @@ - - + + + Octave Editor - + The file %1 is about to be closed but has been modified. @@ -412,12 +423,12 @@ - + Octave Files (*.m);;All Files (*) - + Warning: The contents in the editor is modified! @@ -431,13 +442,13 @@ - + Could not open file %1 for write: %2. - + Line: @@ -447,7 +458,18 @@ - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? @@ -480,7 +502,12 @@ - + + Set Browser Directory... + + + + Find Files... @@ -491,16 +518,17 @@ + New Directory - + Double-click a file to open it - + Show Octave directory @@ -525,7 +553,7 @@ - + Search Directory... @@ -545,7 +573,7 @@ - + File size @@ -656,7 +684,12 @@ - + + New File.txt + + + + Create Directory @@ -719,7 +752,12 @@ find_dialog - + + Find and Replace + + + + Find &what: @@ -789,7 +827,7 @@ - + Search from end @@ -799,7 +837,7 @@ - + Replace Result @@ -809,7 +847,7 @@ - + Find Result @@ -832,12 +870,7 @@ - - Enter the filename expression - - - - + Start in: @@ -857,22 +890,12 @@ - - Recurse directories - - - - + Search recursively through directories for matching files - - Include directories - - - - + Include matching directories in search results @@ -892,8 +915,23 @@ - - Search must match text + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression @@ -957,7 +995,12 @@ - + + %1 match(es) + + + + Set search directory @@ -1043,13 +1086,13 @@ main_window - + Load Workspace - - + + About Octave @@ -1064,12 +1107,7 @@ - - Script - - - - + Figure @@ -1109,12 +1147,23 @@ - + Save Workspace As - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. @@ -1134,7 +1183,7 @@ - + Clear Clipboard @@ -1199,7 +1248,12 @@ - + + Octave + + + + Load Workspace... @@ -1209,7 +1263,12 @@ - + + New Script + + + + Function... @@ -1300,8 +1359,8 @@ - - + + Browse directories @@ -1375,7 +1434,7 @@ news_reader - + <html> <body> <p> @@ -1411,18 +1470,18 @@ octave_dock_widget - - + + Undock widget - + Hide widget - + Dock widget @@ -1453,7 +1512,7 @@ octave_qt_link - + Yes @@ -1478,12 +1537,12 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. @@ -1529,17 +1588,17 @@ settings_dialog - + Settings - + General - + Octave logo only @@ -1549,17 +1608,37 @@ - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor - + Color - + Indent width @@ -1569,7 +1648,7 @@ - + Auto indentation @@ -1614,67 +1693,114 @@ - + Use custom file editor - + + emacs +%l %f + + + + Editor Styles - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> - + Terminal Colors - + Font - + Show line numbers - + Highlight current line - + Code completion - + Show complete path in window title - + + Interface + + + + Graphic icons - + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + Show whitespace - + Do not show whitespace used for indentation - + + Tab width min. + + + + + max. + + + + # of characters typed before completion list displayed @@ -1684,87 +1810,102 @@ - + command line (%f=file, %l=line): - - emacs - - - - + Terminal - + Cursor type: - + Cursor blinking - + Use foreground color - + Font size - + + Set focus to terminal when running a command from within another widget + + + + File Browser - + Show file size - + Show file type - + Show date of last modification - + Show hidden files - + + Display + + + + Alternating row colors - + + Behavior + + + + + Restore last directory of previous session + + + + Workspace - + Storage Class Colors - + Network - + Allow Octave to connect to the Octave web site to display current news and information @@ -1779,27 +1920,27 @@ - + Icon set for dock widgets - + Language (requires restart) - + Icon size - + Synchronize Octave working directory with file browser - + Socks5Proxy @@ -1829,9 +1970,9 @@ - + - + System setting @@ -1878,6 +2019,16 @@ short form for underlined + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -1934,7 +2085,7 @@ webinfo - + Type here and press 'Return' to search @@ -1943,6 +2094,16 @@ Global search + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -1976,7 +2137,7 @@ - Storage Class + Attribute @@ -2025,7 +2186,7 @@ - Colors for the storage class: + Colors for variable attributes: diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/es_ES.ts --- a/libgui/languages/es_ES.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/es_ES.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ cursor - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> <p><strong>Nota acerca de la nueva GUI de Octave</strong></p><p>Una de las novedades más grandes de Octave 3.8 es la interfaz gráfica de usuario. Esto ha sido algo que los usuarios han solicitado frecuentemente durante los últimos años, y ahora está casi lista. Pero como esta interfaz aún no está tan pulida como a nosotros nos gustaría, hemos decidido esperar hasta la serie de versiones 4.0.x de Octave para hacer a la GUI la interfaz por defecto.</p><p>Dado el tiempo transcurrido, el número de correcciones de errores del software (bugs) y el número de mejoras desde la última versión mayor de Octave, también hemos decidido retrasar el lanzamiento de todas estas nuevas mejoras durante más tiempo con el fin de perfeccionar la GUI. Disfrute de la versión 3.8 de Octave y la versión previa de la nueva GUI. Creemos que está funcionando razonablemente bien, pero también somos conscientes de que existen muchas cosas que se pueden mejorar.</p><p><strong>Necesitamos su ayuda</strong></p><p>Hay varias maneras mediante las cuales usted nos puede ayudar a arreglar errores, completar la GUI y, en general, mejorar la experiencia del usuario, ya sean novatos o expertos (los enlaces se abrirán en un navegador externo):</p><p><ul><li>Si usted es un desarrollador de software experimentado, puede contribuir con su tiempo para ayudar <a href="http://octave.org/get-involved.html">Desarrollo de Octave</a>.</li><li>Si Octave no funciona adecuadamente, se le invita a <a href="http://octave.org/bugs.html">reportar problemas </a> que haya encontrado.</li><li>Si usted es usuario o desarrollador, puede <a href="http://octave.org/donate.html">ayudar a financiar el proyecto</a>. El desarrollo de Octave necesita tiempo y conocimientos. Su contribución ayudaría en gran medida a asegurar que Octave continúe mejorando.</li></ul></p><p>Esperamos que haya encontrado Octave muy útil. Por favor, ¡ayúdenos a hacerlo aún mejor en el futuro!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard selección copiada al portapapeles @@ -134,17 +134,12 @@ - + &%1 %2 &%1 %2 - - &New File - &Nuevo archivo - - - + &Save File &Guardar archivo @@ -154,7 +149,12 @@ &Abrir archivo... - + + &New Script + + + + Save File &As... Guardar archivo &como... @@ -240,6 +240,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Buscar y reemplazar... @@ -254,7 +264,7 @@ &Ir a línea... - + &Recent Editor Files Archivos &recientes @@ -279,7 +289,7 @@ Cerrar otros archivos - + &Preferences... &Preferencias... @@ -309,7 +319,7 @@ &Documentación de palabras clave - + Could not open file %1 for read: %2. @@ -342,7 +352,7 @@ La pestaña para la edición del archivo ha desaparecido. - + &File &Archivo @@ -357,7 +367,7 @@ &Editar - + &Debug &Depurar @@ -370,7 +380,7 @@ file_editor_tab - + Goto line Ir a línea @@ -380,7 +390,7 @@ Número de línea - + <unnamed> <sin nombre> @@ -397,14 +407,15 @@ - - + + + Octave Editor Editor de Octave - + The file %1 is about to be closed but has been modified. @@ -412,12 +423,12 @@ El archivo\n%1\nestá a punto de ser cerrado, pero ha sido modificado.\n%2 - + Octave Files (*.m);;All Files (*) Archivos de Octave(*.m);;Todos los archivos(*) - + Warning: The contents in the editor is modified! @@ -431,13 +442,13 @@ Parece que el archivo\n%1\nha sido eliminado o renombrado.¿Desea guardarlo ahora?%2 - + Could not open file %1 for write: %2. No se ha podido abrir el archivo %1 para escritura:\n%2. - + Line: Línea: @@ -447,7 +458,18 @@ Col: - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Parece que el archivo \'%1\' ha sido modificado por otra aplicación. ¿Desea recargarlo? @@ -480,7 +502,12 @@ Acciones en el directorio actual - + + Set Browser Directory... + + + + Find Files... Buscar archivos... @@ -491,16 +518,17 @@ + New Directory Nuevo directorio - + Double-click a file to open it Pulse dos veces en un archivo para abrirlo - + Show Octave directory Mostrar el directorio de Octave @@ -525,7 +553,7 @@ Mostrar el directorio de inicio - + Search Directory... Buscar directorio... @@ -545,7 +573,7 @@ Nuevo directorio... - + File size Tamaño del archivo @@ -657,7 +685,12 @@ - + + New File.txt + + + + Create Directory Crear directorio @@ -739,7 +772,12 @@ find_dialog - + + Find and Replace + + + + Find &what: &Buscar: @@ -809,7 +847,7 @@ Buscar se&lección - + Search from end Buscar desde el final @@ -819,7 +857,7 @@ Buscar desde el inicio - + Replace Result Reemplazar resultado @@ -829,7 +867,7 @@ %1 instancias reemplazadas - + Find Result Resultado de la búsqueda @@ -852,12 +890,7 @@ Nombrado: - - Enter the filename expression - Introducir la expresión del nombre de archivo - - - + Start in: Iniciar en: @@ -877,22 +910,12 @@ Explorar para seleccionar el directorio de inicio - - Recurse directories - Explorar directorios de forma recursiva - - - + Search recursively through directories for matching files Buscar archivos de forma recursiva en los directorios - - Include directories - Incluir directorios - - - + Include matching directories in search results Incluir directorios que coicidan en los resultados de la búsqueda @@ -912,9 +935,24 @@ Contiene el texto: - - Search must match text - La búsqueda debe coincidir con el texto + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -977,7 +1015,12 @@ Buscando... - + + %1 match(es) + + + + Set search directory Seleccionar directorio de búsqueda @@ -1068,13 +1111,13 @@ main_window - + Load Workspace Cargar espacio de trabajo - - + + About Octave Acerca de Octave @@ -1089,13 +1132,7 @@ Nuevo - - Script - Guión/"Script" - Guión - - - + Figure Figura @@ -1135,12 +1172,23 @@ Pegar - + Save Workspace As Guardar espacio de trabajo como - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. El archivo de las notas de versión %1 está vacío. @@ -1160,7 +1208,7 @@ Noticas de la comunidad Octave - + Clear Clipboard Limpiar el portapapeles @@ -1225,7 +1273,12 @@ Iniciar - + + Octave + + + + Load Workspace... Cargar espacio de trabajo... @@ -1235,7 +1288,12 @@ Guardar espacio de trabajo como... - + + New Script + + + + Function... Función... @@ -1326,8 +1384,8 @@ Directorio superior - - + + Browse directories Explorar directorios @@ -1401,7 +1459,7 @@ news_reader - + <html> <body> <p> @@ -1461,20 +1519,20 @@ octave_dock_widget - - + + Undock widget Uso "widget" por ser el término usual: http://es.wikipedia.org/wiki/Widget Desacoplar widget - + Hide widget Uso "widget" por ser el término usual: http://es.wikipedia.org/wiki/Widget Ocultar widget - + Dock widget Uso "widget" por ser el término usual: http://es.wikipedia.org/wiki/Widget Acoplar widget @@ -1506,7 +1564,7 @@ octave_qt_link - + Yes @@ -1531,14 +1589,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - Uso la traducción "ruta" para "path": http://es.wikipedia.org/wiki/Ruta_(informática) - El archivo %1 no existe en la ruta de carga. Para depurar la función que acualmente edita tiene que cambiar al directorio %2 o bien agregar ese directorio a la ruta de carga. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - El archivo %1 se solapa con un archivo con el mismo nombre en la ruta de carga. Para depurar la función que edita, cambie al directorio %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -1585,17 +1642,17 @@ settings_dialog - + Settings Configuración - + General General - + Octave logo only Sólo logo de Octave @@ -1610,17 +1667,37 @@ Iconos gráficos - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Editor - + Color Color - + Indent width Ancho de sangría @@ -1630,7 +1707,7 @@ Sangrar con tabulación - + Auto indentation Sangría automática @@ -1675,63 +1752,68 @@ Restaurar las pestañas del editor de la sesión anterior en el arranque - + Use custom file editor Utilizar editor de archivos personalizado - + + emacs +%l %f + + + + Editor Styles Estilos del editor - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Seleccione fuente, tamaño de fuente (como diferencia con el tamaño por defecto), estilo de fuente (<b>n</b>egrita, <b>c</b>ursiva, <b>s</b>ubrayada), color de texto y color de fondo(para este último, el color rosa (255,0,255) es un marcador de posición para el color de fondo por defecto).</p></body></html> - + Terminal Colors En es_ES, terminal suele ser masculino, aunque en el español iberoamericano suele adoptarse el femenino Colores del terminal - + Font Tipo de fuente - + Show line numbers Mostrar numeros de línea - + Highlight current line Resaltar línea actual - + Code completion Autocompletar código - + Show complete path in window title Mostrar ruta completa en el título de la ventana - + Show whitespace Mostrar espacios en blanco - + Do not show whitespace used for indentation No mostrar los espacios usados para la sangría - + # of characters typed before completion list displayed # de caracteres pulsados antes de completar la lista desplegada @@ -1741,87 +1823,144 @@ Crear archivos no existentes sin consultar - + command line (%f=file, %l=line): línea de comando(%f=archivo, %l=linea): - - emacs - emacs - - - + Terminal Terminal - + Cursor type: Tipo de cursor: - + Cursor blinking Cursor parpadeante - + Use foreground color Usar color de primer plano - + Font size Tamaño de fuente - + + Set focus to terminal when running a command from within another widget + + + + File Browser Explorador de archivos - + Show file size Mostrar tamaño de archivo - + Show file type Mostrar tipo de archivo - + Show date of last modification Mostrar fecha de la última modificación - + Show hidden files Mostrar archivos ocultos - + + Interface + + + + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + + Tab width min. + + + + + max. + + + + + Display + + + + Alternating row colors Alternar colores de filas - + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Espacio de trabajo - + Storage Class Colors Colores para las clases de almacenamiento - + Network Red - + Allow Octave to connect to the Octave web site to display current news and information Permitir a Octave la conexión al sitio web para desplegar las últimas noticias e información @@ -1836,27 +1975,27 @@ HttpProxy - + Icon set for dock widgets Iconos para widget acoplados - + Language (requires restart) Lenguaje (reinicio requerido) - + Icon size Tamaño de icono - + Synchronize Octave working directory with file browser Sincronizar el directorio de trabajo de Octave con el explorador de archivos - + Socks5Proxy "Socks5Proxy" @@ -1886,9 +2025,9 @@ Contraseña: - + - + System setting Configuración del sistema @@ -1935,6 +2074,16 @@ short form for underlined u + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -2002,7 +2151,7 @@ webinfo - + Type here and press 'Return' to search Escriba aquí y pulse la tecla 'Retorno' para buscar @@ -2011,6 +2160,16 @@ Global search Búsqueda global + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -2044,8 +2203,8 @@ - Storage Class - Clase de almacenamiento + Attribute + @@ -2093,8 +2252,8 @@ - Colors for the storage class: - Colores para cada clase de almacenamiento: + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/fr_FR.ts --- a/libgui/languages/fr_FR.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/fr_FR.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ curseur - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> <p><strong>Note à propos du nouveau GUI d'Octave</strong></p><p>Parmi les nouvelles fonctionnalités d'Ocatve 3.8, l'interface graphique est une grande évolution. C'est bien la fonctionnalité que les utilisateurs ont le plus réclamée durant les dernières années, et elle est maintenant presque prête. Elle n'est pas aussi parfaite que nous le souhaiterions et c'est pourquoi nous avons décidé d'attendre la version 4.0 pour en faire l'interface par défaut.</p><p>Au vu du nombre de bug résolus et des améliorations apportées depuis la dernière version majeure d'Octave, nous avons décidé de ne pas retarder plus la parution de ces améliorations pour perfectionner le GUI. Vous pouvez maintenant apprécier la version 3.8 et la version préliminaire de la nouvelle interface graphique. Nous pensons qu'elle fonctionne raisonnablement bien, mais nous savons aussi qu'il y a des points durs évidents et beaucoup d'améliorations possibles.</p><p><strong>Nous avons besoin de votre aide</strong></p><p>Il y a de multiples manières d'aider à résoudre les bogues restants, à terminer le GUI et à améliorer l'expérience utilisateur aussi bien pour les novices que pour les experts (liens ouverts dans un navigateur externe):</p><p><ul><li>Si vous êtes un développeur expérimenté, vous pouvez donner de votre temps et <a href="http://octave.org/get-involved.html">développer Octave</a>.</li><li>Si Octave ne fonctionne pas correctement, vous êtes encouragés à <a href="http://octave.org/bugs.html">signaler les problèmes </a> que vous trouvez.</li><li>Que vous soyez utilisateur ou développeur, vous pouvez <a href="http://octave.org/donate.html">aider à financer le projet</a>. Le développement d'Octave demande beaucoup de temps et d’expertise. Vos contributions permettent d'assurer qu'Octave continuera à s'améliorer.</li></ul></p><p>Nous espérons que vous trouverez Octave utile. S'il vous plaît, aidez nous à l'améliorer encore dans le futur !</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard sélection copiée vers le presse-papier @@ -143,17 +143,12 @@ est déjà ouvert dans l'éditeur - + &%1 %2 &%1 %2 - - &New File - &Nouveau - - - + &Save File &Enregistrer @@ -163,7 +158,12 @@ &Ouvrir... - + + &New Script + + + + Save File &As... Enregistrer &sous... @@ -249,6 +249,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Rechercher et remplacer... @@ -263,7 +273,7 @@ &Aller à la ligne... - + &Recent Editor Files Fichiers &récents @@ -288,7 +298,7 @@ Fermer les autres fichiers - + &Preferences... &Préférences... @@ -318,7 +328,7 @@ &Documentation sur le mot de clés - + Could not open file %1 for read: %2. @@ -350,7 +360,7 @@ L'onglet éditeur de fichier associé a disparu. - + &File &Fichier @@ -365,7 +375,7 @@ &Editer - + &Debug &Déboguer @@ -378,7 +388,7 @@ file_editor_tab - + Goto line Aller à la ligne @@ -388,7 +398,7 @@ Numéro de ligne - + <unnamed> <sans nom> @@ -405,14 +415,15 @@ - - + + + Octave Editor Éditeur d'Octave - + The file %1 is about to be closed but has been modified. @@ -423,12 +434,12 @@ %2 - + Octave Files (*.m);;All Files (*) Fichiers d'Octave (*.m);;Tous les fichiers (*) - + Warning: The contents in the editor is modified! @@ -446,14 +457,14 @@ a été supprimé ou rénommé. Voulez-vous l'enregistrer maintenant ?%2 - + Could not open file %1 for write: %2. Impossible d'ouvrir le fichier %1 pour écrire : %2. - + Line: Ligne : @@ -463,7 +474,18 @@ Col : - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Il semblerait que '%1' a été modifié par une autre application. Voulez-vous le récharger ? @@ -496,7 +518,12 @@ Actions sur le répertoire courant - + + Set Browser Directory... + + + + Find Files... Rechercher des fichiers... @@ -507,16 +534,17 @@ + New Directory Nouveau répertoire - + Double-click a file to open it Double-cliquer sur un fichier pour l'ouvrir - + Show Octave directory Revenir au répertoire d'Octave @@ -541,7 +569,7 @@ Aller au répertoire personnel - + Search Directory... Rechercher dans le répertoire... @@ -561,7 +589,7 @@ Nouveau répertoire... - + File size Taille du fichier @@ -676,7 +704,12 @@ - + + New File.txt + + + + Create Directory Créer un répertoire @@ -755,7 +788,12 @@ find_dialog - + + Find and Replace + + + + Find &what: Rechercher &quoi : @@ -825,7 +863,7 @@ Recherche dans la sé&lection - + Search from end Rechercher depuis la fin @@ -835,7 +873,7 @@ Rechercher depuis le début - + Replace Result Résultats du remplacement @@ -845,7 +883,7 @@ %1 instances remplacées - + Find Result Résultats de la recherche @@ -868,12 +906,7 @@ Nommé: - - Enter the filename expression - Entrer le nom du fichier ou une expression - - - + Start in: Demarrer dans : @@ -893,22 +926,12 @@ Choisir le répertoire de démarrage - - Recurse directories - Parcourir récursivement les sous-répertoires - - - + Search recursively through directories for matching files Rechercher les fichiers recursivement dans les sous-répertoires - - Include directories - Inclure les répertoires - - - + Include matching directories in search results Inclure les répertoires concordants dans des résultats de la recherche @@ -928,9 +951,24 @@ Contenant le texte : - - Search must match text - La recherche doit contenir le texte + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -993,7 +1031,12 @@ Recherche en cours... - + + %1 match(es) + + + + Set search directory Définir le répertoire de recherche @@ -1083,13 +1126,13 @@ main_window - + Load Workspace Charger l'espace de travail - - + + About Octave À propos d'Octave @@ -1104,12 +1147,7 @@ Nouveau - - Script - Fichier de script - - - + Figure Figure @@ -1149,12 +1187,23 @@ Coller - + Save Workspace As Enregistrer l'espace de travail sous - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. Le fichier de notes de version '%1' est vide. @@ -1174,7 +1223,7 @@ Nouvelles de la communauté Octave - + Clear Clipboard Effacer le presse-papiers @@ -1239,7 +1288,12 @@ Avancer d'un pas avec entrée - + + Octave + + + + Load Workspace... Charger l'espace de travail... @@ -1249,7 +1303,12 @@ Enregistrer l'espace de travail sous... - + + New Script + + + + Function... Fonction... @@ -1340,8 +1399,8 @@ Monter au répertoire parent - - + + Browse directories Naviguer dans les répertoires @@ -1415,7 +1474,7 @@ news_reader - + <html> <body> <p> @@ -1474,18 +1533,18 @@ octave_dock_widget - - + + Undock widget Détacher le widget - + Hide widget Cacher le widget - + Dock widget Attacher le widget @@ -1516,7 +1575,7 @@ octave_qt_link - + Yes @@ -1543,13 +1602,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - Le fichier %1 n'existe pas dans les chemins accessibles. Pour déboguer la fonction que vous éditez, vous devez soit modifier le répertoire pour %2 ou ajouter le répertoire aux chemins accessibles. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - Le fichier %1 est occulté par un fichier du même nom dans les chemins accessibles. Pour déboguer la fonction que vous éditez, vous devez modifier le répertoire pour %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -1600,17 +1659,17 @@ settings_dialog - + Settings Configuration - + General Général - + Octave logo only Logo d'Octave seulement @@ -1625,17 +1684,37 @@ Icones graphiques - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Éditeur - + Color Couleur - + Indent width Largeur de l'indentation @@ -1645,7 +1724,7 @@ Indentation par tabulation - + Auto indentation Indentation automatique @@ -1690,62 +1769,67 @@ Restaurer les onglets de la session précédente - + Use custom file editor Utiliser un éditeur externe - + + emacs +%l %f + + + + Editor Styles Affichage - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Sélectionnez la police, sa taille (différence par rapport à la taille par défaut), son style (<b>g</b>ras, <b>i</b>talique, <b>s</b>ouligné), la couleur du texte et de l'arrière plan (pour ce dernier, le rose (255,0,255) fait figure de défaut).</p></body></html> - + Terminal Colors Couleurs de la fenetre de commandes - + Font Police - + Show line numbers Afficher les numéros des lignes - + Highlight current line Surligner la ligne courante - + Code completion Suggestions de saisie - + Show complete path in window title Afficher le chemin complet dans le titre de la fenetre - + Show whitespace Afficher les espaces - + Do not show whitespace used for indentation Ne pas afficher les espaces utilisés pour l'indentation - + # of characters typed before completion list displayed Nb. de caractères avant affichage de la liste de complétion @@ -1755,87 +1839,144 @@ Créer les fichiers non-existants sans prévenir - + command line (%f=file, %l=line): ligne de commande (%f=fichier, %l=ligne) : - - emacs - emacs - - - + Terminal Terminal - + Cursor type: Type de curseur : - + Cursor blinking Curseur clignotant - + Use foreground color Utiliser la couleur de l'avant plan - + Font size Taille de police - + + Set focus to terminal when running a command from within another widget + + + + File Browser Explorateur de fichiers - + Show file size Afficher la taille des fichiers - + Show file type Afficher le type des fichiers - + Show date of last modification Afficher la date de la dernière modification - + Show hidden files Afficher les fichiers cachés - + + Interface + + + + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + + Tab width min. + + + + + max. + + + + + Display + + + + Alternating row colors Alterner les couleurs des lignes - + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Espace de travail - + Storage Class Colors Couleurs des variables - + Network Réseau - + Allow Octave to connect to the Octave web site to display current news and information Autoriser Octave à se connecter à son site internet afin d'afficher les informations et nouvelle fraîches @@ -1850,27 +1991,27 @@ Proxy HTTP - + Icon set for dock widgets Jeu d'icones pour les widgets - + Language (requires restart) Langue (nécessite un redémarrage) - + Icon size Taille des icones - + Synchronize Octave working directory with file browser Synchroniser le répertoire de travail d'Octave et le navigateur de fichiers - + Socks5Proxy Proxy Socks5 @@ -1900,9 +2041,9 @@ Mot de passe : - + - + System setting Reglages système @@ -1949,6 +2090,16 @@ short form for underlined s + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -2016,7 +2167,7 @@ webinfo - + Type here and press 'Return' to search Entrez le texte ici et appuyez sur 'Entrée' pour lancer la recherche @@ -2025,6 +2176,16 @@ Global search Recherche globale + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -2058,8 +2219,8 @@ - Storage Class - Type de stockage + Attribute + @@ -2107,8 +2268,8 @@ - Colors for the storage class: - Couleurs pour le type de stockage : + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/it_IT.ts --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/languages/it_IT.ts Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,4737 @@ + + + + + ListDialog + + + Select All + Seleziona Tutto + + + + QColorDialog + + Hu&e: + Tinta: + + + &Sat: + Saturazione: + + + &Val: + Luminosità: + + + &Red: + Rosso: + + + &Green: + Verde: + + + Bl&ue: + Blu: + + + A&lpha channel: + Canale alfa: + + + Select Color + Seleziona Colore + + + &Basic colors + Colori di base + + + &Custom colors + Colori personalizzati + + + &Add to Custom Colors + Aggiungi ai Colori Personalizzati + + + + QDialog + + Done + Fatto + + + What's This? + Cos'è questo? + + + + QDialogButtonBox + + OK + OK + + + + QErrorMessage + + Debug Message: + Messaggio di Debug: + + + Warning: + Avviso: + + + Fatal Error: + Errore Fatale: + + + &Show this message again + Mostra di nuovo questo messaggio + + + &OK + OK + + + + QFileDialog + + Find Directory + Trova Cartella + + + Open + Apri + + + Save As + Salva come + + + All Files (*) + Tutti i File (*) + + + Show + Mostra + + + &Rename + &Rinomina + + + &Delete + &Elimina + + + Show &hidden files + Mostra &file nascosti + + + &New Folder + &Nuova cartella + + + Directory: + Cartella: + + + File &name: + Nome &file: + + + &Open + &Apri + + + &Save + &Salva + + + Directories + Cartelle + + + &Choose + &Seleziona + + + %1 +Directory not found. +Please verify the correct directory name was given. + %1 +Nessuna cartella trovata. +Verificare la corretta ortografia del nome inserito. + + + %1 already exists. +Do you want to replace it? + %1 esiste già. +Si desidera sostituirlo? + + + %1 +File not found. +Please verify the correct file name was given. + %1 +File non trovato. +Verificare la corretta ortografia del nome inserito. + + + New Folder + Nuova Cartella + + + '%1' is write protected. +Do you want to delete it anyway? + '%1' è protetto da scrittura. +Si è certi di volerlo eliminare? + + + Are sure you want to delete '%1'? + Si è certi di voler eliminare '%1'? + + + Could not delete directory. + Impossibile eliminare la cartella. + + + Recent Places + Percorsi Recenti + + + All Files (*.*) + Tutti i File (*.*) + + + + QFileSystemModel + + %1 TB + %1 TB + + + %1 GB + %1 GB + + + %1 MB + %1 MB + + + %1 KB + %1 KB + + + %1 bytes + %1 byte + + + Invalid filename + Nome del file non valido + + + <b>The name "%1" can not be used.</b><p>Try using another name, with fewer characters or no punctuations marks. + <b>Il nome "%1" non può essere utilizzato.</b><p>Si consiglia di utilizzarne uno con meno caratteri o senza segni di punteggiatura. + + + Name + Nome + + + Size + Dimensione + + + Kind + Match OS X Finder + Tipo + + + Type + All other platforms + Tipo + + + Date Modified + Data Ultima Modifica + + + + QFontDialog + + Select Font + Seleziona Tipo di Carattere + + + &Font + &Tipo + + + Font st&yle + &Stile + + + &Size + &Dimensione + + + Effects + Effetti + + + Stri&keout + Bar&rato + + + &Underline + &Sottolineato + + + Sample + Colore + + + Wr&iting System + Sistema di Scrittura + + + + QInputDialog + + Enter a value: + Inserire un valore: + + + + QMessageBox + + Show Details... + Mostra Dettagli... + + + Hide Details... + Nascondi Dettagli... + + + OK + OK + + + Help + Aiuto + + + <h3>About Qt</h3><p>This program uses Qt version %1.</p> + <h3>A proposito Qt</h3><p>Questo programma utilizza Qt versione %1.</p> + + + <p>Qt is a C++ toolkit for cross-platform application development.</p><p>Qt provides single-source portability across MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, Linux, and all major commercial Unix variants. Qt is also available for embedded devices as Qt for Embedded Linux and Qt for Windows CE.</p><p>Qt is available under three different licensing options designed to accommodate the needs of our various users.</p><p>Qt licensed under our commercial license agreement is appropriate for development of proprietary/commercial software where you do not want to share any source code with third parties or otherwise cannot comply with the terms of the GNU LGPL version 2.1 or GNU GPL version 3.0.</p><p>Qt licensed under the GNU LGPL version 2.1 is appropriate for the development of Qt applications (proprietary or open source) provided you can comply with the terms and conditions of the GNU LGPL version 2.1.</p><p>Qt licensed under the GNU General Public License version 3.0 is appropriate for the development of Qt applications where you wish to use such applications in combination with software subject to the terms of the GNU GPL version 3.0 or where you are otherwise willing to comply with the terms of the GNU GPL version 3.0.</p><p>Please see <a href="http://qt.digia.com/product/licensing">qt.digia.com/product/licensing</a> for an overview of Qt licensing.</p><p>Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).</p><p>Qt is a Digia product. See <a href="http://qt.digia.com/">qt.digia.com</a> for more information.</p> + <p>Qt è uno strumento per lo sviluppo di applicazioni multipiattaforma.</p><p>Fornisce portabilità completa fra MS&nbsp;Windows, Mac&nbsp;OS&nbsp;X, Linux e tutte le principali varianti commerciali di Unix, ed è disponibile per dispositivi embedded come Qt for Embedded Linux e Qt for Windows CE.</p><p>Tre opzioni di liceza sono disponibili per rispondede alle esigenze eterogenee dei nostri utenti.</p><p>La licenza commerciale è adatta allo sviluppo di software proprietario e/o commerciale, quando non si desidera condividere codice sorgente con terze parti o si è in altro modo impossibilitati a rispettare i termini delle licenze GNU LGPL versione 2.1 o GNU GPL version 3.0.</p><p>La licenza GNU LGPL versione 2.1 si presta allo sviluppo di allpicazioni Qt (proprietarie o a sorgente aperto), qualora si sia in condizione di rispettare i termini e le condizioni della licenza GNU LGPL version 2.1.</p><p>La licenza GNU GPL versione 3.0 è adatta allo sviluppo di applicazioni Qt che si desidera utilizzare in combinazione con software soggetto ai termini della licenza GNU GPL version 3.0 o quando si desidera rispettare i termini della licenza GNU GPL version 3.0.</p><p>Si faccia riferimento a <a href="http://qt.digia.com/product/licensing">qt.digia.com/product/licensing</a> per una panoramica delle opzioni di licenza di Qt. </p><p>Copyright (C) 2013 Digia Plc e/o sussidiarie.</p><p>Qt è un prodotto Digia. Si veda <a href="http://qt.digia.com/">qt.digia.com</a> per maggiori informazioni.</p> + + + About Qt + A proposito di Qt + + + + QObject + + + automatic + automatico + + + + function + funzione + + + + global + globale + + + + hidden + nascosto + + + + inherited + ereditato + + + + persistent + persistente + + + + foreground + primo piano + + + + background + sfondo + + + + selection + selezione + + + + cursor + cursore + + + + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> + <p><strong>Nota sulla nuova interfaccia grafica di Octave</strong></p><p>Una delle maggiori novità di Octave 3.8 è l'interfaccia grafica utente. Si tratta della caratteristica più richiesta dagli utenti negli ultimi anni, ed ora è quasi pronta. Tuttavia, poiché essa non è ancora rifinita come vorremmo, abbiamo deciso di attendere fino alle serie di rilascio 4.0.x prima di renderla l'interfaccia predefinita.</p><p>D'altro canto, considerato il lasso di tempo trascorso, i problemi risolti ed i miglioramenti dall'ultima 'major release', abbiamo deciso di non ritardare ulteriormente un nuovo rilascio soltanto per perfezionare l'interfaccia grafica ed è pertanto con piacere che presentiamo la versione 3.8 di Octave con un'anteprima dell'interfaccia grafica. Crediamo che funzioni sufficientemente bene, pur avendo ancora qualche problema ed aspetti che potrebbero essere migliorati.</p><p><strong>Abbiamo bisogno del tuo aiuto</strong></p><p>Sono molti i modi in cui puoi aiutare a risolvere i problemi restanti, a completare l'interfaccia grafica e a migliorare in generale l'esperienza di utilizzo, tanto per i principianti quanto per gli utenti esperti:</p><p><ul><li>Se sei un programmatore esperto, puoi aiutare contribuendo allo <a href="http://octave.org/get-involved.html">sviluppo di Octave</a>.</li><li>Se Octave non funziona correttamente, ti incoraggiamo inoltre a <a href="http://octave.org/bugs.html">segnalare i problemi</a> che incontri.</li><li>Che tu sia un utente o uno sviluppatore, puoi aiutare a <a href="http://octave.org/donate.html">finanziare il progetto</a>. Lo sviluppo di questo software richiede molto tempo e molte competenze. I tuoi contributi aiutano ad assicurare il continuo miglioramento del software.</li></ul></p><p>Speriamo che troverai Octave utile. Perfavore, aiutaci a renderlo ancora migliore per il futuro!</p> + + + + QPPDOptionsModel + + Name + Nome + + + Value + Valore + + + + QPageSetupWidget + + Centimeters (cm) + Centimetri (cm) + + + Millimeters (mm) + Millimetri (mm) + + + Inches (in) + Pollici (in) + + + Points (pt) + Punti (pt) + + + + QPrintDialog + + Print + Stampa + + + A0 + A0 + + + A1 + A1 + + + A2 + A2 + + + A3 + A3 + + + A4 + A4 + + + A5 + A5 + + + A6 + A6 + + + A7 + A7 + + + A8 + A8 + + + A9 + A9 + + + B0 + B0 + + + B1 + B1 + + + B2 + B2 + + + B3 + B3 + + + B4 + B4 + + + B5 + B5 + + + B6 + B6 + + + B7 + B7 + + + B8 + B8 + + + B9 + B9 + + + B10 + B10 + + + C5E + C5E + + + DLE + DLE + + + Executive + Executive + + + Folio + Folio + + + Ledger + Ledger + + + Legal + Legal + + + Letter + Letter + + + Tabloid + Tabloid + + + US Common #10 Envelope + US Common #10 Envelope + + + Custom + Personalizzato + + + File exists + Il file esiste + + + <qt>Do you want to overwrite it?</qt> + <qt>Si desidera sovrascriverlo?</qt> + + + A0 (841 x 1189 mm) + A0 (841 x 1189 mm) + + + A1 (594 x 841 mm) + A1 (594 x 841 mm) + + + A2 (420 x 594 mm) + A2 (420 x 594 mm) + + + A3 (297 x 420 mm) + A3 (297 x 420 mm) + + + A4 (210 x 297 mm, 8.26 x 11.7 inches) + A4 (210 x 297 mm, 8.26 x 11.7 inches) + + + A5 (148 x 210 mm) + A5 (148 x 210 mm)>A5 (148 x 210 mm) + + + A6 (105 x 148 mm) + A6 (105 x 148 mm) + + + A7 (74 x 105 mm) + A7 (74 x 105 mm) + + + A8 (52 x 74 mm) + A8 (52 x 74 mm) + + + A9 (37 x 52 mm) + A9 (37 x 52 mm) + + + B0 (1000 x 1414 mm) + B0 (1000 x 1414 mm) + + + B1 (707 x 1000 mm) + B1 (707 x 1000 mm) + + + B2 (500 x 707 mm) + B2 (500 x 707 mm) + + + B3 (353 x 500 mm) + B3 (353 x 500 mm) + + + B4 (250 x 353 mm) + B4 (250 x 353 mm) + + + B5 (176 x 250 mm, 6.93 x 9.84 inches) + B5 (176 x 250 mm, 6.93 x 9.84 pollici) + + + B6 (125 x 176 mm) + B6 (125 x 176 mm) + + + B7 (88 x 125 mm) + B7 (88 x 125 mm) + + + B8 (62 x 88 mm) + B8 (62 x 88 mm) + + + B9 (44 x 62 mm) + B9 (44 x 62 mm) + + + B10 (31 x 44 mm) + B10 (31 x 44 mm) + + + C5E (163 x 229 mm) + C5E (163 x 229 mm) + + + DLE (110 x 220 mm) + DLE (110 x 220 mm) + + + Executive (7.5 x 10 inches, 191 x 254 mm) + Executive (7.5 x 10 pollici, 191 x 254 mm) + + + Folio (210 x 330 mm) + Folio (210 x 330 mm) + + + Ledger (432 x 279 mm) + Ledger (432 x 279 mm) + + + Legal (8.5 x 14 inches, 216 x 356 mm) + Legal (8.5 x 14 pollici, 216 x 356 mm) + + + Letter (8.5 x 11 inches, 216 x 279 mm) + Letter (8.5 x 11 pollici, 216 x 279 mm) + + + Tabloid (279 x 432 mm) + Tabloid (279 x 432 mm) + + + US Common #10 Envelope (105 x 241 mm) + US Common #10 Busta (105 x 241 mm) + + + Print all + Stampa tutto + + + Print selection + Stampa selezione + + + Print range + Stampa intervallo + + + Print current page + Stampa la pagina corrente + + + &Options >> + &Opzioni>> + + + &Print + &Stampa + + + &Options << + &Opzioni + + + Print to File (PDF) + Stampa su file (PDF) + + + Print to File (Postscript) + Stampa su file (Postscript) + + + Local file + File locale + + + Write %1 file + Scrivi %1 file + + + Print To File... + Stampa su file... + + + %1 is a directory. +Please choose a different file name. + %1 è una cartella. +Si prega di scegliere un altro nome. + + + File %1 is not writable. +Please choose a different file name. + %1 non è scrivibile. +Si prega di scegliere un altro nome. + + + %1 already exists. +Do you want to overwrite it? + %1 esiste già. +Si desidera sovrascriverlo? + + + The 'From' value cannot be greater than the 'To' value. + Il valore 'Da' non può superare il valore 'A'. + + + OK + OK + + + + QPrintPreviewDialog + + Page Setup + Formato Pagina + + + + QTerminal + + + Copy + Copia + + + + Paste + Incolla + + + + Select All + Seleziona Tutto + + + + Clear All + Pulisci tutto + + + + QWinTerminalImpl + + + copied selection to clipboard + selezione copiata negli appunti + + + + QsciLexerBash + + Default + Default + + + Error + Errore + + + Comment + Commento + + + Number + Numero + + + Keyword + Parola chiave + + + Double-quoted string + Stringa con doppi apici + + + Single-quoted string + Stringa con singoli apici + + + Operator + Operatore + + + Identifier + Identificatore + + + Scalar + Scalare + + + Parameter expansion + Espansione dei parametri + + + Backticks + Apici inversi + + + Here document delimiter + Delimitatore dello "here document" + + + Single-quoted here document + "Here document" delimitato da singoli apici + + + + QsciLexerBatch + + Default + Default + + + Comment + Commento + + + Keyword + Parola chiave + + + Label + Etichetta + + + Hide command character + Nascondi caratteri di comando + + + External command + Comando esterno + + + Variable + Variabile + + + Operator + Operatore + + + + QsciLexerCPP + + Default + Default + + + Inactive default + Default inattivo + + + C comment + Commento C + + + Inactive C comment + Commento C inattivo + + + C++ comment + Commento C++ + + + Inactive C++ comment + Commento C++ inattivo + + + JavaDoc style C comment + Commento C in stile JavaDoc + + + Inactive JavaDoc style C comment + Commento C inattivo in stile JavaDoc + + + Number + Numero + + + Inactive number + Numero inattivo + + + Keyword + Parola chiave + + + Inactive keyword + Parola chiave inattiva + + + Double-quoted string + Stringa con doppi apici + + + Inactive double-quoted string + Stringa con doppi apici inattiva + + + Single-quoted string + Stringa con singoli apici + + + Inactive single-quoted string + Stringa con singoli apici inattiva + + + IDL UUID + UUID IDL + + + Inactive IDL UUID + UUID IDL inattivo + + + Pre-processor block + Blocco per il precompilatore + + + Inactive pre-processor block + Blocco inattivo per il precompilatore + + + Operator + Operatore + + + Inactive operator + Operatore inattivo + + + Identifier + Identificatore + + + Inactive identifier + Identificatore inattivo + + + Unclosed string + Stringa non terminata + + + Inactive unclosed string + Stringa non terminata inattiva + + + C# verbatim string + Stringa senza formattazione C# + + + Inactive C# verbatim string + Stringa senza formattazione C# inattiva + + + JavaScript regular expression + Espressione regolare JavaScript + + + Inactive JavaScript regular expression + Espressione regolare JavaScript inattiva + + + JavaDoc style C++ comment + Commento C++ in stile JavaDoc + + + Inactive JavaDoc style C++ comment + Commento C++ inattivo in stile JavaDoc + + + Secondary keywords and identifiers + Parole chiave ed identificatori secondari + + + Inactive secondary keywords and identifiers + Parole chiave ed identificatori secondari inattivi + + + JavaDoc keyword + Parola chiave JavaDoc + + + Inactive JavaDoc keyword + Parola chiave JavaDoc inattiva + + + JavaDoc keyword error + Errore in una parola chiave JavaDoc + + + Inactive JavaDoc keyword error + Errore in una parola chiave JavaDoc inattiva + + + Global classes and typedefs + Classi e typedef globali + + + Inactive global classes and typedefs + Classi e typedef globali inattivi + + + Stringa C++ + Stringa "raw" C++ + + + Inactive C++ raw string + Stringa "raw" C++ inattiva + + + + QsciLexerDiff + + Default + Default + + + Comment + Commento + + + Command + Comando + + + Header + Intestazione + + + Position + Posizione + + + Removed line + Riga rimossa + + + Added line + Riga aggiunta + + + Changed line + Riga modificata + + + + QsciLexerMatlab + + Default + Default + + + Comment + Commento + + + Command + Comando + + + Number + Numero + + + Keyword + Parola chiave + + + Single-quoted string + Stringa con singoli apici + + + Operator + Operatore + + + Identifier + Identificatore + + + Double-quoted string + Stringa con doppi apici + + + + QsciLexerPerl + + Default + Default + + + Error + Errore + + + Comment + Commento + + + POD + POD + + + Number + Numero + + + Keyword + Parola chiave + + + Double-quoted string + Stringa con doppi apici + + + Single-quoted string + Stringa con apici singoli + + + Operator + Operatore + + + Identifier + Identificatore + + + Scalar + Scalare + + + Array + Vettore + + + Hash + Hash + + + Symbol table + Tabella dei simboli + + + Regular expression + Espressione regolare + + + Substitution + Sostituzione + + + Backticks + Apici inversi + + + Data section + Sezione dati + + + Here document delimiter + Delimitatore dello "here document" + + + Single-quoted here document + "Here document" delimitato da apici singoli + + + Double-quoted here document + "Here document" delimitato da doppi apici + + + Backtick here document + "Here document" delimitato da apici inversi + + + Quoted string (q) + Stringa delimitata da apici (q) + + + Quoted string (qq) + Stringa delimitata da apici (qq) + + + Quoted string (qx) + Stringa delimitata da apici (qx) + + + Quoted string (qr) + Stringa delimitata da apici (qr) + + + Quoted string (qw) + Stringa delimitata da apici (qw) + + + POD verbatim + POD senza formattazione + + + Subroutine prototype + Prototipo di subroutine + + + Format identifier + Identificatore del formato + + + Format body + Corpo del formato + + + Double-quoted string (interpolated variable) + Stringa con doppi apici (variabile interpolata) + + + Translation + Traduzione + + + Regular expression (interpolated variable) + Espressione regolare (variabile interpolata) + + + Substitution (interpolated variable) + Sostituzione (variabile interpolata) + + + Backticks (interpolated variable) + Apici inversi (variabile interpolata) + + + Double-quoted here document (interpolated variable) + "Here document" delimitato da doppi apici (variabile interpolata) + + + Backtick here document (interpolated variable) + Here document" delimitato da apici inversi (variabile interpolata) + + + Quoted string (qq, interpolated variable) + Stringa delimitata da apici (qq, variabile interpolata) + + + Quoted string (qx, interpolated variable) + Stringa delimitata da apici (qx, variabile interpolata) + + + Quoted string (qr, interpolated variable) + Stringa delimitata da apici (qr, variabile interpolata) + + + + QsciScintilla + + &Undo + &Annulla + + + &Redo + &Ripeti + + + Cu&t + &Taglia + + + &Copy + &Copia + + + &Paste + &Incolla + + + Delete + &Cancella + + + Select All + Seleziona Tutto + + + + QtHandles::Figure + + + Figure ToolBar + Barra degli strumenti delle figure + + + + &File + &File + + + + &New Figure + &Nuova Figura + + + + &Open... + &Apri... + + + + &Save + &Salva + + + + Save &As + Salva &Come + + + + &Close Figure + &Chiudi Figura + + + + &Edit + &Modifica + + + + Cop&y + Co&pia + + + + Cu&t + &Taglia + + + + &Paste + &Incolla + + + + &Help + Ai&uto + + + + &About QtHandles + A Proposito di Qt&Handles + + + + About &Qt + A Proposito di &Qt + + + + About QtHandles + A Proposito di QtHandles + + + + QtHandles::MouseModeActionGroup + + + Rotate + Ruota + + + + Zoom + Zoom + + + + Pan + Panoramica + + + + Select + Seleziona + + + + S: + + + + Get translations for open and closing quotation marks. The message catalog should translate "`" to a left quotation mark suitable for the locale, and similarly for "'". For example, a French Unicode local should translate these to U+00AB (LEFT-POINTING DOUBLE ANGLE QUOTATION MARK), and U+00BB (RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK), respectively. If the catalog has no translation, we will try to use Unicode U+2018 (LEFT SINGLE QUOTATION MARK) and Unicode U+2019 (RIGHT SINGLE QUOTATION MARK). If the current locale is not Unicode, locale_quoting_style will quote 'like this', and clocale_quoting_style will quote "like this". You should always include translations for "`" and "'" even if U+2018 and U+2019 are appropriate for your locale. If you don't know what to put here, please see <http://en.wikipedia.org/wiki/Quotation_marks_in_other_languages> and use glyphs suitable for your language. + TODO + + + + + documentation_dock_widget + + + Documentation + Documentazione + + + + See the documentation for help. + Si faccia riferimento alla documentazione per maggiori informazioni. + + + + file_editor + + + + + + + + Octave Editor + Editor di Octave + + + + Octave Files (*.m);;All Files (*) + File di Octave (*.m);;Tutti i File (*) + + + + New Function + Nuova Funzione + + + + New function name: + + Nome della nuova funzione: + + + + File not saved! A file with the selected name +%1 +is already open in the editor + File non salvato! Un file chiamato +%1 +è già aperto nell'editor + + + + &%1 %2 + &%1 %2 + + + + &Save File + &Salva File + + + &Open File... + &Apri... + + + &New Script + &Nuovo Script + + + + Save File &As... + Salva &Come... + + + + Print... + Stampa... + + + + &Undo + Annu&lla + + + + &Redo + &Ripeti + + + + &Copy + &Copia + + + + Cu&t + &Taglia + + + + Paste + Incolla + + + + Select All + Seleziona Tutto + + + + &Commands + Co&mandi + + + + Delete Line + Cancella riga + + + + Copy Line + Copia riga + + + + Cut Line + Taglia riga + + + + Delete to Start of Word + Cancella fino a inizio parola + + + + Delete to End of Word + Cancella fino a fine parola + + + + Delete to Start of Line + Cancella fino a inizio riga + + + + Delete to End of Line + Cancella fino a fine riga + + + + Duplicate Selection/Line + Duplica selezion/riga + + + + Transpose Line + Trasponi riga + + + + &Show Completion List + Mostra &lista di completamento + + + + &Format + &Formatta + + + + &Uppercase Selection + Rendi &Maiuscola la selezione + + + + &Lowercase Selection + Rendi Mi&nuscola la selezione + + + + Convert Line Endings to &Windows (CRLF) + A Capo in Stile &Windows (CRLF) + + + + Convert Line Endings to &Unix (LF) + A Capo in Stile &Unix (LF) + + + + Convert Line Endings to &Mac (CR) + A Capo in Stile &Mac (CR) + + + + Navi&gation + Navi&gazione + + + + &Next Bookmark + Segnalibro &Successivo + + + + Pre&vious Bookmark + Segnalibro &Precedente + + + + Toggle &Bookmark + Attiva/disattiva &Segnalibro + + + + &Remove All Bookmarks + &Elimina Tutti i Segnalibri + + + + &View + &Vista + + + + &Editor + &Editor + + + + Show &Line Numbers + Mostra Numeri di &Riga + + + + Show &White Spaces + Mostra &Spazi + + + + Show Line &Endings + Mostra a &Capo + + + + Show &Indentation Guides + Mostre Guide &Indentazione + + + + Show Long Line &Marker + Mostra &Marcatori di Linea Lunga + + + + Zoom &In + &Ingrandisci + + + + Zoom &Out + &Riduci + + + + &Normal Size + Dimensione &Normale + + + + &Next Breakpoint + &Breakpoint Successivo + + + + Pre&vious Breakpoint + &Breakpoint Precedente + + + + Toggle &Breakpoint + Attiva/Disattiva &Breakpoint + + + + &Remove All Breakpoints + &Rimuovi Tutti i Breakpoint + + + + &Comment + &Commenta + + + + &Uncomment + &Decommenta + + + + &Indent + &Indenta + + + + &Unindent + &Rimuovi Indentazione + + + + &Find and Replace... + &Trova e Sostituisci... + + + + Save File and Run + Salva ed Esegui + + + + Go &to Line... + Vai &alla Riga... + + + + Could not start custom file editor +%1 + Impossibile avviare l'editor di file personalizzato +%1 + + + + &Recent Editor Files + &Documenti Recenti + + + + &Edit Function + &Modifica Funzione + + + + &Close + &Chiudi + + + + Close All + Chiudi Tutto + + + + Close Other Files + Chiudi gli Altri File + + + + &Preferences... + &Preferenze... + + + + &Styles Preferences... + &Preferenze di stile... + + + + Run &Selection + Esegui &Selezione + + + + &Help + &Aiuto + + + + &Help on Keyword + &Aiuto su Parola Chiave + + + + &Documentation on Keyword + &Documentazione sulla Parola Chiave + + + + Could not open file +%1 +for read: %2. + Impossibile aprire +%1 +in lettura: %2. + + + + File +%1 +does not exist. Do you want to create it? + Il file +%1 +non esiste. Si desidera crearlo? + + + + Could not open file +%1 +for write: %2. + Impossibile aprire +%1 +in scrittura: %2. + + + + The associated file editor tab has disappeared. + La scheda corrispondente nell'editor è scomparsa. + + + + &File + &File + + + New &Function... + Nuova &Funzione... + + + + &Edit + &Modifica + + + + &Debug + &Debug + + + + &Run + &Esegui + + + + file_editor_tab + + + eol: + fine della riga: + + + + line: + riga: + + + + col: + riga: + + + + %1 is a built-in function + %1 è una funzione built-in + + + + Can not find function %1 + Impossibile trovare la funzione %1 + + + + + + + + + Octave Editor + Editor di Octave + + + + Goto line + Vai alla riga + + + + Line number + Numero riga + + + + + <unnamed> + <senza nome> + + + + Do you want to save or discard the changes? + Si desidera salvare o annullare le modifiche? + + + + Do you want to cancel closing, save or discard the changes? + Si desidera annullare l'operazione di chiusura, salvare o annullare le modifiche? + + + + The file +%1 +is about to be closed but has been modified. +%2 + Il file +%1 +sta per essere chiuso ma è stato modificato. +%2 + + + + Octave Files (*.m);;All Files (*) + File di Octave (*.m);;Tutti i File (*) + + + + + +Warning: The contents in the editor is modified! + + +Attenzione: il contenuto nell'editor è modificato! + + + + It seems that the file +%1 +has been deleted or renamed. Do you want to save it now?%2 + Sembra che il file +%1 +sia stato rinominato o rimosso. Si desidera salvarlo ora?%2 + + + + Could not open file %1 for write: +%2. + Impossibile aprire %1 in scrittura: +%2. + + + Line: + Riga: + + + Col: + Car: + + + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + "%1" +non è un nome valido. + +Se lo si mantiene, non si potrà invocare +lo script come comando Octave. + +Si desidera scegliere un altro nome? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? + Sembra che '%1' sia stato modificato da un'altra applicazione. Si desidera ricaricarlo? + + + + files_dock_widget + + + File Browser + Gestore dei File + + + + Browse your files. + Esplorare i prorpi file. + + + + Enter the path or filename + Inserire il percorso o il nome del file + + + + Move up one directory + Cartella precedente + + + + Actions on current directory + Azioni sulla cartella corrente + + + + Set Browser Directory... + Scegliere la Cartella del Gestore... + + + + + Find Files... + Cerca File... + + + New File + Nuovo File + + + + New Directory + Nuova Cartella + + + + Double-click a file to open it + Fare doppio click su un file per aprirlo + + + + Show Octave directory + Mostra la cartella di Octave + + + + Go to current Octave directory + Vai alla directory corrente di Octave + + + + Set Octave directory + Scegli la cartella di Octave + + + + Set Octave directroy to current browser directory + Scegli la directory corrente come directory di Octave + + + + Show Home Directory + Mostra la Cartella Personale + + + Search Directory... + Cerca Cartella... + + + + + New File... + Nuovo File... + + + + + New Directory... + Nuova Cartella... + + + + File size + Dimensione + + + + File type + Tipo + + + + Date modified + Data ultima modifica + + + + Show hidden + Mostra file nascosti + + + + Open + Apri + + + + Open in Default Application + Apri con l'Applicazione Predefinita + + + + Copy Selection to Clipboard + Copia Selezione negli Appunti + + + + Run + Esegui + + + + Load Data + Carica Dati + + + + Set Current Directory + Seleziona la Cartella Corrente + + + + Rename... + Rinomina... + + + + Delete... + Elimina... + + + Rename + Rinomina + + + Delete + Elimina + + + + Rename file/directory + Rinomina file/cartella + + + + Rename file/directory: + + Rinomina file/cartella: + + + + + + to: + + a: + + + + + Delete file/directory + Elimina file/cartella + + + + Are you sure you want to delete + + Si è sicuri di voler eliminare + + + + + Can not delete a directory that is not empty + Impossibile eliminare una cartella non vuota + + + + Set directory of file browser + Seleziona la cartella del gestore di file + + + + Create File + Nuovo File + + + + Create file in + + String ends with \n! + Nuovo file in + + + + + New File.txt + Nuovo.txt + + + + Create Directory + Nuova Cartella + + + + Create folder in + + String ends with \n! + Nuova cartella in + + + + + final_page + + + Enjoy! + Buon lavoro! + + + + Previous + Precedente + + + + Finish + Finito + + + + Cancel + Annulla + + + + <html><body> +<p>We hope you find Octave to be a useful tool.</p> +<p>If you encounter problems, there are a number of ways to get help, including commercial support options, a mailing list, a wiki, and other commnity-based support channels. +You can find more information about each of these by visiting <a href="http://octave.org/support.html">http://octave.org/support.html</a> (opens in external browser).</p> +</body></html> + <html><body> +<p>Speriamo che troverai Octave un programma utile.</p> +<p>Se incontri dei problemi, ci sono molto modi per ottenere aiuto, incluse possibilità di supporto commerciale, una mailing list, una wiki ed altri canali di supporto basati sulla comunità. +Puoi trovare maggiori informazioni su ciascuno di essi visitando <a href="http://octave.org/support.html">http://octave.org/support.html</a> (utilizza un browser esterno).</p> +</body></html> + + + + <html><head> +<style> +a:link { text-decoration: underline; color: #0000ff; } +</style> +<head/><body> +<p>For more information about Octave:</p> +<ul> +<li>Visit <a href="http://octave.org">http://octave.org</a> (opens in external browser)</li> +<li>Get the documentation online as <a href="http://www.gnu.org/software/octave/doc/interpreter/index.html">html</a>- or <a href="http://www.gnu.org/software/octave/octave.pdf">pdf</span></a>-document (opens in external browser)</li> +<li>Open the documentation browser of the Octave GUI with the help menu</li> +</ul> +</body></html> + <html><head> +<style> +a:link { text-decoration: underline; color: #0000ff; } +</style> +<head/><body> +<p>Per maggiori informazioni su Octave:</p> +<ul> +<li>visita <a href="http://octave.org">http://octave.org</a> (utilizza un browser esterno)</li> +<li>Puoi trovare la documentazione online agli indirizzi <a href="http://www.gnu.org/software/octave/doc/interpreter/index.html">html</a>- o <a href="http://www.gnu.org/software/octave/octave.pdf">pdf</span></a> (utilizza un browser esterno)</li> +<li>Apri la documentazione dell'interfaccia grafica di Octave utilizzando il menu help</li> +</ul> +</body></html> + + + + find_dialog + + + Find and Replace + Trova e Sostituisci + + + + Find &what: + T&rova: + + + + Re&place with: + Sos&tituisci con: + + + + Match &case + Maiuscole/&minuscole + + + + Search from &start + Cerca dall'i&nizio + + + + &Wrap while searching + &Evidenzia durante la ricerca + + + + &Find Next + &Trova Successivo + + + + Find &Previous + Trova &Precedente + + + + &Replace + &Sostituisci + + + + Replace &All + S&ostituisci Tutto + + + + &More... + &Avanzate... + + + + &Whole words + Paro&le intere + + + + Regular E&xpressions + Espressioni Re&golari + + + + Search &backward + Cerca &indietro + + + + Search se&lection + Cerca nella sele&zione + + + + Search from end + Cerca dalla fine + + + + Search from start + Cerca dall'inizio + + + + Replace Result + Sostituisci Risultato + + + + %1 items replaced + %1 occorrenze sostituite + + + + Find Result + Trova Risultato + + + + No more matches found + Nessun'altra corrispondenza trovata + + + + find_files_dialog + + + Find Files + Cerca File + + + + Named: + Chiamato: + + + + Start in: + Comincia da: + + + + Enter the start directory + Inserire la cartella di partenza + + + + Browse... + Esplora... + + + + Browse for start directory + Seleziona la cartella di partenza + + + + Search recursively through directories for matching files + Cerca ricorsivamente nella gerarchia di cartelle + + + + Include matching directories in search results + Includi cartelle nei risultati di ricerca + + + + Name case insensitive + Nessuna distinzione maiuscole/minuscole nel nome + + + + Set matching name is case insensitive + Nessuna distinzione maiuscole/minuscole per le corrispendenze fra nomi + + + + Contains text: + Contiene il testo: + + + + Enter the filename search expression + Inserire una espressione da ricercare nel nome del file + + + + Search subdirectories + Ricerca nelle sottocartelle + + + + Include directory names + Includi i nomi di cartelle + + + + Enter the file content search expression + Inserisci un'espressione da ricercare nel contenuto del file + + + + Text to match + Testo da trovare + + + + Text case insensitive + Testo senza distinzione maisucole/minuscole + + + + Set text content is case insensitive + Nessuna distinzione maiuscole/minuscole nel contenuto del testo + + + + Search results + Risultati della ricerca + + + + Idle. + Inattivo. + + + + Find + Cerca + + + + Start search for matching files + Inizia la ricerca + + + + Stop + Interrompi + + + + Stop searching + Interrompi la ricerca + + + + File name/location + Nome del file/posizione + + + + File contents + Contenuti + + + + Searching... + Ricerca in corso... + + + + %1 match(es) + %1 corrispondenze + + + + Set search directory + Scegli la cartella di ricerca + + + + find_files_model + + + Filename + Nome del file + + + + Directory + Cartella + + + + history_dock_widget + + + Browse and search the command history. + Naviga nello storico dei comandi. + + + + Double-click a command to transfer it to the terminal. + Fare doppio click su un comando per trasferirlo nel termianle. + + + + Enter text to filter the command history. + Inserire del testo per filtrare lo storico dei comandi. + + + + Command History + Storico dei comandi + + + + Copy + Copia + + + + Evaluate + Valuta + + + + Create script + Crea script + + + + initial_page + + + Welcome to Octave! + Benvenuto in Octave! + + + + Next + Successivo + + + + Cancel + Annulla + + + + <html><body> +<p>You seem to be using the Octave graphical interface for the first time on this computer. +Click 'Next' to create a configuration file and launch Octave.</p> +<p>The configuration file is stored in<br>%1.</p> +</body></html> + <html><body> +<p>Sembra che si stia utilizzando l'interfaccia grafica di Octave per la prima volta su questo computer. +Fare click su 'Successivo' per creare un file di configurazione e lanciare Octave.</p> +<p>Il file di configurazione verrà salvato in<br>%1.</p> +</body></html> + + + + main_window + + + Load Workspace + Carica lo Spazio di Lavoro + + + + + About Octave + A proposito di Octave + + + + &File + &File + + + + New + Nuovo + + + Figure + Figura + + + + Open... + Apri... + + + + Preferences... + Preferenze... + + + + Exit + Esci + + + + &Edit + &Modifica + + + + Undo + Annulla + + + + Copy + Copia + + + + Paste + Incolla + + + + Save Workspace As + Salva lo Spazio di Lavoro Come + + + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + Il file %1 +non può essere eseguito perché il suo +nome non è un identificatore valido. + +Si desidera eseguire +%2 +invece? + + + + The release notes file '%1' is empty. + Il file delle note di rilascio '%1' è vuoto. + + + + The release notes file '%1' cannot be read. + Il file delle note di rilascio '%1' non può essere letto. + + + + Octave Release Notes + Note di Rilascio di Octave + + + + Octave Community News + Notizie dalla Comunità di Octave + + + + Open an existing file in editor + Apri file esistente nell'editor + + + + New Function... + Nuova Funzione... + + + + New Figure + Nuova Figura + + + + Select All + Seleziona Tutto + + + + Clear Clipboard + Pulisci Appunti + + + + Find Files... + Trova File... + + + + Clear Command Window + Pulisci la Finestra dei Comandi + + + + Clear Command History + Pulisci lo Storico dei Comandi + + + + Clear Workspace + Pulisci lo Spazio di Lavoro + + + + De&bug + De&bug + + + + Step + Un'istruzione alla volta + + + + Continue + Continua + + + + Are you sure you want to exit Octave? + Si è sicuri di voler uscire da Octave? + + + Exit Debug Mode + Abbandona la Modalità di Debug + + + + Show File Browser + Nostra l'Esploratore di Risorse + + + + File Browser + Esploratore di Risorse + + + + <strong>You are using a release candidate of Octave's experimental GUI.</strong> Octave is under continuous improvement and the GUI will be the default interface for the 4.0 release. For more information, select the "Release Notes" item in the "News" menu of the GUI, or visit <a href="http://octave.org">http://octave.org</a>. + <strong>Stai utilizzando un 'candidato al rilascio' dell'interfaccia grafica sperimentale.</strong> Octave è in continuo miglioramento e l'interfaccia grafica sarà l'interfaccia di default per la versione 4.0. Per maggiori informazioni, seleziona la voce "Note di Rilascio" nel menu "Notizie" dell'interfaccia grafica o visita <a href="http://octave.org">http://octave.org</a>. + + + + Step In + Entra + + + + + Octave + Octave + + + + Load Workspace... + Apri Spazio di Lavoro... + + + + Save Workspace As... + Salva Spazio di Lavoro Come... + + + + New Script + Nuovo Script + + + Function... + Funzione... + + + + Step Out + Esci + + + + Quit Debug Mode + Esci dalla modalità di Debug + + + + Reset Default Window Layout + Ripristina il Layout della Finestra + + + + Octave Packages + Octave Packages + + + + Share Code + Condividi Codice (Agorà) + + + + Contribute to Octave + Contribuisci + + + + Octave Developer Resources + Risorse per Sviluppatori + + + + On Disk + Su Disco + + + + Online + In Linea + + + + &News + &Notizie + + + + Release Notes + Note di Rilascio + + + + Community News + Notizie dalla Comunità + + + + More Info + Maggiori Informazioni + + + + Hide + Nascondi + + + + + Experimental GUI Info + Informazioni sull'Interfaccia Grafica Sperimentale + + + + Enter directory name + Inserisci nome cartella + + + + Current Directory: + Cartella Corrente: + + + + One directory up + Livello precedente + + + + + Browse directories + Naviga cartelle + + + + &Window + &Finestra + + + + Show Command Window + Mostra la Finestra dei Comandi + + + + Show Command History + Mostra lo Storico dei Comandi + + + + Show Workspace + Mostra lo Spazio di Lavoro + + + + Show Editor + Mostra l'Editor + + + + Show Documentation + Mostra la Documentazione + + + + Command Window + Finestra dei Comandi + + + + Command History + Storico dei Comandi + + + + Workspace + Spazio di lavoro + + + + Editor + Editor + + + + + Documentation + Documentazione + + + + &Help + &Aiuto + + + + Report Bug + Segnala un Problema + + + + news_reader + + + <html> +<body> +<p> +Octave's community news source seems to be unavailable. +</p> +<p> +For the latest news, please check +<a href="http://octave.org/community-news.html">http://octave.org/community-news.html</a> +when you have a connection to the web (link opens in an external browser). +</p> +<p> +<small><em>&mdash; The Octave Developers, + <html> +<body> +<p> +Le notizie dalla comunità di Octave non sembrano essere disponibili. +</p> +<p> +Per le ultime novità, si prega di controllare +<a href="http://octave.org/community-news.html">http://octave.org/community-news.html</a> +avendo a disposizione una connesione ad internet (utilizza un browser esterno). +</p> +<p> +<small><em>&mdash; Gli Sviluppatori di Octave, + + + + <html> +<body> +<p> +Connecting to the web to display the latest Octave Community news has been disabled. +</p> +<p> +For the latest news, please check +<a href="http://octave.org/community-news.html">http://octave.org/community-news.html</a> +when you have a connection to the web (link opens in an external browser) +or enable web connections for news in Octave's network settings dialog. +</p> +<p> +<small><em>&mdash; The Octave Developers, + <html> +<body> +<p> +La connessione ad internet per mostrare le ultime notizie dalla comunità di Octave non è abilitata. +</p> +<p> +Per le ultime novità, si prega di controllare +<a href="http://octave.org/community-news.html">http://octave.org/community-news.html</a> +avendo a disposizione una connesione ad internet (utilizza un browser esterno) +o di abilitare, nella finestra delle impostazioni di rete di Octave, la connessione ad internet per le notizie. +</p> +<p> +<small><em>&mdash; Gli Sviluppatori di Octave, + + + + octave_dock_widget + + + + Undock widget + Rimuovi widget dal lanciatore + + + + Hide widget + Nascondi widget + + + + Dock widget + Ancora widget al lanciatore + + + + octave_qscintilla + + + Help on + Aiuto su + + + + Documentation on + Documentazione su + + + + Edit + Modifica + + + &Run Selection + &Esegui Selezione + + + + octave_qt_link + + + + + Yes + + + + + No + No + + + + File +%1 +does not exist. Do you want to create it? + Il file +%1 +non esiste. Si desidera crearlo? + + + + Octave Editor + Editor di octave + + + + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + Il file %1 non esiste nelle cartelle di esecuzione. Per lanciare o eseguire il debug della funzione in corso di modifica, è necessario passare alla cartella %2 o aggiungere tale cartella alle cartelle di esecuzione. + + + + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + Il file %1 è nascosto da un file con lo stesso nome presente nelle cartelle di esecuzione. Per lanciare o esguire il debug del file in corso di modifica, passare alla directory %2. + + + + Change Directory or Add Directory to Load Path + Cambia Cartella o Aggiungi Cartella alle Cartelle di Esecuzione + + + + Change Directory + Cambia Cartella + + + + Add Directory to Load Path + Aggiungi Cartella alle Cartelle di esecuzione + + + + Cancel + Annulla + + + + resource_manager + + + The settings file +%1 +does not exist and can not be created. +Make sure you have read and write permissions to +%2 + +Octave GUI must be closed now. + Il file di configurazione +%1 +non esiste e non può essere creato. +Assicurasi di avere permesso di lettura e scrittura in +%2 + +L'inerfaccia grafica verrà chiusa. + + + + Octave Critical Error + Errore Critico di Octave + + + + settings_dialog + + + + Settings + Impostazioni + + + + + General + Genrale + + + + + Octave logo only + Logo di Octave solamente + + + + + Letter icons + Icone testuali + + + + + Graphic icons + Icone grafiche + + + + + Dock widget title bar + Barra del titolo del lanciatore di widget + + + + + Confirm before exiting + Conferma prima di uscire + + + + + Custom style + Stile personalizzato + + + + + Background color + Colore dello sfondo + + + + + Text color + Colore del testo + + + + + + + Show status bar + Mostra barra di stato + + + + + Editor + Editor + + + + + After Column + Numero di colonne + + + + + Color + Colore + + + + + This works well for monospaced fonts. The line is drawn at a position based on the width of a space character in the default font. It may not work very well if styles use proportional fonts or if varied font sizes or bold, italic and normal texts are used. + Questa impostazione è adatta a tipi di caratteri monospaced. La linea è posta in una posizione basata sulla larghezza di uno spazio bianco del tipo di carattere predefinito. Può non funzionare bene se gli stili usano stili di caratteri proporzionali o se diverse dimensioni di carattere, grassetto, corsivo sono utilizzati. + + + + + Draw a long line marker + Disegna un marcatore di linea lungo + + + + + Enable Code Folding + Attiva espansione del codice + + + + Show eol characters + Mostra terminatore di riga + + + + Default eol mode + Terminatore predefinito + + + + Windows (CRLF) + Windows (CRLF) + + + + Mac (CR) + Mac (CR) + + + + Unix (LF) + Unix (LF) + + + + + Indent width + Ampiezza indentazione + + + + + Tab indents line + Tasto Tab per l'indentazione + + + + + Auto indentation + Indentazione automatica + + + + + Tab width + Ampiezza tabulazione + + + + + Show indentation guides + Mostra guide per l'indentazione + + + + + Backspace unindents line + Tasto Backspace per rimuove l'indentazione + + + + + Auto completion + Completamento automatico + + + + + Match keywords + Abbina parole chiave + + + + + Case sensitive + Distinzione maiuscole/minuscole + + + + + Replace word by suggested one + Sostituisci una parola con quella suggerita + + + + + Match words in document + Abbina parole nel documento + + + + + Restore editor tabs from previous session on startup + Ripristina le schede dell'editor dalla sessione precedente all'avvio + + + + + Use custom file editor + Utilizza editor personalizzato + + + + + emacs +%l %f + emacs +%l %f + + + + + Editor Styles + Stili dell'Editor + + + + + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> + <html><head/><body><p>Seleziona stile di carattere, dimensione carattere (come differenza dalla dimensione iniziale), stile del carattere (<b>g</b>rassetto, <b>c</b>orsivo, <b>s</b>ottolinea), colore del testo e colore dello sfondo (per il quale il colore rosa (255, 0, 255) indica il colore di default).</p></body></html> + + + + + Terminal Colors + Colori del Terminale + + + + + Font + Stile di carattere + + + + + Show line numbers + Mostra numero di riga + + + + + Highlight current line + Evidenzia la riga corrente + + + Code completion + Completamento del codice + + + + + Show complete path in window title + Mostra il percorso completo nel titolo della finestra + + + + + Show whitespace + Mostra spazi + + + + + Do not show whitespace used for indentation + Non mostrare gli spazi utilizzati per l'indentazione + + + # of characters typed before completion list displayed + Numero i caratteri da digitare prima che la lista di completamento appaia + + + + + Create nonexistent files without prompting + Crea file inesistenti senza chiedere conferma + + + + + command line (%f=file, %l=line): + linea di comando (%f=file, %l=riga): + + + + + Terminal + Terminale + + + + + Cursor type: + Tipo di cursore: + + + + + Cursor blinking + Lampeggiamento del cursore + + + + + Use foreground color + Usa colore di primo piano + + + + + Font size + Dimensione carattere + + + + + Set focus to terminal when running a command from within another widget + Rendi il terminale la finestra attiva quando un comando è eseguito da uno widget + + + + + File Browser + Gestore dei file + + + + + Show file size + Mostra dimensione del file + + + + + Show file type + Mostra tipo del file + + + + + Show date of last modification + Mostra la data di ultima modifica + + + + + Show hidden files + Mostra i file nascosti + + + + + Interface + Interfaccia + + + + + Octave Startup + Avvio di Octave + + + + + These preferences are applied after the startup files like .octaverc. + Queste preferenze sono applicate dopo l'esecuzione del file di avvio .octaverc. + + + + + + + Startup path + Percorso di avvio + + + + + + + Browse + Naviga + + + + + Restore last Octave directory of previous session + Ripristina la cartella Octave della sessione precedente + + + + + Tab width min. + Ampiezza tabulazione min. + + + + + max. + max. + + + + + With Octave builtins + Con built-in di Octave + + + + + With Octave functions + Con funzioni di Octave + + + + + Number of characters before list is shwon: + Numero di caratteri da digitare prima che la lista appaia: + + + + + Show completion list automatically + Mostra lista di completamento automaticamente + + + + + Reload externally changed files without prompt + Ricarica file modificati esternamente senza chiedere + + + + + (Changing buffer size clears history) + (Il cambio della dimensione della lista svuota lo storico comandi) + + + + + History buffer Size + Dimensione storico comandi + + + + + Display + Mostra + + + + + Alternating row colors + Colori alternati per le righe + + + + + Behavior + Comportamento + + + + + Restore last directory of previous session + Ripristina l'ultima cartella della sessione precedente + + + + + Workspace + Spazio di lavoro + + + Storage Class Colors + Colori della Storage Class + + + + + Network + Rete + + + + + Allow Octave to connect to the Octave web site to display current news and information + Pemetti ad Octave di connettersi al sito web di Octave per mostrare notizie ed informazioni aggiornate + + + + + Use proxy server + Usa server proxy + + + + + HttpProxy + HttpProxy + + + + + Icon set for dock widgets + Icone per il lanciatore degli widget + + + + + Language (requires restart) + Lingua (richiede riavvio) + + + + + Icon size + Dimensione icona + + + + + Synchronize Octave working directory with file browser + Sincronizza la cartella di lavoro di Octave con il gestore dei file + + + + + Colors for variable attributes + Colori per attributi variabili + + + + + Hide tool tip + Nascondi tooltip + + + + + Shortcuts + Scorciatoie + + + + + Select this option to prevent conflicts with readline shortcuts + Seleziona questa opzione per evitrare conflitti con le scorciatoie readline + + + + + Disable global shortcuts when terminal window has focus + Disabilita le scorciatoie globali quando il terminale è selezionato + + + + + + + Use this set + Utilizza questo insieme + + + + + Set 1: + Insieme 1: + + + + + + + Export + Esporta + + + + + + + Import + Importa + + + + + Set 2: + Insieme 2: + + + + + Edit an actual shortcut by double clicking into the related cell + Modifica una scorciatoia facendo doppio click nella relativa cella + + + + + Action + Azione + + + + + Set 1 Default + Insieme 1 predefinito + + + + + Set 1 Actual + Ineieme 1 attuale + + + + + Set 2 Default + Insieme 2 predefinito + + + + + Set 2 Actual + Insieme 2 attuale + + + + + Socks5Proxy + Socks5Proxy + + + + + Hostname: + Nome host: + + + + + Proxy type: + Tipo di proxy: + + + + + Port: + Porta: + + + + + Username: + Nome utente: + + + + + Password: + Password: + + + + + + System setting + Parametri di sistema + + + + IBeam Cursor + Cursore IBeam + + + + Block Cursor + Cursore blocco + + + + Underline Cursor + Cursore testo sottolineato + + + + Difference to the default size + Differenza rispetto alla dimensione di default + + + + Background color, pink (255,0,255) means default + Colore dello sfondo; rosa (255,0,255) indica default + + + + b + short form for bold + g + + + + i + short form for italic + c + + + + u + short form for underlined + s + + + + Set Octave Startup Directory + Scegli la Cartella di Avvio di Octave + + + + Set File Browser Startup Directory + Scegli la Cartella di Avvio del Gestore di File + + + + setup_community_news + + + Community News + Notizie dalla Comunità + + + + Previous + Precedente + + + + Next + Successivo + + + + Cancel + Chiudi + + + + <html><body> +<p>When the Octave GUI starts, it will check the Octave web site for current news and information about the Octave community. +The check will happen at most once each day and news will only be displayed if there is something new since the last time you viewed the news.</p> +<p>You may also view the news by selecting the "Community News" item in the "Help" menu in the GUI, or by visiting +<a href="http://octave.org/community-news.html">http://octave.org/community-news.html</a>.</p> +</body></html> + <html><body> +<p>Ad ogni avvio dell'interfaccia grafica, l'applicazione controllerà il sito web di Octave per ottenere notizie ed informazioni recenti dalla comunità. Tale controllo averrà non più di una volta al giorno e la finestra delle notizie verrà aperta soltanto nel caso in cui ci sia qualcosa di nuovo rispetto all'ultima consultazione</p> +<p>Le notizie possono essere raggiunte anche selezionando "Notizie dalla Comunità" nel menu "Aiuto" dell'interfaccia grafica, o visitando +<a href="http://octave.org/community-news.html">http://octave.org/community-news.html</a>.</p> +</body></html> + + + + <html><head> +<style> +a:link { text-decoration: underline; color: #0000ff; } +</style> +<head/><body> +<p>Allow Octave to connect to the Octave web site when it starts to display current news and information about the Octave community.</p> +</body></html> + <html><head> +<style> +a:link { text-decoration: underline; color: #0000ff; } +</style> +<head/><body> +<p>Permetti all'applicazione di connettersi all'avvio al sito web di Octave per mostrare notizie ed informazione recenti dalla comunità.</p> +</body></html> + + + + shortcut_manager + + + New File + Nuovo File + + + + New Function + Nuova Funzione + + + + New Figure + Nuova Figura + + + + Open File + Apri File + + + + Load Workspace + Carica lo Spazio di Lavoro + + + + Save Workspace As + Salva lo Spazio di Lavoro Come + + + + + Preferences + Preferenze + + + + Exit Octave + Esci da Octave + + + + + Copy + Copia + + + + + Paste + Incolla + + + + + Undo + Annulla + + + + + Select All + Seleziona Tutto + + + + Clear Clipboard + Pulisci Appunti + + + + Find in Files + Cerca nei file + + + + Clear Command Window + Pulisci la Finestra dei Comandi + + + + Clear Command History + Pulisci lo Storico dei Comandi + + + + Clear Workspace + Pulisci lo Spazio di Lavoro + + + + Step Over + Scavalca + + + + Step Into + Livello Successivo + + + + Step Out + Livello Precedente + + + + Continue + Continua + + + + Quit Debug Mode + Esci dalla modalità di Debug + + + + Show Command Window + Mostra la Finestra dei Comandi + + + + Show Command History + Mostra lo Storico dei Comandi + + + + Show File Browser + Nostra l'Esploratore di Risorse + + + + Show Workspace + Mostra lo Spazio di Lavoro + + + + Show Editor + Mostra l'Editor + + + + Show Documentation + Mostra la Documentazione + + + + Command Window + Finestra dei Comandi + + + + Command History + Storico dei comandi + + + + File Browser + Gestore dei File + + + + Workspace + Spazio di lavoro + + + + + Editor + Editor + + + + Documentation + Documentazione + + + + Reset Window Layout + Ripristina il Layout della Finestra + + + + Show Ondisk Documentation + Mostra la Documentazione su Disco + + + + Show Online Documentation + Mostra la Documentazione in Linea + + + + Report a Bug + Segnala un Problema + + + + Octave Packages + Octave Packages + + + + Share Code + Condividi Codice + + + + Contribute to Octave + Contribuisci + + + + Octave Developer Resources + Risorse per Sviluppatori + + + + About Octave + A proposito di Octave + + + + Release Notes + Note di Rilascio + + + + Community News + Notizie dalla Comunità + + + + Edit Function + Modifica Funzione + + + + Save File + Salva File + + + + Save File As + Salva File Come + + + + Close + Chiudi + + + + Close All + Chiudi Tutto + + + + Close Other + Chiudi Altro + + + + Print + Stampa + + + + Redo + Ripeti + + + + Cuy + Taglia + + + + Find and Replace + Trova e Sostituisci + + + + Delete to Start of Word + Cancella fino a inizio parola + + + + Delete to End of Word + Cancella fino a fine parola + + + + Delete to Start of Line + Cancella fino a inizio riga + + + + Delete to End of Line + Cancella fino a fine riga + + + + Delete Line + Cancella riga + + + + Copy Line + Copia riga + + + + Cut Line + Taglia riga + + + + Duplicate Selection/Line + Duplica selezione/riga + + + + Transpose Line + Trasponi riga + + + + Completion List + Lista di completamento + + + + Comment Selection + Commenta selezione + + + + Uncomment Selection + Decommenta selezione + + + + Uppercase Selection + Rendi la selezione in maisucolo + + + + Lowercase Selection + Rendi la selezione in minuscolo + + + + + Indent Selection + Indenta selezione + + + + + Unindent Selection + Deindenta selezione + + + + Convert Line Ednings to Windows + Converti terminatore di riga a Windows + + + + Convert Line Ednings to Unix + Converti terminatore di riga a Unix + + + + Convert Line Ednings to Mac + Converti terminatore di riga a Mac + + + + Goto Line + Vai alla riga + + + + Toggle Bookmark + Attiva/disattiva Segnalibro + + + + Next Bookmark + Segnalibro Successivo + + + + Previous Bookmark + Segnalibro Precedente + + + + Remove All Bookmark + Elimina Tutti i Segnalibri + + + + Styles Preferences + Preferenze di stile + + + + Show Line Numbers + Mostra numeri di riga + + + + Show White Spaces + Mostra spazi + + + + Show Line Endings + Mostra terminatori di riga + + + + Show Indentation Guides + Mostra guide per l'indentazione + + + + Show Long Line Marker + Mostra marcatori linea lunga + + + + Zoom In + Ingrandisci + + + + Zoom Out + Riduci + + + + + Zoom Normal + Dimensione normale + + + + Toggle Breakpoint + Attiva/disattiva Breakpoint + + + + Next Breakpoint + Breakpoint Successivo + + + + Previous Breakpoint + Breakpoint Precedente + + + + Remove All Breakpoints + Rimuovi Tutti i Breakpoint + + + + Run File + Esegui File + + + + Run Selection + Esegui Selezione + + + + Help on Keyword + Aiuto su Parola Chiave + + + + Document on Keyword + Documentazione sulla Parola Chiave + + + + Main + Principale + + + + + File + File + + + + + Edit + Modifica + + + + + Debug + Debug + + + + Window + Finestra + + + + + Help + Aiuto + + + + News + Novità + + + + View + Vista + + + + Run + Esegui + + + + Enter new Shortcut for Set %1 + Inserisci nuova Scorciatoia per l'Insieme %1 + + + + Apply the desired shortcut or click on the right button to reset the shortcut to its default. + Applica la scorciatoia desiderata o clicca con il tasto destro del mouse per ripristinare la scorciatoia predefinita. + + + + Enter shortcut directly by performing it + Inserici una scorciatoia eseguendola direttamente + + + + Actual shortcut + Scorciatoia attuale + + + + Default shortcut + Scorciatoia predefinita + + + + Set to default + Imposta al valore predefinito + + + + Double Shortcut + Doppia Scorciatoia + + + + The chosen shortcut + "%1" +is already used for the action + "%2". +Do you want to use the shortcut anyhow removing it from the previous action? + La scorciatoia +"%1" +è già utilizzata per un l'azione +"%2" +Si desidera utilizzare comunque la scorciatoia rimuovendola dall'azione cui era precedentemente associata? + + + + Import shortcut set %1 from file ... + Importa l'insieme di scorciatoie %1 dal file... + + + + + Octave Shortcut Files (*.osc);;All Files (*) + File Scorciatoia di Octave (*.osc);;Tutti i File (*) + + + + Export shortcut set %1 into file ... + Esporta l'insieme di scorciatoie %1 nel file... + + + + Failed to open %1 as octave shortcut file + Impossibile aprire il file %1 come file di scorciatoie di Octave + + + + terminal_dock_widget + + + Command Window + Finestra dei Comandi + + + + webinfo + + + Type here and press 'Return' to search + Scrivi qui e premi 'Invio' per cercare + + + + Global search + Ricerca globale + + + + Error + Errore + + + + The info file %1 does not exist + Il file di informazione %1 non esiste + + + + welcome_wizard + + + Welcome to GNU Octave + Benvenuto in GNU Octave + + + + workspace_model + + + Name + Nome + + + + Class + Classe + + + + Dimension + Dimensione + + + + Value + Valore + + + + Attribute + Attributo + + + + Right click to copy, rename, or display + Cliccare con il tasto destro del mouse per copiare, rinominare o mostrare + + + + + complex + complesso + + + + workspace_view + + + Workspace + Spazio di lavoro + + + + View the variables in the active workspace. + Mostra le variabili nello spazio di lavoro attivo. + + + + Copy + Copia + + + + Rename + Rinomina + + + + Only top-level symbols may be renamed. + Solamente i simboli di primo livello possono essere rinominati. + + + + View the variables in the active workspace.<br> + Mostra le variabili nello spazio di lavoro attivo.<br> + + + + Colors for variable attributes: + Colori per gli attributi variabili: + + + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/nl_NL.ts --- a/libgui/languages/nl_NL.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/nl_NL.ts Fri Jan 23 15:23:09 2015 -0500 @@ -474,7 +474,7 @@ Aanwijzer - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> <p><strong>Een opmerking over Octave's Nieuwe GUI</strong></p><p>Een van de belangrijkste nieuwe kenmerken van Octave 3.8 is een grafische user interface (GUI). Dat is waar de gebruikers de afgelopen jaren het meest om gevraagd hebben en hij is bijna af. Maar omdat hij nog niet zo gepolijst is als we zouden willen hebben we besloten te wachten tot de versie 4.0 serie voordat we hem de standaard interface maken.</p><p>Vanwege de lange tijd en het aantal bug fixes en verbeteringen sinds de laatste major release versie hebben we ook besloten om niet langer meer te wachten op de GUI om al die verbeteringen door te voeren. Dus geniet van Octave versie 3.8 en de preview van de nieuwe GUI. We denken dat hij redelijk goed werkt, maar natuurlijk weten we dat er nog ruwe kantjes aan zitten en ruimte voor verbeteringen.</p><p><strong>We hebben je hulp nodig</strong></p><p>Er zijn veel manieren waarop je ons kunt helpen de overgebleven problemen te verhelpen, de GUI te completeren, en de gebruikerservaring voor nieuwelingen en experts (de URLs openen een nieuwe browser):</p><p><ul><li>Als je een bekwame ontwikkelaar bent kun je ons helpen door bij te dragen <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>Als Octave niet goed wekt raden we je aan om <a href="http://octave.org/bugs.html">de problemen te rapporteren </a> die je tegen komt.</li><li>Of je nu gebruiker of ontwikkelaar bent, je kunt ook <a href="http://octave.org/donate.html">een bijdrage geven</a>. De ontwikkeling van Octave vraagt een hoop tijd en expertise. Je bijdrage helpt er aan mee dat Octave verbeterd blijft worden.</li></ul></p><p>We hopen dat je Octave nuttig vindt. Help alsjeblieft om het in de toekomst nog beter te maken!</p> @@ -962,7 +962,7 @@ QWinTerminalImpl - + copied selection to clipboard selectie is naar klembord gekopieerd @@ -1683,17 +1683,12 @@ is reeds geopend in de editor - + &%1 %2 - - &New File - &Nieuw Bestand - - - + &Save File Op&slaan @@ -1703,7 +1698,12 @@ &Openen... - + + &New Script + + + + Save File &As... Opslaan &als... @@ -1789,6 +1789,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... Zoek en Vervang... @@ -1803,7 +1813,7 @@ Ga naar regel... - + &Recent Editor Files &Recent geopend @@ -1828,7 +1838,7 @@ Andere bestanden sluiten - + &Preferences... Voorkeuren... @@ -1858,7 +1868,7 @@ &Documentatie bij sleutelwoord - + Could not open file %1 for read: %2. @@ -1890,7 +1900,7 @@ Het bijbehorende tabblad in de editor is verdwenen. - + &File Bestand @@ -1905,7 +1915,7 @@ B&ewerken - + &Debug &Debuggen @@ -1918,7 +1928,7 @@ file_editor_tab - + Goto line Ga naar regel @@ -1928,7 +1938,7 @@ Regelnummer - + <unnamed> naamloos @@ -1945,14 +1955,15 @@ - - + + + Octave Editor - + The file %1 is about to be closed but has been modified. @@ -1963,12 +1974,12 @@ %2 - + Octave Files (*.m);;All Files (*) Octave bestanden (*.m);;Alle bestanden (*) - + Warning: The contents in the editor is modified! @@ -1985,14 +1996,14 @@ is gewist of hernoemd. Wil je het nu opslaan?%2 - + Could not open file %1 for write: %2. Kon bestand %1 niet openen om te schrijven: %2. - + Line: Regel: @@ -2002,7 +2013,18 @@ Kolom: - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Het lijkt erop dat '%1' is gewijzigd door een ander programma. Wil je het opnieuw laden? @@ -2035,7 +2057,12 @@ Bewerkingen op huidige map - + + Set Browser Directory... + + + + Find Files... Zoek bestanden... @@ -2046,16 +2073,17 @@ + New Directory Nieuwe map - + Double-click a file to open it Dubbelklik een bestand om te openen - + Show Octave directory Laat Octave map zien @@ -2080,7 +2108,7 @@ Laat home map zien - + Search Directory... Zoek in map... @@ -2100,7 +2128,7 @@ Nieuwe map... - + File size Bestandsgrootte @@ -2215,7 +2243,12 @@ - + + New File.txt + + + + Create Directory Maak nieuwe map @@ -2295,7 +2328,12 @@ find_dialog - + + Find and Replace + + + + Find &what: Zoek naar: @@ -2365,7 +2403,7 @@ In se&lectie zoeken - + Search from end vanaf einde terug zoeken @@ -2375,7 +2413,7 @@ Zoeken vanaf begin - + Replace Result Resultaat vervangen @@ -2385,7 +2423,7 @@ %1 vervangingen - + Find Result Zoek resultaat @@ -2408,12 +2446,7 @@ Genaamd: - - Enter the filename expression - Voer de bestandnaam-expressie in - - - + Start in: Begin in: @@ -2433,22 +2466,12 @@ Blader naar begin map - - Recurse directories - Ook in onderliggende mappen - - - + Search recursively through directories for matching files Zoek ook in onderliggende mappen naar overeenkomende bestanden - - Include directories - Neem mappen ook mee - - - + Include matching directories in search results Neem overeenkomende mappen mee in zoekresultaten @@ -2468,9 +2491,24 @@ Met tekst: - - Search must match text - Zoeken naar overeenkomende tekst + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -2533,7 +2571,12 @@ Bezig met zoeken... - + + %1 match(es) + + + + Set search directory Stel zoekmap in @@ -2623,13 +2666,13 @@ main_window - + Load Workspace Werkruimte laden - - + + About Octave Over Octave @@ -2644,12 +2687,7 @@ Nieuw - - Script - Script - - - + Figure Figuur @@ -2689,12 +2727,23 @@ Plakken - + Save Workspace As Sla Werkruimte Op Als - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. Bestand met Release Notes '%1' is leeg. @@ -2714,7 +2763,7 @@ Octave Community Nieuws - + Clear Clipboard Wis klembord @@ -2779,7 +2828,12 @@ Stap In - + + Octave + + + + Load Workspace... Werkruimte laden... @@ -2789,7 +2843,12 @@ Sla Werkruimte Op Als... - + + New Script + + + + Function... Functie... @@ -2880,8 +2939,8 @@ Eén mapniveau omhoog - - + + Browse directories Blader door mappen @@ -2955,7 +3014,7 @@ news_reader - + <html> <body> <p> @@ -3014,18 +3073,18 @@ octave_dock_widget - - + + Undock widget Widget laten zweven - + Hide widget Widget verbergen - + Dock widget Widget in venster opnemen @@ -3056,7 +3115,7 @@ octave_qt_link - + Yes @@ -3083,13 +3142,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - Het bestand %1 is niet in zoekpad. Om de functie die je edit te debuggen moet je òf naar debetreffende map %2 gaan, of die map aan het zoekpad toevoegen. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - Het bestand %1 is overschaduwd door een bestand met dezelfde naam in het zoekpad. Ga naar de map %2 om de functie de je edit te kunnen debuggen. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -3140,17 +3199,17 @@ settings_dialog - + Settings Instellingen - + General Algemeen - + Octave logo only Alleen Octave logo @@ -3165,17 +3224,37 @@ Grafische iconen - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Editor - + Color Kleur - + Indent width Inspringafstand @@ -3185,7 +3264,7 @@ Inspringen met tab - + Auto indentation Automatisch inspringen @@ -3230,62 +3309,67 @@ Herstel bij opstarten de editor tabs uit de vorige sessie - + Use custom file editor Gebruik een andere editor - + + emacs +%l %f + + + + Editor Styles Editorstijlen - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Selecteer font, font grootte (als een verschil van de standaard grootte), font stijl (<b>d</b>ik, <b>s</b>chuin, <b>o</b>nderstreept), tekstkleur en achtergrondkleur (wat betreft de laatste, de kleur roze (255,0,255) is een plaatsvervanger voor de standaard achtergrondkleur).</p></body></html> - + Terminal Colors Terminalkleuren - + Font Lettertype - + Show line numbers Regelnummers weergeven - + Highlight current line Markeer huidige regel - + Code completion Automatisch aanvullen - + Show complete path in window title Hele pad in schermtitel weergeven - + Show whitespace Laat witruimte zien - + Do not show whitespace used for indentation Laat geen voor inspringen gebruikte witruimte zien - + # of characters typed before completion list displayed Getypt aantal karakters voordat de aanvullijst verschijnt @@ -3295,87 +3379,144 @@ Maak niet bestaande bestanden aan zonder te vragen - + command line (%f=file, %l=line): command line (%f=bestand, %l=regel): - - emacs - - - - - Terminal - Opdrachtvenster - - - - Cursor type: - Type aanwijzer: - - - - Cursor blinking - Knipperende aanwijzer - - - - Use foreground color - Gebruik voorgrondkleur - - + Terminal + Opdrachtvenster + + + + Cursor type: + Type aanwijzer: + + + + Cursor blinking + Knipperende aanwijzer + + + + Use foreground color + Gebruik voorgrondkleur + + + Font size Lettergrootte - + + Set focus to terminal when running a command from within another widget + + + + File Browser Bestandsbrowser + + Show file size + Bestandsgrootte weergeven + + + + Show file type + Bestandstype weergeven + + + + Show date of last modification + Datum van laatste wijziging weergeven + + + + Show hidden files + Verborgen bestanden weergeven + + + + Interface + + + + + Octave Startup + + + - Show file size - Bestandsgrootte weergeven - - - - Show file type - Bestandstype weergeven - - - - Show date of last modification - Datum van laatste wijziging weergeven - - - - Show hidden files - Verborgen bestanden weergeven - - - - Alternating row colors - Om en om andere regelkleuren - - - - Workspace - Werkruimte - - - - Storage Class Colors - Kleuren voor klasse + These preferences are applied after the startup files like .octaverc. + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + + Tab width min. + + + + + max. + + + + + Display + + + + + Alternating row colors + Om en om andere regelkleuren + + + + Behavior + + + + + Restore last directory of previous session + + + + + Workspace + Werkruimte + + + + Storage Class Colors + Kleuren voor klasse + + + Network Netwerk - + Allow Octave to connect to the Octave web site to display current news and information Sta Octave toe om te verbinden met de Octave website om recent nieuws en informatie weer te geven @@ -3390,27 +3531,27 @@ http proxy - + Icon set for dock widgets Iconenset voor dock widgets - + Language (requires restart) Taal instellen (vereist herstart) - + Icon size Icoongrootte - + Synchronize Octave working directory with file browser Synchroniseer Octave werkmap met bestandsverkenner - + Socks5Proxy @@ -3440,9 +3581,9 @@ Wachtwoord: - + - + System setting Systeeminstelling @@ -3489,6 +3630,16 @@ short form for underlined o + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -3556,7 +3707,7 @@ webinfo - + Type here and press 'Return' to search Typ hier en druk op 'Enter' om te zoeken @@ -3565,6 +3716,16 @@ Global search Globaal zoeken + + + Error + Fout + + + + The info file %1 does not exist + + welcome_wizard @@ -3598,8 +3759,8 @@ - Storage Class - Klasse + Attribute + @@ -3647,8 +3808,8 @@ - Colors for the storage class: - Kleuren voor klasse: + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/pt_BR.ts --- a/libgui/languages/pt_BR.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/pt_BR.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ indicador - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> <p><strong>Um aviso sobre a nova interface gráfica do Octave</strong></p><p>Uma das funcionalidades novas mais importantes no Octave versão 3.8 é a interface gráfica (GUI). É uma coisa que os usuários solicitaram muito frequentemente nos últimos anos, e agora ela está quase pronta. Mas como ela não está tão bem acabada quanto gostaríamos, decidimos esperar até a próxima versão 4.0 antes de tornar a GUI a interface padrão.</p><p>Dado o tempo transcorrido e o número de correções e melhorias desde a última versão, também decidimos não adiar mais o lançamento de todas essas novidades, ao invés ficar aperfeiçoando a GUI. Portanto, aproveite a versão 3.8 do Octave e a prévia da nova GUI! Acreditamos que ela está funcionando razoavelmente bem, apesar de alguns aspectos obviamente inacabados, além de muitas melhorias possíveis.</p><p><strong>Ajude-nos</strong></p><p>Há muitas formas de você nos ajudar a corrigir os problemas que persistirem, a finalizar a GUI e a melhorar a usabilidade do Octave em geral, tanto para usuários iniciantes quanto para aqueles mais experientes (os links abaixo serão abertos no seu navegador padrão do sistema; o conteúdo poderá estar em inglês):</p><p><ul><li>Se você for um desenvolvedor de software talentoso, ajude-nos contribuindo com o seu tempo, auxiliando no <a href="http://octave.org/get-involved.html">desenvolvimento do Octave</a>.</li><li>Se o Octave não estiver funcionando corretamente, convidamos-lhe a <a href="http://octave.org/bugs.html">relatar os problemas</a> que você vier a encontrar.</li><li>Quer você seja um usuário ou um desenvolvedor, você poderia <a href="http://octave.org/donate.html">fazer uma doação</a> para auxiliar no financiamento do projeto. Afinal, o desenvolvimento do Octave demanda tempo e conhecimento consideráveis. A sua generosidade contribui para assegurar a melhoria contínua do Octave.</li></ul></p><p>Esperamos que você goste do Octave. Ajude-nos a torná-lo ainda melhor no futuro!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard seleção copiada para a área de transferência @@ -141,17 +141,12 @@ Arquivo não foi salvo! Um arquivo com o nome selecionado %1 já está aberto no editor - + &%1 %2 &%1 %2 - - &New File - &Novo Script - - - + &Save File &Salvar Arquivo @@ -161,7 +156,12 @@ &Abrir Arquivo... - + + &New Script + + + + Save File &As... Salvar Arquivo &Como... @@ -247,6 +247,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Buscar e Substituir... @@ -261,7 +271,7 @@ Vá para &Linha... - + &Recent Editor Files Arquivos &Recentes @@ -286,7 +296,7 @@ Fechar Demais Arquivos - + &Preferences... &Preferências... @@ -316,7 +326,7 @@ &Documentação da Palavra-chave - + Could not open file %1 for read: %2. @@ -348,7 +358,7 @@ A aba do editor associada ao arquivo desapareceu. - + &File &Arquivo @@ -363,7 +373,7 @@ &Editar - + &Debug &Depurar @@ -376,7 +386,7 @@ file_editor_tab - + Goto line Vá para linha @@ -386,7 +396,7 @@ Número da linha - + <unnamed> <sem_nome> @@ -403,14 +413,15 @@ - - + + + Octave Editor Editor do Octave - + The file %1 is about to be closed but has been modified. @@ -421,12 +432,12 @@ %2 - + Octave Files (*.m);;All Files (*) Arquivos do Octave (*.m);; Todos os Arquivos (*) - + Warning: The contents in the editor is modified! @@ -444,14 +455,14 @@ foi removido ou renomeado. Gostaria de salvá-lo agora?%2 - + Could not open file %1 for write: %2. Não foi possível abrir arquivo %1 para escrita: %2. - + Line: Linha: @@ -461,7 +472,18 @@ Coluna: - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Parece que o arquivo '%1' foi modificado por outra aplicação. Deseja recarregá-lo? @@ -494,7 +516,12 @@ Ações no diretório atual - + + Set Browser Directory... + + + + Find Files... Buscar Arquivos... @@ -505,16 +532,17 @@ + New Directory Novo Diretório - + Double-click a file to open it Clique duas vezes em um arquivo para abrí-lo - + Show Octave directory Exibir o diretório do Octave @@ -539,7 +567,7 @@ Exibir Diretório Pessoal - + Search Directory... Buscar no Diretório... @@ -559,7 +587,7 @@ Novo Diretório... - + File size Tamanho do arquivo @@ -672,7 +700,12 @@ - + + New File.txt + + + + Create Directory Criar Diretório @@ -751,7 +784,12 @@ find_dialog - + + Find and Replace + + + + Find &what: &Buscar por: @@ -821,7 +859,7 @@ Buscar dentro do texto &selecionado - + Search from end Buscar do final para o começo @@ -831,7 +869,7 @@ Buscar do começo para o final - + Replace Result Substituir Resultado @@ -841,7 +879,7 @@ %1 itens substituidos - + Find Result Buscar Resultado @@ -864,12 +902,7 @@ Nome de arquivo: - - Enter the filename expression - Digite a expressão de busca para os nomes de arquivo - - - + Start in: Diretório inicial: @@ -889,22 +922,12 @@ Escolha o diretório inicial - - Recurse directories - Buscar em sub-diretórios - - - + Search recursively through directories for matching files Buscar recursivamente nos sub-diretórios - - Include directories - Inclur nomes de diretórios - - - + Include matching directories in search results Incluir diretórios no resultado da busca @@ -924,9 +947,24 @@ Contém texto: - - Search must match text - Digite a expressão de busca para conteúdo dos arquivos + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -989,7 +1027,12 @@ Buscando... - + + %1 match(es) + + + + Set search directory Alterar diretório de busca @@ -1079,13 +1122,13 @@ main_window - + Load Workspace Carregar Ambiente de Trabalho - - + + About Octave Sobre o Octave @@ -1100,12 +1143,7 @@ Novo - - Script - Script - - - + Figure Figura @@ -1145,12 +1183,23 @@ Colar - + Save Workspace As Salvar Ambiente de Trabalho Como - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. O arquivo de notas da versão '%1' está vazio. @@ -1170,7 +1219,7 @@ Novidades da Comunidade - + Clear Clipboard Limpar Área de Transferência @@ -1235,7 +1284,12 @@ Passo adentro - + + Octave + + + + Load Workspace... Carregar Ambiente de Trabalho... @@ -1245,7 +1299,12 @@ Salvar Ambiente de Trabalho Como... - + + New Script + + + + Function... Função... @@ -1336,8 +1395,8 @@ Diretório um nível acima - - + + Browse directories Escolher diretório @@ -1411,7 +1470,7 @@ news_reader - + <html> <body> <p> @@ -1470,18 +1529,18 @@ octave_dock_widget - - + + Undock widget Desacoplar painel - + Hide widget Esconder painel - + Dock widget Acoplar painel @@ -1512,7 +1571,7 @@ octave_qt_link - + Yes @@ -1539,13 +1598,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - O arquivo %1 não existe no caminho de pesquisa. Para depurar a função que você está editando, é preciso ou mudar para o diretório %2 ou adicionar esse diretório ao caminho de pesquisa. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - Existe um arquivo com o mesmo nome %1 no caminho de pesquisa. Para depurar a função que você está editando, é preciso mudar para o diretório %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -1596,17 +1655,17 @@ settings_dialog - + Settings Configurações - + General Geral - + Octave logo only Apenas logotipo do Octave @@ -1621,17 +1680,37 @@ Ícones gráficos - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Editor - + Color Cor - + Indent width Largura de identação @@ -1641,7 +1720,7 @@ Tecla Tab causa identação na linha - + Auto indentation Auto-identação @@ -1686,62 +1765,67 @@ Restaurar abas de edição da sessão anterior durante inicialização - + Use custom file editor Usar editor de texto externo - + + emacs +%l %f + + + + Editor Styles Apresentação - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Selecionar fonte, tamanho da fonte (variacão com relacão ao tamanho padrão), estilo da fonte (<b>n</b>egrito, <b>i</b>tálico, <b>s</b>ublinhado), cor da fonte e cor de fundo (a cor rosa (255,0,255) é a cor de fundo padrão).</p></body></html> - + Terminal Colors Cores do Terminal - + Font Fonte - + Show line numbers Exibir números de linha - + Highlight current line Destacar linha atual - + Code completion Oferecer sugestões de preenchimento - + Show complete path in window title Exibir caminho completo no título da janela - + Show whitespace Exibir espaços em branco - + Do not show whitespace used for indentation Não exibir espaços em branco usados para identação - + # of characters typed before completion list displayed Número de caracteres digitados antes da apresentar sugestões de preenchimento @@ -1751,87 +1835,144 @@ Criar arquivos não existentes sem confirmar - + command line (%f=file, %l=line): linha de comando (%f=arquivo, %l=linha): - - emacs - emacs - - - + Terminal Terminal - + Cursor type: Tipo do Indicador: - + Cursor blinking Indicador piscante - + Use foreground color Usar cor de primeiro plano - + Font size Tamanho de fonte - + + Set focus to terminal when running a command from within another widget + + + + File Browser Navegador de Arquivos - + Show file size Exibir tamanho do arquivo - + Show file type Exibir tipo do arquivo - + Show date of last modification Exibir data de última modificação - + Show hidden files Exibir arquivos ocultos - + + Interface + + + + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + + Tab width min. + + + + + max. + + + + + Display + + + + Alternating row colors Cores de linhas alternantes - + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Ambiente de Trabalho - + Storage Class Colors Cores das Categorias - + Network Rede - + Allow Octave to connect to the Octave web site to display current news and information Permitir Octave se conectar à Internet para mostrar notícias e informações recentes @@ -1846,27 +1987,27 @@ Proxy HTTP - + Icon set for dock widgets Conjunto de ícones para painéis - + Language (requires restart) Idioma (alteração exige reinicialização do Octave) - + Icon size Tamanho dos ícones - + Synchronize Octave working directory with file browser Sincronizar diretório atual do Octave com o Navegador de Arquivos - + Socks5Proxy Proxy Socks 5 @@ -1896,9 +2037,9 @@ Senha: - + - + System setting Configuração do sistema @@ -1945,6 +2086,16 @@ short form for underlined s + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -2012,7 +2163,7 @@ webinfo - + Type here and press 'Return' to search Digite aqui e pressione 'Enter' para buscar @@ -2021,6 +2172,16 @@ Global search Busca global + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -2054,8 +2215,8 @@ - Storage Class - Categoria + Attribute + @@ -2103,8 +2264,8 @@ - Colors for the storage class: - Cores das categorias: + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/pt_PT.ts --- a/libgui/languages/pt_PT.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/pt_PT.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ indicador - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard selecçao copiada para a área de transferência @@ -810,17 +810,12 @@ já está aberto no editor - + &%1 %2 &%1 %2 - - &New File - &Novo Ficheiro - - - + &Save File &Guardar Ficheiro @@ -830,7 +825,12 @@ &Abrir Ficheiro... - + + &New Script + + + + Save File &As... Guardar Ficheiro &Como... @@ -916,6 +916,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Buscar e Substituir... @@ -930,7 +940,7 @@ Ir para &Linha... - + &Recent Editor Files Ficheiros &recentes @@ -955,7 +965,7 @@ Fechar os Outros Ficheiros - + &Preferences... &Preferências... @@ -985,7 +995,7 @@ &Documentação da Palavra-chave - + Could not open file %1 for read: %2. @@ -1017,7 +1027,7 @@ A aba do editor associada ao ficheiro desapareceu. - + &File &Ficheiro @@ -1032,7 +1042,7 @@ &Editar - + &Debug &Depurar @@ -1045,7 +1055,7 @@ file_editor_tab - + Goto line Ir para linha @@ -1055,7 +1065,7 @@ Número da linha - + <unnamed> <sem_nome> @@ -1072,14 +1082,15 @@ - - + + + Octave Editor Editor do Octave - + The file %1 is about to be closed but has been modified. @@ -1090,12 +1101,12 @@ %2 - + Octave Files (*.m);;All Files (*) Ficheiros de Octave (*.m);; Todos os Ficheiros (*) - + Warning: The contents in the editor is modified! @@ -1113,14 +1124,14 @@ foi removido ou renomeado. Pretende guardá-lo agora?%2 - + Could not open file %1 for write: %2. Não foi possível abrir o ficheiro %1 para escrita: %2. - + Line: Linha: @@ -1130,7 +1141,18 @@ Col: - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Parece que o ficheiro '%1' foi modificado por outro aplicativo. Deseja recarregá-lo? @@ -1163,7 +1185,12 @@ Acções no directório actual - + + Set Browser Directory... + + + + Find Files... Procurar Ficheiros... @@ -1174,16 +1201,17 @@ + New Directory Novo Directório - + Double-click a file to open it Clicar duas vezes num ficheiro para o abrir - + Show Octave directory Mostrar o directório actual do Octave @@ -1208,7 +1236,7 @@ Mostrar directório pessoal - + Search Directory... Procurar no directório... @@ -1228,7 +1256,7 @@ Novo Directório... - + File size Tamanho de ficheiro @@ -1343,7 +1371,12 @@ - + + New File.txt + + + + Create Directory Criar Directório @@ -1422,7 +1455,12 @@ find_dialog - + + Find and Replace + + + + Find &what: Procurar por: @@ -1492,7 +1530,7 @@ Procurar dentro da selecção - + Search from end Procurar a partir do fim @@ -1502,7 +1540,7 @@ Procurar a partir do início - + Replace Result Substituir Resultado @@ -1512,7 +1550,7 @@ %1 itens substituidos - + Find Result Buscar Resultado @@ -1535,12 +1573,7 @@ Chamados: - - Enter the filename expression - Introduza a expressão para o nome do ficheiro - - - + Start in: Iniciar em: @@ -1560,22 +1593,12 @@ Navegar por directório inicial - - Recurse directories - Entrar em sub-directórios - - - + Search recursively through directories for matching files Procurar recursivamente pelos directórios por ficheiros correspondentes - - Include directories - Incluir directórios - - - + Include matching directories in search results Incluir directórios correspondentes nos resultado da pesquisa @@ -1595,9 +1618,24 @@ Contém texto: - - Search must match text - Pesquisa precisa corresponder ao texto + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression + @@ -1660,7 +1698,12 @@ Procurando... - + + %1 match(es) + + + + Set search directory Definir directório de procura @@ -1750,13 +1793,13 @@ main_window - + Load Workspace Carregar ambiente de trabalho - - + + About Octave Sobre o Octave @@ -1771,12 +1814,7 @@ Novo - - Script - Script - - - + Figure Figura @@ -1816,12 +1854,23 @@ Colar - + Save Workspace As Guardar Ambiente de Trabalho como - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. O ficheiro de notas da versão '%1' está vazio. @@ -1841,7 +1890,7 @@ Notícias da comunidade Octave - + Clear Clipboard Limpar Área de Transferência @@ -1906,7 +1955,12 @@ - + + Octave + + + + Load Workspace... Carregar ambiente de trabalho... @@ -1916,7 +1970,12 @@ Guardar Ambiente de Trabalho como... - + + New Script + + + + Function... Função... @@ -2007,8 +2066,8 @@ Um nível de directório acima - - + + Browse directories Navegar directórios @@ -2082,7 +2141,7 @@ news_reader - + <html> <body> <p> @@ -2141,18 +2200,18 @@ octave_dock_widget - - + + Undock widget Desacoplar painel - + Hide widget Esconder painel - + Dock widget Acoplar painel @@ -2183,7 +2242,7 @@ octave_qt_link - + Yes @@ -2210,13 +2269,13 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - O ficheiro %1 não existe no caminho de pesquisa. Para depurar a função que está a ser editada, é preciso mudar para o directório %2 ou adicionar esse directório ao caminho de pesquisa. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. - O ficheiro %1 é ignorado a favor de outro ficheiro no caminho de pesquisa com o mesmo nome. Para depurar a função, é preciso mudar para o directório %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. + @@ -2267,17 +2326,17 @@ settings_dialog - + Settings Configurações - + General Geral - + Octave logo only Apenas logotipo do Octave @@ -2292,17 +2351,37 @@ Ícones gráficos - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Editor - + Color Cor - + Indent width Largura da identação @@ -2312,7 +2391,7 @@ Tabulador identa linha - + Auto indentation Auto-identação @@ -2357,62 +2436,67 @@ Restaurar abas de edição da sessão anterior durante inicialização - + Use custom file editor Usar editor de texto externo - + + emacs +%l %f + + + + Editor Styles Estilos do Editor - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> <html><head/><body><p>Seleccionar tipo de letra, tamanho (como diferença para o tamanho padrão), decoração (<b>n</b>egrito, <b>i</b>tálico, <b>s</b>ublinhado), cor do texto e cor do fundo de tela (para o último, a cor rosa (255,0,255) é sinônimo da cor de fundo padrão).</p></body></html> - + Terminal Colors Cores do Terminal - + Font Tipo de Letra - + Show line numbers Exibir número de linha - + Highlight current line Enfatizar linha actual - + Code completion Sguestões para copletar código - + Show complete path in window title Exibir caminho completo no título da janela - + Show whitespace Mostrar whitespace - + Do not show whitespace used for indentation Não mostrar whitespace usado para indentação - + # of characters typed before completion list displayed Número de carácteres antes de mostrar lista de preenchimento automático @@ -2422,87 +2506,144 @@ Criar ficheiros não existentes automaticamente - + command line (%f=file, %l=line): linha do comando (%f=ficheiro, %l=linha): - - emacs - emacs - - - - Terminal - Terminal - - - - Cursor type: - Tipo de Cursor: - - - - Cursor blinking - Indicador piscante - - - - Use foreground color - Usar cor do fundo - - + Terminal + Terminal + + + + Cursor type: + Tipo de Cursor: + + + + Cursor blinking + Indicador piscante + + + + Use foreground color + Usar cor do fundo + + + Font size Tamanho da letra - + + Set focus to terminal when running a command from within another widget + + + + File Browser Navegador de Ficheiros + + Show file size + Mostrar tamanho do ficheiro + + + + Show file type + Mostrar tipo de ficheiro + + + + Show date of last modification + Mostrar data da última modificação + + + + Show hidden files + Mostrar ficheiros escondidos + + + + Interface + + + + + Octave Startup + + + - Show file size - Mostrar tamanho do ficheiro - - - - Show file type - Mostrar tipo de ficheiro - - - - Show date of last modification - Mostrar data da última modificação - - - - Show hidden files - Mostrar ficheiros escondidos - - - - Alternating row colors - Cores de linhas alternantes - - - - Workspace - Ambiente de trabalho - - - - Storage Class Colors - Cores das Classes de Armazenamento + These preferences are applied after the startup files like .octaverc. + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + + Tab width min. + + + + + max. + + + + + Display + + + + + Alternating row colors + Cores de linhas alternantes + + + + Behavior + + + + + Restore last directory of previous session + + + + + Workspace + Ambiente de trabalho + + + + Storage Class Colors + Cores das Classes de Armazenamento + + + Network Rede - + Allow Octave to connect to the Octave web site to display current news and information Permitir ao Octave ligar-se ao site do Octave para mostrar notícias e informações @@ -2517,27 +2658,27 @@ Proxy HTTP - + Icon set for dock widgets Conjunto de ícones para paineis - + Language (requires restart) Idioma (reinicialização do Octave necessária) - + Icon size Tamanho do Ícone - + Synchronize Octave working directory with file browser Sincronizar o directório de trabalho do Octave com o navegador de ficheiros - + Socks5Proxy Proxy Socks 5 @@ -2567,9 +2708,9 @@ Senha: - + - + System setting Configuração do sistema @@ -2616,6 +2757,16 @@ short form for underlined s + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -2683,7 +2834,7 @@ webinfo - + Type here and press 'Return' to search Digite aqui e pressione 'Enter' para buscar @@ -2692,6 +2843,16 @@ Global search Procura global + + + Error + Erro + + + + The info file %1 does not exist + + welcome_wizard @@ -2725,8 +2886,8 @@ - Storage Class - Classe de Armazenamento + Attribute + @@ -2774,8 +2935,8 @@ - Colors for the storage class: - Cores para classe de armazenamento: + Colors for variable attributes: + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/ru_RU.ts --- a/libgui/languages/ru_RU.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/ru_RU.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard выделенное скопировано в буфер обмена @@ -143,17 +143,12 @@ уже открыт в редакторе - + &%1 %2 &%1 %2 - - &New File - Созд&ать - - - + &Save File &Сохранить @@ -163,7 +158,12 @@ &Открыть... - + + &New Script + + + + Save File &As... Сохранить &как... @@ -249,6 +249,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... &Найти и заменить... @@ -263,7 +273,7 @@ &Перейти к строчке... - + &Recent Editor Files &Недавние файлы редактора @@ -288,7 +298,7 @@ Закрыть другие файлы - + &Preferences... &Настройки... @@ -318,7 +328,7 @@ &Документация по зарезервированному слову - + Could not open file %1 for read: %2. @@ -350,7 +360,7 @@ - + &File &Файл @@ -365,7 +375,7 @@ &Правка - + &Debug &Отладка @@ -378,7 +388,7 @@ file_editor_tab - + Goto line Перейти к строчке @@ -388,7 +398,7 @@ - + <unnamed> <без названия> @@ -405,14 +415,15 @@ - - + + + Octave Editor Редактор Octave - + The file %1 is about to be closed but has been modified. @@ -423,12 +434,12 @@ %2 - + Octave Files (*.m);;All Files (*) Файлы Octave (*.m);;Все файлы (*) - + Warning: The contents in the editor is modified! @@ -446,14 +457,14 @@ был удален или переименован. Вы хотите сохранить его?%2 - + Could not open file %1 for write: %2. Не удалось открыть файл %1 для записи: %2. - + Line: @@ -463,7 +474,18 @@ - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? Кажется, файл '%1' был изменен другим приложением. Вы хотите обновить его содержимое? @@ -496,7 +518,12 @@ - + + Set Browser Directory... + + + + Find Files... Найти файлы... @@ -507,16 +534,17 @@ + New Directory Новая директория - + Double-click a file to open it - + Show Octave directory Перейти к текущей директории Octave @@ -541,7 +569,7 @@ Показывать домашнюю директорию - + Search Directory... @@ -561,7 +589,7 @@ Новая директория... - + File size @@ -673,7 +701,12 @@ - + + New File.txt + + + + Create Directory Создать директорию @@ -737,7 +770,12 @@ find_dialog - + + Find and Replace + + + + Find &what: &Найти: @@ -807,7 +845,7 @@ - + Search from end Искать с конца @@ -817,7 +855,7 @@ Искать с начала - + Replace Result @@ -827,7 +865,7 @@ - + Find Result @@ -850,12 +888,7 @@ - - Enter the filename expression - - - - + Start in: @@ -875,22 +908,12 @@ - - Recurse directories - - - - + Search recursively through directories for matching files Искать рекурсивно в директориях подходящие файлы - - Include directories - - - - + Include matching directories in search results @@ -910,8 +933,23 @@ Содержит текст: - - Search must match text + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression @@ -975,7 +1013,12 @@ - + + %1 match(es) + + + + Set search directory Установить директорию для поиска @@ -1061,13 +1104,13 @@ main_window - + Load Workspace Загрузить область переменных - - + + About Octave Об Octave @@ -1082,12 +1125,7 @@ Новый - - Script - Скрипт - - - + Figure @@ -1127,12 +1165,23 @@ Вставить - + Save Workspace As - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. @@ -1152,7 +1201,7 @@ - + Clear Clipboard @@ -1217,7 +1266,12 @@ - + + Octave + + + + Load Workspace... Загрузить область переменных... @@ -1227,7 +1281,12 @@ - + + New Script + + + + Function... Функция... @@ -1318,8 +1377,8 @@ Одной директорией вверх - - + + Browse directories Просмотр директорий @@ -1393,7 +1452,7 @@ news_reader - + <html> <body> <p> @@ -1429,18 +1488,18 @@ octave_dock_widget - - + + Undock widget Открепить виджет - + Hide widget Спрятать виджет - + Dock widget Закрепить виджет @@ -1471,7 +1530,7 @@ octave_qt_link - + Yes @@ -1498,12 +1557,12 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - Файл %1 не существует в пути загрузки. Чтобы отладить редактируемую вами функцию, вы должны либо изменить директорию на %2, или добавить эту директорию в путь загрузки. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. @@ -1549,17 +1608,17 @@ settings_dialog - + Settings Параметры - + General Основное - + Octave logo only Только логотип Octave @@ -1569,17 +1628,37 @@ - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Редактор - + Color Цвет - + Indent width Ширина отступа @@ -1589,7 +1668,7 @@ - + Auto indentation Авто-отступы @@ -1634,67 +1713,114 @@ Восстанавливать вкладки редактора с предыдущей сессии во время запуска - + Use custom file editor - + + emacs +%l %f + + + + Editor Styles - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> - + Terminal Colors - + Font Шрифт - + Show line numbers Показывать количество строк - + Highlight current line Подсвечивать текущую строку - + Code completion Дополнение кода - + Show complete path in window title Показывать полный путь в заголовке окна - + + Interface + + + + Graphic icons - + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + Show whitespace - + Do not show whitespace used for indentation - + + Tab width min. + + + + + max. + + + + # of characters typed before completion list displayed @@ -1704,87 +1830,102 @@ - + command line (%f=file, %l=line): - - emacs - emacs - - - + Terminal Командная строка - + Cursor type: Тип курсора: - + Cursor blinking Мигающий курсор - + Use foreground color - + Font size Размер шрифта - + + Set focus to terminal when running a command from within another widget + + + + File Browser Файловый менеджер - + Show file size Показывать размер файлов - + Show file type Показывать типы файлов - + Show date of last modification Показывать дату последнего изменения - + Show hidden files Показывать скрытые файлы - + + Display + + + + Alternating row colors Чередующиеся цвета строк - + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Область переменных - + Storage Class Colors - + Network Сеть - + Allow Octave to connect to the Octave web site to display current news and information @@ -1799,27 +1940,27 @@ HttpProxy - + Icon set for dock widgets - + Language (requires restart) Язык (требуется перезапуск) - + Icon size Размер иконок - + Synchronize Octave working directory with file browser - + Socks5Proxy Socks5Proxy @@ -1849,9 +1990,9 @@ Пароль: - + - + System setting @@ -1898,6 +2039,16 @@ short form for underlined + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -1954,7 +2105,7 @@ webinfo - + Type here and press 'Return' to search Вводите сюда и нажмите 'Enter', чтобы начать поиск @@ -1963,6 +2114,16 @@ Global search Глобальный поиск + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -1996,7 +2157,7 @@ - Storage Class + Attribute @@ -2045,7 +2206,7 @@ - Colors for the storage class: + Colors for variable attributes: diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/translators --- a/libgui/languages/translators Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/translators Fri Jan 23 15:23:09 2015 -0500 @@ -6,6 +6,7 @@ de_DE Andreas Weber es_ES Valentin Ortega-Clavero fr_FR David Bateman , Catalin Codreanu +it_IT Massimiliano Fasi pt_BR Júlio Hoffimann Mendes pt_PT Carnë Draug ru_RU Andriy Shinkarchuck diff -r 75a671fcdd73 -r 844448ae53f3 libgui/languages/uk_UA.ts --- a/libgui/languages/uk_UA.ts Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/languages/uk_UA.ts Fri Jan 23 15:23:09 2015 -0500 @@ -62,7 +62,7 @@ - + <p><strong>A Note about Octave's New GUI</strong></p><p>One of the biggest new features for Octave 3.8 is a graphical user interface. It is the one thing that users have requested most often over the last few years and now it is almost ready. But because it is not quite as polished as we would like, we have decided to wait until the 4.0.x release series before making the GUI the default interface.</p><p>Given the length of time and the number of bug fixes and improvements since the last major release, we also decided against delaying the release of all these new improvements any longer just to perfect the GUI. So please enjoy the 3.8 release of Octave and the preview of the new GUI. We believe it is working reasonably well, but we also know that there are some obvious rough spots and many things that could be improved.</p><p><strong>We Need Your Help</strong></p><p>There are many ways that you can help us fix the remaining problems, complete the GUI, and improve the overall user experience for both novices and experts alike (links will open an external browser):</p><p><ul><li>If you are a skilled software developer, you can help by contributing your time to help <a href="http://octave.org/get-involved.html">develop Octave</a>.</li><li>If Octave does not work properly, you are encouraged to <a href="http://octave.org/bugs.html">report problems </a> that you find.</li><li>Whether you are a user or developer, you can <a href="http://octave.org/donate.html">help to fund the project</a>. Octave development takes a lot of time and expertise. Your contributions help to ensure that Octave will continue to improve.</li></ul></p><p>We hope you find Octave to be useful. Please help us make it even better for the future!</p> @@ -88,7 +88,7 @@ QWinTerminalImpl - + copied selection to clipboard @@ -807,17 +807,12 @@ - + &%1 %2 - - &New File - &Створити - - - + &Save File &Зберегти @@ -827,7 +822,12 @@ &Відкрити... - + + &New Script + + + + Save File &As... Зберегти &як... @@ -913,6 +913,16 @@ + &Indent + + + + + &Unindent + + + + &Find and Replace... @@ -927,7 +937,7 @@ - + &Recent Editor Files @@ -952,7 +962,7 @@ - + &Preferences... @@ -982,7 +992,7 @@ - + Could not open file %1 for read: %2. @@ -1008,7 +1018,7 @@ - + &File &Файл @@ -1023,7 +1033,7 @@ &Правка - + &Debug @@ -1036,7 +1046,7 @@ file_editor_tab - + Goto line @@ -1046,7 +1056,7 @@ - + <unnamed> @@ -1063,14 +1073,15 @@ - - + + + Octave Editor - + The file %1 is about to be closed but has been modified. @@ -1078,12 +1089,12 @@ - + Octave Files (*.m);;All Files (*) - + Warning: The contents in the editor is modified! @@ -1097,13 +1108,13 @@ - + Could not open file %1 for write: %2. - + Line: @@ -1113,7 +1124,18 @@ - + + "%1" +is not a valid identifier. + +If you keep this file name, you will not be able to +call your script using its name as an Octave command. + +Do you want to choose another name? + + + + It seems that '%1' has been modified by another application. Do you want to reload it? @@ -1146,7 +1168,12 @@ - + + Set Browser Directory... + + + + Find Files... @@ -1157,16 +1184,17 @@ + New Directory - + Double-click a file to open it - + Show Octave directory @@ -1191,7 +1219,7 @@ - + Search Directory... @@ -1211,7 +1239,7 @@ - + File size @@ -1322,7 +1350,12 @@ - + + New File.txt + + + + Create Directory @@ -1385,7 +1418,12 @@ find_dialog - + + Find and Replace + + + + Find &what: @@ -1455,7 +1493,7 @@ - + Search from end @@ -1465,7 +1503,7 @@ - + Replace Result @@ -1475,7 +1513,7 @@ - + Find Result @@ -1498,12 +1536,7 @@ - - Enter the filename expression - - - - + Start in: @@ -1523,22 +1556,12 @@ - - Recurse directories - - - - + Search recursively through directories for matching files - - Include directories - - - - + Include matching directories in search results @@ -1558,8 +1581,23 @@ - - Search must match text + + Enter the filename search expression + + + + + Search subdirectories + + + + + Include directory names + + + + + Enter the file content search expression @@ -1623,7 +1661,12 @@ - + + %1 match(es) + + + + Set search directory @@ -1709,13 +1752,13 @@ main_window - + Load Workspace Завантажити область змінних - - + + About Octave Про Octave @@ -1730,12 +1773,7 @@ - - Script - - - - + Figure @@ -1775,12 +1813,23 @@ - + Save Workspace As - + + The file %1 +can not be executed because its name +is not a valid identifier. + +Do you want to execute +%2 +instead? + + + + The release notes file '%1' is empty. @@ -1800,7 +1849,7 @@ - + Clear Clipboard @@ -1865,7 +1914,12 @@ - + + Octave + + + + Load Workspace... @@ -1875,7 +1929,12 @@ - + + New Script + + + + Function... @@ -1966,8 +2025,8 @@ - - + + Browse directories @@ -2041,7 +2100,7 @@ news_reader - + <html> <body> <p> @@ -2077,18 +2136,18 @@ octave_dock_widget - - + + Undock widget - + Hide widget - + Dock widget @@ -2119,7 +2178,7 @@ octave_qt_link - + Yes @@ -2144,12 +2203,12 @@ - The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. + The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path. - The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2. + The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2. @@ -2195,17 +2254,17 @@ settings_dialog - + Settings Налаштування - + General - + Octave logo only @@ -2215,17 +2274,37 @@ - + + Dock widget title bar + + + + + Custom style + + + + + Background color + + + + + Text color + + + + Editor Редактор - + Color - + Indent width @@ -2235,7 +2314,7 @@ - + Auto indentation @@ -2280,67 +2359,114 @@ - + Use custom file editor - + + emacs +%l %f + + + + Editor Styles - + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> - + Terminal Colors - + Font - + Show line numbers - + Highlight current line - + Code completion - + Show complete path in window title - + + Interface + + + + Graphic icons - + + Octave Startup + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + Startup path + + + + + + Browse + + + + + Restore last Octave directory of previous session + + + + Show whitespace - + Do not show whitespace used for indentation - + + Tab width min. + + + + + max. + + + + # of characters typed before completion list displayed @@ -2350,87 +2476,102 @@ - + command line (%f=file, %l=line): - - emacs - emacs - - - - Terminal - Командний рядок - - - - Cursor type: - - - - - Cursor blinking - - - - - Use foreground color - - - + Terminal + Командний рядок + + + + Cursor type: + + + + + Cursor blinking + + + + + Use foreground color + + + + Font size - + + Set focus to terminal when running a command from within another widget + + + + File Browser Файловий менеджер - + Show file size Показувати розмір файлів - + Show file type Показувати типи файлів - - Show date of last modification - Показувати дату останньої зміни - - - - Show hidden files - Показувати приховані файли - - - - Alternating row colors - Чергувати колір рядків - - + Show date of last modification + Показувати дату останньої зміни + + + + Show hidden files + Показувати приховані файли + + + + Display + + + + + Alternating row colors + Чергувати колір рядків + + + + Behavior + + + + + Restore last directory of previous session + + + + Workspace Область змінних - + Storage Class Colors - + Network - + Allow Octave to connect to the Octave web site to display current news and information @@ -2445,27 +2586,27 @@ - + Icon set for dock widgets - + Language (requires restart) - + Icon size - + Synchronize Octave working directory with file browser - + Socks5Proxy @@ -2495,9 +2636,9 @@ Пароль: - + - + System setting @@ -2544,6 +2685,16 @@ short form for underlined + + + Set Octave Startup Directory + + + + + Set File Browser Startup Directory + + setup_community_news @@ -2600,7 +2751,7 @@ webinfo - + Type here and press 'Return' to search @@ -2609,6 +2760,16 @@ Global search + + + Error + + + + + The info file %1 does not exist + + welcome_wizard @@ -2642,7 +2803,7 @@ - Storage Class + Attribute @@ -2691,7 +2852,7 @@ - Colors for the storage class: + Colors for variable attributes: diff -r 75a671fcdd73 -r 844448ae53f3 libgui/link-deps.mk --- a/libgui/link-deps.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/link-deps.mk Fri Jan 23 15:23:09 2015 -0500 @@ -7,10 +7,11 @@ endif LIBOCTGUI_LINK_DEPS += \ - @QT_LIBS@ + $(QT_LIBS) \ + $(OPENGL_LIBS) LIBOCTGUI_LINK_OPTS = \ - @QT_LDFLAGS@ + $(QT_LDFLAGS) if AMCOND_LINK_ALL_DEPS LIBOCTGUI_LINK_DEPS += $(LIBOCTINTERP_LINK_DEPS) diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/QTerminal.cc --- a/libgui/qterminal/libqterminal/QTerminal.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/QTerminal.cc Fri Jan 23 15:23:09 2015 -0500 @@ -118,4 +118,5 @@ (cursorUseForegroundColor, settings->value ("terminal/color_c", QVariant (colors.at (3))).value ()); + setScrollBufferSize (settings->value ("terminal/history_buffer",1000).toInt() ); } diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/QTerminal.h --- a/libgui/qterminal/libqterminal/QTerminal.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/QTerminal.h Fri Jan 23 15:23:09 2015 -0500 @@ -81,6 +81,8 @@ virtual void setCursorColor (bool useForegroundColor, const QColor& color) = 0; + virtual void setScrollBufferSize(int value=1000) = 0; + signals: void report_status_message (const QString&); @@ -93,6 +95,8 @@ virtual void pasteClipboard (void) = 0; + virtual void selectAll (void) = 0; + virtual void handleCustomContextMenuRequested (const QPoint& at) { QClipboard * cb = QApplication::clipboard (); @@ -106,6 +110,8 @@ void notice_settings (const QSettings *settings); + virtual void init_terminal_size (void) { } + void terminal_interrupt (void) { emit interrupt_signal (); } protected: @@ -126,6 +132,12 @@ _contextMenu->addSeparator (); + _selectall_action = _contextMenu->addAction ( + tr ("Select All"), this, SLOT (selectAll ())); + + + _contextMenu->addSeparator (); + _contextMenu->addAction (tr ("Clear All"), parent (), SLOT (handle_clear_command_window_request ())); @@ -138,11 +150,17 @@ connect (xparent, SIGNAL (settings_changed (const QSettings *)), this, SLOT (notice_settings (const QSettings *))); + connect (xparent, SIGNAL (init_terminal_size_signal ()), + this, SLOT (init_terminal_size ())); + connect (xparent, SIGNAL (copyClipboard_signal ()), this, SLOT (copyClipboard ())); connect (xparent, SIGNAL (pasteClipboard_signal ()), this, SLOT (pasteClipboard ())); + + connect (xparent, SIGNAL (selectAll_signal ()), + this, SLOT (selectAll ())); } private: @@ -150,6 +168,7 @@ QMenu *_contextMenu; QAction * _copy_action; QAction * _paste_action; + QAction * _selectall_action; }; #endif // QTERMINAL_H diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp --- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.cpp Fri Jan 23 15:23:09 2015 -0500 @@ -69,13 +69,23 @@ m_terminalModel = new TerminalModel(m_kpty); m_terminalModel->setAutoClose(true); m_terminalModel->setCodec(QTextCodec::codecForName("UTF-8")); - m_terminalModel->setHistoryType(HistoryTypeBuffer(1000)); + m_terminalModel->setHistoryType(HistoryTypeBuffer (1000)); m_terminalModel->setDarkBackground(true); m_terminalModel->setKeyBindings(""); m_terminalModel->run(); m_terminalModel->addView(m_terminalView); connectToPty(); } +void QUnixTerminalImpl::setScrollBufferSize(int value) +{ + if (value > 0) + { + m_terminalModel->clearHistory (); + m_terminalModel->setHistoryType (HistoryTypeBuffer ( value )); + } + else + m_terminalModel->setHistoryType (HistoryTypeNone ()); +} void QUnixTerminalImpl::connectToPty() { @@ -205,6 +215,12 @@ m_terminalView->pasteClipboard(); } +void QUnixTerminalImpl::selectAll() +{ + m_terminalView->selectAll(); +} + + QString QUnixTerminalImpl::selectedText () { return m_terminalView->selectedText (); diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h --- a/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/unix/QUnixTerminalImpl.h Fri Jan 23 15:23:09 2015 -0500 @@ -47,12 +47,13 @@ void setForegroundColor (const QColor& color); void setSelectionColor (const QColor& color); void setCursorColor (bool useForegroundColor, const QColor& color); - + void setScrollBufferSize(int value); QString selectedText(); public slots: void copyClipboard(); void pasteClipboard(); + void selectAll(); protected: void showEvent(QShowEvent *); diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/unix/TerminalView.cpp --- a/libgui/qterminal/libqterminal/unix/TerminalView.cpp Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/unix/TerminalView.cpp Fri Jan 23 15:23:09 2015 -0500 @@ -2293,6 +2293,20 @@ } } +void TerminalView::selectAll() +{ + if ( !_screenWindow || !hasFocus()) + return; + + _screenWindow->setSelectionStart(0,-_screenWindow->currentLine(), false); + //_screenWindow->setSelectionEnd(_screenWindow->windowColumns(), + // _screenWindow->windowLines()); + + _screenWindow->setSelectionEnd(_screenWindow->columnCount(), + _screenWindow->windowLines()); +} + + void TerminalView::pasteSelection() { emitSelection(true,false); @@ -2612,6 +2626,17 @@ // KUrl::List urls = KUrl::List::fromMimeData(event->mimeData()); QString dropText; + + if (event->mimeData ()->hasUrls ()) + { + foreach (QUrl url, event->mimeData ()->urls ()) + { + if(dropText.length () > 0) + dropText += "\n"; + dropText += url.toLocalFile (); + } + } + /* if (!urls.isEmpty()) { for ( int i = 0 ; i < urls.count() ; i++ ) diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/unix/TerminalView.h --- a/libgui/qterminal/libqterminal/unix/TerminalView.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/unix/TerminalView.h Fri Jan 23 15:23:09 2015 -0500 @@ -416,6 +416,11 @@ */ void pasteSelection(); + /** + * selects all content + */ + void selectAll(); + /** * Causes the widget to display or hide a message informing the user that terminal * output has been suspended (by using the flow control key combination Ctrl+S) diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp --- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.cpp Fri Jan 23 15:23:09 2015 -0500 @@ -1,3 +1,4 @@ + /* Copyright (C) 2011, 2013 Michael Goffioul. @@ -24,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -35,6 +36,9 @@ #include #include #include +#include +#include +#include #include #include @@ -173,16 +177,21 @@ QConsolePrivate (QWinTerminalImpl* parent, const QString& cmd = QString ()); ~QConsolePrivate (void); - void updateConsoleSize (bool sync = false); + void updateConsoleSize (bool sync = false, bool allow_smaller_width = false); void syncConsoleParameters (void); void grabConsoleBuffer (CHAR_INFO* buf = 0); - void updateScrollBar (void); - void setScrollValue (int value); + void updateHorizontalScrollBar (void); + void updateVerticalScrollBar (void); + void setHorizontalScrollValue (int value); + void setVerticalScrollValue (int value); void updateConsoleView (bool grab = true); void monitorConsole (void); void startCommand (void); void sendConsoleText (const QString& s); QRect cursorRect (void); + void selectAll(); + void selectWord(const QPoint& cellPos); + void selectLine(const QPoint& cellPos); void log (const char* fmt, ...); @@ -204,6 +213,7 @@ void setForegroundColor (const QColor& color); void setSelectionColor (const QColor& color); void setCursorColor (bool useForegroundColor, const QColor& color); + void setScrollBufferSize (int value); void drawTextBackground (QPainter& p, int cx1, int cy1, int cx2, int cy2, int cw, int ch); @@ -249,7 +259,8 @@ HANDLE m_process; QConsoleView* m_consoleView; - QScrollBar* m_scrollBar; + QScrollBar* m_horizontalScrollBar; + QScrollBar* m_verticalScrollBar; QTimer* m_consoleWatcher; QConsoleThread *m_consoleThread; @@ -362,13 +373,15 @@ m_buffer = m_tmpBuffer = 0; m_consoleView = new QConsoleView (parent); - m_scrollBar = new QScrollBar (Qt::Vertical, parent); + m_horizontalScrollBar = new QScrollBar (Qt::Horizontal, parent); + m_verticalScrollBar = new QScrollBar (Qt::Vertical, parent); - QHBoxLayout* l = new QHBoxLayout (parent); + QGridLayout* l = new QGridLayout (parent); l->setContentsMargins (0, 0, 0, 0); l->setSpacing (0); - l->addWidget (m_consoleView, 1); - l->addWidget (m_scrollBar, 0); + l->addWidget (m_consoleView, 0, 0); + l->addWidget (m_horizontalScrollBar, 1, 0); + l->addWidget (m_verticalScrollBar, 0, 1); // Choose 15 (0xF) as index into the Windows console color map for the // background and 0 (0x0) as the index for the foreground. This @@ -394,7 +407,8 @@ parent->setFocusPolicy (Qt::StrongFocus); parent->winId (); - updateScrollBar (); + updateHorizontalScrollBar (); + updateVerticalScrollBar (); m_consoleWatcher = new QTimer (parent); m_consoleWatcher->setInterval (10); @@ -404,8 +418,12 @@ QObject::connect (m_blinkCursorTimer, SIGNAL (timeout()), q, SLOT (blinkCursorEvent ())); - QObject::connect (m_scrollBar, SIGNAL (valueChanged (int)), - q, SLOT (scrollValueChanged (int))); + QObject::connect (m_horizontalScrollBar, SIGNAL (valueChanged (int)), + q, SLOT (horizontalScrollValueChanged (int))); + + QObject::connect (m_verticalScrollBar, SIGNAL (valueChanged (int)), + q, SLOT (verticalScrollValueChanged (int))); + QObject::connect (m_consoleWatcher, SIGNAL (timeout (void)), q, SLOT (monitorConsole (void))); @@ -575,6 +593,9 @@ void QConsolePrivate::setBackgroundColor (const QColor& color) { m_colors[15] = color; + + QPalette palette (color); + m_consoleView->setPalette (palette); } void QConsolePrivate::setForegroundColor (const QColor& color) @@ -593,6 +614,16 @@ m_cursorColor = useForegroundColor ? QColor () : color; } +void QConsolePrivate::setScrollBufferSize (int value) +{ + CONSOLE_SCREEN_BUFFER_INFO sbi; + GetConsoleScreenBufferInfo (m_stdOut, &sbi); + + m_bufferSize = QSize (sbi.dwSize.X, (SHORT)value); + + updateConsoleSize (true); +} + void QConsolePrivate::drawTextBackground (QPainter& p, int cx1, int cy1, int cx2, int cy2, int cw, int ch) { @@ -654,6 +685,83 @@ p.restore (); } +void QConsolePrivate::selectAll() +{ + m_beginSelection = QPoint (0,0); + m_endSelection = QPoint(m_bufferSize.width (), + m_cursorPos.y()); + updateSelection(); +} + +void QConsolePrivate::selectWord (const QPoint & cellpos) +{ + QPoint begin = cellpos; + QPoint end = cellpos; + + int stride = m_consoleRect.width (); + + int verticalScrollOffset = m_consoleRect.top (); + int horizontalScrollOffset = m_consoleRect.left (); + + // get begin, end in buffer offsets + begin.ry () -= verticalScrollOffset; + end.ry () -= verticalScrollOffset; + + begin.rx () -= horizontalScrollOffset; + end.rx () -= horizontalScrollOffset; + + // loog at current clicked on char to determinate ig getting space chunk or nonspace chunk + if (QChar(m_buffer[begin.y ()*stride + begin.x ()].Char.UnicodeChar).isSpace () == false) + { + // from current char, go back and fwd to find start and end of block + while(begin.x () > 0 && + QChar(m_buffer[begin.y ()*stride + begin.x () -1].Char.UnicodeChar).isSpace() == false) + { + begin.rx () --; + } + + while(end.x () < m_consoleRect.width () && + QChar(m_buffer[end.y ()*stride + end.x () +1].Char.UnicodeChar).isSpace() == false) + { + end.rx () ++; + } + } + else + { + while(begin.x () > 0 && + QChar(m_buffer[begin.y ()*stride + begin.x () -1].Char.UnicodeChar).isSpace()) + { + begin.rx () --; + } + + while(end.x () < m_consoleRect.width () && + QChar(m_buffer[end.y ()*stride + end.x () +1].Char.UnicodeChar).isSpace ()) + { + end.rx () ++; + } + } + + // convert console offsets to absolute cell positions + begin.ry () += verticalScrollOffset; + end.ry () += verticalScrollOffset; + + begin.rx () += horizontalScrollOffset; + end.rx () += horizontalScrollOffset; + + m_beginSelection = begin; + m_endSelection = end; + + updateSelection (); +} + +void QConsolePrivate::selectLine (const QPoint & cellpos) +{ + m_beginSelection = QPoint (0, cellpos.y ()); + m_endSelection = QPoint (m_bufferSize.width ()-1, cellpos.y ()); + updateSelection (); +} + + void QConsolePrivate::drawSelection (QPainter& p, int cx1, int cy1, int cx2, int cy2, int cw, int ch) { @@ -667,10 +775,14 @@ if (haveSelection) maybeSwapPoints (begin, end); - int scrollOffset = m_consoleRect.top (); + int verticalScrollOffset = m_consoleRect.top (); + int horizontalScrollOffset = m_consoleRect.left (); - begin.ry () -= scrollOffset; - end.ry () -= scrollOffset; + begin.ry () -= verticalScrollOffset; + end.ry () -= verticalScrollOffset; + + begin.rx () -= horizontalScrollOffset; + end.rx () -= horizontalScrollOffset; int ascent = p.fontMetrics ().ascent (); int stride = m_consoleRect.width (); @@ -871,7 +983,7 @@ ////////////////////////////////////////////////////////////////////////////// -void QConsolePrivate::updateConsoleSize (bool sync) +void QConsolePrivate::updateConsoleSize (bool sync, bool allow_smaller_width) { QFontMetrics fm (m_font); QSize winSize = m_consoleView->size (); @@ -882,9 +994,30 @@ m_consoleRect.setWidth (winSize.width () / fm.averageCharWidth ()); m_consoleRect.setHeight (winSize.height () / fm.lineSpacing ()); - m_bufferSize.rwidth () = m_consoleRect.width (); - m_bufferSize.rheight () = qMax (m_bufferSize.height (), - m_consoleRect.height ()); + // Don't shrink the size of the buffer. That way wide lines won't be + // truncated and will reappear if the window is enlarged again later. + + if (allow_smaller_width || m_consoleRect.width () > m_bufferSize.width ()) + m_bufferSize.rwidth () = m_consoleRect.width (); + + if (qMax (m_bufferSize.height (), m_consoleRect.height ()) + > m_bufferSize.height ()) + m_bufferSize.rheight () = qMax (m_bufferSize.height (), + m_consoleRect.height ()); + + // Store the terminal size in the environment. When Octave is + // initialized, we ask the command editor (usually readline) to prefer + // using these values rather than querying the terminal so that the + // buffer size can be larger than the size of the window that the + // command editor will actually use. + + qputenv ("LINES", QByteArray::number (m_consoleRect.height ())); + qputenv ("COLUMNS", QByteArray::number (m_consoleRect.width ())); + + // Force the command line editor (usually readline) to notice the + // change in screen size as soon as possible. + + q->setSize (m_consoleRect.height (), m_consoleRect.width ()); m_consoleRect.moveLeft (0); if (m_consoleRect.bottom () >= m_bufferSize.height ()) @@ -902,7 +1035,8 @@ if (sync) syncConsoleParameters (); - updateScrollBar (); + updateHorizontalScrollBar (); + updateVerticalScrollBar (); } ////////////////////////////////////////////////////////////////////////////// @@ -989,25 +1123,70 @@ ////////////////////////////////////////////////////////////////////////////// -void QConsolePrivate::updateScrollBar (void) +void QConsolePrivate::updateHorizontalScrollBar (void) { - m_scrollBar->setMinimum (0); - if (m_bufferSize.height () > m_consoleRect.height ()) - m_scrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ()); + m_horizontalScrollBar->setMinimum (0); + if (m_bufferSize.width () > m_consoleRect.width ()) + m_horizontalScrollBar->setMaximum (m_bufferSize.width () - m_consoleRect.width ()); else - m_scrollBar->setMaximum (0); - m_scrollBar->setSingleStep (1); - m_scrollBar->setPageStep (m_consoleRect.height ()); - m_scrollBar->setValue (m_consoleRect.top ()); + m_horizontalScrollBar->setMaximum (0); + m_horizontalScrollBar->setSingleStep (1); + m_horizontalScrollBar->setPageStep (m_consoleRect.width ()); + m_horizontalScrollBar->setValue (m_consoleRect.left ()); + + log ("Horizontal scrollbar parameters updated: %d/%d/%d/%d\n", + m_horizontalScrollBar->minimum (), + m_horizontalScrollBar->maximum (), + m_horizontalScrollBar->singleStep (), + m_horizontalScrollBar->pageStep ()); +} - log ("Scrollbar parameters updated: %d/%d/%d/%d\n", - m_scrollBar->minimum (), m_scrollBar->maximum (), - m_scrollBar->singleStep (), m_scrollBar->pageStep ()); +void QConsolePrivate::updateVerticalScrollBar (void) +{ + m_verticalScrollBar->setMinimum (0); + if (m_bufferSize.height () > m_consoleRect.height ()) + m_verticalScrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ()); + else + m_verticalScrollBar->setMaximum (0); + m_verticalScrollBar->setSingleStep (1); + m_verticalScrollBar->setPageStep (m_consoleRect.height ()); + m_verticalScrollBar->setValue (m_consoleRect.top ()); + + log ("Vertical scrollbar parameters updated: %d/%d/%d/%d\n", + m_verticalScrollBar->minimum (), m_verticalScrollBar->maximum (), + m_verticalScrollBar->singleStep (), m_verticalScrollBar->pageStep ()); } ////////////////////////////////////////////////////////////////////////////// -void QConsolePrivate::setScrollValue (int value) +void QConsolePrivate::setHorizontalScrollValue (int value) +{ + if (value == m_consoleRect.left ()) + return; + + SMALL_RECT r; + HANDLE hStdOut = m_stdOut; + + if (value + m_consoleRect.width () > m_bufferSize.width ()) + value = m_bufferSize.width () - m_consoleRect.width (); + + r.Left = value; + r.Top = m_consoleRect.top (); + r.Right = value + m_consoleRect.width () - 1; + r.Bottom = m_consoleRect.bottom (); + + log ("Scrolling window horizontally: (%d, %d) -> (%d, %d) [%d x %d]\n", + r.Left, r.Top, r.Right, r.Bottom, + r.Right - r.Left + 1, r.Bottom - r.Top + 1); + + if (SetConsoleWindowInfo (hStdOut, TRUE, &r)) + { + m_consoleRect.moveLeft (value); + updateConsoleView (); + } +} + +void QConsolePrivate::setVerticalScrollValue (int value) { if (value == m_consoleRect.top ()) return; @@ -1023,7 +1202,7 @@ r.Right = m_consoleRect.right (); r.Bottom = value + m_consoleRect.height () - 1; - log ("Scrolling window: (%d, %d) -> (%d, %d) [%d x %d]\n", + log ("Scrolling window vertically: (%d, %d) -> (%d, %d) [%d x %d]\n", r.Left, r.Top, r.Right, r.Bottom, r.Right - r.Left + 1, r.Bottom - r.Top + 1); @@ -1070,7 +1249,8 @@ // Buffer size changed m_bufferSize.rwidth () = sbi.dwSize.X; m_bufferSize.rheight () = sbi.dwSize.Y; - updateScrollBar (); + updateHorizontalScrollBar (); + updateVerticalScrollBar (); } if (m_cursorPos.x () != sbi.dwCursorPosition.X @@ -1098,7 +1278,8 @@ m_consoleRect = QRect (sbi.srWindow.Left, sbi.srWindow.Top, sbi.srWindow.Right - sbi.srWindow.Left + 1, sbi.srWindow.Bottom - sbi.srWindow.Top + 1); - updateScrollBar (); + updateHorizontalScrollBar (); + updateVerticalScrollBar (); updateConsoleView (); return; } @@ -1238,12 +1419,18 @@ ////////////////////////////////////////////////////////////////////////////// QWinTerminalImpl::QWinTerminalImpl (QWidget* parent) - : QTerminal (parent), d (new QConsolePrivate (this)) + : QTerminal (parent), d (new QConsolePrivate (this)), + allowTripleClick (false) { installEventFilter (this); connect (this, SIGNAL (set_global_shortcuts_signal (bool)), parent, SLOT (set_global_shortcuts (bool))); + + connect (this, SIGNAL (set_screen_size_signal (int, int)), + parent, SLOT (set_screen_size (int, int))); + + setAcceptDrops (true); } ////////////////////////////////////////////////////////////////////////////// @@ -1272,7 +1459,11 @@ void QWinTerminalImpl::mousePressEvent (QMouseEvent *event) { - if (event->button () == Qt::LeftButton) + if (allowTripleClick) + { + mouseTripleClickEvent (event); + } + else if (event->button () == Qt::LeftButton) { d->m_settingSelection = true; @@ -1282,7 +1473,7 @@ void QWinTerminalImpl::mouseReleaseEvent (QMouseEvent *event) { - if (event->button () == Qt::LeftButton) + if (event->button () == Qt::LeftButton && d->m_settingSelection) { d->m_endSelection = d->posToCell (event->pos ()); @@ -1292,6 +1483,36 @@ } } +void QWinTerminalImpl::mouseDoubleClickEvent (QMouseEvent *event) +{ + if (event->button () == Qt::LeftButton) + { + // doubleclick - select word + d->m_settingSelection = false; + + d->selectWord (d->posToCell (event->pos ())); + + allowTripleClick = true; + + QTimer::singleShot (QApplication::doubleClickInterval (),this, + SLOT (tripleClickTimeout ())); + + } +} + +void QWinTerminalImpl::mouseTripleClickEvent (QMouseEvent *event) +{ + if (event->button () == Qt::LeftButton) + { + d->selectLine (d->posToCell (event->pos ())); + } +} + +void QWinTerminalImpl::tripleClickTimeout () +{ + allowTripleClick = false; +} + ////////////////////////////////////////////////////////////////////////////// void QWinTerminalImpl::viewResizeEvent (QConsoleView*, QResizeEvent*) @@ -1357,6 +1578,13 @@ } } +// Reset width of console buffer and terminal window to be the same. + +void QWinTerminalImpl::init_terminal_size (void) +{ + d->updateConsoleSize (true, true); +} + ////////////////////////////////////////////////////////////////////////////// void QWinTerminalImpl::wheelEvent (QWheelEvent* event) @@ -1365,16 +1593,21 @@ { // Forward to the scrollbar (avoid recursion) d->m_inWheelEvent = true; - QApplication::sendEvent (d->m_scrollBar, event); + QApplication::sendEvent (d->m_verticalScrollBar, event); d->m_inWheelEvent = false; } } ////////////////////////////////////////////////////////////////////////////// -void QWinTerminalImpl::scrollValueChanged (int value) +void QWinTerminalImpl::horizontalScrollValueChanged (int value) { - d->setScrollValue (value); + d->setHorizontalScrollValue (value); +} + +void QWinTerminalImpl::verticalScrollValueChanged (int value) +{ + d->setVerticalScrollValue (value); } ////////////////////////////////////////////////////////////////////////////// @@ -1500,6 +1733,12 @@ d->setCursorColor (useForegroundColor, color); } +void QWinTerminalImpl::setScrollBufferSize(int value) +{ + d->setScrollBufferSize (value); +} + + ////////////////////////////////////////////////////////////////////////////// void QWinTerminalImpl::setTerminalFont (const QFont& f) @@ -1513,8 +1752,9 @@ void QWinTerminalImpl::setSize (int columns, int lines) { - Q_UNUSED (columns); - Q_UNUSED (lines); + d->log ("emit set_screen_size_signal (%d, %d)\n", columns, lines); + + emit set_screen_size_signal (columns, lines); } ////////////////////////////////////////////////////////////////////////////// @@ -1549,6 +1789,16 @@ sendText (text); } +////////////////////////////////////////////////////////////////////////////// + +void QWinTerminalImpl::selectAll (void) +{ + if(!hasFocus()) return; + + d->selectAll(); +} + + ////////////////////////////////////////////////////////////////////////////// @@ -1557,3 +1807,31 @@ QString selection = d->getSelection (); return selection; } + +////////////////////////////////////////////////////////////////////////////// + +void QWinTerminalImpl::dragEnterEvent (QDragEnterEvent *event) +{ + if (event->mimeData ()->hasUrls ()) + { + event->acceptProposedAction(); + } +} + +////////////////////////////////////////////////////////////////////////////// + +void QWinTerminalImpl::dropEvent (QDropEvent *event) +{ + QString dropText; + + if (event->mimeData ()->hasUrls ()) + { + foreach (QUrl url, event->mimeData ()->urls ()) + { + if(dropText.length () > 0) + dropText += "\n"; + dropText += url.toLocalFile (); + } + sendText (dropText); + } +} diff -r 75a671fcdd73 -r 844448ae53f3 libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h --- a/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/qterminal/libqterminal/win32/QWinTerminalImpl.h Fri Jan 23 15:23:09 2015 -0500 @@ -32,6 +32,8 @@ class QResizeEvent; class QWheelEvent; class QPoint; +class QDragEnterEvent; +class QDropEvent; class QConsolePrivate; class QConsoleThread; @@ -60,18 +62,22 @@ void setForegroundColor (const QColor& color); void setSelectionColor (const QColor& color); void setCursorColor (bool useForegoundColor, const QColor& color); + void setScrollBufferSize(int value); QString selectedText (); public slots: void copyClipboard (void); void pasteClipboard (void); + void selectAll (void); void blinkCursorEvent (void); + void init_terminal_size (void); signals: void terminated (void); void titleChanged (const QString&); void set_global_shortcuts_signal (bool); + void set_screen_size_signal (int, int); protected: void viewPaintEvent (QConsoleView*, QPaintEvent*); @@ -86,16 +92,24 @@ void mouseMoveEvent (QMouseEvent *event); void mousePressEvent (QMouseEvent *event); void mouseReleaseEvent (QMouseEvent *event); + void mouseDoubleClickEvent (QMouseEvent* event); + void mouseTripleClickEvent (QMouseEvent* event); bool eventFilter(QObject *obj, QEvent *ev); + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + private slots: - void scrollValueChanged (int value); + void horizontalScrollValueChanged (int value); + void verticalScrollValueChanged (int value); void monitorConsole (void); void updateSelection (void); + void tripleClickTimeout (void); private: QConsolePrivate* d; + bool allowTripleClick; }; ////////////////////////////////////////////////////////////////////////////// diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/dialog.cc --- a/libgui/src/dialog.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/dialog.cc Fri Jan 23 15:23:09 2015 -0500 @@ -466,18 +466,18 @@ &uiwidget_creator, SLOT (filedialog_finished (const QStringList&, const QString&, int))); + connect (this, SIGNAL (accepted ()), this, SLOT (acceptSelection ())); + connect (this, SIGNAL (rejected ()), this, SLOT (rejectSelection ())); } void -FileDialog::reject (void) +FileDialog::rejectSelection(void) { QStringList empty; emit finish_input (empty, "", 0); - done (QDialog::Rejected); - } -void FileDialog::accept (void) +void FileDialog::acceptSelection (void) { QStringList string_result; QString path; @@ -485,20 +485,33 @@ string_result = selectedFiles (); + if (testOption (QFileDialog::ShowDirsOnly) == true && + string_result.size () > 0) + { + path = string_result[0]; + } + else + { + path = directory ().absolutePath (); + } + // Matlab expects just the file name, whereas the file dialog gave us - // pull path names, so fix it. + // full path names, so fix it. for (int i = 0; i < string_result.size (); i++) string_result[i] = QFileInfo (string_result[i]).fileName (); + // if not showing only dirs, add end slash for the path component + if (testOption (QFileDialog::ShowDirsOnly) == false) + path = path + "/"; - path = directory ().absolutePath (); + // convert to native slashes + path = QDir::toNativeSeparators (path); QStringList name_filters = nameFilters (); idx = name_filters.indexOf (selectedNameFilter ()) + 1; // send the selected info emit finish_input (string_result, path, idx); - done (QDialog::Accepted); } diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/dialog.h --- a/libgui/src/dialog.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/dialog.h Fri Jan 23 15:23:09 2015 -0500 @@ -261,9 +261,9 @@ private slots: - void reject (void); + void rejectSelection (void); - void accept (void); + void acceptSelection (void); }; #endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/documentation-dock-widget.cc --- a/libgui/src/documentation-dock-widget.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/documentation-dock-widget.cc Fri Jan 23 15:23:09 2015 -0500 @@ -52,12 +52,17 @@ _webinfo->pasteClipboard (); } void +documentation_dock_widget::selectAll () +{ + _webinfo->selectAll (); +} + +void documentation_dock_widget::showDoc (const QString &name) { - // show the doc pane + // show the doc pane without focus for carrying on typing in the console if (!isVisible ()) setVisible (true); - setFocus (); raise (); _webinfo->load_ref (name); diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/documentation-dock-widget.h --- a/libgui/src/documentation-dock-widget.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/documentation-dock-widget.h Fri Jan 23 15:23:09 2015 -0500 @@ -38,6 +38,7 @@ protected slots: void copyClipboard (); void pasteClipboard (); + void selectAll (); void showDoc (const QString & name); private: diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/files-dock-widget.cc --- a/libgui/src/files-dock-widget.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/files-dock-widget.cc Fri Jan 23 15:23:09 2015 -0500 @@ -127,7 +127,7 @@ popdown_menu->addSeparator (); popdown_menu->addAction (QIcon (":/actions/icons/folder.png"), - tr ("Search Directory..."), + tr ("Set Browser Directory..."), this, SLOT (popdownmenu_search_dir (bool))); popdown_menu->addSeparator (); popdown_menu->addAction (QIcon (":/actions/icons/findf.png"), @@ -155,8 +155,29 @@ QSettings *settings = resource_manager::get_settings (); // FIXME: what should happen if settings is 0? - // Create the QFileSystemModel starting in the actual directory - QDir curr_dir; + // Create the QFileSystemModel starting in the desired directory + QDir startup_dir; // take current dir + + if (settings->value ("filesdockwidget/restore_last_dir",false).toBool ()) + { + // restore last dir from previous session + QStringList last_dirs + = settings->value ("filesdockwidget/mru_dir_list").toStringList (); + if (last_dirs.length () > 0) + startup_dir = QDir (last_dirs.at (0)); // last dir in previous session + } + else if (! settings->value ("filesdockwidget/startup_dir").toString ().isEmpty ()) + { + // do not restore but there is a startup dir configured + startup_dir = QDir (settings->value ("filesdockwidget/startup_dir").toString ()); + } + + if (! startup_dir.exists ()) + { + // the configured startup dir does not exist, take actual one + startup_dir = QDir (); + } + _file_system_model = new QFileSystemModel (this); if (settings->value ("filesdockwidget/showHiddenFiles",false).toBool ()) { @@ -168,7 +189,7 @@ _file_system_model->setFilter (QDir::NoDotAndDotDot | QDir::AllEntries); } QModelIndex rootPathIndex = _file_system_model->setRootPath ( - curr_dir.absolutePath ()); + startup_dir.absolutePath ()); // Attach the model to the QTreeView and set the root index _file_tree_view = new FileTreeViewer (container); @@ -502,18 +523,18 @@ } menu.addSeparator (); - menu.addAction (tr ("Rename"), this, SLOT (contextmenu_rename (bool))); - menu.addAction (QIcon (":/actions/icons/editdelete.png"), tr ("Delete"), - this, SLOT (contextmenu_delete (bool))); + menu.addAction (tr ("Rename..."), this, SLOT (contextmenu_rename (bool))); + menu.addAction (QIcon (":/actions/icons/editdelete.png"), + tr ("Delete..."), this, SLOT (contextmenu_delete (bool))); if (info.isDir ()) { menu.addSeparator (); menu.addAction (QIcon (":/actions/icons/filenew.png"), - tr ("New File"), + tr ("New File..."), this, SLOT (contextmenu_newfile (bool))); menu.addAction (QIcon (":/actions/icons/folder_new.png"), - tr ("New Directory"), + tr ("New Directory..."), this, SLOT (contextmenu_newdir (bool))); } @@ -836,7 +857,7 @@ QString name = QInputDialog::getText (this, tr ("Create File"), tr ("Create file in\n","String ends with \\n!") + parent_dir, - QLineEdit::Normal, "New File.txt", &ok); + QLineEdit::Normal, tr ("New File.txt"), &ok); if (ok && name.length () > 0) { name = parent_dir + "/" + name; @@ -854,7 +875,7 @@ QString name = QInputDialog::getText (this, tr ("Create Directory"), tr ("Create folder in\n","String ends with \\n!") + parent_dir, - QLineEdit::Normal, "New Directory", &ok); + QLineEdit::Normal, tr ("New Directory"), &ok); if (ok && name.length () > 0) { QDir dir (parent_dir); @@ -903,5 +924,20 @@ } } +void +files_dock_widget::selectAll () +{ + if (_file_tree_view->hasFocus ()) + _file_tree_view->selectAll (); + if (_current_directory->hasFocus ()) + { + QLineEdit * edit = _current_directory->lineEdit (); + if (edit) + { + edit->selectAll (); + } + } +} + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/files-dock-widget.h --- a/libgui/src/files-dock-widget.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/files-dock-widget.h Fri Jan 23 15:23:09 2015 -0500 @@ -113,6 +113,7 @@ /* from octave_doc_widget */ void copyClipboard (); void pasteClipboard (); + void selectAll (); signals: diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/find-files-dialog.cc --- a/libgui/src/find-files-dialog.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/find-files-dialog.cc Fri Jan 23 15:23:09 2015 -0500 @@ -61,7 +61,7 @@ QLabel * file_name_label = new QLabel (tr ("Named:")); _file_name_edit = new QLineEdit; - _file_name_edit->setToolTip (tr ("Enter the filename expression")); + _file_name_edit->setToolTip (tr ("Enter the filename search expression")); _file_name_edit->setText (settings->value ("findfiles/file_name", "*").toString ()); @@ -79,13 +79,13 @@ _browse_button->setToolTip (tr ("Browse for start directory")); connect (_browse_button, SIGNAL (clicked ()), this, SLOT (browse_folders ())); - _recurse_dirs_check = new QCheckBox (tr ("Recurse directories")); + _recurse_dirs_check = new QCheckBox (tr ("Search subdirectories")); _recurse_dirs_check->setChecked (settings->value ("findfiles/recurse_dirs", false).toBool ()); _recurse_dirs_check->setToolTip ( tr ("Search recursively through directories for matching files")); - _include_dirs_check = new QCheckBox (tr ("Include directories")); + _include_dirs_check = new QCheckBox (tr ("Include directory names")); _include_dirs_check->setChecked (settings->value ("findfiles/include_dirs", false).toBool ()); _include_dirs_check->setToolTip ( @@ -97,7 +97,7 @@ _name_case_check->setToolTip (tr ("Set matching name is case insensitive")); _contains_text_check = new QCheckBox (tr ("Contains text:")); - _contains_text_check->setToolTip (tr ("Search must match text")); + _contains_text_check->setToolTip (tr ("Enter the file content search expression")); _contains_text_check->setChecked (settings->value ("findfiles/check_text", false).toBool ()); @@ -304,7 +304,7 @@ _contains_text_edit->setEnabled (true); find_files_model *m = static_cast (_file_list->model ()); - QString res_str = QString ("%1 matches").arg (m->rowCount ()); + QString res_str = QString (tr("%1 match(es)")).arg (m->rowCount ()); _status_bar->showMessage (res_str); } diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/history-dock-widget.cc --- a/libgui/src/history-dock-widget.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/history-dock-widget.cc Fri Jan 23 15:23:09 2015 -0500 @@ -29,8 +29,12 @@ #include #include #include +#include +#include +#include #include "error.h" +#include "resource-manager.h" #include "cmd-hist.h" @@ -71,28 +75,105 @@ SIGNAL (customContextMenuRequested (const QPoint &)), this, SLOT (ctxMenu (const QPoint &))); - _filter_line_edit = new QLineEdit (this); - _filter_line_edit->setStatusTip ( - tr ("Enter text to filter the command history.")); - QVBoxLayout *vbox_layout = new QVBoxLayout (); + _filter = new QComboBox (this); + _filter->setToolTip (tr ("Enter text to filter the command history")); + _filter->setEditable (true); + _filter->setMaxCount (MaxFilterHistory); + _filter->setInsertPolicy (QComboBox::NoInsert); + _filter->setSizeAdjustPolicy ( + QComboBox::AdjustToMinimumContentsLengthWithIcon); + QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Maximum); + _filter->setSizePolicy (sizePol); + _filter->completer ()->setCaseSensitivity (Qt::CaseSensitive); + + QLabel *filter_label = new QLabel (tr ("Filter")); + + _filter_checkbox = new QCheckBox (); setWindowIcon (QIcon (":/actions/icons/logo.png")); set_title (tr ("Command History")); setWidget (new QWidget ()); + QVBoxLayout *vbox_layout = new QVBoxLayout (); + QHBoxLayout *hbox_layout = new QHBoxLayout (); + hbox_layout->addWidget (filter_label); + hbox_layout->addWidget (_filter_checkbox); + hbox_layout->addWidget (_filter); + vbox_layout->addLayout (hbox_layout); vbox_layout->addWidget (_history_list_view); - vbox_layout->addWidget (_filter_line_edit); vbox_layout->setMargin (2); widget ()->setLayout (vbox_layout); - connect (_filter_line_edit, SIGNAL (textEdited (QString)), - &_sort_filter_proxy_model, SLOT (setFilterWildcard (QString))); + setFocusProxy (_filter->lineEdit ()); + + // Init state of the filter + QSettings *settings = resource_manager::get_settings (); + _filter->addItems (settings->value ("history_dock_widget/mru_list").toStringList ()); + + bool filter_state = + settings->value ("history_dock_widget/filter_active", false).toBool (); + _filter_checkbox->setChecked (filter_state); + filter_activate (filter_state); + + // Connect signals and slots + connect (_filter, SIGNAL (editTextChanged (const QString&)), + &_sort_filter_proxy_model, SLOT (setFilterWildcard (const QString&))); + connect (_filter_checkbox, SIGNAL (toggled (bool)), + this, SLOT (filter_activate (bool))); + connect (_filter->lineEdit (), SIGNAL (editingFinished ()), + this, SLOT (update_filter_history ())); connect (_history_list_view, SIGNAL (doubleClicked (QModelIndex)), this, SLOT (handle_double_click (QModelIndex))); - setFocusProxy (_filter_line_edit); + // shrink max. displayed entry size to desktop width + QSize screen = QDesktopWidget ().screenGeometry ().size (); + int w = screen.width (); + QFontMetrics fm = _history_list_view->fontMetrics (); + int h = fm.height (); + _history_list_view->setGridSize (QSize (w,h)); + _history_list_view->setTextElideMode (Qt::ElideRight); +} + +history_dock_widget::~history_dock_widget () +{ + QSettings *settings = resource_manager::get_settings (); + + settings->setValue ("history_dock_widget/filter_active", + _filter_checkbox->isChecked ()); + + QStringList mru; + for (int i = 0; i < _filter->count (); i++) + mru.append (_filter->itemText (i)); + settings->setValue ("history_dock_widget/mru_list", mru); + + settings->sync (); +} + +void +history_dock_widget::filter_activate (bool state) +{ + _filter->setEnabled (state); + _sort_filter_proxy_model.setDynamicSortFilter (state); + + if (state) + _sort_filter_proxy_model.setFilterWildcard (_filter->currentText ()); + else + _sort_filter_proxy_model.setFilterWildcard (QString ()); +} + +void +history_dock_widget::update_filter_history () +{ + QString text = _filter->currentText (); // get current text + int index = _filter->findText (text); // and its actual index + + if (index > -1) + _filter->removeItem (index); // remove if already existing + + _filter->insertItem (0, text); // (re)insert at beginning + _filter->setCurrentIndex (0); } void history_dock_widget::ctxMenu (const QPoint &xpos) @@ -203,22 +284,34 @@ { if (_history_list_view->hasFocus ()) handle_contextmenu_copy (true); - if (_filter_line_edit->hasFocus () && _filter_line_edit->hasSelectedText ()) + if (_filter->lineEdit ()->hasFocus () && _filter->lineEdit ()->hasSelectedText ()) { QClipboard *clipboard = QApplication::clipboard (); - clipboard->setText ( _filter_line_edit->selectedText ()); + clipboard->setText ( _filter->lineEdit ()->selectedText ()); } } void history_dock_widget::pasteClipboard () { - if (_filter_line_edit->hasFocus ()) + if (_filter->lineEdit ()->hasFocus ()) { QClipboard *clipboard = QApplication::clipboard (); QString str = clipboard->text (); if (str.length () > 0) - _filter_line_edit->insert (str); + _filter->lineEdit ()->insert (str); } } +void +history_dock_widget::selectAll () +{ + if (_filter->lineEdit ()->hasFocus ()) + { + _filter->lineEdit ()->selectAll (); + } + if (_history_list_view->hasFocus ()) + { + _history_list_view->selectAll (); + } +} diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/history-dock-widget.h --- a/libgui/src/history-dock-widget.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/history-dock-widget.h Fri Jan 23 15:23:09 2015 -0500 @@ -27,6 +27,9 @@ #include #include #include +#include +#include + #include "octave-dock-widget.h" class history_dock_widget : public octave_dock_widget @@ -36,6 +39,7 @@ public: history_dock_widget (QWidget *parent = 0); + ~history_dock_widget (); public slots: @@ -56,6 +60,9 @@ private slots: + void update_filter_history (); + void filter_activate (bool enable); + void handle_double_click (QModelIndex modelIndex); void handle_contextmenu_copy (bool flag); void handle_contextmenu_evaluate (bool flag); @@ -64,16 +71,20 @@ void copyClipboard (); void pasteClipboard (); + void selectAll (); private: void construct (); QListView *_history_list_view; - QLineEdit *_filter_line_edit; QSortFilterProxyModel _sort_filter_proxy_model; /** Stores the current history_model. */ QStringListModel *_history_model; + + QCheckBox *_filter_checkbox; + QComboBox *_filter; + enum { MaxFilterHistory = 10 }; }; #endif // HISTORYDOCKWIDGET_H diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/icons/widget-close-light.png Binary file libgui/src/icons/widget-close-light.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/icons/widget-dock-light.png Binary file libgui/src/icons/widget-dock-light.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/icons/widget-undock-light.png Binary file libgui/src/icons/widget-undock-light.png has changed diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/file-editor-interface.h --- a/libgui/src/m-editor/file-editor-interface.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/file-editor-interface.h Fri Jan 23 15:23:09 2015 -0500 @@ -44,6 +44,7 @@ virtual QMenu *debug_menu () = 0; virtual QToolBar *toolbar () = 0; + virtual void insert_new_open_actions (QAction*,QAction*,QAction*) = 0; virtual void handle_enter_debug_mode (void) = 0; virtual void handle_exit_debug_mode (void) = 0; @@ -59,7 +60,11 @@ virtual void handle_edit_file_request (const QString& file) = 0; - virtual void set_focus () = 0; + virtual bool check_closing (int closing_state) = 0; + + virtual void empty_script (bool, bool) = 0; + + virtual void enable_menu_shortcuts (bool enable) = 0; public slots: virtual void request_new_file (const QString& command = QString ()) = 0; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/file-editor-tab.cc --- a/libgui/src/m-editor/file-editor-tab.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/file-editor-tab.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1,3 +1,4 @@ + /* Copyright (C) 2011-2013 Jacob Dawid @@ -47,15 +48,20 @@ #include #include #include +#include #include "file-editor-tab.h" #include "file-editor.h" +#include "octave-txt-lexer.h" #include "file-ops.h" #include "debug.h" #include "octave-qt-link.h" #include "version.h" +#include "utils.h" +#include "defaults.h" +#include // Make parent null for the file editor tab so that warning // WindowModal messages don't affect grandparents. @@ -63,7 +69,9 @@ { QString directory = directory_arg; _lexer_apis = 0; - _app_closing = false; + _app_closing = 0; // app is not closing + _is_octave_file = true; + _modal_dialog = false; // Make sure there is a slash at the end of the directory name // for identification when saved later. @@ -74,34 +82,30 @@ _file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller"); _edit_area = new octave_qscintilla (this); - // Connect signal for command execution to a slot of this tab which in turn - // emits a signal connected to the main window. - // Direct connection is not possible because tab's parent is null. - connect (_edit_area, - SIGNAL (execute_command_in_terminal_signal (const QString&)), - this, - SLOT (execute_command_in_terminal (const QString&))); - connect (_edit_area, - SIGNAL (cursorPositionChanged (int, int)), - this, - SLOT (handle_cursor_moved (int,int))); + connect (_edit_area, SIGNAL (cursorPositionChanged (int, int)), + this, SLOT (handle_cursor_moved (int,int))); + + connect (_edit_area, SIGNAL (context_menu_edit_signal (const QString&)), + this, SLOT (handle_context_menu_edit (const QString&))); // create statusbar for row/col indicator and eol mode _status_bar = new QStatusBar (this); // eol mode + QLabel *eol_label = new QLabel (tr ("eol:"), this); _eol_indicator = new QLabel ("",this); _eol_indicator->setMinimumSize (35,0); + _status_bar->addPermanentWidget (eol_label, 0); _status_bar->addPermanentWidget (_eol_indicator, 0); // row- and col-indicator _row_indicator = new QLabel ("", this); _row_indicator->setMinimumSize (30,0); - QLabel *row_label = new QLabel (tr ("Line:"), this); + QLabel *row_label = new QLabel (tr ("line:"), this); _col_indicator = new QLabel ("", this); _col_indicator->setMinimumSize (25,0); - QLabel *col_label = new QLabel (tr ("Col:"), this); + QLabel *col_label = new QLabel (tr ("col:"), this); _status_bar->addPermanentWidget (row_label, 0); _status_bar->addPermanentWidget (_row_indicator, 0); _status_bar->addPermanentWidget (col_label, 0); @@ -130,10 +134,6 @@ _edit_area->setMarginsBackgroundColor (QColor (232, 232, 220)); _edit_area->setMarginType (2, QsciScintilla::TextMargin); - // code folding - _edit_area->setMarginType (3, QsciScintilla::SymbolMargin); - _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); - // other features _edit_area->setBraceMatching (QsciScintilla::StrictBraceMatch); _edit_area->setAutoIndent (true); @@ -143,8 +143,7 @@ _edit_area->setUtf8 (true); // auto completion - _edit_area->autoCompleteFromAll (); - _edit_area->setAutoCompletionSource (QsciScintilla::AcsAll); + _edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCSETCANCELATSTART, false); QVBoxLayout *edit_area_layout = new QVBoxLayout (); edit_area_layout->addWidget (_edit_area); @@ -198,9 +197,107 @@ } void -file_editor_tab::execute_command_in_terminal (const QString& command) +file_editor_tab::handle_context_menu_edit (const QString& word_at_cursor) { - emit execute_command_in_terminal_signal (command); // connected to main window + // 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 ()); + + if (! filename.endsWith (".m")) + filename.append (".m"); + + emit request_open_file (filename); } void @@ -218,9 +315,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); } @@ -273,6 +370,8 @@ delete lexer; lexer = 0; + _is_octave_file = false; + if (_file_name.endsWith (".m") || _file_name.endsWith ("octaverc")) { @@ -280,7 +379,10 @@ lexer = new QsciLexerOctave (); #elif defined (HAVE_LEXER_MATLAB) lexer = new QsciLexerMatlab (); +#else + lexer = new octave_txt_lexer (); #endif + _is_octave_file = true; } if (! lexer) @@ -309,35 +411,99 @@ { lexer = new QsciLexerDiff (); } + else if (_file_name.endsWith (".sh")) + { + lexer = new QsciLexerBash (); + } else if (! valid_file_name ()) { // 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 (); + lexer = new octave_txt_lexer (); #endif } else { // other or no extension - lexer = new QsciLexerBash (); + lexer = new octave_txt_lexer (); } } + QSettings *settings = resource_manager::get_settings (); + + // build information for auto completion (APIs) _lexer_apis = new QsciAPIs(lexer); + if (_lexer_apis) { + bool update_apis_file = false; // flag, whether update of apis files + // get path to prepared api info QDesktopServices desktopServices; QString prep_apis_path = desktopServices.storageLocation (QDesktopServices::HomeLocation) + "/.config/octave/" + QString(OCTAVE_VERSION) + "/qsci/"; - _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; + + // get settings which infos are used for octave + bool octave_builtins = settings->value ( + "editor/codeCompletion_octave_builtins", true).toBool (); + bool octave_functions = settings->value ( + "editor/codeCompletion_octave_functions", true).toBool (); + + if (_is_octave_file) + { + // octave file: keywords are always used + _prep_apis_file = prep_apis_path + lexer->lexer () + "_k"; + + if (octave_builtins) + _prep_apis_file = _prep_apis_file + "b"; // use builtins, too + + if (octave_functions) + _prep_apis_file = _prep_apis_file + "f"; // use keywords, too + + _prep_apis_file = _prep_apis_file + ".pap"; // final name of apis file + + // check whether the APIs info needs to be prepared and saved + QFileInfo apis_file = QFileInfo (_prep_apis_file); + update_apis_file = ! apis_file.exists (); // flag whether apis file needs update - if (!_lexer_apis->loadPrepared (_prep_apis_file)) + // function list depends on installed packages: check mod. date + if (! update_apis_file & octave_functions) + { + // check whether package file is newer than apis_file + QDateTime apis_date = apis_file.lastModified (); + + // compare to local package list + // FIXME: How to get user chosen location? + QFileInfo local_pkg_list = QFileInfo ( + desktopServices.storageLocation (QDesktopServices::HomeLocation) + + "/.octave_packages"); + if (local_pkg_list.exists () + & (apis_date < local_pkg_list.lastModified ()) ) + update_apis_file = true; + + // compare to global package list + // FIXME: How to get user chosen location? + QFileInfo global_pkg_list = QFileInfo ( + QString::fromStdString (Voctave_home) + + "/share/octave/octave_packages"); + if (global_pkg_list.exists () + & (apis_date < global_pkg_list.lastModified ()) ) + update_apis_file = true; + } + } + else // no octave file, just add extension + { + _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; + } + + if (update_apis_file | !_lexer_apis->loadPrepared (_prep_apis_file)) { // no prepared info loaded, prepare and save if possible @@ -345,12 +511,34 @@ QString keyword; QStringList keyword_list; int i,j; - for (i=1; i<=3; i++) // test the first 5 keyword sets + + if (_is_octave_file) { - keyword = QString(lexer->keywords (i)); // get list - keyword_list = keyword.split (QRegExp ("\\s+")); // split - for (j = 0; j < keyword_list.size (); j++) // add to API - _lexer_apis->add (keyword_list.at (j)); + // octave: get keywords from internal informations depending on + // user preferences + + // keywords are always used + add_octave_apis (F__keywords__ ()); // add new entries + + if (octave_builtins) + add_octave_apis (F__builtins__ ()); // add new entries + + if (octave_functions) + add_octave_apis (F__list_functions__ ()); // add new entries + + } + else + { + + _prep_apis_file = prep_apis_path + lexer->lexer () + ".pap"; + + for (i=1; i<=3; i++) // test the first 5 keyword sets + { + keyword = QString(lexer->keywords (i)); // get list + keyword_list = keyword.split (QRegExp ("\\s+")); // split + for (j = 0; j < keyword_list.size (); j++) // add to API + _lexer_apis->add (keyword_list.at (j)); + } } // dsiconnect slot for saving prepared info if already connected @@ -366,11 +554,11 @@ } } - QSettings *settings = resource_manager::get_settings (); - if (settings) - lexer->readSettings (*settings); + lexer->readSettings (*settings); _edit_area->setLexer (lexer); + _edit_area->setCaretForegroundColor (lexer->color (0)); + _edit_area->setIndentationGuidesForegroundColor (lexer->color (0)); // fix line number width with respect to the font size of the lexer if (settings->value ("editor/showLineNumbers", true).toBool ()) @@ -380,6 +568,17 @@ } +// function for adding entries to the octave lexer's APIs +void +file_editor_tab::add_octave_apis (octave_value_list key_ovl) +{ + octave_value keys = key_ovl(0); + Cell key_list = keys.cell_value (); + + for (int idx = 0; idx < key_list.numel (); idx++) + _lexer_apis->add (QString (key_list.elem (idx).string_value ().data ())); +} + void file_editor_tab::save_apis_info () { @@ -411,51 +610,6 @@ } void -file_editor_tab::undo (const QWidget *ID) -{ - if (ID != this) - return; - - _edit_area->undo (); -} - -void -file_editor_tab::redo (const QWidget *ID) -{ - if (ID != this) - return; - - _edit_area->redo (); -} - -void -file_editor_tab::copy (const QWidget *ID) -{ - if (ID != this) - return; - - _edit_area->copy (); -} - -void -file_editor_tab::cut (const QWidget *ID) -{ - if (ID != this) - return; - - _edit_area->cut (); -} - -void -file_editor_tab::paste (const QWidget *ID) -{ - if (ID != this) - return; - - _edit_area->paste (); -} - -void file_editor_tab::context_help (const QWidget *ID, bool doc) { if (ID != this) @@ -523,8 +677,12 @@ if (ID != this) return; - if (_edit_area->isModified ()) - save_file (_file_name); + if (_edit_area->isModified () | ! valid_file_name ()) + { + _modal_dialog = true; // force modal dialog if the file is a new one + save_file (_file_name); // save file dialog + _modal_dialog = false; // back to non-modal dialogs + } QFileInfo info (_file_name); emit run_file_signal (info); @@ -734,6 +892,15 @@ } void +file_editor_tab::scintilla_command (const QWidget *ID, unsigned int sci_msg) +{ + if (ID != this) + return; + + _edit_area->SendScintilla (sci_msg); +} + +void file_editor_tab::comment_selected_text (const QWidget *ID) { if (ID != this) @@ -752,6 +919,66 @@ } void +file_editor_tab::indent_selected_text (const QWidget *ID) +{ + if (ID != this) + return; + + do_indent_selected_text (true); +} + +void +file_editor_tab::unindent_selected_text (const QWidget *ID) +{ + if (ID != this) + return; + + do_indent_selected_text (false); +} + +void +file_editor_tab::convert_eol (const QWidget *ID, QsciScintilla::EolMode eol_mode) +{ + if (ID != this) + return; + + _edit_area->convertEols (eol_mode); + _edit_area->setEolMode (eol_mode); + update_eol_indicator (); +} + +void +file_editor_tab::zoom_in (const QWidget *ID) +{ + if (ID != this) + return; + + _edit_area->zoomIn (1); + auto_margin_width (); +} + +void +file_editor_tab::zoom_out (const QWidget *ID) +{ + if (ID != this) + return; + + _edit_area->zoomOut (1); + auto_margin_width (); +} + +void +file_editor_tab::zoom_normal (const QWidget *ID) +{ + if (ID != this) + return; + + _edit_area->zoomTo (0); + auto_margin_width (); +} + + +void file_editor_tab::handle_find_dialog_finished (int) { // Find dialog is going to hide. Save location of window for @@ -782,14 +1009,15 @@ _find_dialog->setWindowModality (Qt::NonModal); _find_dialog_geometry = _find_dialog->geometry (); } - - if (!_find_dialog->isVisible ()) + else if (!_find_dialog->isVisible ()) { _find_dialog->setGeometry (_find_dialog_geometry); - _find_dialog->show (); - _find_dialog_is_visible = true; + QPoint p = _find_dialog->pos (); + _find_dialog->move(p.x ()+10, p.y ()+10); } + _find_dialog->show (); + _find_dialog_is_visible = true; _find_dialog->activateWindow (); _find_dialog->init_search_text (); @@ -819,6 +1047,69 @@ _edit_area->setCursorPosition (line-1, 0); } +void +file_editor_tab::show_auto_completion (const QWidget *ID) +{ + if (ID != this) + return; + + QsciScintilla::AutoCompletionSource s = _edit_area->autoCompletionSource (); + switch (s) + { + case QsciScintilla::AcsAll: + _edit_area->autoCompleteFromAll (); + break; + + case QsciScintilla::AcsAPIs: + _edit_area->autoCompleteFromAPIs (); + break; + + case QsciScintilla::AcsDocument: + _edit_area->autoCompleteFromDocument (); + break; + + case QsciScintilla::AcsNone: + break; + } +} + +void +file_editor_tab::do_indent_selected_text (bool indent) +{ + // TODO + _edit_area->beginUndoAction (); + + if (_edit_area->hasSelectedText ()) + { + int lineFrom, lineTo, colFrom, colTo; + _edit_area->getSelection (&lineFrom, &colFrom, &lineTo, &colTo); + + if (colTo == 0) // the beginning of last line is not selected + lineTo--; // stop at line above + + for (int i = lineFrom; i <= lineTo; i++) + { + if (indent) + _edit_area->indent (i); + else + _edit_area->unindent (i); + } + //set selection on (un)indented section + _edit_area->setSelection (lineFrom, 0, lineTo, + _edit_area->text (lineTo).length ()); + } + else + { + int cpline, col; + _edit_area->getCursorPosition (&cpline, &col); + if (indent) + _edit_area->indent (cpline); + else + _edit_area->unindent (cpline); + } + + _edit_area->endUndoAction (); +} void file_editor_tab::do_comment_selected_text (bool comment) @@ -901,16 +1192,17 @@ 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 -// of the app +// of the app and the flag _modal_dialog void file_editor_tab::show_dialog (QDialog *dlg) { dlg->setAttribute (Qt::WA_DeleteOnClose); - if (_app_closing) + if (_app_closing | _modal_dialog) dlg->exec (); else { @@ -934,13 +1226,24 @@ QMessageBox::Discard; QString available_actions; - if (_app_closing) - available_actions = tr ("Do you want to save or discard the changes?"); - else + switch (_app_closing) { - buttons = buttons | QMessageBox::Cancel; // cancel is allowed - available_actions - = tr ("Do you want to cancel closing, save or discard the changes?"); + case -1: // octave is exiting and so does the gui + available_actions = + tr ("Do you want to save or discard the changes?"); + break; + + case 1: // gui is exiting + available_actions = + tr ("Do you want to cancel exiting octave, save or discard the changes?"); + buttons = buttons | QMessageBox::Cancel; + break; + + case 0: // tab is closing + available_actions = + tr ("Do you want to cancel closing, save or discard the changes?"); + buttons = buttons | QMessageBox::Cancel; + break; } QString file; @@ -1017,6 +1320,7 @@ return file.errorString (); QTextStream in (&file); + in.setCodec("UTF-8"); QApplication::setOverrideCursor (Qt::WaitCursor); _edit_area->setText (in.readAll ()); _edit_area->setEolMode (detect_eol_mode ()); @@ -1066,17 +1370,34 @@ } } - QsciScintilla::EolMode eol_mode = QsciScintilla::EolUnix; - int count_max = count_lf; + // get default from OS or from settings +#if defined (Q_OS_WIN32) + int os_eol_mode = QsciScintilla::EolWindows; +#elif defined (Q_OS_MAC) + int os_eol_mode = QsciScintilla::EolMac; +#else + int os_eol_mode = QsciScintilla::EolUnix; +#endif +QSettings *settings = resource_manager::get_settings (); +QsciScintilla::EolMode eol_mode = static_cast ( + settings->value("editor/default_eol_mode",os_eol_mode).toInt ()); + int count_max = 0; + + if (count_crlf > count_max) + { + eol_mode = QsciScintilla::EolWindows; + count_max = count_crlf; + } if (count_cr > count_max) { eol_mode = QsciScintilla::EolMac; count_max = count_cr; } - if (count_crlf > count_max) + if (count_lf > count_max) { - eol_mode = QsciScintilla::EolWindows; + eol_mode = QsciScintilla::EolUnix; + count_max = count_lf; } return eol_mode; @@ -1103,9 +1424,26 @@ file_editor_tab::new_file (const QString &commands) { update_window_title (false); // window title (no modification) + + QSettings *settings = resource_manager::get_settings (); + + // set the eol mode from the settings or depending on the OS if the entry is + // missing in the settings +#if defined (Q_OS_WIN32) + int eol_mode = QsciScintilla::EolWindows; +#elif defined (Q_OS_MAC) + int eol_mode = QsciScintilla::EolMac; +#else + int eol_mode = QsciScintilla::EolUnix; +#endif + _edit_area->setEolMode ( + static_cast ( + settings->value("editor/default_eol_mode",eol_mode).toInt ())); + + update_eol_indicator (); + _edit_area->setText (commands); _edit_area->setModified (false); // new file is not modified yet - update_eol_indicator (); } void @@ -1154,6 +1492,7 @@ // save the contents into the file QTextStream out (&file); + out.setCodec("UTF-8"); QApplication::setOverrideCursor (Qt::WaitCursor); out << _edit_area->text (); out.flush (); @@ -1205,9 +1544,56 @@ // it had/has no effect on Windows, though) fileDialog->setOption(QFileDialog::DontUseNativeDialog, true); + // get the dialog's layout for adding extra elements + QGridLayout *dialog_layout = dynamic_cast (fileDialog->layout ()); + int rows = dialog_layout->rowCount (); + + // define a new grid layout with the extra elements + QGridLayout *extra = new QGridLayout (fileDialog); + QSpacerItem *spacer = new QSpacerItem (1,1,QSizePolicy::Expanding, + QSizePolicy::Fixed); + QFrame *separator = new QFrame (fileDialog); + separator->setFrameShape (QFrame::HLine); // horizontal line as separator + separator->setFrameStyle (QFrame::Sunken); + + // combo box for choosing new line ending chars + QLabel *label_eol = new QLabel (tr ("Line Endings:")); + QComboBox *combo_eol = new QComboBox (); + combo_eol->addItem ("Windows (CRLF)"); // ensure the same order as in + combo_eol->addItem ("Mac (CR)"); // the settings dialog + combo_eol->addItem ("Unix (LF)"); + _save_as_desired_eol = _edit_area->eolMode (); // init with current eol + combo_eol->setCurrentIndex (_save_as_desired_eol); + + // track changes in the combo box + connect (combo_eol, SIGNAL (currentIndexChanged (int)), + this, SLOT (handle_combo_eol_current_index (int))); + + // build the extra grid layout + extra->addWidget (separator,0,0,1,3); + extra->addWidget (label_eol,1,0); + extra->addWidget (combo_eol,1,1); + extra->addItem (spacer, 1,2); + + // 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 { @@ -1221,13 +1607,19 @@ // constructor argument. fileDialog->setDirectory (_file_name); } + + // propose a name corresponding to the function name + QString fname = get_function_name (); + if (! fname.isEmpty ()) + 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&)), @@ -1246,8 +1638,55 @@ } void +file_editor_tab::handle_combo_eol_current_index (int index) +{ + _save_as_desired_eol = static_cast (index); +} + +void +file_editor_tab::handle_save_as_filter_selected (const QString& filter) +{ + QFileDialog *file_dialog = qobject_cast (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) +{ + QFileInfo file = QFileInfo (file_name); + QString base_name = file.baseName (); + + if ((file.suffix () == "m") + && (! valid_identifier (base_name.toStdString ()))) + { + int ans = QMessageBox::question (0, tr ("Octave Editor"), + tr ("\"%1\"\n" + "is not a valid identifier.\n\n" + "If you keep this file name, you will not be able to\n" + "call your script using its name as an Octave command.\n\n" + "Do you want to choose another name?").arg (base_name), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + if (ans == QMessageBox::Yes) + return true; + } + + return false; +} + +void file_editor_tab::handle_save_file_as_answer (const QString& saveFileName) { + if (_save_as_desired_eol != _edit_area->eolMode ()) + convert_eol (this,_save_as_desired_eol); + if (saveFileName == _file_name) { // same name as actual file, save it as "save" would do @@ -1256,18 +1695,31 @@ else { // Have editor check for conflict, do not delete tab after save. - emit editor_check_conflict_save (saveFileName, false); + if (check_valid_identifier (saveFileName)) + save_file_as (false); + else + emit editor_check_conflict_save (saveFileName, false); } } void file_editor_tab::handle_save_file_as_answer_close (const QString& saveFileName) { + if (_save_as_desired_eol != _edit_area->eolMode ()) + { + _edit_area->setReadOnly (false); // was set to read-only in save_file_as + convert_eol (this,_save_as_desired_eol); + _edit_area->setReadOnly (true); // restore read-only mode + } + // saveFileName == _file_name can not happen, because we only can get here // when we close a tab and _file_name is not a valid file name yet // Have editor check for conflict, delete tab after save. - emit editor_check_conflict_save (saveFileName, true); + if (check_valid_identifier (saveFileName)) + save_file_as (true); + else + emit editor_check_conflict_save (saveFileName, true); } void @@ -1289,21 +1741,28 @@ if (QFile::exists (_file_name)) { - // Create a WindowModal message that blocks the edit area - // by making _edit_area parent. - QMessageBox* msgBox - = new QMessageBox (QMessageBox::Warning, - tr ("Octave Editor"), - tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). - arg (_file_name), - QMessageBox::Yes | QMessageBox::No, this); + if (_always_reload_changed_files) + + load_file (_file_name); - connect (msgBox, SIGNAL (finished (int)), - this, SLOT (handle_file_reload_answer (int))); + else + { + // Create a WindowModal message that blocks the edit area + // by making _edit_area parent. + QMessageBox* msgBox + = new QMessageBox (QMessageBox::Warning, + tr ("Octave Editor"), + tr ("It seems that \'%1\' has been modified by another application. Do you want to reload it?"). + arg (_file_name), + QMessageBox::Yes | QMessageBox::No, this); - msgBox->setWindowModality (Qt::WindowModal); - msgBox->setAttribute (Qt::WA_DeleteOnClose); - msgBox->show (); + connect (msgBox, SIGNAL (finished (int)), + this, SLOT (handle_file_reload_answer (int))); + + msgBox->setWindowModality (Qt::WindowModal); + msgBox->setAttribute (Qt::WA_DeleteOnClose); + msgBox->show (); + } } else { @@ -1340,6 +1799,23 @@ update_lexer (); + // code folding + if (settings->value ("editor/code_folding",true).toBool ()) + { + _edit_area->setMarginType (3, QsciScintilla::SymbolMargin); + _edit_area->setFolding (QsciScintilla::BoxedTreeFoldStyle , 3); + } + else + { + _edit_area->setFolding (QsciScintilla::NoFoldStyle, 3); + } + + // status bar + if (settings->value ("editor/show_edit_status_bar",true).toBool ()) + _status_bar->show (); + else + _status_bar->hide (); + //highlight current line color QVariant default_var = QColor (240, 240, 240); QColor setting_color = settings->value ("editor/highlight_current_line_color", @@ -1348,30 +1824,29 @@ _edit_area->setCaretLineVisible (settings->value ("editor/highlightCurrentLine", true).toBool ()); - if (settings->value ("editor/codeCompletion", true).toBool ()) // auto compl. - { - bool match_keywords = settings->value + bool match_keywords = settings->value ("editor/codeCompletion_keywords",true).toBool (); - bool match_document = settings->value + bool match_document = settings->value ("editor/codeCompletion_document",true).toBool (); - QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone; - if (match_keywords) - if (match_document) - source = QsciScintilla::AcsAll; - else - source = QsciScintilla::AcsAPIs; - else if (match_document) - source = QsciScintilla::AcsDocument; - _edit_area->setAutoCompletionSource (source); + QsciScintilla::AutoCompletionSource source = QsciScintilla::AcsNone; + if (match_keywords) + if (match_document) + source = QsciScintilla::AcsAll; + else + source = QsciScintilla::AcsAPIs; + else if (match_document) + source = QsciScintilla::AcsDocument; + _edit_area->setAutoCompletionSource (source); - _edit_area->setAutoCompletionReplaceWord - (settings->value ("editor/codeCompletion_replace",false).toBool ()); - _edit_area->setAutoCompletionCaseSensitivity - (settings->value ("editor/codeCompletion_case",true).toBool ()); - _edit_area->setAutoCompletionThreshold - (settings->value ("editor/codeCompletion_threshold",2).toInt ()); - } + _edit_area->setAutoCompletionReplaceWord + (settings->value ("editor/codeCompletion_replace",false).toBool ()); + _edit_area->setAutoCompletionCaseSensitivity + (settings->value ("editor/codeCompletion_case",true).toBool ()); + + if (settings->value ("editor/codeCompletion", true).toBool ()) + _edit_area->setAutoCompletionThreshold + (settings->value ("editor/codeCompletion_threshold",2).toInt ()); else _edit_area->setAutoCompletionThreshold (-1); @@ -1383,6 +1858,9 @@ else _edit_area->setWhitespaceVisibility (QsciScintilla::WsInvisible); + _edit_area->setEolVisibility ( + settings->value("editor/show_eol_chars",false).toBool ()); + if (settings->value ("editor/showLineNumbers", true).toBool ()) { _edit_area->setMarginLineNumbers (2, true); @@ -1404,13 +1882,32 @@ (settings->value ("editor/backspace_unindents_line",false).toBool ()); _edit_area->setIndentationGuides (settings->value ("editor/show_indent_guides",false).toBool ()); + _edit_area->setIndentationsUseTabs + (settings->value ("editor/indent_uses_tabs",false).toBool ()); + _edit_area->setIndentationWidth + (settings->value ("editor/indent_width",2).toInt ()); _edit_area->setTabWidth (settings->value ("editor/tab_width",2).toInt ()); + _edit_area->SendScintilla (QsciScintillaBase::SCI_SETHSCROLLBAR, + settings->value ("editor/show_hscroll_bar",true).toBool ()); + _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTH,-1); + _edit_area->SendScintilla (QsciScintillaBase::SCI_SETSCROLLWIDTHTRACKING,true); + _long_title = settings->value ("editor/longWindowTitle", false).toBool (); update_window_title (_edit_area->isModified ()); + _edit_area->setEdgeColumn ( + settings->value ("editor/long_line_column",80).toInt ()); + if (settings->value ("editor/long_line_marker",true).toBool ()) + _edit_area->setEdgeMode (QsciScintilla::EdgeLine); + else + _edit_area->setEdgeMode (QsciScintilla::EdgeNone); + + // reload changed files + _always_reload_changed_files = + settings->value ("editor/always_reload_changed_files",false).toBool (); } void @@ -1419,14 +1916,16 @@ _edit_area->setMarginWidth (2, "1"+QString::number (_edit_area->lines ())); } -void -file_editor_tab::conditional_close (const QWidget *ID, bool app_closing) +// the following close request was changed from a signal slot into a +// normal function because we need the return value from close whether +// the tab really was closed (for canceling exiting octave). +// When emitting a signal, only the return value from the last slot +// goes back to the sender +bool +file_editor_tab::conditional_close (int app_closing) { - if (ID != this) - return; - _app_closing = app_closing; - close (); + return close (); } void @@ -1449,10 +1948,13 @@ if (_find_dialog && _find_dialog_is_visible) { _find_dialog->setGeometry (_find_dialog_geometry); + QPoint p = _find_dialog->pos (); + _find_dialog->move(p.x ()+10, p.y ()+10); _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 @@ -1563,8 +2065,36 @@ void file_editor_tab::handle_cursor_moved (int line, int col) { + if (_edit_area->SendScintilla (QsciScintillaBase::SCI_AUTOCACTIVE)) + show_auto_completion (this); + _row_indicator->setNum (line+1); _col_indicator->setNum (col+1); } +QString +file_editor_tab::get_function_name () +{ + 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 (1).remove (QRegExp("[ \t]*")); + else if (rxfun2.indexIn (lines.at (i)) != -1) + return rxfun2.cap (1).remove (QRegExp("[ \t]*")); + else if (rxfun3.indexIn (lines.at (i)) != -1) + return rxfun3.cap (1).remove (QRegExp("[ \t]*")); + else if (rxfun4.indexIn (lines.at (i)) != -1) + return rxfun4.cap (1).remove (QRegExp("[ \t]*")); + } + + return QString (); +} + #endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/file-editor-tab.h --- a/libgui/src/m-editor/file-editor-tab.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/file-editor-tab.h Fri Jan 23 15:23:09 2015 -0500 @@ -31,9 +31,11 @@ #include #include #include +#include #include "find-dialog.h" #include "octave-qscintilla.h" +#include "builtin-defun-decls.h" class file_editor; @@ -47,6 +49,12 @@ ~file_editor_tab (void); + octave_qscintilla *qsci_edit_area () { return _edit_area; } + + // Will initiate close if associated with the identifier tag. + bool conditional_close (int app_closing = 0); // default 0: close tab only + + public slots: void update_window_title (bool modified); @@ -57,9 +65,6 @@ // Tells the editor tab to react on changed settings. void notice_settings (const QSettings *settings); - // Will initiate close if associated with the identifier tag. - void conditional_close (const QWidget *ID, bool app_closing = false); - // Change to a different editor tab by identifier tag. void change_editor_state (const QWidget *ID); @@ -67,11 +72,6 @@ void file_name_query (const QWidget *ID); void set_focus (const QWidget *ID); - void undo (const QWidget *ID); - void redo (const QWidget *ID); - void copy (const QWidget *ID); - void cut (const QWidget *ID); - void paste (const QWidget *ID); void context_help (const QWidget *ID, bool); void context_edit (const QWidget *ID); void save_file (const QWidget *ID); @@ -91,10 +91,22 @@ void previous_breakpoint (const QWidget *ID); void remove_all_breakpoints (const QWidget *ID); + void scintilla_command (const QWidget *, unsigned int); + void comment_selected_text (const QWidget *ID); void uncomment_selected_text (const QWidget *ID); + + void indent_selected_text (const QWidget *ID); + void unindent_selected_text (const QWidget *ID); + void convert_eol (const QWidget *ID, QsciScintilla::EolMode); + + void zoom_in (const QWidget *ID); + void zoom_out (const QWidget *ID); + void zoom_normal (const QWidget *ID); + void find (const QWidget *ID); void goto_line (const QWidget *ID, int line = -1); + void show_auto_completion (const QWidget *ID); void insert_debugger_pointer (const QWidget *ID, int line = -1); void delete_debugger_pointer (const QWidget *ID, int line = -1); @@ -108,19 +120,21 @@ void file_has_changed (const QString& fileName); - void execute_command_in_terminal (const QString& command); + void handle_context_menu_edit (const QString&); signals: void file_name_changed (const QString& fileName, const QString& toolTip); - void editor_state_changed (bool copy_available, const QString& fileName); + void editor_state_changed (bool copy_available, const QString& fileName, + bool is_octave_file); void tab_remove_request (); void add_filename_to_list (const QString&, QWidget *); void mru_add_file (const QString& file_name); void editor_check_conflict_save (const QString& saveFileName, bool remove_on_success); void run_file_signal (const QFileInfo& info); - void execute_command_in_terminal_signal (const QString&); + void set_global_edit_shortcuts_signal (bool); + void request_open_file (const QString&); protected: @@ -145,6 +159,8 @@ 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 void save_apis_info (); @@ -176,6 +192,7 @@ bool valid_file_name (const QString& file=QString ()); void save_file (const QString& saveFileName, bool remove_on_success = false); void save_file_as (bool remove_on_success = false); + bool check_valid_identifier (QString file_name); void update_lexer (); void request_add_breakpoint (int line); @@ -185,12 +202,16 @@ int check_file_modified (); void do_comment_selected_text (bool comment); QString comment_string (const QString&); + void do_indent_selected_text (bool indent); void add_breakpoint_callback (const bp_info& info); void remove_breakpoint_callback (const bp_info& info); void remove_all_breakpoints_callback (const bp_info& info); void center_current_line (); + void add_octave_apis (octave_value_list key_ovl); + QString get_function_name (); + QsciScintilla::EolMode detect_eol_mode (); void update_eol_indicator (); @@ -201,12 +222,17 @@ QLabel *_col_indicator; QLabel *_eol_indicator; + QsciScintilla::EolMode _save_as_desired_eol; + QString _file_name; QString _file_name_short; bool _long_title; bool _copy_available; - bool _app_closing; + int _app_closing; // -1: octave exits, 1: exit request in gui, 0: no exit + bool _is_octave_file; + bool _modal_dialog; + bool _always_reload_changed_files; QFileSystemWatcher _file_system_watcher; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/file-editor.cc --- a/libgui/src/m-editor/file-editor.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/file-editor.cc Fri Jan 23 15:23:09 2015 -0500 @@ -28,6 +28,8 @@ #include "file-editor.h" #include "resource-manager.h" +#include "shortcut-manager.h" + #include #include #include @@ -36,8 +38,10 @@ #include #include #include +#include #include #include +#include #include "octave-link.h" #include "utils.h" @@ -53,10 +57,26 @@ construct (); setVisible (false); + + setAcceptDrops(true); } file_editor::~file_editor (void) { + // Close open tabs, if existing. In this case app closing must be + // initiated by octave. All tabs will be definetly closed and the + // user can not cancel exiting (close state -1) + if (_tab_widget->count ()) + check_closing (-1); + + if (_mru_file_menu) + delete _mru_file_menu; +} + +bool +file_editor::check_closing (int closing_state) +{ + // Save open files for restoring in next session; this only is possible QSettings *settings = resource_manager::get_settings (); // Have all file editor tabs signal what their file names are. @@ -76,31 +96,29 @@ settings->setValue ("editor/savedSessionTabs", fetFileNames); settings->sync (); + // Close all tabs. If exit is requested by the gui (octave still running) + // check whether closing a tab is successful or whether user wnats to cancel + // exiting the program. Return false in the latter case. + file_editor_tab *editor_tab; + for (int index = _tab_widget->count ()-1; index >= 0; index--) { - // true: app closing - emit fetab_close_request (_tab_widget->widget (index), true); + editor_tab = static_cast (_tab_widget->widget (index)); + if ((! editor_tab->conditional_close (closing_state)) && closing_state == 1) + return false; } - if (_mru_file_menu) - delete _mru_file_menu; + // Here, we really want to exit and all tabs are closed + return true; } + void file_editor::focus (void) { - set_focus (); -} + octave_dock_widget::focus (); -// set focus to editor and its current tab -void -file_editor::set_focus (void) -{ - if (!isVisible ()) - setVisible (true); - setFocus (); - activateWindow (); - raise (); +// set focus to current tab QWidget *fileEditorTab = _tab_widget->currentWidget (); if (fileEditorTab) emit fetab_set_focus (fileEditorTab); @@ -147,7 +165,7 @@ { add_file_editor_tab (fileEditorTab, ""); // new tab with empty title fileEditorTab->new_file (commands); // title is updated here - set_focus (); // focus editor and new tab + focus (); // focus editor and new tab } } @@ -211,10 +229,11 @@ fileDialog->setAcceptMode (QFileDialog::AcceptOpen); fileDialog->setViewMode (QFileDialog::Detail); + fileDialog->setFileMode (QFileDialog::ExistingFiles); fileDialog->setDirectory (ced); - connect (fileDialog, SIGNAL (fileSelected (const QString&)), - this, SLOT (request_open_file (const QString&))); + connect (fileDialog, SIGNAL (filesSelected (const QStringList&)), + this, SLOT (request_open_files (const QStringList&))); fileDialog->setWindowModality (Qt::NonModal); fileDialog->setAttribute (Qt::WA_DeleteOnClose); @@ -254,7 +273,21 @@ editor.replace ("%f", file_name); editor.replace ("%l", QString::number (line)); - QProcess::startDetached (editor); + bool started_ok = QProcess::startDetached (editor); + + if (started_ok != true) + { + QMessageBox *msgBox + = new QMessageBox (QMessageBox::Critical, + tr ("Octave Editor"), + tr ("Could not start custom file editor\n%1"). + arg (editor), + QMessageBox::Ok, this); + + msgBox->setWindowModality (Qt::NonModal); + msgBox->setAttribute (Qt::WA_DeleteOnClose); + msgBox->show (); + } if (line < 0 && ! file_name.isEmpty ()) handle_mru_add_file (QFileInfo (file_name).canonicalFilePath ()); @@ -283,6 +316,13 @@ } void +file_editor::request_open_files (const QStringList& open_file_names) +{ + for (int i = 0; i < open_file_names.count (); i++) + request_open_file (open_file_names.at (i)); +} + +void file_editor::request_open_file (const QString& openFileName, int line, bool debug_pointer, bool breakpoint_marker, bool insert) @@ -323,7 +363,7 @@ if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ())) { emit fetab_set_focus (tab); - set_focus (); + focus (); } } else @@ -376,27 +416,31 @@ else { // File does not exist, should it be crated? + bool create_file = true; QMessageBox *msgBox; - int answer; QSettings *settings = resource_manager::get_settings (); - if (settings->value ("editor/create_new_file", false).toBool ()) - { - answer = QMessageBox::Yes; - } - else + + if (!settings->value ("editor/create_new_file", false).toBool ()) { msgBox = new QMessageBox (QMessageBox::Question, tr ("Octave Editor"), tr ("File\n%1\ndoes not exist. " "Do you want to create it?").arg (openFileName), - QMessageBox::Yes - | QMessageBox::No, 0); + QMessageBox::NoButton,0); + QPushButton *create_button = + msgBox->addButton (tr ("Create"), QMessageBox::YesRole); + msgBox->addButton (tr ("Cancel"), QMessageBox::RejectRole); + msgBox->setDefaultButton (create_button); + msgBox->exec (); - msgBox->setAttribute (Qt::WA_DeleteOnClose); - answer = msgBox->exec (); + QAbstractButton *clicked_button = msgBox->clickedButton (); + if (clicked_button != create_button) + create_file = false; + + delete msgBox; } - if (answer == QMessageBox::Yes) + if (create_file) { // create the file and call the editor again QFile file (openFileName); @@ -426,7 +470,7 @@ if (! ((breakpoint_marker || debug_pointer) && is_editor_console_tabbed ())) { // really show editor and the current editor tab - set_focus (); + focus (); emit file_loaded_signal (); } } @@ -556,33 +600,45 @@ } void -file_editor::request_undo (void) +file_editor::request_undo (bool) { - emit fetab_undo (_tab_widget->currentWidget ()); + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_UNDO); } void -file_editor::request_redo (void) +file_editor::request_redo (bool) { - emit fetab_redo (_tab_widget->currentWidget ()); + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_REDO); } void -file_editor::request_copy (void) +file_editor::request_copy (bool) { - emit fetab_copy (_tab_widget->currentWidget ()); + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_COPY); } void -file_editor::request_cut (void) +file_editor::request_cut (bool) { - emit fetab_cut (_tab_widget->currentWidget ()); + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_CUT); } void -file_editor::request_paste (void) +file_editor::request_paste (bool) { - emit fetab_paste (_tab_widget->currentWidget ()); + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_PASTE); +} + +void +file_editor::request_selectall (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_SELECTALL); } void @@ -603,26 +659,26 @@ } void -file_editor::request_save_file (void) +file_editor::request_save_file (bool) { emit fetab_save_file (_tab_widget->currentWidget ()); } void -file_editor::request_save_file_as (void) +file_editor::request_save_file_as (bool) { emit fetab_save_file_as (_tab_widget->currentWidget ()); } void -file_editor::request_print_file (void) +file_editor::request_print_file (bool) { emit fetab_print_file (_tab_widget->currentWidget ()); } void -file_editor::request_run_file (void) +file_editor::request_run_file (bool) { emit fetab_run_file (_tab_widget->currentWidget ()); } @@ -634,83 +690,192 @@ } void -file_editor::request_toggle_bookmark (void) +file_editor::request_toggle_bookmark (bool) { emit fetab_toggle_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_next_bookmark (void) +file_editor::request_next_bookmark (bool) { emit fetab_next_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_previous_bookmark (void) +file_editor::request_previous_bookmark (bool) { emit fetab_previous_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_remove_bookmark (void) +file_editor::request_remove_bookmark (bool) { emit fetab_remove_bookmark (_tab_widget->currentWidget ()); } void -file_editor::request_toggle_breakpoint (void) +file_editor::request_toggle_breakpoint (bool) { emit fetab_toggle_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_next_breakpoint (void) +file_editor::request_next_breakpoint (bool) { emit fetab_next_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_previous_breakpoint (void) +file_editor::request_previous_breakpoint (bool) { emit fetab_previous_breakpoint (_tab_widget->currentWidget ()); } void -file_editor::request_remove_breakpoint (void) +file_editor::request_remove_breakpoint (bool) { emit fetab_remove_all_breakpoints (_tab_widget->currentWidget ()); } +// slots for Edit->Commands actions void -file_editor::request_comment_selected_text (void) +file_editor::request_delete_start_word (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_DELWORDLEFT); +} +void +file_editor::request_delete_end_word (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_DELWORDRIGHT); +} +void +file_editor::request_delete_start_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_DELLINELEFT); +} +void +file_editor::request_delete_end_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_DELLINERIGHT); +} +void +file_editor::request_delete_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_LINEDELETE); +} +void +file_editor::request_copy_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_LINECOPY); +} +void +file_editor::request_cut_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_LINECUT); +} +void +file_editor::request_duplicate_selection (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_SELECTIONDUPLICATE); +} +void +file_editor::request_transpose_line (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_LINETRANSPOSE); +} +void +file_editor::request_comment_selected_text (bool) { emit fetab_comment_selected_text (_tab_widget->currentWidget ()); } - void -file_editor::request_uncomment_selected_text (void) +file_editor::request_uncomment_selected_text (bool) { emit fetab_uncomment_selected_text (_tab_widget->currentWidget ()); } +// slots for Edit->Format actions void -file_editor::request_find (void) +file_editor::request_upper_case (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_UPPERCASE); +} +void +file_editor::request_lower_case (bool) +{ + emit fetab_scintilla_command (_tab_widget->currentWidget (), + QsciScintillaBase::SCI_LOWERCASE); +} +void +file_editor::request_indent_selected_text (bool) +{ + emit fetab_indent_selected_text (_tab_widget->currentWidget ()); +} + +void +file_editor::request_unindent_selected_text (bool) +{ + emit fetab_unindent_selected_text (_tab_widget->currentWidget ()); +} + +void +file_editor::request_conv_eol_windows (bool) +{ + emit fetab_convert_eol (_tab_widget->currentWidget (), + QsciScintilla::EolWindows); +} +void +file_editor::request_conv_eol_unix (bool) +{ + emit fetab_convert_eol (_tab_widget->currentWidget (), + QsciScintilla::EolUnix); +} +void +file_editor::request_conv_eol_mac (bool) +{ + emit fetab_convert_eol (_tab_widget->currentWidget (), + QsciScintilla::EolMac); +} + + +void +file_editor::request_find (bool) { emit fetab_find (_tab_widget->currentWidget ()); } void -file_editor::request_goto_line (void) +file_editor::request_goto_line (bool) { emit fetab_goto_line (_tab_widget->currentWidget ()); } void +file_editor::request_completion (bool) +{ + emit fetab_completion (_tab_widget->currentWidget ()); +} + +void file_editor::handle_mru_add_file (const QString& 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); _mru_files.prepend (file_name); + mru_menu_update (); } @@ -766,26 +931,39 @@ void file_editor::request_close_file (bool) { - emit fetab_close_request (_tab_widget->currentWidget ()); + file_editor_tab *editor_tab = + static_cast (_tab_widget->currentWidget ()); + editor_tab->conditional_close (0); // 0: app is not closing, only tab } void file_editor::request_close_all_files (bool) { + file_editor_tab *editor_tab; + // loop over all tabs starting from last one otherwise deletion changes index for (int index = _tab_widget->count ()-1; index >= 0; index--) - emit fetab_close_request (_tab_widget->widget (index)); + { + editor_tab = static_cast (_tab_widget->widget (index)); + editor_tab->conditional_close (0); // 0: app is not closing, only tab + } } void file_editor::request_close_other_files (bool) { + file_editor_tab *editor_tab; QWidget *tabID = _tab_widget->currentWidget (); + // loop over all tabs starting from last one otherwise deletion changes index for (int index = _tab_widget->count ()-1; index >= 0; index--) { if (tabID != _tab_widget->widget (index)) - emit fetab_close_request (_tab_widget->widget (index)); + { + editor_tab = + static_cast (_tab_widget->widget (index)); + editor_tab->conditional_close (0); // 0: app is not closing, only tab + } } } @@ -793,12 +971,9 @@ void file_editor::handle_tab_close_request (int index) { - // Signal to the tabs a request to close whomever matches the identifying - // tag (i.e., unique widget pointer). The reason for this indirection is - // that it will enable a file editor widget to toss up a non-static - // dialog box and later signal that it wants to be removed. - QWidget *tabID = _tab_widget->widget (index); - emit fetab_close_request (tabID); + file_editor_tab *editor_tab = + static_cast (_tab_widget->widget (index)); + editor_tab->conditional_close (0); // 0: app is not closing, only tab } void @@ -828,15 +1003,99 @@ editor_tab_map[fileName] = ID; } +// context menu of edit area void file_editor::active_tab_changed (int index) { emit fetab_change_request (_tab_widget->widget (index)); } +void file_editor::create_context_menu (QMenu *menu) +{ + // remove all standard actions from scintilla + QList all_actions = menu->actions (); + QAction* a; + + foreach (a, all_actions) + menu->removeAction (a); + + // add editor's actions with icons and customized shortcuts + menu->addAction (_undo_action); + menu->addAction (_redo_action); + menu->addSeparator (); + menu->addAction (_cut_action); + menu->addAction (_copy_action); + menu->addAction (_paste_action); + menu->addSeparator (); + menu->addAction (_selectall_action); + menu->addSeparator (); + menu->addAction (_run_selection_action); +} + +void +file_editor::toggle_preference (const QString& preference, bool def) +{ + QSettings *settings = resource_manager::get_settings (); + bool old = settings->value (preference,def).toBool (); + settings->setValue (preference,!old); + notice_settings (settings); +} + +void +file_editor::show_line_numbers (bool) +{ + toggle_preference ("editor/showLineNumbers",true); +} +void +file_editor::show_white_space (bool) +{ + toggle_preference ("editor/show_white_space",false); +} +void +file_editor::show_eol_chars (bool) +{ + toggle_preference ("editor/show_eol_chars",false); +} +void +file_editor::show_indent_guides (bool) +{ + toggle_preference ("editor/show_indent_guides",false); +} +void +file_editor::show_long_line (bool) +{ + toggle_preference ("editor/long_line_marker",true); +} + +void +file_editor::zoom_in (bool) +{ + emit fetab_zoom_in (_tab_widget->currentWidget ()); +} + +void +file_editor::zoom_out (bool) +{ + emit fetab_zoom_out (_tab_widget->currentWidget ()); +} + +void +file_editor::zoom_normal (bool) +{ + emit fetab_zoom_normal (_tab_widget->currentWidget ()); +} + +void +file_editor::edit_status_update (bool undo, bool redo) +{ + _undo_action->setEnabled (undo); + _redo_action->setEnabled (redo); +} + void file_editor::handle_editor_state_changed (bool copy_available, - const QString& file_name) + const QString& file_name, + bool is_octave_file) { // In case there is some scenario where traffic could be coming from // all the file editor tabs, just process info from the current active tab. @@ -844,7 +1103,8 @@ { _copy_action->setEnabled (copy_available); _cut_action->setEnabled (copy_available); - _context_run_action->setEnabled (copy_available); + _run_selection_action->setEnabled (copy_available); + _run_action->setEnabled (is_octave_file); if (!file_name.isEmpty ()) { @@ -866,6 +1126,39 @@ { int icon_size = settings->value ("toolbar_icon_size", 16).toInt (); _tool_bar->setIconSize (QSize (icon_size, icon_size)); + + int tab_width_min = settings->value ("editor/notebook_tab_width_min", 160) + .toInt (); + int tab_width_max = settings->value ("editor/notebook_tab_width_max", 300) + .toInt (); + + if (settings->value ("editor/longWindowTitle", false).toBool ()) + { + QString style_sheet = QString ("QTabBar::tab " + "{min-width: %1px; max-width: %2px;}") + .arg (tab_width_min).arg (tab_width_max); + _tab_widget->setElideMode (Qt::ElideLeft); + _tab_widget->setStyleSheet (style_sheet); + } + else + _tab_widget->setElideMode (Qt::ElideNone); + + _tab_widget->setUsesScrollButtons (true); + + bool show_it; + show_it = settings->value ("editor/showLineNumbers",true).toBool (); + _show_linenum_action->setChecked (show_it); + show_it = settings->value ("editor/show_white_space",false).toBool (); + _show_whitespace_action->setChecked (show_it); + show_it = settings->value ("editor/show_eol_chars",false).toBool (); + _show_eol_action->setChecked (show_it); + show_it = settings->value ("editor/show_indent_guides",false).toBool (); + _show_indguide_action->setChecked (show_it); + show_it = settings->value ("editor/long_line_marker",true).toBool (); + _show_longline_action->setChecked (show_it); + + set_shortcuts (); + // Relay signal to file editor tabs. emit fetab_settings_changed (settings); } @@ -883,6 +1176,59 @@ } void +file_editor::insert_new_open_actions (QAction *new_action, + QAction *new_fcn_action, + QAction *open_action) +{ + _fileMenu->insertAction (_mru_file_menu->menuAction (), open_action); + _fileMenu->insertAction (open_action, new_fcn_action); + _fileMenu->insertAction (new_fcn_action, new_action); + _tool_bar->insertAction (_save_action, open_action); + _tool_bar->insertAction (open_action, new_action); +} + +QAction* +file_editor::add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member) +{ + QAction *a = menu->addAction (icon, text, this, member); + addAction (a); // important for shortcut context + a->setShortcutContext (Qt::WidgetWithChildrenShortcut); + return a; +} + +void +file_editor::enable_menu_shortcuts (bool enable) +{ + QHash::const_iterator i = _hash_menu_text.constBegin(); + + while (i != _hash_menu_text.constEnd()) + { + i.key ()->setTitle (i.value ().at (! enable)); + ++i; + } +} + +QMenu* +file_editor::m_add_menu (QMenuBar *p, QString name) +{ + QMenu *menu = p->addMenu (name); + + QString base_name = name; // get a copy + // replace intended '&' ("&&") by a temp. string + base_name.replace ("&&","___octave_amp_replacement___"); + // remove single '&' (shortcut) + base_name.remove ("&"); + // restore intended '&' + base_name.replace ("___octave_amp_replacement___","&&"); + + // remember names with and without shortcut + _hash_menu_text[menu] = QStringList () << name << base_name; + + return menu; +} + +void file_editor::construct (void) { QWidget *editor_widget = new QWidget (this); @@ -897,79 +1243,13 @@ _tool_bar->setMovable (true); _tab_widget = new QTabWidget (editor_widget); _tab_widget->setTabsClosable (true); - - QAction *new_action = new QAction (QIcon (":/actions/icons/filenew.png"), - tr ("&New File"), _tool_bar); - - QAction *open_action = new QAction (QIcon (":/actions/icons/folder_documents.png"), - tr ("&Open File..."), _tool_bar); - - _save_action = new QAction (QIcon (":/actions/icons/filesave.png"), - tr ("&Save File"), _tool_bar); - - _save_as_action = new QAction (QIcon (":/actions/icons/filesaveas.png"), - tr ("Save File &As..."), _tool_bar); - - _print_action = new QAction ( QIcon (":/actions/icons/fileprint.png"), - tr ("Print..."), _tool_bar); - - _undo_action = new QAction (QIcon (":/actions/icons/undo.png"), - tr ("&Undo"), _tool_bar); - - _redo_action = new QAction (QIcon (":/actions/icons/redo.png"), - tr ("&Redo"), _tool_bar); - - _copy_action = new QAction (QIcon (":/actions/icons/editcopy.png"), - tr ("&Copy"), _tool_bar); - _copy_action->setEnabled (false); - - _cut_action = new QAction (QIcon (":/actions/icons/editcut.png"), - tr ("Cu&t"), _tool_bar); - _cut_action->setEnabled (false); - - _paste_action - = new QAction (QIcon (":/actions/icons/editpaste.png"), - tr ("Paste"), _tool_bar); +#ifdef HAVE_QTABWIDGET_SETMOVABLE + _tab_widget->setMovable (true); +#endif - _next_bookmark_action = new QAction (tr ("&Next Bookmark"), _tool_bar); - - _previous_bookmark_action = new QAction (tr ("Pre&vious Bookmark"), - _tool_bar); - - _toggle_bookmark_action = new QAction (tr ("Toggle &Bookmark"), _tool_bar); - - _remove_bookmark_action - = new QAction (tr ("&Remove All Bookmarks"), _tool_bar); - - QAction *next_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_next.png"), - tr ("&Next Breakpoint"), _tool_bar); - QAction *previous_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_prev.png"), - tr ("Pre&vious Breakpoint"), _tool_bar); - QAction *toggle_breakpoint_action - = new QAction (QIcon (":/actions/icons/bp_toggle.png"), - tr ("Toggle &Breakpoint"), _tool_bar); - QAction *remove_all_breakpoints_action - = new QAction (QIcon (":/actions/icons/bp_rm_all.png"), - tr ("&Remove All Breakpoints"), _tool_bar); - - _comment_selection_action - = new QAction (tr ("&Comment"), _tool_bar); - _uncomment_selection_action - = new QAction (tr ("&Uncomment"), _tool_bar); - - _find_action = new QAction (QIcon (":/actions/icons/find.png"), - tr ("&Find and Replace..."), _tool_bar); - - _run_action = new QAction (QIcon (":/actions/icons/artsbuilderexecute.png"), - tr ("Save File and Run"), _tool_bar); - - _goto_line_action = new QAction (tr ("Go &to Line..."), _tool_bar); // the mru-list and an empty array of actions QSettings *settings = resource_manager::get_settings (); - // FIXME: what should happen if settings is 0? _mru_files = settings->value ("editor/mru_file_list").toStringList (); for (int i = 0; i < MaxMRUFiles; ++i) { @@ -977,27 +1257,251 @@ _mru_file_actions[i]->setVisible (false); } - // some actions are disabled from the beginning - _copy_action->setEnabled (false); - _cut_action->setEnabled (false); + // menu bar + + // file menu + + _fileMenu = m_add_menu (_menu_bar, tr ("&File")); + + // new and open menus are inserted later by the main window + _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), _fileMenu); + for (int i = 0; i < MaxMRUFiles; ++i) + _mru_file_menu->addAction (_mru_file_actions[i]); + _fileMenu->addMenu (_mru_file_menu); + + _fileMenu->addSeparator (); + + _edit_function_action = add_action (_fileMenu, QIcon (), + tr ("&Edit Function"), SLOT (request_context_edit (bool))); + + _fileMenu->addSeparator (); + + _save_action = add_action (_fileMenu, QIcon (":/actions/icons/filesave.png"), + tr ("&Save File"), SLOT (request_save_file (bool))); + _save_as_action = add_action (_fileMenu, QIcon (":/actions/icons/filesaveas.png"), + tr ("Save File &As..."), SLOT (request_save_file_as (bool))); + + _fileMenu->addSeparator (); + + _close_action = add_action (_fileMenu, + QIcon::fromTheme("window-close",QIcon (":/actions/icons/fileclose.png")), + tr ("&Close"), SLOT (request_close_file (bool))); + _close_all_action = add_action (_fileMenu, + QIcon::fromTheme("window-close", QIcon (":/actions/icons/fileclose.png")), + tr ("Close All"), SLOT (request_close_all_files (bool))); + _close_others_action = add_action (_fileMenu, + QIcon::fromTheme("window-close", QIcon (":/actions/icons/fileclose.png")), + tr ("Close Other Files"), SLOT (request_close_other_files (bool))); + + _fileMenu->addSeparator (); + + _print_action = add_action (_fileMenu, QIcon (":/actions/icons/fileprint.png"), + tr ("Print..."), SLOT (request_print_file (bool))); + + // edit menu + + QMenu *editMenu = m_add_menu (_menu_bar, tr ("&Edit")); + + _undo_action = add_action (editMenu, QIcon (":/actions/icons/undo.png"), + tr ("&Undo"), SLOT (request_undo (bool))); + _undo_action->setEnabled (false); + _redo_action = add_action (editMenu, QIcon (":/actions/icons/redo.png"), + tr ("&Redo"), SLOT (request_redo (bool))); + _redo_action->setEnabled (false); + + editMenu->addSeparator (); - _run_action->setShortcutContext (Qt::WindowShortcut); - _save_action->setShortcutContext (Qt::WindowShortcut); - _save_as_action->setShortcutContext (Qt::WindowShortcut); + _copy_action = add_action (editMenu, QIcon (":/actions/icons/editcopy.png"), + tr ("&Copy"), SLOT (request_copy (bool))); + _copy_action->setEnabled (false); + _cut_action = add_action (editMenu, QIcon (":/actions/icons/editcut.png"), + tr ("Cu&t"), SLOT (request_cut (bool))); + _cut_action->setEnabled (false); + _paste_action = add_action (editMenu, QIcon (":/actions/icons/editpaste.png"), + tr ("Paste"), SLOT (request_paste (bool))); + + editMenu->addSeparator (); + + _selectall_action = add_action (editMenu, QIcon (), tr ("Select All"), + SLOT (request_selectall (bool))); + + editMenu->addSeparator (); + + _find_action = add_action (editMenu, QIcon (":/actions/icons/find.png"), + tr ("&Find and Replace..."), SLOT (request_find (bool))); + + editMenu->addSeparator (); + + _edit_cmd_menu = editMenu->addMenu (tr ("&Commands")); + + _delete_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete Line"), SLOT (request_delete_line (bool))); + _copy_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Copy Line"), SLOT (request_copy_line (bool))); + _cut_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Cut Line"), SLOT (request_cut_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _delete_start_word_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to Start of Word"), SLOT (request_delete_start_word (bool))); + _delete_end_word_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to End of Word"), SLOT (request_delete_end_word (bool))); + _delete_start_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to Start of Line"), SLOT (request_delete_start_line (bool))); + _delete_end_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Delete to End of Line"), SLOT (request_delete_end_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _duplicate_selection_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Duplicate Selection/Line"), SLOT (request_duplicate_selection (bool))); + _transpose_line_action = add_action (_edit_cmd_menu, QIcon (), + tr ("Transpose Line"), SLOT (request_transpose_line (bool))); + + _edit_cmd_menu->addSeparator (); + + _completion_action = add_action (_edit_cmd_menu, QIcon (), + tr ("&Show Completion List"), SLOT (request_completion (bool))); + + _edit_fmt_menu = editMenu->addMenu (tr ("&Format")); + + _upper_case_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Uppercase Selection"), SLOT (request_upper_case (bool))); + _lower_case_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Lowercase Selection"), SLOT (request_lower_case (bool))); + + _edit_fmt_menu->addSeparator (); + + _comment_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Comment"), SLOT (request_comment_selected_text (bool))); + _uncomment_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Uncomment"), SLOT (request_uncomment_selected_text (bool))); - _print_action->setShortcutContext (Qt::WindowShortcut); + _edit_fmt_menu->addSeparator (); + + _indent_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Indent"), SLOT (request_indent_selected_text (bool))); + _unindent_selection_action = add_action (_edit_fmt_menu, QIcon (), + tr ("&Unindent"), SLOT (request_unindent_selected_text (bool))); + + _edit_fmt_menu->addSeparator (); + + _conv_eol_windows_action = add_action (_edit_fmt_menu, QIcon (), + tr ("Convert Line Endings to &Windows (CRLF)"), + SLOT (request_conv_eol_windows (bool))); + _conv_eol_unix_action = add_action (_edit_fmt_menu, QIcon (), + tr ("Convert Line Endings to &Unix (LF)"), + SLOT (request_conv_eol_unix (bool))); + _conv_eol_mac_action = add_action (_edit_fmt_menu, QIcon (), + tr ("Convert Line Endings to &Mac (CR)"), + SLOT (request_conv_eol_mac (bool))); + + _edit_nav_menu = editMenu->addMenu (tr ("Navi&gation")); + + _goto_line_action = add_action (_edit_nav_menu, QIcon (), + tr ("Go &to Line..."), SLOT (request_goto_line (bool))); + + _edit_nav_menu->addSeparator (); + + _next_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("&Next Bookmark"), SLOT (request_next_bookmark (bool))); + _previous_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("Pre&vious Bookmark"), SLOT (request_previous_bookmark (bool))); + _toggle_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("Toggle &Bookmark"), SLOT (request_toggle_bookmark (bool))); + _remove_bookmark_action = add_action (_edit_nav_menu, QIcon (), + tr ("&Remove All Bookmarks"), SLOT (request_remove_bookmark (bool))); + + editMenu->addSeparator (); + + _preferences_action = add_action (editMenu, + QIcon (":/actions/icons/configure.png"), + tr ("&Preferences..."), SLOT (request_preferences (bool))); + _styles_preferences_action = add_action (editMenu, + QIcon (":/actions/icons/configure.png"), + tr ("&Styles Preferences..."), SLOT (request_styles_preferences (bool))); + + // view menu + + QMenu *view_menu = m_add_menu (_menu_bar, tr ("&View")); + + _view_editor_menu = view_menu->addMenu (tr ("&Editor")); + + _show_linenum_action = add_action (_view_editor_menu, QIcon (), + tr ("Show &Line Numbers"), SLOT (show_line_numbers (bool))); + _show_linenum_action->setCheckable (true); + + _show_whitespace_action = add_action (_view_editor_menu, QIcon (), + tr ("Show &White Spaces"), SLOT (show_white_space (bool))); + _show_whitespace_action->setCheckable (true); - _next_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _previous_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _toggle_bookmark_action->setShortcutContext (Qt::WindowShortcut); - _comment_selection_action->setShortcutContext (Qt::WindowShortcut); - _uncomment_selection_action->setShortcutContext (Qt::WindowShortcut); - _find_action->setShortcutContext (Qt::WindowShortcut); - _goto_line_action->setShortcutContext (Qt::WindowShortcut); + _show_eol_action = add_action (_view_editor_menu, QIcon (), + tr ("Show Line &Endings"), SLOT (show_eol_chars (bool))); + _show_eol_action->setCheckable (true); + + _show_indguide_action = add_action (_view_editor_menu, QIcon (), + tr ("Show &Indentation Guides"), SLOT (show_indent_guides (bool))); + _show_indguide_action->setCheckable (true); + + _show_longline_action = add_action (_view_editor_menu, QIcon (), + tr ("Show Long Line &Marker"), SLOT (show_long_line (bool))); + _show_longline_action->setCheckable (true); + + view_menu->addSeparator (); + + _zoom_in_action = add_action (view_menu, QIcon (), + tr ("Zoom &In"), SLOT (zoom_in (bool))); + _zoom_out_action = add_action (view_menu, QIcon (), + tr ("Zoom &Out"), SLOT (zoom_out (bool))); + _zoom_normal_action = add_action (view_menu, QIcon (), + tr ("&Normal Size"), SLOT (zoom_normal (bool))); + + _menu_bar->addMenu (view_menu); + + // debug menu + + _debug_menu = m_add_menu (_menu_bar, tr ("&Debug")); + + _toggle_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_toggle.png"), tr ("Toggle &Breakpoint"), + SLOT (request_toggle_breakpoint (bool))); + _next_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_next.png"), tr ("&Next Breakpoint"), + SLOT (request_next_breakpoint (bool))); + _previous_breakpoint_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_prev.png"), tr ("Pre&vious Breakpoint"), + SLOT (request_previous_breakpoint (bool))); + _remove_all_breakpoints_action = add_action (_debug_menu, + QIcon (":/actions/icons/bp_rm_all.png"), tr ("&Remove All Breakpoints"), + SLOT (request_remove_breakpoint (bool))); + + _debug_menu->addSeparator (); + + // The other debug actions will be added by the main window. + + // run menu + + QMenu *_run_menu = m_add_menu (_menu_bar, tr ("&Run")); + + _run_action = add_action (_run_menu, QIcon (":/actions/icons/artsbuilderexecute.png"), + tr ("Save File and Run"), SLOT (request_run_file (bool))); + _run_selection_action = add_action (_run_menu, QIcon (), + tr ("Run &Selection"), SLOT (request_context_run (bool))); + _run_selection_action->setEnabled (false); + + // help menu + + QMenu *_help_menu = m_add_menu (_menu_bar, tr ("&Help")); + + _context_help_action = add_action (_help_menu, QIcon (), + tr ("&Help on Keyword"), SLOT (request_context_help (bool))); + _context_doc_action = add_action (_help_menu, QIcon (), + tr ("&Documentation on Keyword"), SLOT (request_context_doc (bool))); // toolbar - _tool_bar->addAction (new_action); - _tool_bar->addAction (open_action); + + // new and open actions are inserted later from main window _tool_bar->addAction (_save_action); _tool_bar->addAction (_save_as_action); _tool_bar->addSeparator (); @@ -1012,111 +1516,10 @@ _tool_bar->addAction (_find_action); _tool_bar->addAction (_run_action); _tool_bar->addSeparator (); - _tool_bar->addAction (toggle_breakpoint_action); - _tool_bar->addAction (next_breakpoint_action); - _tool_bar->addAction (previous_breakpoint_action); - _tool_bar->addAction (remove_all_breakpoints_action); - - // menu bar - QMenu *fileMenu = new QMenu (tr ("&File"), _menu_bar); - - _mru_file_menu = new QMenu (tr ("&Recent Editor Files"), fileMenu); - for (int i = 0; i < MaxMRUFiles; ++i) - _mru_file_menu->addAction (_mru_file_actions[i]); - - fileMenu->addAction (new_action); - fileMenu->addAction (QIcon (), tr ("New &Function..."), - this, SLOT (request_new_function (bool))); - fileMenu->addAction (open_action); - fileMenu->addMenu (_mru_file_menu); - fileMenu->addSeparator (); - _context_edit_action = - fileMenu->addAction (QIcon (), tr ("&Edit Function"), - this, SLOT (request_context_edit (bool))); - fileMenu->addSeparator (); - fileMenu->addAction (_save_action); - fileMenu->addAction (_save_as_action); - - fileMenu->addSeparator (); - _close_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("&Close"), this, SLOT (request_close_file (bool))); - _close_all_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("Close All"), - this, SLOT (request_close_all_files (bool))); - _close_others_action = - fileMenu->addAction (QIcon::fromTheme("window-close", - QIcon (":/actions/icons/fileclose.png")), - tr ("Close Other Files"), - this, SLOT (request_close_other_files (bool))); - - fileMenu->addSeparator (); - fileMenu->addAction (_print_action); - - _menu_bar->addMenu (fileMenu); - - - QMenu *editMenu = new QMenu (tr ("&Edit"), _menu_bar); - editMenu->addAction (_undo_action); - editMenu->addAction (_redo_action); - editMenu->addSeparator (); - editMenu->addAction (_copy_action); - editMenu->addAction (_cut_action); - editMenu->addAction (_paste_action); - editMenu->addSeparator (); - editMenu->addAction (_find_action); - editMenu->addSeparator (); - editMenu->addAction (_comment_selection_action); - editMenu->addAction (_uncomment_selection_action); - editMenu->addSeparator (); - editMenu->addAction (_toggle_bookmark_action); - editMenu->addAction (_next_bookmark_action); - editMenu->addAction (_previous_bookmark_action); - editMenu->addAction (_remove_bookmark_action); - editMenu->addSeparator (); - editMenu->addAction (_goto_line_action); - editMenu->addSeparator (); - _preferences_action = - editMenu->addAction (QIcon (":/actions/icons/configure.png"), - tr ("&Preferences..."), - this, SLOT (request_preferences (bool))); - _styles_preferences_action = - editMenu->addAction (QIcon (":/actions/icons/configure.png"), - tr ("&Styles Preferences..."), - this, SLOT (request_styles_preferences (bool))); - _menu_bar->addMenu (editMenu); - - _debug_menu = new QMenu (tr ("&Debug"), _menu_bar); - _debug_menu->addAction (toggle_breakpoint_action); - _debug_menu->addAction (next_breakpoint_action); - _debug_menu->addAction (previous_breakpoint_action); - _debug_menu->addAction (remove_all_breakpoints_action); - _debug_menu->addSeparator (); - // The other debug actions will be added by the main window. - _menu_bar->addMenu (_debug_menu); - - QMenu *_run_menu = new QMenu (tr ("&Run"), _menu_bar); - _run_menu->addAction (_run_action); - _context_run_action = - _run_menu->addAction (QIcon (), tr ("Run &Selection"), - this, SLOT (request_context_run (bool))); - _context_run_action->setEnabled (false); - _menu_bar->addMenu (_run_menu); - - QMenu *_help_menu = new QMenu (tr ("&Help"), _menu_bar); - _context_help_action = - _help_menu->addAction (QIcon (), tr ("&Help on Keyword"), - this, SLOT (request_context_help (bool))); - _context_doc_action = - _help_menu->addAction (QIcon (), tr ("&Documentation on Keyword"), - this, SLOT (request_context_doc (bool))); - _menu_bar->addMenu (_help_menu); - - // shortcuts - set_shortcuts (true); + _tool_bar->addAction (_toggle_breakpoint_action); + _tool_bar->addAction (_next_breakpoint_action); + _tool_bar->addAction (_previous_breakpoint_action); + _tool_bar->addAction (_remove_all_breakpoints_action); // layout QVBoxLayout *vbox_layout = new QVBoxLayout (); @@ -1138,75 +1541,6 @@ connect (main_win (), SIGNAL (open_file_signal (const QString&)), this, SLOT (request_open_file (const QString&))); - connect (new_action, SIGNAL (triggered ()), - this, SLOT (request_new_file ())); - - connect (open_action, SIGNAL (triggered ()), - this, SLOT (request_open_file ())); - - connect (_undo_action, SIGNAL (triggered ()), - this, SLOT (request_undo ())); - - connect (_redo_action, SIGNAL (triggered ()), - this, SLOT (request_redo ())); - - connect (_copy_action, SIGNAL (triggered ()), - this, SLOT (request_copy ())); - - connect (_cut_action, SIGNAL (triggered ()), - this, SLOT (request_cut ())); - - connect (_paste_action, SIGNAL (triggered ()), - this, SLOT (request_paste ())); - - connect (_save_action, SIGNAL (triggered ()), - this, SLOT (request_save_file ())); - - connect (_save_as_action, SIGNAL (triggered ()), - this, SLOT (request_save_file_as ())); - - connect (_print_action, SIGNAL (triggered ()), - this, SLOT (request_print_file ())); - - connect (_run_action, SIGNAL (triggered ()), - this, SLOT (request_run_file ())); - - connect (_toggle_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_toggle_bookmark ())); - - connect (_next_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_next_bookmark ())); - - connect (_previous_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_previous_bookmark ())); - - connect (_remove_bookmark_action, SIGNAL (triggered ()), - this, SLOT (request_remove_bookmark ())); - - connect (toggle_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_toggle_breakpoint ())); - - connect (next_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_next_breakpoint ())); - - connect (previous_breakpoint_action, SIGNAL (triggered ()), - this, SLOT (request_previous_breakpoint ())); - - connect (remove_all_breakpoints_action, SIGNAL (triggered ()), - this, SLOT (request_remove_breakpoint ())); - - connect (_comment_selection_action, SIGNAL (triggered ()), - this, SLOT (request_comment_selected_text ())); - - connect (_uncomment_selection_action, SIGNAL (triggered ()), - this, SLOT (request_uncomment_selected_text ())); - - connect (_find_action, SIGNAL (triggered ()), - this, SLOT (request_find ())); - - connect (_goto_line_action, SIGNAL (triggered ()), - this, SLOT (request_goto_line ())); - connect (_mru_file_menu, SIGNAL (triggered (QAction *)), this, SLOT (request_mru_open_file (QAction *))); @@ -1233,7 +1567,11 @@ QStringList ()).toStringList (); for (int n = 0; n < sessionFileNames.count (); ++n) - request_open_file (sessionFileNames.at (n)); + { + QFileInfo file = QFileInfo (sessionFileNames.at (n)); + if (file.exists ()) + request_open_file (sessionFileNames.at (n)); + } } check_actions (); @@ -1244,13 +1582,26 @@ { _tab_widget->addTab (f, fn); + // signals from the qscintilla edit area + connect (f->qsci_edit_area (), SIGNAL (status_update (bool, bool)), + this, SLOT (edit_status_update (bool, bool))); + + connect (f->qsci_edit_area (), SIGNAL (show_doc_signal (const QString&)), + main_win (), SLOT (handle_show_doc (const QString&))); + + connect (f->qsci_edit_area (), SIGNAL (create_context_menu_signal (QMenu *)), + this, SLOT (create_context_menu (QMenu *))); + + connect (f->qsci_edit_area (), SIGNAL (execute_command_in_terminal_signal (const QString&)), + main_win (), SLOT (execute_command_in_terminal (const QString&))); + // Signals from the file editor_tab connect (f, SIGNAL (file_name_changed (const QString&, const QString&)), this, SLOT (handle_file_name_changed (const QString&, const QString&))); - connect (f, SIGNAL (editor_state_changed (bool, const QString&)), - this, SLOT (handle_editor_state_changed (bool, const QString&))); + connect (f, SIGNAL (editor_state_changed (bool, const QString&, bool)), + this, SLOT (handle_editor_state_changed (bool, const QString&, bool))); connect (f, SIGNAL (tab_remove_request ()), this, SLOT (handle_tab_remove_request ())); @@ -1267,16 +1618,16 @@ connect (f, SIGNAL (run_file_signal (const QFileInfo&)), main_win (), SLOT (run_file_in_terminal (const QFileInfo&))); - connect (f, SIGNAL (execute_command_in_terminal_signal (const QString&)), - main_win (), SLOT (execute_command_in_terminal (const QString&))); + connect (f, SIGNAL (request_open_file (const QString&)), + this, SLOT (request_open_file (const QString&))); + + connect (f, SIGNAL (set_global_edit_shortcuts_signal (bool)), + main_win (), SLOT (set_global_edit_shortcuts (bool))); // Signals from the file_editor non-trivial operations connect (this, SIGNAL (fetab_settings_changed (const QSettings *)), f, SLOT (notice_settings (const QSettings *))); - connect (this, SIGNAL (fetab_close_request (const QWidget*,bool)), - f, SLOT (conditional_close (const QWidget*,bool))); - connect (this, SIGNAL (fetab_change_request (const QWidget*)), f, SLOT (change_editor_state (const QWidget*))); @@ -1288,20 +1639,12 @@ f, SLOT (save_file (const QWidget*, const QString&, bool))); // Signals from the file_editor trivial operations - connect (this, SIGNAL (fetab_undo (const QWidget*)), - f, SLOT (undo (const QWidget*))); - - connect (this, SIGNAL (fetab_redo (const QWidget*)), - f, SLOT (redo (const QWidget*))); - - connect (this, SIGNAL (fetab_copy (const QWidget*)), - f, SLOT (copy (const QWidget*))); - - connect (this, SIGNAL (fetab_cut (const QWidget*)), - f, SLOT (cut (const QWidget*))); - - connect (this, SIGNAL (fetab_paste (const QWidget*)), - f, SLOT (paste (const QWidget*))); + connect (this, SIGNAL (fetab_zoom_in (const QWidget*)), + f, SLOT (zoom_in (const QWidget*))); + connect (this, SIGNAL (fetab_zoom_out (const QWidget*)), + f, SLOT (zoom_out (const QWidget*))); + connect (this, SIGNAL (fetab_zoom_normal (const QWidget*)), + f, SLOT (zoom_normal (const QWidget*))); connect (this, SIGNAL (fetab_context_help (const QWidget*, bool)), f, SLOT (context_help (const QWidget*, bool))); @@ -1348,18 +1691,33 @@ connect (this, SIGNAL (fetab_remove_all_breakpoints (const QWidget*)), f, SLOT (remove_all_breakpoints (const QWidget*))); + connect (this, SIGNAL (fetab_scintilla_command (const QWidget *, unsigned int)), + f, SLOT (scintilla_command (const QWidget *, unsigned int))); + connect (this, SIGNAL (fetab_comment_selected_text (const QWidget*)), f, SLOT (comment_selected_text (const QWidget*))); connect (this, SIGNAL (fetab_uncomment_selected_text (const QWidget*)), f, SLOT (uncomment_selected_text (const QWidget*))); + connect (this, SIGNAL (fetab_indent_selected_text (const QWidget*)), + f, SLOT (indent_selected_text (const QWidget*))); + + connect (this, SIGNAL (fetab_unindent_selected_text (const QWidget*)), + f, SLOT (unindent_selected_text (const QWidget*))); + + connect (this, SIGNAL (fetab_convert_eol (const QWidget*, QsciScintilla::EolMode)), + f, SLOT (convert_eol (const QWidget*, QsciScintilla::EolMode))); + connect (this, SIGNAL (fetab_find (const QWidget*)), f, SLOT (find (const QWidget*))); connect (this, SIGNAL (fetab_goto_line (const QWidget*, int)), f, SLOT (goto_line (const QWidget*, int))); + connect (this, SIGNAL (fetab_completion (const QWidget*)), + f, SLOT (show_auto_completion (const QWidget*))); + connect (this, SIGNAL (fetab_set_focus (const QWidget*)), f, SLOT (set_focus (const QWidget*))); @@ -1385,7 +1743,7 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_copy (); + request_copy (true); } } void @@ -1395,76 +1753,94 @@ if (foc_w && foc_w->inherits ("octave_qscintilla")) { - request_paste (); + request_paste (true); + } +} +void +file_editor::selectAll () +{ + QWidget * foc_w = focusWidget (); + + if (foc_w && foc_w->inherits ("octave_qscintilla")) + { + request_selectall (true); } } void -file_editor::set_shortcuts (bool set) +file_editor::set_shortcuts () { - if (set) - { - _comment_selection_action->setShortcut (Qt::ControlModifier + Qt::Key_R); - _uncomment_selection_action->setShortcut (Qt::SHIFT - + Qt::ControlModifier - + Qt::Key_R); - - _copy_action->setShortcut (QKeySequence::Copy); - _cut_action->setShortcut (QKeySequence::Cut); - _paste_action->setShortcut (QKeySequence::Paste); - _context_help_action->setShortcut (QKeySequence::HelpContents); - _context_doc_action->setShortcut (Qt::SHIFT + Qt::Key_F1); + // File menu + shortcut_manager::set_shortcut (_edit_function_action, "editor_file:edit_function"); + shortcut_manager::set_shortcut (_save_action, "editor_file:save"); + shortcut_manager::set_shortcut (_save_as_action, "editor_file:save_as"); + shortcut_manager::set_shortcut (_close_action, "editor_file:close"); + shortcut_manager::set_shortcut (_close_all_action, "editor_file:close_all"); + shortcut_manager::set_shortcut (_close_others_action, "editor_file:close_other"); + shortcut_manager::set_shortcut (_print_action, "editor_file:print"); - _find_action->setShortcut (QKeySequence::Find); - _goto_line_action->setShortcut (Qt::ControlModifier+ Qt::Key_G); - - _next_bookmark_action->setShortcut (Qt::Key_F2); - _previous_bookmark_action->setShortcut (Qt::SHIFT + Qt::Key_F2); - _toggle_bookmark_action->setShortcut (Qt::Key_F7); + // Edit menu + shortcut_manager::set_shortcut (_undo_action, "editor_edit:undo"); + shortcut_manager::set_shortcut (_redo_action, "editor_edit:redo"); + shortcut_manager::set_shortcut (_copy_action, "editor_edit:copy"); + shortcut_manager::set_shortcut (_cut_action, "editor_edit:cut"); + shortcut_manager::set_shortcut (_paste_action, "editor_edit:paste"); + shortcut_manager::set_shortcut (_selectall_action, "editor_edit:select_all"); + shortcut_manager::set_shortcut (_find_action, "editor_edit:find_replace"); - _print_action->setShortcut (QKeySequence::Print); - _run_action->setShortcut (Qt::Key_F5); - _context_run_action->setShortcut (Qt::Key_F9); - - _context_edit_action->setShortcut (Qt::ControlModifier + Qt::Key_E); - _save_action->setShortcut (QKeySequence::Save); - _save_as_action->setShortcut (QKeySequence::SaveAs); - _close_action->setShortcut (QKeySequence::Close); + shortcut_manager::set_shortcut (_delete_start_word_action, "editor_edit:delete_start_word"); + shortcut_manager::set_shortcut (_delete_end_word_action, "editor_edit:delete_end_word"); + shortcut_manager::set_shortcut (_delete_start_line_action, "editor_edit:delete_start_line"); + shortcut_manager::set_shortcut (_delete_end_line_action, "editor_edit:delete_end_line"); + shortcut_manager::set_shortcut (_delete_line_action, "editor_edit:delete_line"); + shortcut_manager::set_shortcut (_copy_line_action, "editor_edit:copy_line"); + shortcut_manager::set_shortcut (_cut_line_action, "editor_edit:cut_line"); + shortcut_manager::set_shortcut (_duplicate_selection_action, "editor_edit:duplicate_selection"); + shortcut_manager::set_shortcut (_transpose_line_action, "editor_edit:transpose_line"); + shortcut_manager::set_shortcut (_comment_selection_action, "editor_edit:comment_selection"); + shortcut_manager::set_shortcut (_uncomment_selection_action, "editor_edit:uncomment_selection"); - _redo_action->setShortcut (QKeySequence::Redo); - _undo_action->setShortcut (QKeySequence::Undo); - } - else - { - QKeySequence no_key = QKeySequence (); + shortcut_manager::set_shortcut (_upper_case_action, "editor_edit:upper_case"); + shortcut_manager::set_shortcut (_lower_case_action, "editor_edit:lower_case"); + shortcut_manager::set_shortcut (_indent_selection_action, "editor_edit:indent_selection"); + shortcut_manager::set_shortcut (_unindent_selection_action, "editor_edit:unindent_selection"); + shortcut_manager::set_shortcut (_completion_action, "editor_edit:completion_list"); + shortcut_manager::set_shortcut (_goto_line_action, "editor_edit:goto_line"); + shortcut_manager::set_shortcut (_toggle_bookmark_action, "editor_edit:toggle_bookmark"); + shortcut_manager::set_shortcut (_next_bookmark_action, "editor_edit:next_bookmark"); + shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_edit:previous_bookmark"); + shortcut_manager::set_shortcut (_remove_bookmark_action, "editor_edit:remove_bookmark"); + shortcut_manager::set_shortcut (_preferences_action, "editor_edit:preferences"); + shortcut_manager::set_shortcut (_styles_preferences_action, "editor_edit:styles_preferences"); - _comment_selection_action->setShortcut (no_key); - _uncomment_selection_action->setShortcut (no_key); - - _copy_action->setShortcut (no_key); - _cut_action->setShortcut (no_key); - _paste_action->setShortcut (no_key); - _context_help_action->setShortcut (no_key); + shortcut_manager::set_shortcut (_conv_eol_windows_action, "editor_edit:conv_eol_winows"); + shortcut_manager::set_shortcut (_conv_eol_unix_action, "editor_edit:conv_eol_unix"); + shortcut_manager::set_shortcut (_conv_eol_mac_action, "editor_edit:conv_eol_mac"); - _find_action->setShortcut (no_key); - _goto_line_action->setShortcut (no_key); - - _next_bookmark_action->setShortcut (no_key); - _previous_bookmark_action->setShortcut (no_key); - _toggle_bookmark_action->setShortcut (no_key); + // View menu + shortcut_manager::set_shortcut (_show_linenum_action, "editor_view:show_line_numbers"); + shortcut_manager::set_shortcut (_show_whitespace_action, "editor_view:show_white_spaces"); + shortcut_manager::set_shortcut (_show_eol_action, "editor_view:show_eol_chars"); + shortcut_manager::set_shortcut (_show_indguide_action, "editor_view:show_ind_guides"); + shortcut_manager::set_shortcut (_show_longline_action, "editor_view:show_long_line"); + shortcut_manager::set_shortcut (_zoom_in_action, "editor_view:zoom_in"); + shortcut_manager::set_shortcut (_zoom_out_action, "editor_view:zoom_out"); + shortcut_manager::set_shortcut (_zoom_normal_action, "editor_view:zoom_normal"); - _print_action->setShortcut (no_key); - _run_action->setShortcut (no_key); - _context_run_action->setShortcut (no_key); + // Debug menu + shortcut_manager::set_shortcut (_toggle_breakpoint_action, "editor_debug:toggle_breakpoint"); + shortcut_manager::set_shortcut (_next_breakpoint_action, "editor_debug:next_breakpoint"); + shortcut_manager::set_shortcut (_previous_bookmark_action, "editor_debug:previous_breakpoint"); + shortcut_manager::set_shortcut (_remove_all_breakpoints_action, "editor_debug:remove_breakpoints"); - _context_edit_action->setShortcut (no_key); - _save_action->setShortcut (no_key); - _save_as_action->setShortcut (no_key); - _close_action->setShortcut (no_key); + // Run menu + shortcut_manager::set_shortcut (_run_action, "editor_run:run_file"); + shortcut_manager::set_shortcut (_run_selection_action, "editor_run:run_selection"); - _redo_action->setShortcut (no_key); - _undo_action->setShortcut (no_key); - } + // Help menu + shortcut_manager::set_shortcut (_context_help_action, "editor_help:help_keyword"); + shortcut_manager::set_shortcut (_context_doc_action, "editor_help:doc_keyword"); + } void @@ -1472,34 +1848,120 @@ { bool have_tabs = _tab_widget->count () > 0; + _edit_cmd_menu->setEnabled (have_tabs); + _edit_fmt_menu->setEnabled (have_tabs); + _edit_nav_menu->setEnabled (have_tabs); + _comment_selection_action->setEnabled (have_tabs); _uncomment_selection_action->setEnabled (have_tabs); + _indent_selection_action->setEnabled (have_tabs); + _unindent_selection_action->setEnabled (have_tabs); _paste_action->setEnabled (have_tabs); _context_help_action->setEnabled (have_tabs); _context_doc_action->setEnabled (have_tabs); - _find_action->setEnabled (have_tabs); - _goto_line_action->setEnabled (have_tabs); + _view_editor_menu->setEnabled (have_tabs); + _zoom_in_action->setEnabled (have_tabs); + _zoom_out_action->setEnabled (have_tabs); + _zoom_normal_action->setEnabled (have_tabs); - _next_bookmark_action->setEnabled (have_tabs); - _previous_bookmark_action->setEnabled (have_tabs); - _toggle_bookmark_action->setEnabled (have_tabs); - _remove_bookmark_action->setEnabled (have_tabs); - + _find_action->setEnabled (have_tabs); _print_action->setEnabled (have_tabs); _run_action->setEnabled (have_tabs); - _context_edit_action->setEnabled (have_tabs); + _edit_function_action->setEnabled (have_tabs); _save_action->setEnabled (have_tabs); _save_as_action->setEnabled (have_tabs); _close_action->setEnabled (have_tabs); _close_all_action->setEnabled (have_tabs); _close_others_action->setEnabled (have_tabs && _tab_widget->count () > 1); - _undo_action->setEnabled (have_tabs); - _redo_action->setEnabled (have_tabs); + _selectall_action->setEnabled (have_tabs); } +// empty_script determines whether we have to create an empty script +// 1. At startup, when the editor has to be (really) visible +// (Here we can not use the visibility changed signal) +// 2. When the editor becomes visible when octave is running +void +file_editor::empty_script (bool startup, bool visible) +{ + bool real_visible; + + if (startup) + real_visible = isVisible (); + else + real_visible = visible; + + if (! real_visible || _tab_widget->count () > 0) + return; + + if (startup && ! isFloating ()) + { + // check is editor is really visible or hidden between tabbed widgets + QList tab_list = main_win ()->findChildren(); + + bool in_tab = false; + int i = 0; + while ((i < tab_list.count ()) && (! in_tab)) + { + QTabBar *tab = tab_list.at (i); + i++; + + int j = 0; + while ((j < tab->count ()) && (! in_tab)) + { + // check all tabs for the editor + if (tab->tabText (j) == windowTitle ()) + { + // editor is in this tab widget + in_tab = true; + int top = tab->currentIndex (); + if (top > -1 && tab->tabText (top) == windowTitle ()) + real_visible = true; // and is the current tab + else + return; // not current tab -> not visible + } + j++; + } + } + } + + request_new_file (""); +} + +// This slot is a reimplementation of the virtual slot in octave_dock_widget. +// We need this for creating an empty script when the editor has no open files +// and is made visible +void +file_editor::handle_visibility (bool visible) + { + empty_script (false, visible); + + if (visible && ! isFloating ()) + focus (); + } + +void +file_editor::dragEnterEvent (QDragEnterEvent *e) + { + if (e->mimeData ()->hasUrls ()) + { + e->acceptProposedAction(); + } + } + +void +file_editor::dropEvent (QDropEvent *e) + { + if (e->mimeData ()->hasUrls ()) + { + foreach (QUrl url, e->mimeData ()->urls ()) + { + request_open_file (url.toLocalFile ()); + } + } + } #endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/file-editor.h --- a/libgui/src/m-editor/file-editor.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/file-editor.h Fri Jan 23 15:23:09 2015 -0500 @@ -29,6 +29,10 @@ #include #include #include +#include + +#include +#include #include @@ -52,16 +56,17 @@ QMenu *get_mru_menu (void) { return _mru_file_menu; } QMenu *debug_menu (void); QToolBar *toolbar (void); + void insert_new_open_actions (QAction*,QAction*,QAction*); - void set_focus (void); void handle_enter_debug_mode (void); void handle_exit_debug_mode (void); void check_actions (void); + void empty_script (bool startup, bool visible); + signals: void fetab_settings_changed (const QSettings *settings); - void fetab_close_request (const QWidget* ID, bool app_closing = false); void fetab_change_request (const QWidget* ID); void fetab_file_name_query (const QWidget* ID); // Save is a ping-pong type of communication @@ -69,11 +74,6 @@ bool remove_on_success); // No fetab_open, functionality in editor // No fetab_new, functionality in editor - void fetab_undo (const QWidget* ID); - void fetab_redo (const QWidget* ID); - void fetab_copy (const QWidget* ID); - void fetab_cut (const QWidget* ID); - void fetab_paste (const QWidget* ID); void fetab_context_help (const QWidget* ID, bool); void fetab_context_edit (const QWidget* ID); void fetab_save_file (const QWidget* ID); @@ -91,19 +91,32 @@ void fetab_remove_all_breakpoints (const QWidget* ID); void fetab_comment_selected_text (const QWidget* ID); void fetab_uncomment_selected_text (const QWidget* ID); + void fetab_indent_selected_text (const QWidget* ID); + void fetab_unindent_selected_text (const QWidget* ID); + void fetab_convert_eol (const QWidget* ID, QsciScintilla::EolMode eol_mode); void fetab_find (const QWidget* ID); void fetab_goto_line (const QWidget* ID, int line = -1); + void fetab_completion (const QWidget*); void fetab_insert_debugger_pointer (const QWidget* ID, int line = -1); void fetab_delete_debugger_pointer (const QWidget* ID, int line = -1); void fetab_do_breakpoint_marker (bool insert, const QWidget* ID, int line = -1); void fetab_set_focus (const QWidget* ID); + void fetab_scintilla_command (const QWidget* ID, unsigned int sci_msg); + + void fetab_zoom_in (const QWidget* ID); + void fetab_zoom_out (const QWidget* ID); + void fetab_zoom_normal (const QWidget* ID); + void request_settings_dialog (const QString&); void execute_command_in_terminal_signal (const QString&); void file_loaded_signal (); public slots: + void focus (void); + void enable_menu_shortcuts (bool); + bool check_closing (int closing_state); void request_new_file (const QString& commands); void request_new_script (const QString& commands); @@ -113,35 +126,56 @@ void request_close_all_files (bool); void request_close_other_files (bool); void request_mru_open_file (QAction *action); - void request_print_file (void); + void request_print_file (bool); - void request_undo (void); - void request_redo (void); - void request_copy (void); - void request_cut (void); - void request_paste (void); + void request_undo (bool); + void request_redo (bool); + void request_copy (bool); + void request_cut (bool); + void request_paste (bool); + void request_selectall (bool); void request_context_help (bool); void request_context_doc (bool); void request_context_edit (bool); - void request_save_file (void); - void request_save_file_as (void); - void request_run_file (void); + void request_save_file (bool); + void request_save_file_as (bool); + void request_run_file (bool); void request_context_run (bool); - void request_toggle_bookmark (void); - void request_next_bookmark (void); - void request_previous_bookmark (void); - void request_remove_bookmark (void); + void request_toggle_bookmark (bool); + void request_next_bookmark (bool); + void request_previous_bookmark (bool); + void request_remove_bookmark (bool); + + void request_toggle_breakpoint (bool); + void request_next_breakpoint (bool); + void request_previous_breakpoint (bool); + void request_remove_breakpoint (bool); - void request_toggle_breakpoint (void); - void request_next_breakpoint (void); - void request_previous_breakpoint (void); - void request_remove_breakpoint (void); + void request_delete_start_word (bool); + void request_delete_end_word (bool); + void request_delete_start_line (bool); + void request_delete_end_line (bool); + void request_delete_line (bool); + void request_copy_line (bool); + void request_cut_line (bool); + void request_duplicate_selection (bool); + void request_transpose_line (bool); + + void request_comment_selected_text (bool); + void request_uncomment_selected_text (bool); - void request_comment_selected_text (void); - void request_uncomment_selected_text (void); - void request_find (void); + void request_upper_case (bool); + void request_lower_case (bool); + void request_indent_selected_text (bool); + void request_unindent_selected_text (bool); + void request_conv_eol_windows (bool); + void request_conv_eol_unix (bool); + void request_conv_eol_mac (bool); - void request_goto_line (void); + void request_find (bool); + + void request_goto_line (bool); + void request_completion (bool); void handle_file_name_changed (const QString& fileName, const QString& toolTip); @@ -149,7 +183,8 @@ void handle_tab_remove_request (void); void handle_add_filename_to_list (const QString& fileName, QWidget *ID); void active_tab_changed (int index); - void handle_editor_state_changed (bool enableCopy, const QString& fileName); + void handle_editor_state_changed (bool enableCopy, const QString& fileName, + bool is_octave_file); void handle_mru_add_file (const QString& file_name); void check_conflict_save (const QString& fileName, bool remove_on_success); @@ -163,16 +198,19 @@ // Tells the editor to react on changed settings. void notice_settings (const QSettings *settings); - // Tells the ditor to dis- or enable some shortcuts - void set_shortcuts (bool set_shortcuts); + void set_shortcuts (); + + void handle_visibility (bool visible); protected slots: void copyClipboard (); void pasteClipboard (); + void selectAll (); private slots: + void request_open_files (const QStringList&); void request_open_file (const QString& fileName, int line = -1, bool debug_pointer = false, bool breakpoint_marker = false, bool insert = true); @@ -180,6 +218,23 @@ void request_styles_preferences (bool); void restore_create_file_setting (); + void show_line_numbers (bool); + void show_white_space (bool); + void show_eol_chars (bool); + void show_indent_guides (bool); + void show_long_line (bool); + void zoom_in (bool); + void zoom_out (bool); + void zoom_normal (bool); + + void create_context_menu (QMenu *); + void edit_status_update (bool, bool); + +protected: + + void dragEnterEvent(QDragEnterEvent *event); + void dropEvent(QDropEvent *event); + private: bool is_editor_console_tabbed (); @@ -189,9 +244,16 @@ void mru_menu_update (void); bool call_custom_editor (const QString& file_name = QString (), int line = -1); + void toggle_preference (const QString& preference, bool def); + QWidget *find_tab_widget (const QString& openFileName) const; + QAction *add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member); + + QMenu* m_add_menu (QMenuBar *p, QString text); std::map editor_tab_map; + QHash _hash_menu_text; QString ced; @@ -199,17 +261,49 @@ QToolBar *_tool_bar; QMenu *_debug_menu; + QAction *_new_action; + QAction *_new_function_action; + QAction *_open_action; + + QAction *_upper_case_action; + QAction *_lower_case_action; QAction *_comment_selection_action; QAction *_uncomment_selection_action; + QAction *_indent_selection_action; + QAction *_unindent_selection_action; + QAction *_conv_eol_windows_action; + QAction *_conv_eol_unix_action; + QAction *_conv_eol_mac_action; QAction *_copy_action; QAction *_cut_action; QAction *_paste_action; + QAction *_selectall_action; QAction *_context_help_action; QAction *_context_doc_action; + QAction *_show_linenum_action; + QAction *_show_whitespace_action; + QAction *_show_eol_action; + QAction *_show_indguide_action; + QAction *_show_longline_action; + QAction *_zoom_in_action; + QAction *_zoom_out_action; + QAction *_zoom_normal_action; + + QAction *_delete_start_word_action; + QAction *_delete_end_word_action; + QAction *_delete_start_line_action; + QAction *_delete_end_line_action; + QAction *_delete_line_action; + QAction *_copy_line_action; + QAction *_cut_line_action; + QAction *_duplicate_selection_action; + QAction *_transpose_line_action; + QAction *_find_action; QAction *_goto_line_action; + QAction *_completion_action; QAction *_next_bookmark_action; QAction *_previous_bookmark_action; @@ -218,9 +312,9 @@ QAction *_print_action; QAction *_run_action; - QAction *_context_run_action; + QAction *_run_selection_action; - QAction *_context_edit_action; + QAction *_edit_function_action; QAction *_save_action; QAction *_save_as_action; QAction *_close_action; @@ -233,6 +327,17 @@ QAction *_preferences_action; QAction *_styles_preferences_action; + QAction *_toggle_breakpoint_action; + QAction *_next_breakpoint_action; + QAction *_previous_breakpoint_action; + QAction *_remove_all_breakpoints_action; + + QMenu *_edit_cmd_menu; + QMenu *_edit_fmt_menu; + QMenu *_edit_nav_menu; + QMenu *_fileMenu; + QMenu *_view_editor_menu; + QTabWidget *_tab_widget; int _marker_breakpoint; @@ -241,7 +346,6 @@ QMenu *_mru_file_menu; QAction *_mru_file_actions[MaxMRUFiles]; QStringList _mru_files; - }; #endif // FILEEDITORMDISUBWINDOW_H diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/find-dialog.cc --- a/libgui/src/m-editor/find-dialog.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/find-dialog.cc Fri Jan 23 15:23:09 2015 -0500 @@ -71,7 +71,7 @@ find_dialog::find_dialog (QsciScintilla* edit_area, QWidget *p) : QDialog (p) { - setWindowTitle ("Find and Replace"); + setWindowTitle (tr ("Find and Replace")); setWindowIcon (QIcon(":/actions/icons/find.png")); _search_label = new QLabel (tr ("Find &what:")); @@ -107,8 +107,13 @@ _regex_check_box = new QCheckBox (tr ("Regular E&xpressions")); _backward_check_box = new QCheckBox (tr ("Search &backward")); _search_selection_check_box = new QCheckBox (tr ("Search se&lection")); - _search_selection_check_box->setCheckable (false); // TODO: Not implemented. +#ifdef HAVE_QSCI_FINDSELECTION + _search_selection_check_box->setCheckable (true); + _search_selection_check_box->setEnabled (edit_area->hasSelectedText ()); +#else + _search_selection_check_box->setCheckable (false); _search_selection_check_box->setEnabled (false); +#endif _edit_area = edit_area; connect (_find_next_button, SIGNAL (clicked ()), @@ -125,6 +130,15 @@ this, SLOT (handle_backward_search_changed (int))); connect (_button_box, SIGNAL (rejected ()), this, SLOT (close ())); + connect (_search_line_edit, SIGNAL (textChanged (QString)), + this, SLOT (handle_search_text_changed (QString))); + +#ifdef HAVE_QSCI_FINDSELECTION + connect (_edit_area, SIGNAL (copyAvailable (bool)), + this, SLOT (handle_selection_changed (bool))); + connect (_search_selection_check_box, SIGNAL (stateChanged (int)), + this, SLOT (handle_sel_search_changed (int))); +#endif QVBoxLayout *extension_layout = new QVBoxLayout (); extension_layout->setMargin (0); @@ -157,16 +171,15 @@ _extension->hide (); _find_next_button->setDefault (true); _find_result_available = false; + _rep_all = 0; + _rep_active = false; // move dialog to side of the parent if there is room on the desktop to do so. - QWidget * desktop = QApplication::desktop (); - int xp = p->x () + p->frameGeometry ().width (); - int yp= p->y (); - if (desktop != 0 && sizeHint ().isValid ()) - { - if (xp + sizeHint ().width () > desktop->width ()) - xp = desktop->width () - sizeHint ().width (); - } + int xp = p->x () +20; + int yp = p->y () + p->frameGeometry ().height () - sizeHint ().height () -20; + + if (yp < 0) + yp = 0; move (xp, yp); @@ -182,6 +195,35 @@ _from_start_check_box->setText (tr ("Search from start")); } +// search text has changed: reset the search +void +find_dialog::handle_search_text_changed (QString) +{ + if (_search_selection_check_box->isChecked ()) + _find_result_available = false; +} + +#ifdef HAVE_QSCI_FINDSELECTION +void +find_dialog::handle_sel_search_changed (int selected) +{ + _from_start_check_box->setEnabled (! selected); + _find_result_available = false; +} + +void +find_dialog::handle_selection_changed (bool has_selected) +{ + if (_rep_active) + return; + + _search_selection_check_box->setEnabled (has_selected); + _find_result_available = false; + if (! has_selected) + _search_selection_check_box->setChecked (false); +} +#endif + // initialize search text with selected text if this is in one single line void find_dialog::init_search_text () @@ -212,100 +254,153 @@ { int line = -1, col = -1; bool do_wrap = _wrap_check_box->isChecked (); - bool do_forward = true; + bool do_forward = forward; - if (_find_result_available) + if (_rep_all) { - // we found a match last time, cursor is at the end of the match - if (!forward) + if (_rep_all == 1) + { + line = 0; + col = 0; + } + do_wrap = false; + // The following line is a workaround for the issue that when replacing + // a text with a new one with different size within the selection, + // the selection is not updated leading to missing or extra replacements. + // This does not happen, when the selection is search backwards + do_forward = ! _search_selection_check_box->isChecked (); + } + else + { + if (_from_start_check_box->isChecked ()) { - // backward: go back one position or we will find the same again - do_forward = false; - _edit_area->getCursorPosition (&line,&col); - if (col > 0) - _edit_area->setCursorPosition (line,--col); + if (do_forward) + { + line = 0; + col = 0; + } + else + { + line = _edit_area->lines () - 1; + col = _edit_area->text (line).length () - 1; + if (col == -1) + col = 0; + } } - } - - _find_result_available = false; - - if (_from_start_check_box->isChecked ()) - { - line = 0; - col = 0; - if (_backward_check_box->isChecked ()) - do_wrap = true; + else if (! do_forward) + { + // search from previous character if search backward + _edit_area->getCursorPosition (&line,&col); + int currpos = _edit_area->positionFromLineIndex(line,col); + if (currpos > 0) currpos --; + _edit_area->lineIndexFromPosition(currpos, &line,&col); + } } if (_edit_area) { - _find_result_available - = _edit_area->findFirst (_search_line_edit->text (), - _regex_check_box->isChecked (), - _case_check_box->isChecked (), - _whole_words_check_box->isChecked (), - do_wrap, - do_forward, - line,col, - true + if (_edit_area->hasSelectedText () + && _search_selection_check_box->isChecked ()) + { +#ifdef HAVE_QSCI_FINDSELECTION + if (_find_result_available) + _find_result_available = _edit_area->findNext (); + else + _find_result_available + = _edit_area->findFirstInSelection ( + _search_line_edit->text (), + _regex_check_box->isChecked (), + _case_check_box->isChecked (), + _whole_words_check_box->isChecked (), + do_forward, + true #ifdef HAVE_QSCI_VERSION_2_6_0 - , true + , true +#endif + ); #endif - ); + } + else + { + _find_result_available + = _edit_area->findFirst (_search_line_edit->text (), + _regex_check_box->isChecked (), + _case_check_box->isChecked (), + _whole_words_check_box->isChecked (), + do_wrap, + do_forward, + line,col, + true +#ifdef HAVE_QSCI_VERSION_2_6_0 + , true +#endif + ); + } } + if (_find_result_available) _from_start_check_box->setChecked (0); - else + else if (! _rep_all) no_matches_message (); } +void +find_dialog::do_replace () +{ + _rep_active = true; // changes in selection not made by the user + _edit_area->replace (_replace_line_edit->text ()); + _rep_active = false; +} void find_dialog::replace () { if (_edit_area) { - _edit_area->replace (_replace_line_edit->text ()); - if (!_edit_area->findNext()) - no_matches_message (); + // The following line is a workaround for the issue that when replacing + // a text with a new one with different size within the selection, + // the selection is not updated leading to missing or extra replacements. + // This does not happen, when the selection is search backwards + if (_search_selection_check_box->isChecked ()) + _backward_check_box->setChecked (true); + + // do the replace if we have selected text + if (_find_result_available && _edit_area->hasSelectedText ()) + do_replace (); + + find_next (); } } void find_dialog::replace_all () { - int count = 0; + int line, col; - // check whether find & replace srings are different (avoid endless loop!) - int strDiff; - Qt::CaseSensitivity cs; - if (_case_check_box->isChecked()) + if (_edit_area) { - cs = Qt::CaseSensitive; - } - else - { - cs = Qt::CaseInsensitive; - } - strDiff = QString::compare (_search_line_edit->text(), - _replace_line_edit->text(), cs); + _edit_area->getCursorPosition (&line,&col); - // replace all if strings are different - if (_edit_area && strDiff ) - { - find (!_backward_check_box->isChecked ()); // find first occurence + _rep_all = 1; + find_next (); // find first occurence (forward) while (_find_result_available) // while search string is found { - _edit_area->replace (_replace_line_edit->text ()); // replace - count++; // inc counter - _find_result_available = _edit_area->findNext(); // and find next + do_replace (); + _rep_all++; // inc counter + find_next (); // find next } + QMessageBox msg_box (QMessageBox::Information, tr ("Replace Result"), - tr ("%1 items replaced").arg(count), + tr ("%1 items replaced").arg(_rep_all-1), QMessageBox::Ok, this); msg_box.exec (); + + _rep_all = 0; + _find_result_available = false; + + if (! _search_selection_check_box->isChecked ()) + _edit_area->setCursorPosition (line,col); } - // TODO: Show number of replaced strings } void diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/find-dialog.h --- a/libgui/src/m-editor/find-dialog.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/find-dialog.h Fri Jan 23 15:23:09 2015 -0500 @@ -79,7 +79,13 @@ void init_search_text (); private slots: +#ifdef HAVE_QSCI_FINDSELECTION + void handle_sel_search_changed (int); + void handle_selection_changed (bool has_selected); +#endif void handle_backward_search_changed (int); + void handle_search_text_changed (QString new_search_text); + void find (bool forward = true); void find_next (); void find_prev (); @@ -87,7 +93,10 @@ void replace_all (); private: + void no_matches_message (); + void do_replace (); + QLabel *_search_label; QLineEdit *_search_line_edit; QLabel *_replace_label; @@ -108,6 +117,8 @@ QWidget *_extension; QsciScintilla *_edit_area; bool _find_result_available; + int _rep_all; + bool _rep_active; }; #endif // FIND_DIALOG_H diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/octave-qscintilla.cc --- a/libgui/src/m-editor/octave-qscintilla.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.cc Fri Jan 23 15:23:09 2015 -0500 @@ -29,13 +29,107 @@ #ifdef HAVE_QSCINTILLA #include +#include +#include +#include #include "octave-qscintilla.h" #include "file-editor-tab.h" +#include "shortcut-manager.h" octave_qscintilla::octave_qscintilla (QWidget *p) : QsciScintilla (p) -{ } +{ + connect (this, SIGNAL (textChanged ()), this, SLOT (text_changed ())); + + // clear scintilla edit shortcuts that are handled by the editor + QsciCommandSet *cmd_set = standardCommands (); + +#ifdef HAVE_QSCI_VERSION_2_6_0 + // find () was added in QScintilla 2.6 + cmd_set->find (QsciCommand::SelectionCopy)->setKey (0); + cmd_set->find (QsciCommand::SelectionCut)->setKey (0); + cmd_set->find (QsciCommand::Paste)->setKey (0); + cmd_set->find (QsciCommand::SelectAll)->setKey (0); + cmd_set->find (QsciCommand::SelectionDuplicate)->setKey (0); + cmd_set->find (QsciCommand::LineTranspose)->setKey (0); + cmd_set->find (QsciCommand::Undo)->setKey (0); + cmd_set->find (QsciCommand::Redo)->setKey (0); + cmd_set->find (QsciCommand::SelectionUpperCase)->setKey (0); + cmd_set->find (QsciCommand::SelectionLowerCase)->setKey (0); + cmd_set->find (QsciCommand::ZoomIn)->setKey (0); + cmd_set->find (QsciCommand::ZoomOut)->setKey (0); + cmd_set->find (QsciCommand::DeleteWordLeft)->setKey (0); + cmd_set->find (QsciCommand::DeleteWordRight)->setKey (0); + cmd_set->find (QsciCommand::DeleteLineLeft)->setKey (0); + cmd_set->find (QsciCommand::DeleteLineRight)->setKey (0); + cmd_set->find (QsciCommand::LineDelete)->setKey (0); + cmd_set->find (QsciCommand::LineCut)->setKey (0); + cmd_set->find (QsciCommand::LineCopy)->setKey (0); +#else + // find commands via its default key (tricky way without find ()) + QList< QsciCommand * > cmd_list = cmd_set->commands (); + for (int i = 0; i < cmd_list.length (); i++) + { + int cmd_key = cmd_list.at (i)->key (); + switch (cmd_key) + { + case Qt::Key_C | Qt::CTRL : // SelectionCopy + case Qt::Key_X | Qt::CTRL : // SelectionCut + case Qt::Key_V | Qt::CTRL : // Paste + case Qt::Key_A | Qt::CTRL : // SelectAll + case Qt::Key_D | Qt::CTRL : // SelectionDuplicate + case Qt::Key_T | Qt::CTRL : // LineTranspose + case Qt::Key_Z | Qt::CTRL : // Undo + case Qt::Key_Y | Qt::CTRL : // Redo + case Qt::Key_Z | Qt::CTRL | Qt::SHIFT : // Redo + case Qt::Key_U | Qt::CTRL : // SelectionLowerCase + case Qt::Key_U | Qt::CTRL | Qt::SHIFT : // SelectionUpperCase + case Qt::Key_Plus | Qt::CTRL : // ZoomIn + case Qt::Key_Minus | Qt::CTRL : // ZoomOut + case Qt::Key_Backspace | Qt::CTRL | Qt::SHIFT : // DeleteLineLeft + case Qt::Key_Delete | Qt::CTRL | Qt::SHIFT : // DeleteLineRight + case Qt::Key_K | Qt::META : // DeleteLineRight + case Qt::Key_Backspace | Qt::CTRL : // DeleteWordLeft + case Qt::Key_Delete | Qt::CTRL : // DeleteWordRight + case Qt::Key_L | Qt::CTRL | Qt::SHIFT : // LineDelete + case Qt::Key_L | Qt::CTRL : // LineCut + case Qt::Key_T | Qt::CTRL | Qt::SHIFT : // LineCopy + cmd_list.at (i)->setKey (0); + } + } +#endif + +#if defined (Q_OS_MAC) + // Octave interprets Cmd key as Meta whereas Qscintilla interprets it + // as Ctrl. We thus invert Meta/Ctrl in Qscintilla's shortcuts list. + QList< QsciCommand * > cmd_list_mac = cmd_set->commands (); + for (int i = 0; i < cmd_list_mac.length (); i++) + { + // Primary key + int key = cmd_list_mac.at (i)->key (); + + if (static_cast (key | Qt::META) == key && + static_cast (key | Qt::CTRL) != key) + key = (key ^ Qt::META) | Qt::CTRL; + else if (static_cast (key | Qt::CTRL) == key) + key = (key ^ Qt::CTRL) | Qt::META; + + cmd_list_mac.at (i)->setKey (key); + + // Alternate key + key = cmd_list_mac.at (i)->alternateKey (); + + if (static_cast (key | Qt::META) == key && + static_cast (key | Qt::CTRL) != key) + key = (key ^ Qt::META) | Qt::CTRL; + else if (static_cast (key | Qt::CTRL) == key) + key = (key ^ Qt::CTRL) | Qt::META; + + cmd_list_mac.at (i)->setAlternateKey (key); + } +#endif +} octave_qscintilla::~octave_qscintilla () { } @@ -44,11 +138,11 @@ octave_qscintilla::get_global_textcursor_pos (QPoint *global_pos, QPoint *local_pos) { - long position = SendScintilla (QsciScintillaBase::SCI_GETCURRENTPOS); + long position = SendScintilla (SCI_GETCURRENTPOS); long point_x = SendScintilla - (QsciScintillaBase::SCI_POINTXFROMPOSITION,0,position); + (SCI_POINTXFROMPOSITION,0,position); long point_y = SendScintilla - (QsciScintillaBase::SCI_POINTYFROMPOSITION,0,position); + (SCI_POINTYFROMPOSITION,0,position); *local_pos = QPoint (point_x,point_y); // local cursor position *global_pos = mapToGlobal (*local_pos); // global position of cursor } @@ -94,11 +188,13 @@ void octave_qscintilla::contextMenuEvent (QContextMenuEvent *e) { + QPoint global_pos, local_pos; // the menu's position QMenu *context_menu = createStandardContextMenu ( ); // standard menu - // the menu's position - QPoint global_pos, local_pos; + // fill context menu with editor's standard actions + emit create_context_menu_signal (context_menu); + // determine position depending on mouse or keyboard event if (e->reason () == QContextMenuEvent::Mouse) { // context menu by mouse @@ -135,10 +231,6 @@ context_menu->addAction (tr ("Edit") + " " + _word_at_cursor, this, SLOT (contextmenu_edit (bool))); } - context_menu->addSeparator (); // separator before custom entries - if (hasSelectedText ()) - context_menu->addAction (tr ("&Run Selection"), - this, SLOT (contextmenu_run (bool))); } // finaly show the menu @@ -163,18 +255,16 @@ void octave_qscintilla::contextmenu_help_doc (bool documentation) { - QString command; if (documentation) - command = "doc "; + emit show_doc_signal (_word_at_cursor); else - command = "help "; - emit execute_command_in_terminal_signal (command + _word_at_cursor); + emit execute_command_in_terminal_signal ("help " + _word_at_cursor); } 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 @@ -186,4 +276,10 @@ emit execute_command_in_terminal_signal (commands.at (i)); } +void +octave_qscintilla::text_changed () +{ + emit status_update (isUndoAvailable (), isRedoAvailable ()); +} + #endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/octave-qscintilla.h --- a/libgui/src/m-editor/octave-qscintilla.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/m-editor/octave-qscintilla.h Fri Jan 23 15:23:09 2015 -0500 @@ -50,6 +50,11 @@ signals: 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); + void show_doc_signal (const QString&); private slots: @@ -59,6 +64,10 @@ void contextmenu_edit (bool); void contextmenu_run (bool); + void text_changed (void); + +protected: + private: QString _word_at_cursor; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/octave-txt-lexer.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/src/m-editor/octave-txt-lexer.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,52 @@ +/* + +Copyright (C) 2014 Torsten + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +// Author: Torsten + +#ifdef HAVE_CONFIG_H +#include +#endif + +#ifdef HAVE_QSCINTILLA + +#include + +#include "octave-txt-lexer.h" + +QString +octave_txt_lexer::description (int style) const +{ + if (style == 0) + return tr ("Default"); + else + return QString (); +}; + + +const char* +octave_txt_lexer::language () const +{ + return "Text"; +} + + +#endif diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/m-editor/octave-txt-lexer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/src/m-editor/octave-txt-lexer.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,43 @@ +/* + +Copyright (C) 2013 Torsten + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +// Author: Torsten + +#if !defined (octave_txt_lexer_h) +#define octave_txt_lexer_h 1 + +#include +#include + + +class octave_txt_lexer : public QsciLexer +{ + Q_OBJECT + +public: + + virtual const char *language () const; + virtual QString description (int style) const; + +}; + +#endif \ No newline at end of file diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/main-window.cc --- a/libgui/src/main-window.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/main-window.cc Fri Jan 23 15:23:09 2015 -0500 @@ -51,6 +51,9 @@ #endif #include "main-window.h" #include "settings-dialog.h" +#include "shortcut-manager.h" + +#include "__init_qt__.h" #include "Array.h" #include "cmd-edit.h" @@ -60,6 +63,7 @@ #include "defaults.h" #include "symtab.h" #include "version.h" +#include "utils.h" static file_editor_interface * create_default_editor (QWidget *p) @@ -91,13 +95,15 @@ _cmd_queue_mutex (), _dbg_queue (new QStringList ()), // no debug pending _dbg_processing (1), - _dbg_queue_mutex () + _dbg_queue_mutex (), + _prevent_readline_conflicts (true) { QSettings *settings = resource_manager::get_settings (); bool connect_to_web = true; QDateTime last_checked; int serial = 0; + _active_dock = 0; if (settings) { @@ -153,6 +159,55 @@ delete _cmd_queue; } +// catch focus changes and determine the active dock widget +void +main_window::focus_changed (QWidget *, QWidget *new_widget) +{ + octave_dock_widget* dock = 0; + QWidget *w_new = new_widget; // get a copy of new focus widget + QWidget *start = w_new; // Save it as start of our search + int count = 0; // fallback to prevent endless loop + + while (w_new && w_new != _main_tool_bar && count < 100) + { + dock = qobject_cast (w_new); + if (dock) + break; // it is a QDockWidget ==> exit loop + +#ifdef HAVE_QSCINTILLA + if (qobject_cast (w_new)) + { + dock = static_cast (editor_window); + break; // it is the editor window ==> exit loop + } +#endif + + w_new = qobject_cast (w_new->previousInFocusChain ()); + if (w_new == start) + break; // we have arrived where we began ==> exit loop + + count++; + } + + // editor needs extra handling + octave_dock_widget *edit_dock_widget = + static_cast (editor_window); + // if new dock has focus, emit signal and store active focus + // except editor changes to a dialog (dock=0) + if ((dock || _active_dock != edit_dock_widget) && (dock != _active_dock)) + { + // signal to all dock widgets for updating the style + emit active_dock_changed (_active_dock, dock); + + if (edit_dock_widget == dock) + emit editor_focus_changed (true); + else if (edit_dock_widget == _active_dock) + emit editor_focus_changed (false); + + _active_dock = dock; + } +} + bool main_window::command_window_has_focus (void) const { @@ -244,17 +299,50 @@ octave_link::post_event (this, &main_window::clear_history_callback); } +bool +main_window::focus_console_after_command () +{ + QSettings *settings = resource_manager::get_settings (); + return settings->value ("terminal/focus_after_command",false).toBool (); +} + void main_window::execute_command_in_terminal (const QString& command) { queue_command (command); - focus_command_window (); + if (focus_console_after_command ()) + focus_command_window (); } void main_window::run_file_in_terminal (const QFileInfo& info) { + QString file_name = info.canonicalFilePath (); + QString command = "run \"" + file_name + "\""; + + QString function_name = info.fileName (); + function_name.chop (info.suffix ().length () + 1); + + if (! valid_identifier (function_name.toStdString ())) + { + int ans = QMessageBox::question (0, tr ("Octave"), + tr ("The file %1\n" + "can not be executed because its name\n" + "is not a valid identifier.\n\n" + "Do you want to execute\n%2\n" + "instead?"). + arg (file_name).arg (command), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + if (ans == QMessageBox::Yes) + execute_command_in_terminal (command); + + return; + } + octave_link::post_event (this, &main_window::run_file_callback, info); + if (focus_console_after_command ()) + focus_command_window (); } void @@ -331,14 +419,17 @@ release_notes_window->setWindowTitle (tr ("Octave Release Notes")); browser->document()->adjustSize (); - QSize doc_size = browser->document()->size().toSize (); - doc_size.rwidth () += 45; - int h = QApplication::desktop ()->height (); - if (h > 800) - h = 800; - doc_size.rheight () = h; - - release_notes_window->resize (doc_size); + + // center the window on the screen where octave is running + QDesktopWidget *m_desktop = QApplication::desktop (); + int screen = m_desktop->screenNumber (this); // screen of the main window + QRect screen_geo = m_desktop->availableGeometry (screen); + int win_x = screen_geo.width (); // width of the screen + int win_y = screen_geo.height (); // height of the screen + int reln_x = std::min (480, win_x-80); // desired width of release notes + int reln_y = std::min (640, win_y-80); // desired height of release notes + release_notes_window->resize (reln_x, reln_y); // set size + release_notes_window->move (20, 0); // move to the top left corner } if (! release_notes_window->isVisible ()) @@ -518,9 +609,16 @@ community_news_window->setLayout (vlayout); community_news_window->setWindowTitle (tr ("Octave Community News")); - community_news_window->resize (640, 480); - int win_x = QApplication::desktop ()->width (); - int win_y = QApplication::desktop ()->height (); + + // center the window on the screen where octave is running + QDesktopWidget *m_desktop = QApplication::desktop (); + int screen = m_desktop->screenNumber (this); // screen of the main window + QRect screen_geo = m_desktop->availableGeometry (screen); + int win_x = screen_geo.width (); // width of the screen + int win_y = screen_geo.height (); // height of the screen + int news_x = std::min (640, win_x-80); // desired width of news window + int news_y = std::min (480, win_y-80); // desired height of news window + community_news_window->resize (news_x, news_y); // set size and center community_news_window->move ((win_x - community_news_window->width ())/2, (win_y - community_news_window->height ())/2); } @@ -644,6 +742,19 @@ int icon_size = settings->value ("toolbar_icon_size",16).toInt (); _main_tool_bar->setIconSize (QSize (icon_size,icon_size)); + if (settings->value ("show_status_bar",true).toBool ()) + status_bar->show (); + else + status_bar->hide (); + + _prevent_readline_conflicts = + settings->value ("shortcuts/prevent_readline_conflicts", true).toBool (); + configure_shortcuts (); + set_global_shortcuts (command_window_has_focus ()); + + _suppress_dbg_location = + ! settings->value ("terminal/print_debug_location", false).toBool (); + resource_manager::update_network_settings (); } @@ -855,7 +966,8 @@ main_window::closeEvent (QCloseEvent *e) { e->ignore (); - octave_link::post_event (this, &main_window::exit_callback); + if (confirm_exit_octave()) + octave_link::post_event (this, &main_window::exit_callback); } void @@ -882,6 +994,12 @@ } void +main_window::init_terminal_size (void) +{ + emit init_terminal_size_signal (); +} + +void main_window::set_window_layout (QSettings *settings) { #if ! defined (Q_OS_WIN32) @@ -965,6 +1083,10 @@ { foreach (octave_dock_widget *widget, dock_widget_list ()) widget->connect_visibility_changed (); + +#ifdef HAVE_QSCINTILLA + editor_window->enable_menu_shortcuts (false); +#endif } void @@ -1000,6 +1122,22 @@ emit pasteClipboard_signal (); } +void +main_window::selectAll (void) +{ + if (_current_directory_combo_box->hasFocus ()) + { + QLineEdit * edit = _current_directory_combo_box->lineEdit (); + if (edit) + { + edit->selectAll (); + } + } + else + emit selectAll_signal (); +} + + // Connect the signals emitted when the Octave thread wants to create // a dialog box of some sort. Perhaps a better place for this would be // as part of the QUIWidgetCreator class. However, mainWindow currently @@ -1146,23 +1284,27 @@ construct_tool_bar (); - construct_warning_bar (); - connect (qApp, SIGNAL (aboutToQuit ()), this, SLOT (prepare_to_exit ())); + connect (qApp, SIGNAL (focusChanged (QWidget*, QWidget*)), + this, SLOT(focus_changed (QWidget*, QWidget*))); + connect (this, SIGNAL (settings_changed (const QSettings *)), this, SLOT (notice_settings (const QSettings *))); + connect (this, SIGNAL (editor_focus_changed (bool)), + this, SLOT (set_global_edit_shortcuts (bool))); + + connect (this, SIGNAL (editor_focus_changed (bool)), + editor_window, SLOT (enable_menu_shortcuts (bool))); + connect (file_browser_window, SIGNAL (load_file_signal (const QString&)), this, SLOT (handle_load_workspace_request (const QString&))); connect (file_browser_window, SIGNAL (find_files_signal (const QString&)), this, SLOT (find_files (const QString&))); - connect (this, SIGNAL (set_widget_shortcuts_signal (bool)), - editor_window, SLOT (set_shortcuts (bool))); - connect_uiwidget_links (); setWindowTitle ("Octave"); @@ -1218,19 +1360,61 @@ int))); #endif - QDir curr_dir; - set_current_working_directory (curr_dir.absolutePath ()); - octave_link::post_event (this, &main_window::resize_command_window_callback); - set_global_shortcuts (true); + install___init_qt___functions (); + + Fregister_graphics_toolkit (ovl ("qt")); + + configure_shortcuts (); +} + + +void +main_window::handle_octave_ready () +{ + // actions after the startup files are executed + QSettings *settings = resource_manager::get_settings (); + + QDir startup_dir = QDir (); // current octave dir after startup + + if (settings->value ("restore_octave_dir").toBool ()) + { + // restore last dir from previous session + QStringList curr_dirs + = settings->value ("MainWindow/current_directory_list").toStringList (); + startup_dir = QDir (curr_dirs.at (0)); // last dir in previous session + } + else if (! settings->value ("octave_startup_dir").toString ().isEmpty ()) + { + // do not restore but there is a startup dir configured + startup_dir = QDir (settings->value ("octave_startup_dir").toString ()); + } + + if (! startup_dir.exists ()) + { + // the configured startup dir does not exist, take actual one + startup_dir = QDir (); + } + + set_current_working_directory (startup_dir.absolutePath ()); + +#ifdef HAVE_QSCINTILLA + // Octave ready, determine whether to create an empty script. + // This can not be done when the editor is created because all functions + // must be known for the lexer's auto completion informations + editor_window->empty_script (true, false); +#endif + + focus_command_window (); // make sure that the command window has focus } + void main_window::construct_octave_qt_link (void) { - _octave_qt_link = new octave_qt_link (); + _octave_qt_link = new octave_qt_link (this); connect (_octave_qt_link, SIGNAL (exit_signal (int)), this, SLOT (exit (int))); @@ -1337,10 +1521,57 @@ construct_news_menu (menu_bar); } +QAction* +main_window::add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member, const QWidget *receiver) +{ + QAction *a; + + if (receiver) + a = menu->addAction (icon, text, receiver, member); + else + a = menu->addAction (icon, text, this, member); + + addAction (a); // important for shortcut context + a->setShortcutContext (Qt::ApplicationShortcut); + return a; +} + +void +main_window::enable_menu_shortcuts (bool enable) +{ + QHash::const_iterator i = _hash_menu_text.constBegin(); + + while (i != _hash_menu_text.constEnd()) + { + i.key ()->setTitle (i.value ().at (! enable)); + ++i; + } +} + +QMenu* +main_window::m_add_menu (QMenuBar *p, QString name) +{ + QMenu *menu = p->addMenu (name); + + QString base_name = name; // get a copy + // replace intended '&' ("&&") by a temp. string + base_name.replace ("&&","___octave_amp_replacement___"); + // remove single '&' (shortcut) + base_name.remove ("&"); + // restore intended '&' + base_name.replace ("___octave_amp_replacement___","&&"); + + // remember names with and without shortcut + _hash_menu_text[menu] = QStringList () << name << base_name; + + return menu; +} + void main_window::construct_file_menu (QMenuBar *p) { - QMenu *file_menu = p->addMenu (tr ("&File")); + QMenu *file_menu = m_add_menu (p, tr ("&File")); construct_new_menu (file_menu); @@ -1348,23 +1579,27 @@ = file_menu->addAction (QIcon (":/actions/icons/folder_documents.png"), tr ("Open...")); _open_action->setShortcutContext (Qt::ApplicationShortcut); - + _open_action->setToolTip (tr ("Open an existing file in editor")); #ifdef HAVE_QSCINTILLA + editor_window->insert_new_open_actions (_new_script_action, + _new_function_action, + _open_action); + file_menu->addMenu (editor_window->get_mru_menu ()); #endif file_menu->addSeparator (); - QAction *load_workspace_action + _load_workspace_action = file_menu->addAction (tr ("Load Workspace...")); - QAction *save_workspace_action + _save_workspace_action = file_menu->addAction (tr ("Save Workspace As...")); file_menu->addSeparator (); - QAction *preferences_action + _preferences_action = file_menu->addAction (QIcon (":/actions/icons/configure.png"), tr ("Preferences...")); @@ -1373,7 +1608,7 @@ _exit_action = file_menu->addAction (tr ("Exit")); _exit_action->setShortcutContext (Qt::ApplicationShortcut); - connect (preferences_action, SIGNAL (triggered ()), + connect (_preferences_action, SIGNAL (triggered ()), this, SLOT (process_settings_dialog_request ())); #ifdef HAVE_QSCINTILLA @@ -1381,10 +1616,10 @@ editor_window, SLOT (request_open_file ())); #endif - connect (load_workspace_action, SIGNAL (triggered ()), + connect (_load_workspace_action, SIGNAL (triggered ()), this, SLOT (handle_load_workspace_request ())); - connect (save_workspace_action, SIGNAL (triggered ()), + connect (_save_workspace_action, SIGNAL (triggered ()), this, SLOT (handle_save_workspace_request ())); connect (_exit_action, SIGNAL (triggered ()), @@ -1398,15 +1633,15 @@ _new_script_action = new_menu->addAction (QIcon (":/actions/icons/filenew.png"), - tr ("Script")); + tr ("New Script")); _new_script_action->setShortcutContext (Qt::ApplicationShortcut); - _new_function_action = new_menu->addAction (tr ("Function...")); + _new_function_action = new_menu->addAction (tr ("New Function...")); _new_function_action->setEnabled (true); _new_function_action->setShortcutContext (Qt::ApplicationShortcut); - QAction *new_figure_action = new_menu->addAction (tr ("Figure")); - new_figure_action->setEnabled (true); + _new_figure_action = new_menu->addAction (tr ("New Figure")); + _new_figure_action->setEnabled (true); #ifdef HAVE_QSCINTILLA connect (_new_script_action, SIGNAL (triggered ()), @@ -1416,33 +1651,32 @@ editor_window, SLOT (request_new_function ())); #endif - connect (new_figure_action, SIGNAL (triggered ()), + connect (_new_figure_action, SIGNAL (triggered ()), this, SLOT (handle_new_figure_request ())); } void main_window::construct_edit_menu (QMenuBar *p) { - QMenu *edit_menu = p->addMenu (tr ("&Edit")); + QMenu *edit_menu = m_add_menu (p, tr ("&Edit")); QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier; _undo_action = edit_menu->addAction (QIcon (":/actions/icons/undo.png"), tr ("Undo")); - _undo_action->setShortcut (QKeySequence::Undo); edit_menu->addSeparator (); _copy_action = edit_menu->addAction (QIcon (":/actions/icons/editcopy.png"), tr ("Copy"), this, SLOT (copyClipboard ())); - _copy_action->setShortcut (QKeySequence::Copy); - _paste_action = edit_menu->addAction (QIcon (":/actions/icons/editpaste.png"), tr ("Paste"), this, SLOT (pasteClipboard ())); - _paste_action->setShortcut (QKeySequence::Paste); + + _select_all_action + = edit_menu->addAction (tr ("Select All"), this, SLOT (selectAll ())); _clear_clipboard_action = edit_menu->addAction (tr ("Clear Clipboard"), this, @@ -1454,25 +1688,25 @@ edit_menu->addSeparator (); - QAction *clear_command_window_action + _clear_command_window_action = edit_menu->addAction (tr ("Clear Command Window")); - QAction *clear_command_history + _clear_command_history_action = edit_menu->addAction (tr ("Clear Command History")); - QAction *clear_workspace_action + _clear_workspace_action = edit_menu->addAction (tr ("Clear Workspace")); connect (_find_files_action, SIGNAL (triggered ()), this, SLOT (find_files ())); - connect (clear_command_window_action, SIGNAL (triggered ()), + connect (_clear_command_window_action, SIGNAL (triggered ()), this, SLOT (handle_clear_command_window_request ())); - connect (clear_command_history, SIGNAL (triggered ()), + connect (_clear_command_history_action, SIGNAL (triggered ()), this, SLOT (handle_clear_history_request ())); - connect (clear_workspace_action, SIGNAL (triggered ()), + connect (_clear_workspace_action, SIGNAL (triggered ()), this, SLOT (handle_clear_workspace_request ())); connect (_clipboard, SIGNAL (changed (QClipboard::Mode)), @@ -1481,14 +1715,12 @@ } QAction * -main_window::construct_debug_menu_item (const char *icon_file, - const QString& item, - const QKeySequence& key) +main_window::construct_debug_menu_item (const char *icon, const QString& item, + const char *member) { - QAction *action = _debug_menu->addAction (QIcon (icon_file), item); + QAction *action = add_action (_debug_menu, QIcon (icon), item, member); action->setEnabled (false); - action->setShortcut (key); #ifdef HAVE_QSCINTILLA editor_window->debug_menu ()->addAction (action); @@ -1501,23 +1733,23 @@ void main_window::construct_debug_menu (QMenuBar *p) { - _debug_menu = p->addMenu (tr ("De&bug")); + _debug_menu = m_add_menu (p, tr ("De&bug")); _debug_step_over = construct_debug_menu_item - (":/actions/icons/db_step.png", tr ("Step"), - Qt::Key_F10); + (":/actions/icons/db_step.png", tr ("Step"), + SLOT (debug_step_over ())); _debug_step_into = construct_debug_menu_item - (":/actions/icons/db_step_in.png", tr ("Step In"), - Qt::Key_F11); + (":/actions/icons/db_step_in.png", tr ("Step In"), + SLOT (debug_step_into ())); _debug_step_out = construct_debug_menu_item (":/actions/icons/db_step_out.png", tr ("Step Out"), - Qt::ShiftModifier + Qt::Key_F11); + SLOT (debug_step_out ())); _debug_continue = construct_debug_menu_item (":/actions/icons/db_cont.png", tr ("Continue"), - Qt::Key_F5); + SLOT (debug_continue ())); _debug_menu->addSeparator (); #ifdef HAVE_QSCINTILLA @@ -1525,415 +1757,142 @@ #endif _debug_quit = construct_debug_menu_item - (":/actions/icons/db_stop.png", tr ("Exit Debug Mode"), - Qt::ShiftModifier + Qt::Key_F5); - - connect (_debug_step_over, SIGNAL (triggered ()), - this, SLOT (debug_step_over ())); - - connect (_debug_step_into, SIGNAL (triggered ()), - this, SLOT (debug_step_into ())); - - connect (_debug_step_out, SIGNAL (triggered ()), - this, SLOT (debug_step_out ())); - - connect (_debug_continue, SIGNAL (triggered ()), - this, SLOT (debug_continue ())); - - connect (_debug_quit, SIGNAL (triggered ()), - this, SLOT (debug_quit ())); + (":/actions/icons/db_stop.png", tr ("Quit Debug Mode"), + SLOT (debug_quit ())); } QAction * main_window::construct_window_menu_item (QMenu *p, const QString& item, - bool checkable, - const QKeySequence& key) + bool checkable, QWidget *widget) { - QAction *action = p->addAction (item); - + QAction *action = p->addAction (QIcon (), item); + + addAction (action); // important for shortcut context action->setCheckable (checkable); - action->setShortcut (key); action->setShortcutContext (Qt::ApplicationShortcut); + if (widget) // might be zero for editor_window + { + if (checkable) + { + // action for visibilty of dock widget + connect (action, SIGNAL (toggled (bool)), + widget, SLOT (setVisible (bool))); + + connect (widget, SIGNAL (active_changed (bool)), + action, SLOT (setChecked (bool))); + } + else + { + // action for focus of dock widget + connect (action, SIGNAL (triggered ()), widget, SLOT (focus ())); + } + } + return action; } void main_window::construct_window_menu (QMenuBar *p) { - QMenu *window_menu = p->addMenu (tr ("&Window")); - - QKeySequence ctrl = Qt::ControlModifier; - QKeySequence ctrl_shift = Qt::ControlModifier + Qt::ShiftModifier; - - QAction *show_command_window_action = construct_window_menu_item - (window_menu, - tr ("Show Command Window"), true, - ctrl_shift + Qt::Key_0); - - QAction *show_history_action = construct_window_menu_item - (window_menu, tr ("Show Command History"), - true, ctrl_shift + Qt::Key_1); - - QAction *show_file_browser_action = construct_window_menu_item - (window_menu, tr ("Show File Browser"), - true, ctrl_shift + Qt::Key_2); - - QAction *show_workspace_action = construct_window_menu_item - (window_menu, tr ("Show Workspace"), true, - ctrl_shift + Qt::Key_3); - - QAction *show_editor_action = construct_window_menu_item - (window_menu, tr ("Show Editor"), true, - ctrl_shift + Qt::Key_4); - - QAction *show_documentation_action = construct_window_menu_item - (window_menu, tr ("Show Documentation"), - true, ctrl_shift + Qt::Key_5); - - window_menu->addSeparator (); - - QAction *command_window_action = construct_window_menu_item - (window_menu, tr ("Command Window"), false, - ctrl + Qt::Key_0); - - QAction *history_action = construct_window_menu_item - (window_menu, tr ("Command History"), false, - ctrl + Qt::Key_1); - - QAction *file_browser_action = construct_window_menu_item - (window_menu, tr ("File Browser"), false, - ctrl + Qt::Key_2); - - QAction *workspace_action = construct_window_menu_item - (window_menu, tr ("Workspace"), false, - ctrl + Qt::Key_3); - - QAction *editor_action = construct_window_menu_item - (window_menu, tr ("Editor"), false, - ctrl + Qt::Key_4); - - QAction *documentation_action = construct_window_menu_item - (window_menu, tr ("Documentation"), false, - ctrl + Qt::Key_5); + QMenu *window_menu = m_add_menu (p, tr ("&Window")); + + _show_command_window_action = construct_window_menu_item + (window_menu, tr ("Show Command Window"), true, command_window); + + _show_history_action = construct_window_menu_item + (window_menu, tr ("Show Command History"), true, history_window); + + _show_file_browser_action = construct_window_menu_item + (window_menu, tr ("Show File Browser"), true, file_browser_window); + + _show_workspace_action = construct_window_menu_item + (window_menu, tr ("Show Workspace"), true, workspace_window); + + _show_editor_action = construct_window_menu_item + (window_menu, tr ("Show Editor"), true, editor_window); + + _show_documentation_action = construct_window_menu_item + (window_menu, tr ("Show Documentation"), true, doc_browser_window); window_menu->addSeparator (); - QAction *reset_windows_action - = window_menu->addAction (tr ("Reset Default Window Layout")); - - connect (show_command_window_action, SIGNAL (toggled (bool)), - command_window, SLOT (setVisible (bool))); - - connect (command_window, SIGNAL (active_changed (bool)), - show_command_window_action, SLOT (setChecked (bool))); - - connect (show_workspace_action, SIGNAL (toggled (bool)), - workspace_window, SLOT (setVisible (bool))); - - connect (workspace_window, SIGNAL (active_changed (bool)), - show_workspace_action, SLOT (setChecked (bool))); - - connect (show_history_action, SIGNAL (toggled (bool)), - history_window, SLOT (setVisible (bool))); - - connect (history_window, SIGNAL (active_changed (bool)), - show_history_action, SLOT (setChecked (bool))); - - connect (show_file_browser_action, SIGNAL (toggled (bool)), - file_browser_window, SLOT (setVisible (bool))); - - connect (file_browser_window, SIGNAL (active_changed (bool)), - show_file_browser_action, SLOT (setChecked (bool))); - -#ifdef HAVE_QSCINTILLA - connect (show_editor_action, SIGNAL (toggled (bool)), - editor_window, SLOT (setVisible (bool))); - - connect (editor_window, SIGNAL (active_changed (bool)), - show_editor_action, SLOT (setChecked (bool))); -#endif - - connect (show_documentation_action, SIGNAL (toggled (bool)), - doc_browser_window, SLOT (setVisible (bool))); - - connect (doc_browser_window, SIGNAL (active_changed (bool)), - show_documentation_action, SLOT (setChecked (bool))); - - connect (command_window_action, SIGNAL (triggered ()), - command_window, SLOT (focus ())); - - connect (workspace_action, SIGNAL (triggered ()), - workspace_window, SLOT (focus ())); - - connect (history_action, SIGNAL (triggered ()), - history_window, SLOT (focus ())); - - connect (file_browser_action, SIGNAL (triggered ()), - file_browser_window, SLOT (focus ())); - -#ifdef HAVE_QSCINTILLA - connect (editor_action, SIGNAL (triggered ()), - editor_window, SLOT (focus ())); -#endif - - connect (documentation_action, SIGNAL (triggered ()), - doc_browser_window, SLOT (focus ())); - - connect (reset_windows_action, SIGNAL (triggered ()), - this, SLOT (reset_windows ())); + _command_window_action = construct_window_menu_item + (window_menu, tr ("Command Window"), false, command_window); + + _history_action = construct_window_menu_item + (window_menu, tr ("Command History"), false, history_window); + + _file_browser_action = construct_window_menu_item + (window_menu, tr ("File Browser"), false, file_browser_window); + + _workspace_action = construct_window_menu_item + (window_menu, tr ("Workspace"), false, workspace_window); + + _editor_action = construct_window_menu_item + (window_menu, tr ("Editor"), false, editor_window); + + _documentation_action = construct_window_menu_item + (window_menu, tr ("Documentation"), false, doc_browser_window); + + window_menu->addSeparator (); + + _reset_windows_action = add_action (window_menu, QIcon (), + tr ("Reset Default Window Layout"), SLOT (reset_windows ())); } void main_window::construct_help_menu (QMenuBar *p) { - QMenu *help_menu = p->addMenu (tr ("&Help")); + QMenu *help_menu = m_add_menu (p, tr ("&Help")); construct_documentation_menu (help_menu); help_menu->addSeparator (); - QAction *report_bug_action - = help_menu->addAction (tr ("Report Bug")); - - QAction *octave_packages_action - = help_menu->addAction (tr ("Octave Packages")); - - QAction *agora_action - = help_menu->addAction (tr ("Share Code")); - - QAction *contribute_action - = help_menu->addAction (tr ("Contribute to Octave")); - - QAction *developer_action - = help_menu->addAction (tr ("Octave Developer Resources")); + _report_bug_action = add_action (help_menu, QIcon (), + tr ("Report Bug"), SLOT (open_bug_tracker_page ())); + + _octave_packages_action = add_action (help_menu, QIcon (), + tr ("Octave Packages"), SLOT (open_octave_packages_page ())); + + _agora_action = add_action (help_menu, QIcon (), + tr ("Share Code"), SLOT (open_agora_page ())); + + _contribute_action = add_action (help_menu, QIcon (), + tr ("Contribute to Octave"), SLOT (open_contribute_page ())); + + _developer_action = add_action (help_menu, QIcon (), + tr ("Octave Developer Resources"), SLOT (open_developer_page ())); help_menu->addSeparator (); - QAction *about_octave_action - = help_menu->addAction (tr ("About Octave")); - - connect (report_bug_action, SIGNAL (triggered ()), - this, SLOT (open_bug_tracker_page ())); - - connect (octave_packages_action, SIGNAL (triggered ()), - this, SLOT (open_octave_packages_page ())); - - connect (agora_action, SIGNAL (triggered ()), - this, SLOT (open_agora_page ())); - - connect (contribute_action, SIGNAL (triggered ()), - this, SLOT (open_contribute_page ())); - - connect (developer_action, SIGNAL (triggered ()), - this, SLOT (open_developer_page ())); - - connect (about_octave_action, SIGNAL (triggered ()), - this, SLOT (show_about_octave ())); + _about_octave_action = add_action (help_menu, QIcon (), + tr ("About Octave"), SLOT (show_about_octave ())); } void main_window::construct_documentation_menu (QMenu *p) { - QMenu *documentation_menu = p->addMenu (tr ("Documentation")); - - QAction *ondisk_documentation_action - = documentation_menu->addAction (tr ("On Disk")); - - QAction *online_documentation_action - = documentation_menu->addAction (tr ("Online")); - - connect (ondisk_documentation_action, SIGNAL (triggered ()), - doc_browser_window, SLOT (focus ())); - - connect (online_documentation_action, SIGNAL (triggered ()), - this, SLOT (open_online_documentation_page ())); + QMenu *doc_menu = p->addMenu (tr ("Documentation")); + + _ondisk_doc_action = add_action (doc_menu, QIcon (), + tr ("On Disk"), SLOT (focus ()), doc_browser_window); + + _online_doc_action = add_action (doc_menu, QIcon (), + tr ("Online"), SLOT (open_online_documentation_page ())); } void main_window::construct_news_menu (QMenuBar *p) { - QMenu *news_menu = p->addMenu (tr ("&News")); - - QAction *release_notes_action - = news_menu->addAction (tr ("Release Notes")); - - QAction *current_news_action - = news_menu->addAction (tr ("Community News")); - - connect (release_notes_action, SIGNAL (triggered ()), - this, SLOT (display_release_notes ())); - - connect (current_news_action, SIGNAL (triggered ()), - this, SLOT (load_and_display_community_news ())); -} - -void -main_window::construct_warning_bar (void) -{ - QSettings *settings = resource_manager::get_settings (); - - if (settings - && settings->value ("General/hide_new_gui_warning", false).toBool ()) - { - construct_gui_info_button (); - - return; - } - - _warning_bar = new QDockWidget (this); - _warning_bar->setAttribute (Qt::WA_DeleteOnClose); - - QFrame *box = new QFrame (_warning_bar); - - QLabel *icon = new QLabel (box); - QIcon warning_icon - = QIcon::fromTheme ("dialog-warning", - QIcon (":/actions/icons/warning.png")); - QPixmap icon_pixmap = warning_icon.pixmap (QSize (32, 32)); - icon->setPixmap (icon_pixmap); - - QTextBrowser *msg = new QTextBrowser (box); - msg->setOpenExternalLinks (true); - msg->setText - (tr ("You are using a release candidate of Octave's experimental GUI. " - "Octave is under continuous improvement and the GUI will be the " - "default interface for the 4.0 release. For more information, " - "select the \"Release Notes\" item in the \"News\" menu of the GUI, " - "or visit http://octave.org.")); - - msg->setStyleSheet ("background-color: #ffd97f; color: black; margin 4px;"); - msg->setMinimumWidth (100); - msg->setMinimumHeight (60); - msg->setMaximumHeight (80); - msg->setSizePolicy (QSizePolicy (QSizePolicy::Expanding, - QSizePolicy::Minimum)); - - QPushButton *info_button = new QPushButton (tr ("More Info"), box); - QPushButton *hide_button = new QPushButton (tr ("Hide"), box); - - connect (info_button, SIGNAL (clicked ()), - this, SLOT (show_gui_info ())); - - connect (hide_button, SIGNAL (clicked ()), - this, SLOT (hide_warning_bar ())); - - QVBoxLayout *button_layout = new QVBoxLayout; - - button_layout->addWidget (info_button); - button_layout->addWidget (hide_button); - - QHBoxLayout *icon_and_message = new QHBoxLayout; - - icon_and_message->addWidget (icon); - icon_and_message->addSpacing (10); - icon_and_message->addWidget (msg); - icon_and_message->addSpacing (10); - icon_and_message->addLayout (button_layout); - - icon_and_message->setAlignment (hide_button, Qt::AlignTop); - - box->setFrameStyle (QFrame::Box); - box->setLineWidth (2); - box->setMaximumWidth (1000); - box->adjustSize (); - box->setLayout (icon_and_message); - - _warning_bar->setFeatures (QDockWidget::NoDockWidgetFeatures); - _warning_bar->setObjectName ("WarningToolBar"); - _warning_bar->setWidget (box); - - setCorner (Qt::TopLeftCorner, Qt::TopDockWidgetArea); - setCorner (Qt::TopRightCorner, Qt::TopDockWidgetArea); - - addDockWidget (Qt::TopDockWidgetArea, _warning_bar); -}; - -void -main_window::construct_gui_info_button (void) -{ - QIcon warning_icon - = QIcon::fromTheme ("dialog-warning", - QIcon (":/actions/icons/warning.png")); - - _gui_info_button - = new QPushButton (warning_icon, tr ("Experimental GUI Info")); - - _main_tool_bar->addWidget (_gui_info_button); - - connect (_gui_info_button, SIGNAL (clicked ()), - this, SLOT (show_gui_info ())); -} - -void -main_window::hide_warning_bar (void) -{ - QSettings *settings = resource_manager::get_settings (); - - if (settings) - { - settings->setValue ("General/hide_new_gui_warning", true); - - settings->sync (); - } - - removeDockWidget (_warning_bar); - - construct_gui_info_button (); -} - -void -main_window::show_gui_info (void) -{ - QString gui_info - ( QObject::tr ("

A Note about Octave's New GUI

" - "

One of the biggest new features for Octave 3.8 is a graphical " - "user interface. It is the one thing that users have requested " - "most often over the last few years and now it is almost ready. " - "But because it is not quite as polished as we would like, we " - "have decided to wait until the 4.0.x release series before " - "making the GUI the default interface.

" - "

Given the length of time and the number of bug fixes and " - "improvements since the last major release, we also " - "decided against delaying the release of all these new " - "improvements any longer just to perfect the GUI. So please " - "enjoy the 3.8 release of Octave and the preview of the new GUI. " - "We believe it is working reasonably well, but we also know that " - "there are some obvious rough spots and many things that could be " - "improved.

" - "

We Need Your Help

" - "

There are many ways that you can help us fix the remaining " - "problems, complete the GUI, and improve the overall user " - "experience for both novices and experts alike (links will open " - "an external browser):

" - "

  • If you are a skilled software developer, you can " - "help by contributing your time to help " - "develop " - "Octave.
  • " - "
  • If Octave does not work properly, you are encouraged to " - "report problems " - "that you find.
  • " - "
  • Whether you are a user or developer, you can " - "help to fund the " - "project. " - "Octave development takes a lot of time and expertise. " - "Your contributions help to ensure that Octave will continue " - "to improve.

" - "

We hope you find Octave to be useful. Please help us make " - "it even better for the future!

")); - - QMessageBox gui_info_dialog (QMessageBox::Warning, - tr ("Experimental GUI Info"), - QString (gui_info.length (),' '), QMessageBox::Close); - QGridLayout *box_layout - = qobject_cast(gui_info_dialog.layout()); - if (box_layout) - { - QTextEdit *text = new QTextEdit(gui_info); - text->setReadOnly(true); - box_layout->addWidget(text, 0, 1); - } - gui_info_dialog.exec (); + QMenu *news_menu = m_add_menu (p, tr ("&News")); + + _release_notes_action = add_action (news_menu, QIcon (), + tr ("Release Notes"), SLOT (display_release_notes ())); + + _current_news_action = add_action (news_menu, QIcon (), + tr ("Community News"), SLOT (load_and_display_community_news ())); } void @@ -2044,6 +2003,12 @@ } void +main_window::set_screen_size_callback (const int_pair& sz) +{ + command_editor::set_screen_size (sz.first, sz.second); +} + +void main_window::clear_history_callback (void) { Fhistory (ovl ("-c")); @@ -2072,7 +2037,8 @@ command_editor::redisplay (); // We are executing inside the command editor event loop. Force // the current line to be returned for processing. - command_editor::interrupt (); + Fdb_next_breakpoint_quiet (ovl (_suppress_dbg_location)); + command_editor::accept_line (); } if (repost) // queue not empty, so repost event for further processing @@ -2127,13 +2093,22 @@ _dbg_queue_mutex.unlock (); if (debug == "step") - Fdbstep (); + { + Fdb_next_breakpoint_quiet (ovl (_suppress_dbg_location)); + Fdbstep (); + } else if (debug == "cont") - Fdbcont (); + { + Fdb_next_breakpoint_quiet (ovl (_suppress_dbg_location)); + Fdbcont (); + } else if (debug == "quit") Fdbquit (); else - Fdbstep (ovl (debug.toStdString ())); + { + Fdb_next_breakpoint_quiet (ovl (_suppress_dbg_location)); + Fdbstep (ovl (debug.toStdString ())); + } command_editor::interrupt (true); } @@ -2188,40 +2163,149 @@ } void +main_window::set_global_edit_shortcuts (bool editor_has_focus) +{ + // this slot is called when editor gets/loses focus + if (editor_has_focus) + { // disable shortcuts that are also provided by the editor itself + QKeySequence no_key = QKeySequence (); + _copy_action->setShortcut (no_key); + _paste_action->setShortcut (no_key); + _undo_action->setShortcut (no_key); + _select_all_action->setShortcut (no_key); + } + else + { // editor loses focus, set the global shortcuts + shortcut_manager::set_shortcut (_copy_action, "main_edit:copy"); + shortcut_manager::set_shortcut (_paste_action, "main_edit:paste"); + shortcut_manager::set_shortcut (_undo_action, "main_edit:undo"); + shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all"); + } + + // dis-/enable global menu depending on editor's focus + enable_menu_shortcuts (! editor_has_focus); +} + +void +main_window::configure_shortcuts () +{ + // file menu + shortcut_manager::set_shortcut (_open_action, "main_file:open_file"); + shortcut_manager::set_shortcut (_new_script_action, "main_file:new_file"); + shortcut_manager::set_shortcut (_new_function_action, "main_file:new_function"); + shortcut_manager::set_shortcut (_new_function_action, "main_file:new_figure"); + shortcut_manager::set_shortcut (_load_workspace_action, "main_file:load_workspace"); + shortcut_manager::set_shortcut (_save_workspace_action, "main_file:save_workspace"); + shortcut_manager::set_shortcut (_preferences_action, "main_file:preferences"); + shortcut_manager::set_shortcut (_exit_action,"main_file:exit"); + + // edit menu + shortcut_manager::set_shortcut (_copy_action, "main_edit:copy"); + shortcut_manager::set_shortcut (_paste_action, "main_edit:paste"); + shortcut_manager::set_shortcut (_undo_action, "main_edit:undo"); + shortcut_manager::set_shortcut (_select_all_action, "main_edit:select_all"); + shortcut_manager::set_shortcut (_clear_clipboard_action, "main_edit:clear_clipboard"); + shortcut_manager::set_shortcut (_find_files_action, "main_edit:find_in_files"); + shortcut_manager::set_shortcut (_clear_command_history_action, "main_edit:clear_history"); + shortcut_manager::set_shortcut (_clear_command_window_action, "main_edit:clear_command_window"); + shortcut_manager::set_shortcut (_clear_workspace_action, "main_edit:clear_workspace"); + + // debug menu + shortcut_manager::set_shortcut (_debug_step_over, "main_debug:step_over"); + shortcut_manager::set_shortcut (_debug_step_into, "main_debug:step_into"); + shortcut_manager::set_shortcut (_debug_step_out, "main_debug:step_out"); + shortcut_manager::set_shortcut (_debug_continue, "main_debug:continue"); + shortcut_manager::set_shortcut (_debug_quit, "main_debug:quit"); + + // window menu + shortcut_manager::set_shortcut (_show_command_window_action, "main_window:show_command"); + shortcut_manager::set_shortcut (_show_history_action, "main_window:show_history"); + shortcut_manager::set_shortcut (_show_workspace_action, "main_window:show_workspace"); + shortcut_manager::set_shortcut (_show_file_browser_action, "main_window:show_file_browser"); + shortcut_manager::set_shortcut (_show_editor_action, "main_window:show_editor"); + shortcut_manager::set_shortcut (_show_documentation_action, "main_window:show_doc"); + shortcut_manager::set_shortcut (_command_window_action, "main_window:command"); + shortcut_manager::set_shortcut (_history_action, "main_window:history"); + shortcut_manager::set_shortcut (_workspace_action, "main_window:workspace"); + shortcut_manager::set_shortcut (_file_browser_action, "main_window:file_browser"); + shortcut_manager::set_shortcut (_editor_action, "main_window:editor"); + shortcut_manager::set_shortcut (_documentation_action, "main_window:doc"); + shortcut_manager::set_shortcut (_reset_windows_action, "main_window:reset"); + + // help menu + shortcut_manager::set_shortcut (_ondisk_doc_action, "main_help:ondisk_doc"); + shortcut_manager::set_shortcut (_online_doc_action, "main_help:online_doc"); + shortcut_manager::set_shortcut (_report_bug_action, "main_help:report_bug"); + shortcut_manager::set_shortcut (_octave_packages_action, "main_help:packages"); + shortcut_manager::set_shortcut (_agora_action, "main_help:agora"); + shortcut_manager::set_shortcut (_contribute_action, "main_help:contribute"); + shortcut_manager::set_shortcut (_developer_action, "main_help:developer"); + shortcut_manager::set_shortcut (_about_octave_action, "main_help:about"); + + // news menu + shortcut_manager::set_shortcut (_release_notes_action, "main_news:release_notes"); + shortcut_manager::set_shortcut (_current_news_action, "main_news:community_news"); +} + +void main_window::set_global_shortcuts (bool set_shortcuts) { + // this slot is called when the terminal gets/loses focus + + // return if the user don't want to use readline shortcuts + if (! _prevent_readline_conflicts) + return; + if (set_shortcuts) - { - - _open_action->setShortcut (QKeySequence::Open); - _new_script_action->setShortcut (QKeySequence::New); - _new_function_action->setShortcut (Qt::ControlModifier - + Qt::ShiftModifier - + Qt::Key_N); - - _exit_action->setShortcut (QKeySequence::Quit); - - _find_files_action->setShortcut (Qt::ControlModifier - + Qt::ShiftModifier - + Qt::Key_F); - + { // terminal loses focus: set the global shortcuts + configure_shortcuts (); } else - { - + { // terminal gets focus: disable some shortcuts QKeySequence no_key = QKeySequence (); + // file menu _open_action->setShortcut (no_key); _new_script_action->setShortcut (no_key); _new_function_action->setShortcut (no_key); - + _new_function_action->setShortcut (no_key); + _load_workspace_action->setShortcut (no_key); + _save_workspace_action->setShortcut (no_key); + _preferences_action->setShortcut (no_key); _exit_action->setShortcut (no_key); + // edit menu + _select_all_action->setShortcut (no_key); + _clear_clipboard_action->setShortcut (no_key); _find_files_action->setShortcut (no_key); - + _clear_command_history_action->setShortcut (no_key); + _clear_command_window_action->setShortcut (no_key); + _clear_workspace_action->setShortcut (no_key); + + // window menu + _reset_windows_action->setShortcut (no_key); + + // help menu + _ondisk_doc_action->setShortcut (no_key); + _online_doc_action->setShortcut (no_key); + _report_bug_action->setShortcut (no_key); + _octave_packages_action->setShortcut (no_key); + _agora_action->setShortcut (no_key); + _contribute_action->setShortcut (no_key); + _developer_action->setShortcut (no_key); + _about_octave_action->setShortcut (no_key); + + // news menu + _release_notes_action->setShortcut (no_key); + _current_news_action->setShortcut (no_key); } - - emit set_widget_shortcuts_signal (set_shortcuts); +} + +void +main_window::set_screen_size (int ht, int wd) +{ + octave_link::post_event (this, &main_window::set_screen_size_callback, + int_pair (ht, wd)); } void @@ -2254,3 +2338,30 @@ { _clipboard->clear (QClipboard::Clipboard); } + +bool +main_window::confirm_exit_octave () +{ + bool closenow = true; + + QSettings *settings = resource_manager::get_settings (); + + if (settings->value ("prompt_to_exit", false ).toBool()) + { + int ans = QMessageBox::question (this, tr ("Octave"), + tr ("Are you sure you want to exit Octave?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + + if (ans != QMessageBox::Ok) + return false; + + } + +#ifdef HAVE_QSCINTILLA + closenow = editor_window->check_closing (1); // 1: exit request from gui +#endif + + return closenow; +} + + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/main-window.h --- a/libgui/src/main-window.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/main-window.h Fri Jan 23 15:23:09 2015 -0500 @@ -69,6 +69,7 @@ public: typedef std::pair name_pair; + typedef std::pair int_pair; main_window (QWidget *parent = 0); @@ -79,7 +80,12 @@ void focus_command_window (void); signals: + + void active_dock_changed (octave_dock_widget *, octave_dock_widget *); + void editor_focus_changed (bool); + void settings_changed (const QSettings *); + void init_terminal_size_signal (void); void new_file_signal (const QString&); void open_file_signal (const QString&); @@ -92,10 +98,13 @@ void copyClipboard_signal (void); void pasteClipboard_signal (void); - - void set_widget_shortcuts_signal (bool); + void selectAll_signal (void); public slots: + + void focus_changed (QWidget *w_old, QWidget *w_new); + + void report_status_message (const QString& statusMessage); void handle_save_workspace_request (void); void handle_load_workspace_request (const QString& file = QString ()); @@ -124,9 +133,6 @@ void exit (int status); void reset_windows (void); - void hide_warning_bar (void); - void show_gui_info (void); - void change_directory (const QString& dir); void browse_for_directory (void); void set_current_working_directory (const QString& dir); @@ -152,12 +158,14 @@ const QString& file, int line); void read_settings (void); + void init_terminal_size (void); void set_window_layout (QSettings *settings); void write_settings (void); void connect_visibility_changed (void); void copyClipboard (void); void pasteClipboard (void); + void selectAll (void); void connect_uiwidget_links (); @@ -185,12 +193,17 @@ void handle_show_doc (const QString &file); + void handle_octave_ready (); + // find files dialog void find_files (const QString &startdir=QDir::currentPath ()); void find_files_finished (int); // setting global shortcuts void set_global_shortcuts (bool enable); + void set_global_edit_shortcuts (bool enable); + + void set_screen_size (int ht, int wd); // handling the clipboard void clipboard_has_changed (QClipboard::Mode); @@ -209,28 +222,26 @@ void construct_octave_qt_link (void); + QAction *add_action (QMenu *menu, const QIcon &icon, const QString &text, + const char *member, const QWidget *receiver = 0); + + void enable_menu_shortcuts (bool enable); + QMenu* m_add_menu (QMenuBar *p, QString text); void construct_menu_bar (void); void construct_file_menu (QMenuBar *p); void construct_new_menu (QMenu *p); void construct_edit_menu (QMenuBar *p); - void construct_debug_menu_item (QMenu *p, const QString& item, - const QKeySequence& key); - QAction *construct_debug_menu_item (const char *icon_file, - const QString& item, - const QKeySequence& key); + QAction *construct_debug_menu_item (const char *icon, const QString& item, + const char* member); void construct_debug_menu (QMenuBar *p); QAction *construct_window_menu_item (QMenu *p, const QString& item, - bool checkable, - const QKeySequence& key); + bool checkable, QWidget*); void construct_window_menu (QMenuBar *p); void construct_help_menu (QMenuBar *p); void construct_documentation_menu (QMenu *p); void construct_news_menu (QMenuBar *p); - void construct_warning_bar (void); - void construct_gui_info_button (void); - void construct_tool_bar (void); void establish_octave_link (void); @@ -247,12 +258,15 @@ void resize_command_window_callback (void); + void set_screen_size_callback (const int_pair&); + void clear_workspace_callback (void); void clear_history_callback (void); void execute_command_callback (); void run_file_callback (const QFileInfo& info); + bool focus_console_after_command (); void new_figure_callback (void); @@ -266,8 +280,15 @@ void execute_debug_callback (); + void configure_shortcuts (); + + bool confirm_exit_octave (); + workspace_model *_workspace_model; + QHash _hash_menu_text; + + // Toolbars. QStatusBar *status_bar; @@ -291,14 +312,12 @@ list.append (static_cast (workspace_window)); return list; } + octave_dock_widget *_active_dock; QString _release_notes_icon; QToolBar *_main_tool_bar; - QDockWidget *_warning_bar; - QPushButton *_gui_info_button; - QMenu *_debug_menu; QAction *_debug_continue; @@ -310,14 +329,47 @@ QAction *_new_script_action; QAction *_new_function_action; QAction *_open_action; + QAction *_new_figure_action; + QAction *_load_workspace_action; + QAction *_save_workspace_action; + QAction *_preferences_action; + QAction *_exit_action; QAction *_copy_action; QAction *_paste_action; QAction *_clear_clipboard_action; QAction *_undo_action; - + QAction *_clear_command_window_action; + QAction *_clear_command_history_action; + QAction *_clear_workspace_action; QAction *_find_files_action; - QAction *_exit_action; + QAction *_select_all_action; + + QAction *_show_command_window_action; + QAction *_show_history_action; + QAction *_show_workspace_action; + QAction *_show_file_browser_action; + QAction *_show_editor_action; + QAction *_show_documentation_action; + QAction *_command_window_action; + QAction *_history_action; + QAction *_workspace_action; + QAction *_file_browser_action; + QAction *_editor_action; + QAction *_documentation_action; + QAction *_reset_windows_action; + + QAction *_ondisk_doc_action; + QAction *_online_doc_action; + QAction *_report_bug_action; + QAction *_octave_packages_action; + QAction *_agora_action; + QAction *_contribute_action; + QAction *_developer_action; + QAction *_about_octave_action; + + QAction *_release_notes_action; + QAction *_current_news_action; // Toolbars. QComboBox *_current_directory_combo_box; @@ -350,6 +402,9 @@ QStringList *_dbg_queue; QSemaphore _dbg_processing; QMutex _dbg_queue_mutex; + + bool _prevent_readline_conflicts; + bool _suppress_dbg_location; }; class news_reader : public QObject diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/module.mk --- a/libgui/src/module.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/module.mk Fri Jan 23 15:23:09 2015 -0500 @@ -67,6 +67,9 @@ src/icons/widget-close.png \ src/icons/widget-dock.png \ src/icons/widget-undock.png \ + src/icons/widget-close-light.png \ + src/icons/widget-dock-light.png \ + src/icons/widget-undock-light.png \ src/icons/zoom-in.png \ src/icons/zoom-out.png @@ -78,7 +81,8 @@ src/m-editor/moc-file-editor-tab.cc \ src/m-editor/moc-file-editor.cc \ src/m-editor/moc-find-dialog.cc \ - src/m-editor/moc-octave-qscintilla.cc + src/m-editor/moc-octave-qscintilla.cc \ + src/m-editor/moc-octave-txt-lexer.cc endif octave_gui_MOC += \ @@ -93,6 +97,7 @@ src/moc-terminal-dock-widget.cc \ src/moc-color-picker.cc \ src/moc-resource-manager.cc \ + src/moc-shortcut-manager.cc \ src/moc-welcome-wizard.cc \ src/moc-workspace-model.cc \ src/moc-workspace-view.cc \ @@ -122,6 +127,7 @@ src/m-editor/file-editor.h \ src/m-editor/find-dialog.h \ src/m-editor/octave-qscintilla.h \ + src/m-editor/octave-txt-lexer.h \ src/main-window.h \ src/octave-gui.h \ src/octave-interpreter.h \ @@ -130,6 +136,7 @@ src/qtinfo/webinfo.h \ src/resource-manager.h \ src/settings-dialog.h \ + src/shortcut-manager.h \ src/thread-manager.h \ src/terminal-dock-widget.h \ src/color-picker.h \ @@ -148,6 +155,7 @@ src/m-editor/file-editor.cc \ src/m-editor/find-dialog.cc \ src/m-editor/octave-qscintilla.cc \ + src/m-editor/octave-txt-lexer.cc \ src/main-window.cc \ src/octave-dock-widget.cc \ src/octave-gui.cc \ @@ -157,6 +165,7 @@ src/qtinfo/webinfo.cc \ src/resource-manager.cc \ src/settings-dialog.cc \ + src/shortcut-manager.cc \ src/thread-manager.cc \ src/terminal-dock-widget.cc \ src/color-picker.cc \ @@ -170,12 +179,15 @@ src_libgui_src_la_CPPFLAGS = \ $(AM_CPPFLAGS) \ + $(FT2_CFLAGS) \ + $(FONTCONFIG_CPPFLAGS) \ @OCTGUI_DLL_DEFS@ \ @QT_CPPFLAGS@ \ -I$(srcdir)/qterminal/libqterminal \ -Isrc -I$(srcdir)/src \ -I$(srcdir)/src/m-editor \ -I$(srcdir)/src/qtinfo \ + -I$(srcdir)/graphics \ -I$(top_srcdir)/liboctave/cruft/misc \ -I$(top_srcdir)/liboctave/array \ -I$(top_builddir)/liboctave/numeric -I$(top_srcdir)/liboctave/numeric \ diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-dock-widget.cc --- a/libgui/src/octave-dock-widget.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-dock-widget.cc Fri Jan 23 15:23:09 2015 -0500 @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -48,7 +47,10 @@ this, SLOT (handle_visibility_changed (bool))); connect (p, SIGNAL (settings_changed (const QSettings*)), - this, SLOT (notice_settings (const QSettings*))); + this, SLOT (handle_settings (const QSettings*))); + + connect (p, SIGNAL (active_dock_changed (octave_dock_widget*, octave_dock_widget*)), + this, SLOT (handle_active_dock_changed (octave_dock_widget*, octave_dock_widget*))); #if defined (Q_OS_WIN32) // windows: add an extra title bar that persists when floating @@ -61,31 +63,33 @@ _dock_action-> setToolTip (tr ("Undock widget")); connect (_dock_action, SIGNAL (triggered (bool)), this, SLOT (change_floating (bool))); - QToolButton *dock_button = new QToolButton (this); - dock_button->setDefaultAction (_dock_action); - dock_button->setFocusPolicy (Qt::NoFocus); - dock_button->setIconSize (QSize (12,12)); + _dock_button = new QToolButton (this); + _dock_button->setDefaultAction (_dock_action); + _dock_button->setFocusPolicy (Qt::NoFocus); + _dock_button->setIconSize (QSize (12,12)); - QAction *close_action = new QAction + _close_action = new QAction (QIcon (":/actions/icons/widget-close.png"), "", this ); - close_action-> setToolTip (tr ("Hide widget")); - connect (close_action, SIGNAL (triggered (bool)), + _close_action-> setToolTip (tr ("Hide widget")); + connect (_close_action, SIGNAL (triggered (bool)), this, SLOT (change_visibility (bool))); - QToolButton *close_button = new QToolButton (this); - close_button->setDefaultAction (close_action); - close_button->setFocusPolicy (Qt::NoFocus); - close_button->setIconSize (QSize (12,12)); + _close_button = new QToolButton (this); + _close_button->setDefaultAction (_close_action); + _close_button->setFocusPolicy (Qt::NoFocus); + _close_button->setIconSize (QSize (12,12)); + + _icon_color = ""; QHBoxLayout *h_layout = new QHBoxLayout (); h_layout->addStretch (100); - h_layout->addWidget (dock_button); - h_layout->addWidget (close_button); + h_layout->addWidget (_dock_button); + h_layout->addWidget (_close_button); h_layout->setSpacing (0); - h_layout->setContentsMargins (6,0,0,0); + h_layout->setContentsMargins (5,2,2,2); - QWidget *title_widget = new QWidget (); - title_widget->setLayout (h_layout); - setTitleBarWidget (title_widget); + _title_widget = new QWidget (); + _title_widget->setLayout (h_layout); + setTitleBarWidget (_title_widget); #else @@ -104,6 +108,11 @@ this, SLOT (copyClipboard ())); connect (p, SIGNAL (pasteClipboard_signal ()), this, SLOT (pasteClipboard ())); + connect (p, SIGNAL (selectAll_signal ()), + this, SLOT (selectAll ())); + + installEventFilter (this); + } octave_dock_widget::~octave_dock_widget () @@ -147,6 +156,7 @@ QHBoxLayout* h_layout = static_cast (titleBarWidget ()->layout ()); QLabel *label = new QLabel (title); + label->setStyleSheet ("background: transparent;"); h_layout->insertWidget (0,label); #endif setWindowTitle (title); @@ -171,7 +181,7 @@ // remove parent and adjust the (un)dock icon setParent (0, Qt::Window); - _dock_action->setIcon (QIcon (":/actions/icons/widget-dock.png")); + _dock_action->setIcon (QIcon (":/actions/icons/widget-dock"+_icon_color+".png")); _dock_action->setToolTip (tr ("Dock widget")); // restore the last geometry( when floating @@ -183,6 +193,10 @@ // non windows: Just set the appripriate window flag setWindowFlags (Qt::Window); + QString css = styleSheet (); + css.replace ("widget-undock","widget-dock"); + setStyleSheet (css); + #endif _floating = true; @@ -220,14 +234,21 @@ setParent (_parent); // adjust the (un)dock icon - _dock_action->setIcon (QIcon (":/actions/icons/widget-undock.png")); + _dock_action->setIcon (QIcon (":/actions/icons/widget-undock"+_icon_color+".png")); _dock_action->setToolTip (tr ("Undock widget")); #else // non windows: just say we are a docked widget again + + Q_UNUSED (dock); + setWindowFlags (Qt::Widget); + QString css = styleSheet (); + css.replace ("widget-dock","widget-undock"); + setStyleSheet (css); + #endif _floating = false; @@ -262,3 +283,151 @@ if (w && w->focusProxy ()) w = w->focusProxy (); return w; } + +void +octave_dock_widget::set_style (bool active) +{ + QString css; + QString css_button; + QString dock_icon; + + QString icon_col = _icon_color; + + if (_floating) + dock_icon = "widget-dock"; + else + dock_icon = "widget-undock"; + + if (_custom_style) + { + + QColor bg_col, fg_col; + + if (active) + { + bg_col = _bg_color_active; + fg_col = _fg_color_active; + icon_col = _icon_color_active; + } + else + { + bg_col = _bg_color; + fg_col = _fg_color; + icon_col = _icon_color; + } + + QString background = + QString ("background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1," + " stop: 0 %1, stop: 0.75 %2, stop: 0.9 %2, stop: 1.0 %1);"). + arg (bg_col.lighter ().name ()). + arg (bg_col.name ()); + +#if defined (Q_OS_WIN32) + css = background + QString (" color: %1 ;").arg (fg_col.name ()); +#else + css = QString ("QDockWidget::title { " + background + + " text-align: center left;" + " padding: 0px 0px 0px 4px;}\n" + "QDockWidget { color: %1 ; " + " titlebar-close-icon: url(:/actions/icons/widget-close%2.png);" + " titlebar-normal-icon: url(:/actions/icons/"+dock_icon+"%2); }" + "QDockWidget::close-button," + "QDockWidget::float-button { border: 0px;}" + ). + arg (fg_col.name ()). + arg (icon_col); +#endif + } + else + { +#if defined (Q_OS_WIN32) + css = QString (""); +#else + css = QString ("QDockWidget::title { text-align: center left;" + " padding: 0px 0px 0px 4px;}" + "QDockWidget {" + " titlebar-close-icon: url(:/actions/icons/widget-close.png);" + " titlebar-normal-icon: url(:/actions/icons/"+dock_icon+"); }" + "QDockWidget::close-button," + "QDockWidget::float-button { border: 0px; }" + ); +#endif + } + +#if defined (Q_OS_WIN32) + _title_widget->setStyleSheet (css); + css_button = QString ("background: transparent; border: 0px;"); + _dock_button->setStyleSheet (css_button); + _close_button->setStyleSheet (css_button); + _dock_action->setIcon (QIcon (":/actions/icons/" + dock_icon + icon_col + ".png")); + _close_action->setIcon (QIcon (":/actions/icons/widget-close" + dock_icon + icon_col + ".png")); +#else + setStyleSheet (css); +#endif +} + +void +octave_dock_widget::handle_settings (const QSettings *settings) +{ + _custom_style = + settings->value ("DockWidgets/widget_title_custom_style",false).toBool (); + + QColor default_var = QColor (0,0,0); + _fg_color = settings->value ("Dockwidgets/title_fg_color", + default_var).value (); + default_var = QColor (0,0,0); + _fg_color_active = settings->value ("Dockwidgets/title_fg_color_active", + default_var).value (); + + default_var = QColor (255,255,255); + _bg_color = settings->value ("Dockwidgets/title_bg_color", + default_var).value (); + default_var = QColor (192,192,192); + _bg_color_active = settings->value ("Dockwidgets/title_bg_color_active", + default_var).value (); + + int r, g, b; + _bg_color.getRgb (&r, &g, &b); + if (r+g+b < 400) + _icon_color = "-light"; + else + _icon_color = ""; + + _bg_color_active.getRgb (&r, &g, &b); + if (r+g+b < 400) + _icon_color_active = "-light"; + else + _icon_color_active = ""; + + notice_settings (settings); // call individual handler + + set_style (false); +} + +bool octave_dock_widget::eventFilter(QObject *obj, QEvent *e) +{ + if (e->type () == QEvent::NonClientAreaMouseButtonDblClick) + { + e->ignore (); // ignore double clicks into window decoration elements + return true; + } + + return QDockWidget::eventFilter (obj,e); +} + +void +octave_dock_widget::handle_active_dock_changed (octave_dock_widget *w_old, + octave_dock_widget *w_new) +{ + if (_custom_style && this == w_old) + { + set_style (false); + update (); + } + + if (_custom_style && this == w_new) + { + set_style (true); + update (); + } +} diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-dock-widget.h --- a/libgui/src/octave-dock-widget.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-dock-widget.h Fri Jan 23 15:23:09 2015 -0500 @@ -27,6 +27,7 @@ #include #include #include +#include #include class octave_dock_widget : public QDockWidget @@ -81,6 +82,9 @@ virtual void notice_settings (const QSettings*) { } + void handle_settings (const QSettings*); + + void handle_active_dock_changed (octave_dock_widget*, octave_dock_widget*); QMainWindow *main_win () { return _parent; } @@ -99,6 +103,12 @@ virtual void pasteClipboard () { } + virtual void selectAll () + { + } + + // event filter for double clicks into the window decoration elements + bool eventFilter(QObject *obj, QEvent *e); private slots: @@ -107,9 +117,25 @@ private: + void set_style (bool active); + QMainWindow *_parent; // store the parent since we are reparenting to 0 + bool _floating; + bool _custom_style; + QColor _bg_color; + QColor _bg_color_active; + QColor _fg_color; + QColor _fg_color_active; + QString _icon_color; + QString _icon_color_active; + +#if defined (Q_OS_WIN32) + QWidget *_title_widget; + QToolButton *_dock_button; + QToolButton *_close_button; QAction *_dock_action; - bool _floating; + QAction *_close_action; +#endif }; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-gui.cc --- a/libgui/src/octave-gui.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-gui.cc Fri Jan 23 15:23:09 2015 -0500 @@ -48,6 +48,7 @@ #include "welcome-wizard.h" #include "resource-manager.h" +#include "shortcut-manager.h" #include "main-window.h" #include "octave-gui.h" #include "thread-manager.h" @@ -88,7 +89,7 @@ // Disable all Qt messages by default. static void -message_handler (QtMsgType type, const char *msg) +message_handler (QtMsgType, const char *) { } @@ -158,19 +159,24 @@ octave_env::putenv ("TERM", "cygwin"); #endif + // shortcut manager + shortcut_manager::init_data (); + // Create and show main window. main_window w; w.read_settings (); - w.focus_command_window (); + w.init_terminal_size (); // Connect signals for changes in visibility not before w // is shown. w.connect_visibility_changed (); + w.focus_command_window (); + return application.exec (); } else diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-interpreter.cc --- a/libgui/src/octave-interpreter.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-interpreter.cc Fri Jan 23 15:23:09 2015 -0500 @@ -43,6 +43,8 @@ octave_initialize_interpreter (octave_cmdline_argc, octave_cmdline_argv, octave_embedded); + emit octave_ready_signal (); + octave_execute_interpreter (); } diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-interpreter.h --- a/libgui/src/octave-interpreter.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-interpreter.h Fri Jan 23 15:23:09 2015 -0500 @@ -38,6 +38,10 @@ octave_interpreter (void) : QObject (), thread_manager () { } +signals: + + void octave_ready_signal (); + public slots: // Initialize and execute the octave interpreter. diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-qt-link.cc --- a/libgui/src/octave-qt-link.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-qt-link.cc Fri Jan 23 15:23:09 2015 -0500 @@ -43,13 +43,16 @@ #include "resource-manager.h" -octave_qt_link::octave_qt_link (void) +octave_qt_link::octave_qt_link (QWidget *p) : octave_link (), main_thread (new QThread ()), command_interpreter (new octave_interpreter ()) { connect (this, SIGNAL (execute_interpreter_signal (void)), command_interpreter, SLOT (execute (void))); + connect (command_interpreter, SIGNAL (octave_ready_signal ()), + p, SLOT (handle_octave_ready ())); + command_interpreter->moveToThread (main_thread); main_thread->start (); @@ -90,21 +93,21 @@ QFileInfo file_info (QString::fromStdString (file)); QStringList btn; QStringList role; - role << "AcceptRole" << "AcceptRole"; - btn << tr ("Yes") << tr ("No"); + role << "YesRole" << "RejectRole"; + btn << tr ("Create") << tr ("Cancel"); uiwidget_creator.signal_dialog ( tr ("File\n%1\ndoes not exist. Do you want to create it?"). arg (QDir::currentPath () + QDir::separator () + QString::fromStdString (file)), - tr ("Octave Editor"), "quest", btn, tr ("Yes"), role ); + tr ("Octave Editor"), "quest", btn, tr ("Create"), role ); // Wait while the user is responding to message box. uiwidget_creator.wait (); // The GUI has sent a signal and the process has been awakened. QString answer = uiwidget_creator.get_dialog_button (); - return (answer == tr ("Yes")); + return (answer == tr ("Create")); } int @@ -308,8 +311,8 @@ QString msg = (addpath_option - ? tr ("The file %1 does not exist in the load path. To debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir) - : tr ("The file %1 is shadowed by a file with the same name in the load path. To debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir)); + ? tr ("The file %1 does not exist in the load path. To run or debug the function you are editing, you must either change to the directory %2 or add that directory to the load path.").arg (qfile).arg (qdir) + : tr ("The file %1 is shadowed by a file with the same name in the load path. To run or debug the function you are editing, change to the directory %2.").arg (qfile).arg (qdir)); QString title = tr ("Change Directory or Add Directory to Load Path"); diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/octave-qt-link.h --- a/libgui/src/octave-qt-link.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/octave-qt-link.h Fri Jan 23 15:23:09 2015 -0500 @@ -53,7 +53,7 @@ public: - octave_qt_link (void); + octave_qt_link (QWidget *p); ~octave_qt_link (void); diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/qtinfo/parser.cc --- a/libgui/src/qtinfo/parser.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/qtinfo/parser.cc Fri Jan 23 15:23:09 2015 -0500 @@ -47,7 +47,7 @@ _compressors_map.insert ("Z", "gunzip -c \"%1\""); } -void +bool parser::set_info_path (const QString& infoPath) { this->_info_path = infoPath; @@ -56,15 +56,32 @@ QFileInfo info (infoPath); - QString path = info.absolutePath (); - QString fileName = info.fileName (); + bool info_file_exists = info.exists (); + QHash::iterator it; + for (it = _compressors_map.begin (); it != _compressors_map.end (); it++) + { + if (info_file_exists) + break; + info_file_exists = QFileInfo (info.absoluteFilePath () + "." + it.key ()).exists (); + } - QDir infoDir (path); - QStringList filter; - filter.append (fileName + "*"); + if (info_file_exists) + { + QString path = info.absolutePath (); + QString fileName = info.fileName (); + + QDir infoDir (path); + QStringList filter; + filter.append (fileName + "*"); - _info_files = infoDir.entryInfoList (filter, QDir::Files); - parse_info_map (); + _info_files = infoDir.entryInfoList (filter, QDir::Files); + + parse_info_map (); + + return true; + } + else + return false; } QString @@ -115,6 +132,10 @@ return ref.pos-_node_map [ref._node_name].pos; } + if (_node_map.contains (node)) + { + return 0; // node: show from the beginning + } return -1; } @@ -653,8 +674,25 @@ { // found ref, so return its name text = "XREF" + ref_name; + break; } } + + if (text.isEmpty ()) // try the statement-nodes + { + QHash::iterator itn; + for (itn=_node_map.begin (); itn!=_node_map.end (); ++itn) + { + QString k = itn.key (); + if (k == "The " + ref_name + " Statement") + { + // found ref, so return its name + text = k; + break; + } + } + } + return text; } diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/qtinfo/parser.h --- a/libgui/src/qtinfo/parser.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/qtinfo/parser.h Fri Jan 23 15:23:09 2015 -0500 @@ -53,7 +53,7 @@ public: parser (QObject *parent = 0); - void set_info_path (const QString& _info_path); + bool set_info_path (const QString& _info_path); QString get_info_path (); QString search_node (const QString& node); QString global_search (const QString& text, int maxFounds); diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/qtinfo/webinfo.cc --- a/libgui/src/qtinfo/webinfo.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/qtinfo/webinfo.cc Fri Jan 23 15:23:09 2015 -0500 @@ -57,7 +57,9 @@ _tab_bar->setSizePolicy (QSizePolicy::Preferred,QSizePolicy::Preferred); _tab_bar->setExpanding (false); _tab_bar->setTabsClosable (true); +#ifdef HAVE_QTABWIDGET_SETMOVABLE _tab_bar->setMovable (true); +#endif hbox_layout->addWidget (_tab_bar); _zoom_in_button = new QToolButton (this); @@ -94,15 +96,30 @@ resize (500, 300); - set_info_path (QString::fromStdString (Vinfo_file)); + if (! set_info_path (QString::fromStdString (Vinfo_file))) + { // Info file does not exist + _search_check_box->setEnabled (false); + _search_line_edit->setEnabled (false); + QTextBrowser *msg = addNewTab (tr ("Error")); + QString msg_text = QString ( + "

%1
"). + arg (tr ("The info file

%1

or compressed versions do not exist"). + arg(QString::fromStdString (Vinfo_file))); + msg->setHtml (msg_text); + } } -void +bool webinfo::set_info_path (const QString& info_path) { - _parser.set_info_path (info_path); - load_node ("Top"); + if (_parser.set_info_path (info_path)) + { + load_node ("Top"); + return true; + } + else + return false; } void @@ -267,6 +284,20 @@ } void +webinfo::selectAll () +{ + if (_search_line_edit->hasFocus ()) + { + _search_line_edit->selectAll (); + } + if (_text_browser->hasFocus ()) + { + _text_browser->selectAll (); + } +} + + +void webinfo::pasteClipboard () { if (_search_line_edit->hasFocus ()) diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/qtinfo/webinfo.h --- a/libgui/src/qtinfo/webinfo.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/qtinfo/webinfo.h Fri Jan 23 15:23:09 2015 -0500 @@ -38,7 +38,7 @@ Q_OBJECT public: webinfo (QWidget *parent = 0); - void set_info_path (const QString& info_path); + bool set_info_path (const QString& info_path); void load_node (const QString& node_name); void load_ref (const QString &ref_name); @@ -53,6 +53,7 @@ void copyClipboard (); void pasteClipboard (); + void selectAll (); private: QTextBrowser *_text_browser; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/resource.qrc --- a/libgui/src/resource.qrc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/resource.qrc Fri Jan 23 15:23:09 2015 -0500 @@ -63,5 +63,8 @@ icons/widget-close.png icons/widget-dock.png icons/widget-undock.png + icons/widget-close-light.png + icons/widget-dock-light.png + icons/widget-undock-light.png diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/settings-dialog.cc --- a/libgui/src/settings-dialog.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/settings-dialog.cc Fri Jan 23 15:23:09 2015 -0500 @@ -25,15 +25,19 @@ #endif #include "resource-manager.h" +#include "shortcut-manager.h" #include "workspace-model.h" #include "settings-dialog.h" #include "ui-settings-dialog.h" #include #include +#include #include #include #ifdef HAVE_QSCINTILLA +#include "octave-qscintilla.h" +#include "octave-txt-lexer.h" #include #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H) @@ -57,7 +61,9 @@ ui->setupUi (this); QSettings *settings = resource_manager::get_settings (); - // FIXME: what should happen if settings is 0? + + // restore last geometry + restoreGeometry (settings->value("settings/geometry").toByteArray ()); // look for available language files and the actual settings QString qm_dir_name = resource_manager::get_gui_translation_dir (); @@ -90,6 +96,63 @@ ui->general_icon_graphic-> setChecked (widget_icon_set == "GRAPHIC"); ui->general_icon_letter-> setChecked (widget_icon_set == "LETTER"); + // custom title bar of dock widget + QVariant default_var = QColor (255,255,255); + QColor bg_color = settings->value ("Dockwidgets/title_bg_color", + default_var).value (); + _widget_title_bg_color = new color_picker (bg_color); + _widget_title_bg_color->setEnabled (false); + ui->layout_widget_bgtitle->addWidget (_widget_title_bg_color,0); + connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), + _widget_title_bg_color, SLOT (setEnabled (bool))); + + default_var = QColor (192,192,192); + QColor bg_color_active = settings->value ("Dockwidgets/title_bg_color_active", + default_var).value (); + _widget_title_bg_color_active = new color_picker (bg_color_active); + _widget_title_bg_color_active->setEnabled (false); + ui->layout_widget_bgtitle_active->addWidget (_widget_title_bg_color_active,0); + connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), + _widget_title_bg_color_active, SLOT (setEnabled (bool))); + + default_var = QColor (0,0,0); + QColor fg_color = settings->value ("Dockwidgets/title_fg_color", + default_var).value (); + _widget_title_fg_color = new color_picker (fg_color); + _widget_title_fg_color->setEnabled (false); + ui->layout_widget_fgtitle->addWidget (_widget_title_fg_color,0); + connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), + _widget_title_fg_color, SLOT (setEnabled (bool))); + + default_var = QColor (0,0,0); + QColor fg_color_active = settings->value ("Dockwidgets/title_fg_color_active", + default_var).value (); + _widget_title_fg_color_active = new color_picker (fg_color_active); + _widget_title_fg_color_active->setEnabled (false); + ui->layout_widget_fgtitle_active->addWidget (_widget_title_fg_color_active,0); + connect (ui->cb_widget_custom_style, SIGNAL (toggled (bool)), + _widget_title_fg_color_active, SLOT (setEnabled (bool))); + + ui->cb_widget_custom_style->setChecked ( + settings->value ("DockWidgets/widget_title_custom_style",false).toBool ()); + + // prompt on exit + ui->cb_prompt_to_exit->setChecked ( + settings->value ("prompt_to_exit",false).toBool ()); + + // Main status bar + ui->cb_status_bar->setChecked ( + settings->value ("show_status_bar",true).toBool ()); + + // Octave startup + ui->cb_restore_octave_dir->setChecked ( + settings->value ("restore_octave_dir",false).toBool ()); + ui->le_octave_dir->setText ( + settings->value ("octave_startup_dir").toString ()); + connect (ui->pb_octave_dir, SIGNAL (pressed ()), + this, SLOT (get_octave_dir ())); + + // editor ui->useCustomFileEditor->setChecked (settings->value ("useCustomFileEditor", false).toBool ()); ui->customFileEditor->setText ( @@ -97,7 +160,7 @@ ui->editor_showLineNumbers->setChecked ( settings->value ("editor/showLineNumbers",true).toBool () ); - QVariant default_var = QColor (240, 240, 240); + default_var = QColor (240, 240, 240); QColor setting_color = settings->value ("editor/highlight_current_line_color", default_var).value (); _editor_current_line_color = new color_picker (setting_color); @@ -108,6 +171,14 @@ _editor_current_line_color, SLOT (setEnabled (bool))); ui->editor_highlightCurrentLine->setChecked ( settings->value ("editor/highlightCurrentLine",true).toBool () ); + ui->editor_long_line_marker->setChecked ( + settings->value ("editor/long_line_marker",true).toBool ()); + ui->editor_long_line_column->setValue ( + settings->value ("editor/long_line_column",80).toInt ()); + ui->cb_edit_status_bar->setChecked ( + settings->value ("editor/show_edit_status_bar",true).toBool ()); + ui->cb_code_folding->setChecked ( + settings->value ("editor/code_folding",true).toBool ()); ui->editor_codeCompletion->setChecked ( settings->value ("editor/codeCompletion", true).toBool () ); @@ -115,6 +186,14 @@ settings->value ("editor/codeCompletion_threshold",2).toInt ()); ui->editor_checkbox_ac_keywords->setChecked ( settings->value ("editor/codeCompletion_keywords",true).toBool ()); + ui->editor_checkbox_ac_builtins->setEnabled ( + ui->editor_checkbox_ac_keywords->isChecked ()); + ui->editor_checkbox_ac_functions->setEnabled ( + ui->editor_checkbox_ac_keywords->isChecked ()); + ui->editor_checkbox_ac_builtins->setChecked ( + settings->value ("editor/codeCompletion_octave_builtins",true).toBool ()); + ui->editor_checkbox_ac_functions->setChecked ( + settings->value ("editor/codeCompletion_octave_functions",true).toBool ()); ui->editor_checkbox_ac_document->setChecked ( settings->value ("editor/codeCompletion_document",false).toBool ()); ui->editor_checkbox_ac_case->setChecked ( @@ -125,6 +204,24 @@ settings->value ("editor/show_white_space", false).toBool ()); ui->editor_ws_indent_checkbox->setChecked ( settings->value ("editor/show_white_space_indent",false).toBool ()); + ui->cb_show_eol->setChecked ( + settings->value ("editor/show_eol_chars",false).toBool () ); + ui->cb_show_hscrollbar->setChecked ( + settings->value ("editor/show_hscroll_bar",true).toBool ()); + +#ifdef HAVE_QSCINTILLA +#if defined (Q_OS_WIN32) + int eol_mode = QsciScintilla::EolWindows; +#elif defined (Q_OS_MAC) + int eol_mode = QsciScintilla::EolMac; +#else + int eol_mode = QsciScintilla::EolUnix; +#endif +#else + int eol_mode = 2; +#endif + ui->combo_eol_mode->setCurrentIndex ( + settings->value ("editor/default_eol_mode",eol_mode).toInt () ); ui->editor_auto_ind_checkbox->setChecked ( settings->value ("editor/auto_indent", true).toBool ()); ui->editor_tab_ind_checkbox->setChecked ( @@ -135,39 +232,38 @@ settings->value ("editor/show_indent_guides",false).toBool ()); ui->editor_ind_width_spinbox->setValue ( settings->value ("editor/indent_width", 2).toInt ()); + ui->editor_ind_uses_tabs_checkbox->setChecked ( + settings->value ("editor/indent_uses_tabs", false).toBool ()); ui->editor_tab_width_spinbox->setValue ( settings->value ("editor/tab_width", 2).toInt ()); ui->editor_longWindowTitle->setChecked ( settings->value ("editor/longWindowTitle",false).toBool ()); + ui->editor_notebook_tab_width_min->setValue ( + settings->value ("editor/notebook_tab_width_min", 160).toInt ()); + ui->editor_notebook_tab_width_max->setValue ( + settings->value ("editor/notebook_tab_width_max", 300).toInt ()); ui->editor_restoreSession->setChecked ( settings->value ("editor/restoreSession", true).toBool ()); ui->editor_create_new_file->setChecked ( settings->value ("editor/create_new_file",false).toBool ()); + ui->editor_reload_changed_files->setChecked ( + settings->value ("editor/always_reload_changed_files",false).toBool ()); + + // terminal ui->terminal_fontName->setCurrentFont (QFont ( settings->value ("terminal/fontName","Courier New").toString ()) ); ui->terminal_fontSize->setValue ( settings->value ("terminal/fontSize", 10).toInt ()); - ui->showFileSize->setChecked ( - settings->value ("filesdockwidget/showFileSize", false).toBool ()); - ui->showFileType->setChecked ( - settings->value ("filesdockwidget/showFileType", false).toBool ()); - ui->showLastModified->setChecked ( - settings->value ("filesdockwidget/showLastModified",false).toBool ()); - ui->showHiddenFiles->setChecked ( - settings->value ("filesdockwidget/showHiddenFiles",false).toBool ()); - ui->useAlternatingRowColors->setChecked ( - settings->value ("filesdockwidget/useAlternatingRowColors",true).toBool ()); - ui->sync_octave_directory->setChecked ( - settings->value ("filesdockwidget/sync_octave_directory",true).toBool ()); - ui->checkbox_allow_web_connect->setChecked ( - settings->value ("news/allow_web_connection",false).toBool ()); - ui->useProxyServer->setChecked ( - settings->value ("useProxyServer", false).toBool ()); - ui->proxyHostName->setText (settings->value ("proxyHostName").toString ()); + ui->terminal_history_buffer->setValue ( + settings->value ("terminal/history_buffer",1000).toInt ()); ui->terminal_cursorBlinking->setChecked ( settings->value ("terminal/cursorBlinking",true).toBool ()); ui->terminal_cursorUseForegroundColor->setChecked ( settings->value ("terminal/cursorUseForegroundColor",true).toBool ()); + ui->terminal_focus_command->setChecked ( + settings->value ("terminal/focus_after_command",false).toBool ()); + ui->terminal_print_dbg_location->setChecked ( + settings->value ("terminal/print_debug_location",false).toBool ()); QString cursorType = settings->value ("terminal/cursorType", "ibeam").toString (); @@ -186,6 +282,34 @@ else if (cursorType == "underline") ui->terminal_cursorType->setCurrentIndex (2); + // file browser + ui->showFileSize->setChecked ( + settings->value ("filesdockwidget/showFileSize", false).toBool ()); + ui->showFileType->setChecked ( + settings->value ("filesdockwidget/showFileType", false).toBool ()); + ui->showLastModified->setChecked ( + settings->value ("filesdockwidget/showLastModified",false).toBool ()); + ui->showHiddenFiles->setChecked ( + settings->value ("filesdockwidget/showHiddenFiles",false).toBool ()); + ui->useAlternatingRowColors->setChecked ( + settings->value ("filesdockwidget/useAlternatingRowColors",true).toBool ()); + connect (ui->sync_octave_directory, SIGNAL (toggled (bool)), + this, SLOT (set_disabled_pref_file_browser_dir (bool))); + ui->sync_octave_directory->setChecked ( + settings->value ("filesdockwidget/sync_octave_directory",true).toBool ()); + ui->cb_restore_file_browser_dir->setChecked ( + settings->value ("filesdockwidget/restore_last_dir",false).toBool ()); + ui->le_file_browser_dir->setText ( + settings->value ("filesdockwidget/startup_dir").toString ()); + connect (ui->pb_file_browser_dir, SIGNAL (pressed ()), + this, SLOT (get_file_browser_dir ())); + + ui->checkbox_allow_web_connect->setChecked ( + settings->value ("news/allow_web_connection",false).toBool ()); + ui->useProxyServer->setChecked ( + settings->value ("useProxyServer", false).toBool ()); + ui->proxyHostName->setText (settings->value ("proxyHostName").toString ()); + int currentIndex = 0; QString proxyTypeString = settings->value ("proxyType").toString (); while ( (currentIndex < ui->proxyType->count ()) @@ -199,12 +323,38 @@ 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); + // shortcuts + + ui->cb_prevent_readline_conflicts->setChecked ( + settings->value ("shortcuts/prevent_readline_conflicts", true).toBool ()); + int set = settings->value ("shortcuts/set",0).toInt (); + ui->rb_sc_set1->setChecked (set == 0); + ui->rb_sc_set2->setChecked (set == 1); + + // initialize the tree view with all shortcut data + shortcut_manager::fill_treewidget (ui->shortcuts_treewidget); + + // connect the buttons for import/export of the shortcut sets + connect (ui->btn_import_shortcut_set1, SIGNAL (clicked ()), + this, SLOT (import_shortcut_set1 ())); + connect (ui->btn_export_shortcut_set1, SIGNAL (clicked ()), + this, SLOT (export_shortcut_set1 ())); + connect (ui->btn_import_shortcut_set2, SIGNAL (clicked ()), + this, SLOT (import_shortcut_set2 ())); + connect (ui->btn_export_shortcut_set2, SIGNAL (clicked ()), + this, SLOT (export_shortcut_set2 ())); + + #ifdef HAVE_QSCINTILLA // editor styles: create lexer, read settings, and create dialog elements QsciLexer *lexer; @@ -232,6 +382,9 @@ lexer = new QsciLexerBash (); read_lexer_settings (lexer,settings); delete lexer; + lexer = new octave_txt_lexer (); + read_lexer_settings (lexer,settings); + delete lexer; #endif // which tab is the desired one? @@ -465,8 +618,33 @@ language = "SYSTEM"; settings->setValue ("language", language); - // other settings + // dock widget title bar + settings->setValue ("DockWidgets/widget_title_custom_style", + ui->cb_widget_custom_style->isChecked ()); + settings->setValue ("Dockwidgets/title_bg_color", + _widget_title_bg_color->color ()); + settings->setValue ("Dockwidgets/title_bg_color_active", + _widget_title_bg_color_active->color ()); + settings->setValue ("Dockwidgets/title_fg_color", + _widget_title_fg_color->color ()); + settings->setValue ("Dockwidgets/title_fg_color_active", + _widget_title_fg_color_active->color ()); + + // icon size settings->setValue ("toolbar_icon_size", ui->toolbar_icon_size->value ()); + + // promp to exit + settings->setValue ( "prompt_to_exit", ui->cb_prompt_to_exit->isChecked ()); + + // status bar + settings->setValue ( "show_status_bar", ui->cb_status_bar->isChecked ()); + + // Octave startup + settings->setValue ("restore_octave_dir", + ui->cb_restore_octave_dir->isChecked ()); + settings->setValue ("octave_startup_dir", ui->le_octave_dir->text ()); + + //editor settings->setValue ("useCustomFileEditor", ui->useCustomFileEditor->isChecked ()); settings->setValue ("customFileEditor", ui->customFileEditor->text ()); @@ -476,12 +654,24 @@ ui->editor_highlightCurrentLine->isChecked ()); settings->setValue ("editor/highlight_current_line_color", _editor_current_line_color->color ()); + settings->setValue ("editor/long_line_marker", + ui->editor_long_line_marker->isChecked ()); + settings->setValue ("editor/long_line_column", + ui->editor_long_line_column->value ()); + settings->setValue ("editor/code_folding", + ui->cb_code_folding->isChecked ()); + settings->setValue ("editor/show_edit_status_bar", + ui->cb_edit_status_bar->isChecked ()); settings->setValue ("editor/codeCompletion", ui->editor_codeCompletion->isChecked ()); settings->setValue ("editor/codeCompletion_threshold", ui->editor_spinbox_ac_threshold->value ()); settings->setValue ("editor/codeCompletion_keywords", ui->editor_checkbox_ac_keywords->isChecked ()); + settings->setValue ("editor/codeCompletion_octave_builtins", + ui->editor_checkbox_ac_builtins->isChecked ()); + settings->setValue ("editor/codeCompletion_octave_functions", + ui->editor_checkbox_ac_functions->isChecked ()); settings->setValue ("editor/codeCompletion_document", ui->editor_checkbox_ac_document->isChecked ()); settings->setValue ("editor/codeCompletion_case", @@ -492,6 +682,12 @@ ui->editor_ws_checkbox->isChecked ()); settings->setValue ("editor/show_white_space_indent", ui->editor_ws_indent_checkbox->isChecked ()); + settings->setValue ("editor/show_eol_chars", + ui->cb_show_eol->isChecked ()); + settings->setValue ("editor/show_hscroll_bar", + ui->cb_show_hscrollbar->isChecked ()); + settings->setValue ("editor/default_eol_mode", + ui->combo_eol_mode->currentIndex ()); settings->setValue ("editor/auto_indent", ui->editor_auto_ind_checkbox->isChecked ()); settings->setValue ("editor/tab_indents_line", @@ -502,17 +698,26 @@ ui->editor_ind_guides_checkbox->isChecked ()); settings->setValue ("editor/indent_width", ui->editor_ind_width_spinbox->value ()); + settings->setValue ("editor/indent_uses_tabs", + ui->editor_ind_uses_tabs_checkbox->isChecked ()); settings->setValue ("editor/tab_width", ui->editor_tab_width_spinbox->value ()); settings->setValue ("editor/longWindowTitle", ui->editor_longWindowTitle->isChecked ()); + settings->setValue ("editor/notebook_tab_width_min", + ui->editor_notebook_tab_width_min->value ()); + settings->setValue ("editor/notebook_tab_width_max", + ui->editor_notebook_tab_width_max->value ()); settings->setValue ("editor/restoreSession", ui->editor_restoreSession->isChecked ()); settings->setValue ("editor/create_new_file", ui->editor_create_new_file->isChecked ()); + settings->setValue ("editor/always_reload_changed_files", + ui->editor_reload_changed_files->isChecked ()); settings->setValue ("terminal/fontSize", ui->terminal_fontSize->value ()); settings->setValue ("terminal/fontName", ui->terminal_fontName->currentFont ().family ()); + settings->setValue ("filesdockwidget/showFileSize", ui->showFileSize->isChecked ()); settings->setValue ("filesdockwidget/showFileType", @@ -525,6 +730,12 @@ ui->useAlternatingRowColors->isChecked ()); settings->setValue ("filesdockwidget/sync_octave_directory", ui->sync_octave_directory->isChecked ()); + settings->setValue ("filesdockwidget/restore_last_dir", + ui->cb_restore_file_browser_dir->isChecked ()); + settings->setValue ("filesdockwidget/startup_dir", + ui->le_file_browser_dir->text ()); + + settings->setValue ("news/allow_web_connection", ui->checkbox_allow_web_connect->isChecked ()); settings->setValue ("useProxyServer", ui->useProxyServer->isChecked ()); @@ -537,6 +748,12 @@ ui->terminal_cursorBlinking->isChecked ()); settings->setValue ("terminal/cursorUseForegroundColor", ui->terminal_cursorUseForegroundColor->isChecked ()); + settings->setValue ("terminal/focus_after_command", + ui->terminal_focus_command->isChecked ()); + settings->setValue ("terminal/print_debug_location", + ui->terminal_print_dbg_location->isChecked ()); + settings->setValue ("terminal/history_buffer", + ui->terminal_history_buffer->value() ); // the cursor QString cursorType; @@ -547,7 +764,6 @@ case 2: cursorType = "underline"; break; } settings->setValue ("terminal/cursorType", cursorType); - settings->sync (); #ifdef HAVE_QSCINTILLA // editor styles: create lexer, get dialog contents, and write settings @@ -576,13 +792,34 @@ lexer = new QsciLexerBash (); write_lexer_settings (lexer,settings); delete lexer; + lexer = new octave_txt_lexer (); + write_lexer_settings (lexer,settings); + 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 + settings->setValue ("shortcuts/prevent_readline_conflicts", + ui->cb_prevent_readline_conflicts->isChecked ()); + int set = 0; + if (ui->rb_sc_set2->isChecked ()) + set = 1; + settings->setValue ("shortcuts/set",set); + shortcut_manager::write_shortcuts (0, settings); // 0: write both sets + + // settings dialog's geometry settings->setValue ("settings/last_tab",ui->tabWidget->currentIndex ()); + settings->setValue ("settings/geometry",saveGeometry ()); + + settings->sync (); } #ifdef HAVE_QSCINTILLA @@ -666,6 +903,7 @@ settings->setValue ( "settings/last_editor_styles_tab",ui->tabs_editor_lexers->currentIndex ()); + settings->sync (); } #endif @@ -703,3 +941,69 @@ } settings->sync (); } + + +// internal slots + +void +settings_dialog::get_dir (QLineEdit *line_edit, const QString& title) +{ + QString dir = QFileDialog::getExistingDirectory(this, + title, line_edit->text (), + QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks); + line_edit->setText (dir); +} + +void +settings_dialog::get_octave_dir () +{ + get_dir (ui->le_octave_dir, tr ("Set Octave Startup Directory")); +} + +void +settings_dialog::get_file_browser_dir () +{ + get_dir (ui->le_file_browser_dir, tr ("Set File Browser Startup Directory")); +} + +void +settings_dialog::set_disabled_pref_file_browser_dir (bool disable) +{ + ui->cb_restore_file_browser_dir->setDisabled (disable); + + if (! disable) + { + ui->le_file_browser_dir->setDisabled (ui->cb_restore_file_browser_dir->isChecked ()); + ui->pb_file_browser_dir->setDisabled (ui->cb_restore_file_browser_dir->isChecked ()); + } + else + { + ui->le_file_browser_dir->setDisabled (disable); + ui->pb_file_browser_dir->setDisabled (disable); + } +} + +// slots for import/export of shortcut sets +void +settings_dialog::import_shortcut_set1 () +{ + shortcut_manager::import_export (true,1); +} + +void +settings_dialog::export_shortcut_set1 () +{ + shortcut_manager::import_export (false,1); +} + +void +settings_dialog::import_shortcut_set2 () +{ + shortcut_manager::import_export (true,2); +} + +void +settings_dialog::export_shortcut_set2 () +{ + shortcut_manager::import_export (false,2); +} diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/settings-dialog.h --- a/libgui/src/settings-dialog.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/settings-dialog.h Fri Jan 23 15:23:09 2015 -0500 @@ -25,6 +25,7 @@ #include #include +#include #include "color-picker.h" @@ -45,6 +46,18 @@ ~settings_dialog (); void write_changed_settings (); +private slots: + void get_octave_dir (); + void get_file_browser_dir (); + void get_dir (QLineEdit*, const QString&); + void set_disabled_pref_file_browser_dir (bool disable); + + // slots for import/export-buttons of shortcut sets + void import_shortcut_set1 (); + void export_shortcut_set1 (); + void import_shortcut_set2 (); + void export_shortcut_set2 (); + private: Ui::settings_dialog * ui; #ifdef HAVE_QSCINTILLA @@ -61,6 +74,10 @@ void read_terminal_colors (QSettings *settings); void write_terminal_colors (QSettings *settings); + color_picker *_widget_title_bg_color; + color_picker *_widget_title_bg_color_active; + color_picker *_widget_title_fg_color; + color_picker *_widget_title_fg_color_active; color_picker *_editor_current_line_color; }; diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/settings-dialog.ui --- a/libgui/src/settings-dialog.ui Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/settings-dialog.ui Fri Jan 23 15:23:09 2015 -0500 @@ -9,20 +9,14 @@ 0 0 - 700 + 720 480 - 700 - 480 - - - - - 700 - 480 + 400 + 400 @@ -31,8 +25,14 @@ + + + 0 + 0 + + - 6 + 3 @@ -41,154 +41,402 @@ General - - - - 9 - 10 - 651 - 371 - - - - - - - - - Icon set for dock widgets - - - - - - - Language (requires restart) - - - - - - - Icon size - - - - - - - - - 16 - - - 32 - - - 4 - - - 24 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - QComboBox::InsertAtBottom - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Octave logo only - - - true - - - - - - - Letter icons - - - - - - - Graphic icons - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Vertical + + + + + true + + + + + 0 + 0 + 678 + 378 + - - - 20 - 40 - - - - - - + + + + + Interface + + + + + + + + Dock widget title bar + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + + + QComboBox::InsertAtBottom + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Icon size + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Confirm before exiting + + + + + + + + + 16 + + + 32 + + + 4 + + + 24 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Language (requires restart) + + + + + + + + + Octave logo only + + + true + + + + + + + Letter icons + + + + + + + Graphic icons + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Icon set for dock widgets + + + + + + + Show status bar + + + true + + + + + + + + + + + false + + + Text inactive + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + false + + + Active + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + Custom style + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 12 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 40 + 20 + + + + + + + + false + + + Active + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + false + + + Background inactive + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Octave Startup + + + + + + These preferences are applied after the startup files like .octaverc. + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Startup path + + + + + + + + 0 + 0 + + + + Browse + + + + + + + Restore last Octave directory of previous session + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + @@ -196,961 +444,1672 @@ - - - 4 + + + true - - - - 6 - - - - - Show whitespace - - - - - - - true - - - Show line numbers - - - - - - - Show complete path in window title - - - - - - - false - - - Do not show whitespace used for indentation - - - - - - - true - - - Highlight current line - - - - - - - 12 - - - 0 - - - - - false + + + + 0 + 0 + 662 + 661 + + + + + + + + + 6 - - Color + + + + + + After Column + + + + + + + 2 + + + 256 + + + 80 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Show whitespace + + + + + + + true + + + Show line numbers + + + + + + + + 0 + 0 + + + + Show complete path in window title + + + + + + + false + + + Do not show whitespace used for indentation + + + + + + + true + + + Highlight current line + + + + + + + 12 + + + 0 + + + + + false + + + Color + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 80 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Tab width min. + + + + + + + 80 + + + 600 + + + 20 + + + 160 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + 180 + + + 600 + + + 20 + + + 300 + + + + + + + max. + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + + + + + This works well for monospaced fonts. The line is drawn at a position based on the width of a space character in the default font. It may not work very well if styles use proportional fonts or if varied font sizes or bold, italic and normal texts are used. + + + Draw a long line marker + + + true + + + + + + + Enable Code Folding + + + true + + + + + + + Show status bar + + + true + + + + + + + Show eol characters + + + + + + + + + Default eol mode + + + + + + + QComboBox::AdjustToContents + + + 7 + + + + Windows (CRLF) + + + + + Mac (CR) + + + + + Unix (LF) + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + true + + + Show horizontal scroll bar + + + true + + + + + + + + + Qt::Horizontal - - + + + + 0 + + + + + Indent width + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + + + + + Tab indents line + + + + + + + Auto indentation + + + + + + + 1 + + + 32 + + + 2 + + + + + + + Tab width + + + + + + + Show indentation guides + + + + + + + 1 + + + 32 + + + + + + + Backspace unindents line + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + + + + + Indentation uses tabs + + + + + + + Qt::Horizontal - - QSizePolicy::Fixed - - - - 80 - 20 - - - + - - + + + + + + 6 + + + 4 + + + + + Auto completion + + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + + + + + true + + + Match keywords + + + true + + + + + + + true + + + Case sensitive + + + true + + + + + + + true + + + Match words in document + + + + + + + true + + + Replace word by suggested one + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + false + + + With Octave builtins + + + + + + + false + + + With Octave functions + + + + + + + + + + + + + false + + + Number of characters before list is shwon: + + + + + + + false + + + + + + + + + + + + 1 + + + 6 + + + 2 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + true + + + Show completion list automatically + + + false + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 0 + + + + + + + + + + Qt::Horizontal - - - 40 - 20 - + + + + + + 0 + + + 0 - + + + + + 0 + 0 + + + + Restore editor tabs from previous session on startup + + + + + + + + 0 + 0 + + + + Create nonexistent files without prompting + + + + + + + Reload externally changed files without prompt + + + + + + + + + Qt::Horizontal + + + + + + + + + true + + + Use custom file editor + + + + + + + false + + + command line (%f=file, %l=line): + + + + + + + false + + + emacs +%l %f + + + + - - + + - Qt::Horizontal + Qt::Vertical - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 + 20 + 40 - + + + + + + + + + 0 + 0 + + + + Editor Styles + + + + - - - Qt::Horizontal + + + + 0 + 0 + + + + QFrame::NoFrame + + + <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> + + + false + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + true + + + 4 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 0 - - - - - - - - Indent width - - - - - - - Tab indents line - - - - - - - Auto indentation - - - - - - - 1 - - - 32 - - - 2 - - - - - - - Tab width - - - - - - - Show indentation guides - - - - - - - 1 - - - 32 - - - - - - - Backspace unindents line - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal + + + + 0 + 0 + - - - - 0 - - - - - true - - - Code completion - - - false - - - - - - - 6 - + + + + + + + Terminal + + + + + + true + + + + + 0 + 0 + 678 + 378 + + + + + - - - false - - - # of characters typed before completion list displayed - - - - - - - false - - - - - - - - - - - - 1 - - - 6 - - - 2 - - - - - - - Qt::Horizontal - + 40 20 - + + + + + + Use foreground color + + + + + + + Cursor blinking + + + + + + + + + + + Cursor type: + + + + + + + + + + + + + + Font + + + + + + + false + + + QFontComboBox::MonospacedFonts + + + + + + + + + + + Font size + + + + + + + 2 + + + 96 + + + 10 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + 0 + + + + + 0 + + + 5000 + + + 20 + + + 1000 + + + + + + + (Changing buffer size clears history) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 100 + 20 + + + + History buffer Size + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + - - - - - - 0 - - - + + + + + + Set focus to terminal when running a command from within another widget + + + + + + + Print debug location in terminal window in addition to the marker in the editor + + + + + + + Qt::Horizontal - - QSizePolicy::Fixed - - - - 10 - 0 - - - - - - - - false - - - Match keywords - - - true - - - - - - - false - - - Case sensitive - - - true - - - - - false + + + + + 0 + 81 + - - Replace word by suggested one + + Terminal Colors - - + + + + + 0 + 0 + + Qt::Horizontal - - - 40 - 20 - - - - - - - - false - - - Match words in document - - - + + Qt::Horizontal - - - 40 - 20 - - - + - - + + - Qt::Horizontal + Qt::Vertical - QSizePolicy::Fixed + QSizePolicy::Expanding - 10 - 0 + 20 + 40 - - - - - Qt::Horizontal - - - - - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Restore editor tabs from previous session on startup - - - - - - - - 0 - 0 - - - - Create nonexistent files without prompting - - - - - - - - - - - Qt::Horizontal - + - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - 0 - - - 0 - - - - - - - true - - - Use custom file editor - - - - - - - false - - - command line (%f=file, %l=line): - - - - - - - false - - - emacs - - - - - - - - - - Editor Styles - - - - - 0 - 0 - 651 - 401 - - - - - - - - 676 - 16777215 - - - - QFrame::NoFrame - - - <html><head/><body><p>Select font, font size (as a difference from the default size), font style (<b>b</b>old, <b>i</b>talic, <b>u</b>nderline), text color and background color (for the latter, the color pink (255,0,255) is a placeholder for the default background color).</p></body></html> - - - false - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - true - - - 4 - - - - - - - - 676 - 351 - - - - - - - - - - Terminal - - - - - 10 - 50 - 631 - 31 - - - - - - - Cursor type: - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Cursor blinking - - - - - - - Use foreground color - - - - - - - - - 10 - 90 - 631 - 291 - - - - - - - Qt::Horizontal - - - - - - - - 0 - 81 - - - - Terminal Colors - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - 10 - 10 - 631 - 31 - - - - - - - Font - - - - - - - false - - - QFontComboBox::MonospacedFonts - - - - - - - Font size - - - - - - - 2 - - - 96 - - - 10 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - File Browser - - - Show file size - - - - - - - Show file type + + + true - - - - - - Show date of last modification - - - - - - - Show hidden files - + + + + 0 + 0 + 678 + 378 + + + + + + + Display + + + + + + 0 + + + + + Show file type + + + + + + + Show hidden files + + + + + + + Show file size + + + + + + + Show date of last modification + + + + + + + Alternating row colors + + + + + + + + + + + + Behavior + + + + + + + + Synchronize Octave working directory with file browser + + + + + + + + + Startup path + + + + + + + + + + Restore last directory of previous session + + + + + + + Browse + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 360 + + + + + + - - - - Synchronize Octave working directory with file browser - - - - - - - Alternating row colors - - - - - - - Qt::Vertical - - - - 20 - 360 - - - - Workspace - - - - 10 - 8 - 631 - 381 - - - - - - - true + + + + + true + + + + + 0 + 0 + 678 + 378 + - - - 0 - 0 - - - - - 0 - 81 - - - - Storage Class Colors + + + + + 0 + + + + + true + + + + 0 + 0 + + + + + 0 + 81 + + + + Colors for variable attributes + + + + + + + Hide tool tip + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Shortcuts + + + + + + true + + + + + 0 + 0 + 678 + 378 + - - - - - - - 0 - 1 - - - - Qt::Horizontal - + + + + + QLayout::SetDefaultConstraint + + + 0 + + + + + + + Select this option to prevent conflicts with readline shortcuts + + + Disable global shortcuts when terminal window has focus + + + true + + + + + + + + + Qt::Horizontal + + + + + + + 10 + + + + + 0 + + + + + + + Use this set + + + + + + + Set 1: + + + + + + + Export + + + + + + + Import + + + + + + + Use this set + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Export + + + + + + + Import + + + + + + + Set 2: + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 20 + 20 + + + + + + + + + + Edit an actual shortcut by double clicking into the related cell + + + + + + + 0 + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 0 + 0 + + + + true + + + false + + + false + + + false + + + 5 + + + false + + + 120 + + + false + + + 64 + + + true + + + + Action + + + + false + + + + + + Set 1 Default + + + + + Set 1 Actual + + + + + Set 2 Default + + + + false + + + + + + Set 2 Actual + + + + + + + + + - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - + + + @@ -1158,137 +2117,156 @@ - - - - - Allow Octave to connect to the Octave web site to display current news and information - - - - - - - - - false - - - Hostname: - - - - - - - false - + + + true + + + + + 0 + 0 + 678 + 378 + + + + + - - HttpProxy - + + + Allow Octave to connect to the Octave web site to display current news and information + + - - Socks5Proxy - + + + + + false + + + Hostname: + + + + + + + false + + + + HttpProxy + + + + + Socks5Proxy + + + + + + + + false + + + Username: + + + + + + + Use proxy server + + + + + + + false + + + Proxy type: + + + + + + + false + + + Port: + + + + + + + false + + + Password: + + + + + + + false + + + + + + + false + + + + + + + false + + + + + + + false + + + QLineEdit::Password + + + + - - - - - - false - - - Username: - - + - - - - Use proxy server - - - - - - - false - - - Proxy type: - - - - - - - false - - - Port: + + + + Qt::Vertical - - - - - - false - - - Password: - - - - - - - false + + + 20 + 40 + - - - - - - false - - - - - - - false - - - - - - - false - - - QLineEdit::Password - - + - - - - - - - Qt::Vertical - - - - 20 - 40 - - - + + @@ -1562,54 +2540,6 @@ - editor_codeCompletion - toggled(bool) - editor_checkbox_ac_keywords - setEnabled(bool) - - - 83 - 170 - - - 238 - 201 - - - - - editor_codeCompletion - toggled(bool) - editor_checkbox_ac_document - setEnabled(bool) - - - 83 - 170 - - - 390 - 201 - - - - - editor_codeCompletion - toggled(bool) - editor_checkbox_ac_replace - setEnabled(bool) - - - 83 - 170 - - - 427 - 229 - - - - editor_highlightCurrentLine toggled(bool) editor_label_cl_color @@ -1626,22 +2556,6 @@ - editor_codeCompletion - toggled(bool) - editor_checkbox_ac_case - setEnabled(bool) - - - 83 - 172 - - - 525 - 203 - - - - editor_ws_checkbox toggled(bool) editor_ws_indent_checkbox @@ -1657,5 +2571,261 @@ + + cb_widget_custom_style + toggled(bool) + label_bgtitle + setEnabled(bool) + + + 228 + 156 + + + 380 + 156 + + + + + cb_widget_custom_style + toggled(bool) + label_fgtitle + setEnabled(bool) + + + 228 + 156 + + + 496 + 156 + + + + + cb_restore_octave_dir + toggled(bool) + le_octave_dir + setDisabled(bool) + + + 270 + 255 + + + 270 + 285 + + + + + cb_restore_octave_dir + toggled(bool) + pb_octave_dir + setDisabled(bool) + + + 270 + 255 + + + 467 + 285 + + + + + cb_restore_file_browser_dir + toggled(bool) + le_file_browser_dir + setDisabled(bool) + + + 250 + 294 + + + 250 + 324 + + + + + cb_restore_file_browser_dir + toggled(bool) + pb_file_browser_dir + setDisabled(bool) + + + 250 + 294 + + + 426 + 324 + + + + + editor_longWindowTitle + toggled(bool) + editor_lbl_min_tab_width + setEnabled(bool) + + + 145 + 72 + + + 343 + 72 + + + + + editor_longWindowTitle + toggled(bool) + editor_notebook_tab_width_max + setEnabled(bool) + + + 145 + 72 + + + 437 + 72 + + + + + editor_longWindowTitle + toggled(bool) + editor_lbl_max_tab_width + setEnabled(bool) + + + 145 + 72 + + + 439 + 72 + + + + + editor_longWindowTitle + toggled(bool) + editor_notebook_tab_width_min + setEnabled(bool) + + + 145 + 72 + + + 393 + 72 + + + + + editor_long_line_marker + toggled(bool) + editor_long_line_column + setEnabled(bool) + + + 145 + 187 + + + 355 + 187 + + + + + editor_long_line_marker + toggled(bool) + editor_long_line_column_text + setEnabled(bool) + + + 145 + 187 + + + 302 + 187 + + + + + editor_checkbox_ac_keywords + toggled(bool) + editor_checkbox_ac_builtins + setEnabled(bool) + + + 118 + 231 + + + 296 + 231 + + + + + editor_checkbox_ac_keywords + toggled(bool) + editor_checkbox_ac_functions + setEnabled(bool) + + + 118 + 231 + + + 446 + 231 + + + + + cb_widget_custom_style + toggled(bool) + label_bgtitle_active + setEnabled(bool) + + + 260 + 190 + + + 525 + 190 + + + + + cb_widget_custom_style + toggled(bool) + label_fgtitle_active + setEnabled(bool) + + + 260 + 190 + + + 533 + 214 + + + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/shortcut-manager.cc --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/src/shortcut-manager.cc Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,724 @@ +/* + +Copyright (C) 2014 Torsten + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "error.h" +#include "resource-manager.h" +#include "shortcut-manager.h" +#include "singleton-cleanup.h" + +shortcut_manager *shortcut_manager::instance = 0; + +shortcut_manager::shortcut_manager () +{ + setObjectName ("Shortcut_Manager"); + + // Mac: don't let Qt interpret CMD key ("Meta" in Qt terminology) as Ctrl +#if defined (Q_OS_MAC) + QCoreApplication::setAttribute (Qt::AA_MacDontSwapCtrlAndMeta, true); +#endif + + _settings = resource_manager::get_settings (); +} + +shortcut_manager::~shortcut_manager () +{ +} + +bool +shortcut_manager::instance_ok (void) +{ + bool retval = true; + + if (! instance) + { + instance = new shortcut_manager (); + + if (instance) + singleton_cleanup_list::add (cleanup_instance); + } + + if (! instance) + { + ::error ("unable to create shortcut_manager object!"); + + retval = false; + } + + return retval; +} + +void +shortcut_manager::do_init_data () +{ + QKeySequence ctrl; + int prefix; +#if defined (Q_OS_MAC) + // Use CMD key as an equivalent of Ctrl key on other platforms + ctrl = Qt::MetaModifier; + // Some of octave default shortcuts on windows/linux are already defined + // as system wide shortcuts on Mac Os X (almost all Function keys). + // Prefix those with Option (Alt) modifier to avoid conflicts. + prefix = Qt::AltModifier; +#else + ctrl = Qt::ControlModifier; + prefix = Qt::NoModifier; +#endif + + QKeySequence ctrl_shift = ctrl + Qt::ShiftModifier; + QKeySequence ctrl_alt = ctrl + Qt::AltModifier; + + // actions of the main window + + // file + init (tr ("New File"), "main_file:new_file", QKeySequence::New); + init (tr ("New Function"), "main_file:new_function", + QKeySequence (ctrl_shift + Qt::Key_N)); + init (tr ("New Figure"), "main_file:new_figure", QKeySequence ()); + init (tr ("Open File"), "main_file:open_file", QKeySequence::Open); + init (tr ("Load Workspace"), "main_file:load_workspace", QKeySequence ()); + init (tr ("Save Workspace As"), "main_file:save_workspace", QKeySequence ()); + init (tr ("Preferences"), "main_file:preferences", QKeySequence ()); + init (tr ("Exit Octave"), "main_file:exit", QKeySequence::Quit); + + // edit + init (tr ("Copy"), "main_edit:copy", QKeySequence::Copy); + init (tr ("Paste"), "main_edit:paste", QKeySequence::Paste); + init (tr ("Undo"), "main_edit:undo", QKeySequence::Undo); + init (tr ("Select All"), "main_edit:select_all", QKeySequence ()); + init (tr ("Clear Clipboard"), "main_edit:clear_clipboard", QKeySequence ()); + init (tr ("Find in Files"), "main_edit:find_in_files", + QKeySequence (ctrl_shift + Qt::Key_F)); + init (tr ("Clear Command Window"), "main_edit:clear_command_window", + QKeySequence ()); + init (tr ("Clear Command History"), "main_edit:clear_history", + QKeySequence ()); + init (tr ("Clear Workspace"), "main_edit:clear_workspace", QKeySequence ()); + + // debug + init (tr ("Step Over"), "main_debug:step_over", + QKeySequence (prefix + Qt::Key_F10)); + init (tr ("Step Into"), "main_debug:step_into", + QKeySequence (prefix + Qt::Key_F11)); + init (tr ("Step Out"), "main_debug:step_out", + QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F11)); + init (tr ("Continue"), "main_debug:continue", + QKeySequence (prefix + Qt::Key_F5)); + init (tr ("Quit Debug Mode"), "main_debug:quit", + QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_F5)); + + // window + init (tr ("Show Command Window"), "main_window:show_command", + prefix + ctrl_shift + Qt::Key_0); + init (tr ("Show Command History"), "main_window:show_history", + prefix + ctrl_shift + Qt::Key_1); + init (tr ("Show File Browser"), "main_window:show_file_browser", + prefix + ctrl_shift + Qt::Key_2); + init (tr ("Show Workspace"), "main_window:show_workspace", + prefix + ctrl_shift + Qt::Key_3); + init (tr ("Show Editor"), "main_window:show_editor", + prefix + ctrl_shift + Qt::Key_4); + init (tr ("Show Documentation"), "main_window:show_doc", + prefix + ctrl_shift + Qt::Key_5); + init (tr ("Command Window"), "main_window:command", + prefix + ctrl + Qt::Key_0); + init (tr ("Command History"), "main_window:history", + prefix + ctrl + Qt::Key_1); + init (tr ("File Browser"), "main_window:file_browser", + prefix + ctrl + Qt::Key_2); + init (tr ("Workspace"), "main_window:workspace", + prefix + ctrl + Qt::Key_3); + init (tr ("Editor"), "main_window:editor", + prefix + ctrl + Qt::Key_4); + init (tr ("Documentation"), "main_window:doc", + prefix + ctrl + Qt::Key_5); + init (tr ("Reset Window Layout"), "main_window:reset", QKeySequence ()); + + // help + init (tr ("Show Ondisk Documentation"), "main_help:ondisk_doc", QKeySequence ()); + init (tr ("Show Online Documentation"), "main_help:online_doc", QKeySequence ()); + init (tr ("Report a Bug"), "main_help:report_bug", QKeySequence ()); + init (tr ("Octave Packages"), "main_help:packages", QKeySequence ()); + init (tr ("Share Code"), "main_help:agora", QKeySequence ()); + init (tr ("Contribute to Octave"), "main_help:contribute", QKeySequence ()); + init (tr ("Octave Developer Resources"), "main_help:developer", QKeySequence ()); + init (tr ("About Octave"), "main_help:about", QKeySequence ()); + + // news + init (tr ("Release Notes"), "main_news:release_notes", QKeySequence ()); + init (tr ("Community News"), "main_news:community_news", QKeySequence ()); + + // actions of the editor + + // file + init (tr ("Edit Function"), "editor_file:edit_function", + QKeySequence (ctrl + Qt::Key_E)); + init (tr ("Save File"), "editor_file:save", QKeySequence::Save); + init (tr ("Save File As"), "editor_file:save_as", QKeySequence::SaveAs); + init (tr ("Close"), "editor_file:close", QKeySequence::Close); + init (tr ("Close All"), "editor_file:close_all", QKeySequence ()); + init (tr ("Close Other"), "editor_file:close_other", QKeySequence ()); + init (tr ("Print"), "editor_file:print", QKeySequence::Print); + + // edit + init (tr ("Undo"), "editor_edit:undo", QKeySequence::Undo); + init (tr ("Redo"), "editor_edit:redo", QKeySequence::Redo); + init (tr ("Copy"), "editor_edit:copy", QKeySequence::Copy); + init (tr ("Cut"), "editor_edit:cut", QKeySequence::Cut); + init (tr ("Paste"), "editor_edit:paste", QKeySequence::Paste); + init (tr ("Select All"), "editor_edit:select_all", QKeySequence::SelectAll); + init (tr ("Find and Replace"), "editor_edit:find_replace", + QKeySequence::Find); + init (tr ("Delete to Start of Word"), "editor_edit:delete_start_word", + QKeySequence::DeleteStartOfWord); + init (tr ("Delete to End of Word"), "editor_edit:delete_end_word", + QKeySequence::DeleteEndOfWord); + init (tr ("Delete to Start of Line"), "editor_edit:delete_start_line", + QKeySequence (ctrl_shift + Qt::Key_Backspace)); + init (tr ("Delete to End of Line"), "editor_edit:delete_end_line", + QKeySequence (ctrl_shift + Qt::Key_Delete)); + init (tr ("Delete Line"), "editor_edit:delete_line", + QKeySequence (ctrl_shift + Qt::Key_L)); + init (tr ("Copy Line"), "editor_edit:copy_line", + QKeySequence (ctrl_shift + Qt::Key_C)); + init (tr ("Cut Line"), "editor_edit:cut_line", + QKeySequence (ctrl_shift + Qt::Key_X)); + init (tr ("Duplicate Selection/Line"), "editor_edit:duplicate_selection", + QKeySequence (ctrl + Qt::Key_D)); + init (tr ("Transpose Line"), "editor_edit:transpose_line", + QKeySequence (ctrl + Qt::Key_T)); + init (tr ("Completion List"), "editor_edit:completion_list", + QKeySequence (ctrl + Qt::Key_Space)); + + init (tr ("Comment Selection"), "editor_edit:comment_selection", + QKeySequence (ctrl + Qt::Key_R)); + init (tr ("Uncomment Selection"), "editor_edit:uncomment_selection", + QKeySequence (ctrl_shift + Qt::Key_R)); + init (tr ("Uppercase Selection"), "editor_edit:upper_case", + QKeySequence (ctrl + Qt::Key_U)); + init (tr ("Lowercase Selection"), "editor_edit:lower_case", + QKeySequence (ctrl_alt + Qt::Key_U)); + +#if defined (Q_OS_MAC) + init (tr ("Indent Selection"), "editor_edit:indent_selection", + QKeySequence (prefix + Qt::Key_Tab)); + init (tr ("Unindent Selection"), "editor_edit:unindent_selection", + QKeySequence (prefix + Qt::ShiftModifier + Qt::Key_Tab)); +#else + init (tr ("Indent Selection"), "editor_edit:indent_selection", + QKeySequence (ctrl + Qt::Key_Tab)); + init (tr ("Unindent Selection"), "editor_edit:unindent_selection", + QKeySequence (ctrl_shift + Qt::Key_Tab)); +#endif + + init (tr ("Convert Line Ednings to Windows"), "editor_edit:conv_eol_winows", + QKeySequence ()); + init (tr ("Convert Line Ednings to Unix"), "editor_edit:conv_eol_unix", + QKeySequence ()); + init (tr ("Convert Line Ednings to Mac"), "editor_edit:conv_eol_mac", + QKeySequence ()); + + init (tr ("Goto Line"), "editor_edit:goto_line", + QKeySequence (ctrl + Qt::Key_G)); + init (tr ("Toggle Bookmark"), "editor_edit:toggle_bookmark", + QKeySequence (prefix + Qt::Key_F7)); + init (tr ("Next Bookmark"), "editor_edit:next_bookmark", + QKeySequence (prefix + Qt::Key_F2)); + init (tr ("Previous Bookmark"), "editor_edit:previous_bookmark", + QKeySequence (prefix + Qt::SHIFT + Qt::Key_F2)); + init (tr ("Remove All Bookmark"), "editor_edit:remove_bookmark", + QKeySequence ()); + + init (tr ("Preferences"), "editor_edit:preferences", QKeySequence ()); + init (tr ("Styles Preferences"), "editor_edit:styles_preferences", + QKeySequence ()); + + // view + init (tr ("Show Line Numbers"), "editor_view:show_line_numbers", QKeySequence ()); + init (tr ("Show White Spaces"), "editor_view:show_white_spaces", QKeySequence ()); + init (tr ("Show Line Endings"), "editor_view:show_eol_chars", QKeySequence ()); + init (tr ("Show Indentation Guides"), "editor_view:show_ind_guides", QKeySequence ()); + init (tr ("Show Long Line Marker"), "editor_view:show_long_line", QKeySequence ()); + init (tr ("Zoom In"), "editor_view:zoom_in", QKeySequence::ZoomIn); + init (tr ("Zoom Out"), "editor_view:zoom_out", QKeySequence::ZoomOut); +#if defined (Q_OS_MAC) + init (tr ("Zoom Normal"), "editor_view:zoom_normal", + QKeySequence (ctrl + Qt::Key_Underscore)); +#else + init (tr ("Zoom Normal"), "editor_view:zoom_normal", + QKeySequence (ctrl_alt + Qt::Key_0)); +#endif + + // debug + init (tr ("Toggle Breakpoint"), "editor_debug:toggle_breakpoint", + QKeySequence ()); + init (tr ("Next Breakpoint"), "editor_debug:next_breakpoint", + QKeySequence ()); + init (tr ("Previous Breakpoint"), "editor_debug:previous_breakpoint", + QKeySequence ()); + init (tr ("Remove All Breakpoints"), "editor_debug:remove_breakpoints", + QKeySequence ()); + + // run + init (tr ("Run File"), "editor_run:run_file", + QKeySequence (prefix + Qt::Key_F5) ); + init (tr ("Run Selection"), "editor_run:run_selection", + QKeySequence (prefix + Qt::Key_F9) ); + + // help + init (tr ("Help on Keyword"), "editor_help:help_keyword", QKeySequence::HelpContents); + init (tr ("Document on Keyword"), "editor_help:doc_keyword", QKeySequence (Qt::SHIFT + Qt::Key_F1)); +} + +void +shortcut_manager::init (QString description, QString key, QKeySequence def_sc) +{ + QKeySequence actual_0 = QKeySequence (_settings->value ("shortcuts/"+key, def_sc).toString ()); + QKeySequence actual_1 = QKeySequence (_settings->value ("shortcuts/"+key+"_1", def_sc).toString ()); + + // append the new shortcut to the list + shortcut_t shortcut_info; + shortcut_info.description = description; + shortcut_info.settings_key = key; + shortcut_info.actual_sc [0] = actual_0; + shortcut_info.actual_sc [1] = actual_1; + shortcut_info.default_sc [0] = def_sc; + shortcut_info.default_sc [1] = def_sc; // TODO: Different defaults + _sc << shortcut_info; + + // insert shortcut prepended by widget in order check for duplicates later + QString widget = key.section ('_',0,0); // get widget that uses the shortcut + if (! actual_0.isEmpty ()) + _shortcut_hash[widget + ":" + actual_0.toString ()] = _sc.count (); // offset of 1 to avoid 0 + if (! actual_1.isEmpty ()) + _shortcut_hash[widget + "_1:" + actual_1.toString ()] = _sc.count (); // offset of 1 to avoid 0 + _action_hash[key] = _sc.count (); // offset of 1 to avoid 0 +} + +void +shortcut_manager::do_fill_treewidget (QTreeWidget *tree_view) +{ + _dialog = 0; + _level_hash.clear (); + + tree_view->header ()->setResizeMode (QHeaderView::ResizeToContents); + + QTreeWidgetItem *main = new QTreeWidgetItem (tree_view); + main->setText (0, tr ("Main")); + main->setExpanded (true); + QTreeWidgetItem *main_file = new QTreeWidgetItem (main); + main_file->setText (0, tr ("File")); + QTreeWidgetItem *main_edit = new QTreeWidgetItem (main); + main_edit->setText (0, tr ("Edit")); + QTreeWidgetItem *main_debug = new QTreeWidgetItem (main); + main_debug->setText (0, tr ("Debug")); + QTreeWidgetItem *main_window = new QTreeWidgetItem (main); + main_window->setText (0, tr ("Window")); + QTreeWidgetItem *main_help = new QTreeWidgetItem (main); + main_help->setText (0, tr ("Help")); + QTreeWidgetItem *main_news = new QTreeWidgetItem (main); + main_news->setText (0, tr ("News")); + + _level_hash["main_file"] = main_file; + _level_hash["main_edit"] = main_edit; + _level_hash["main_debug"] = main_debug; + _level_hash["main_window"] = main_window; + _level_hash["main_help"] = main_help; + _level_hash["main_news"] = main_news; + + QTreeWidgetItem *editor = new QTreeWidgetItem (tree_view); + editor->setText (0, tr ("Editor")); + editor->setExpanded (true); + QTreeWidgetItem *editor_file = new QTreeWidgetItem (editor); + editor_file->setText (0, tr ("File")); + QTreeWidgetItem *editor_edit = new QTreeWidgetItem (editor); + editor_edit->setText (0, tr ("Edit")); + QTreeWidgetItem *editor_view = new QTreeWidgetItem (editor); + editor_view->setText (0, tr ("View")); + QTreeWidgetItem *editor_debug = new QTreeWidgetItem (editor); + editor_debug->setText (0, tr ("Debug")); + QTreeWidgetItem *editor_run = new QTreeWidgetItem (editor); + editor_run->setText (0, tr ("Run")); + QTreeWidgetItem *editor_help = new QTreeWidgetItem (editor); + editor_help->setText (0, tr ("Help")); + + _level_hash["editor_file"] = editor_file; + _level_hash["editor_edit"] = editor_edit; + _level_hash["editor_view"] = editor_view; + _level_hash["editor_debug"] = editor_debug; + _level_hash["editor_run"] = editor_run; + _level_hash["editor_help"] = editor_help; + + connect (tree_view, SIGNAL (itemDoubleClicked (QTreeWidgetItem*, int)), + this, SLOT (handle_double_clicked (QTreeWidgetItem*, int))); + + for (int i = 0; i < _sc.count (); i++) + { + shortcut_t sc = _sc.at (i); + + QTreeWidgetItem* section = _level_hash[sc.settings_key.section(':',0,0)]; + QTreeWidgetItem* tree_item = new QTreeWidgetItem (section); + + // set a slightly transparent foreground for default columns + QColor fg = QColor (tree_item->foreground (1).color ()); + fg.setAlpha (128); + tree_item->setForeground (1, QBrush (fg)); + tree_item->setForeground (3, QBrush (fg)); + + // write the shortcuts + tree_item->setText (0, sc.description); + tree_item->setText (1, sc.default_sc [0]); + tree_item->setText (2, sc.actual_sc [0]); + tree_item->setText (3, sc.default_sc [1]); + tree_item->setText (4, sc.actual_sc [1]); + + _item_index_hash[tree_item] = i + 1; // index+1 to avoid 0 + _index_item_hash[i] = tree_item; + } + +} + +// write one or all actual shortcut set(s) into a settings file +void +shortcut_manager::do_write_shortcuts (int set, QSettings* settings) +{ + if (set) + { + // set is not zero, only write the desired set (index = set-1) + // into the settings file that the user has selected for this export + for (int i = 0; i < _sc.count (); i++) // loop over all shortcuts + { + settings->setValue("shortcuts/"+_sc.at (i).settings_key, + _sc.at (i).actual_sc[set-1].toString ()); + } + } + else + { + // set is zero, write all sets into the normal octave settings file + // (this is only the case when called from the closing settings dialog) + for (int i = 0; i < _sc.count (); i++) // loop over all shortcuts + { + settings->setValue("shortcuts/"+_sc.at (i).settings_key, + _sc.at (i).actual_sc[0].toString ()); + settings->setValue("shortcuts/"+_sc.at (i).settings_key+"_1", + _sc.at (i).actual_sc[1].toString ()); + } + delete _dialog; // the dialog for key sequences can be removed now + } + + settings->sync (); // sync the settings file +} + +void +shortcut_manager::do_set_shortcut (QAction* action, const QString& key) +{ + int set = _settings->value ("shortcuts/set",0).toInt (); + int index; + + index = _action_hash[key] - 1; + + QString key_set = key; + if (set == 1) + key_set = key+"_1"; + + if (index > -1 && index < _sc.count ()) + action->setShortcut (QKeySequence ( + _settings->value ("shortcuts/" + key_set, _sc.at (index).default_sc[set]).toString ())); + else + qDebug () << "Key: " << key_set << " not found in _action_hash"; +} + +void +shortcut_manager::handle_double_clicked (QTreeWidgetItem* item, int col) +{ + switch (col) + { + case 2: + case 4: + _selected_set = col/2 - 1; + break; + + default: + return; + } + + int i = _item_index_hash[item]; + if (i == 0) + return; // top-level-item clicked + + shortcut_dialog (i-1); // correct to index starting at 0 +} + +void +shortcut_manager::shortcut_dialog (int index) +{ + if (! _dialog) + { + _dialog = new QDialog (this); + + _dialog->setWindowTitle (tr ("Enter new Shortcut for Set %1") + .arg (_selected_set + 1)); + + QVBoxLayout *box = new QVBoxLayout(_dialog); + + QLabel *help = new QLabel (tr ("Apply the desired shortcut or click " + "on the right button to reset the " + "shortcut to its default.")); + help->setWordWrap (true); + box->addWidget (help); + + QCheckBox *direct = new QCheckBox (tr ("Enter shortcut directly by performing it")); + direct->setCheckState (Qt::Checked); + box->addWidget (direct); + + QGridLayout *grid = new QGridLayout(); + + QLabel *actual = new QLabel (tr ("Actual shortcut")); + _edit_actual = new enter_shortcut (_dialog); + _edit_actual->setAlignment (Qt::AlignHCenter); + grid->addWidget (actual, 0, 0); + grid->addWidget (_edit_actual, 0, 1); + + QLabel *def = new QLabel (tr ("Default shortcut")); + _label_default = new QLabel (_dialog); + _label_default->setAlignment (Qt::AlignHCenter); + grid->addWidget (def, 1, 0); + grid->addWidget (_label_default, 1, 1); + + QPushButton *set_default = new QPushButton (tr ("Set to default")); + grid->addWidget (set_default, 0, 2); + connect (set_default, SIGNAL (clicked ()), + this, SLOT (shortcut_dialog_set_default ())); + + box->addLayout (grid); + + QDialogButtonBox *button_box = new QDialogButtonBox (QDialogButtonBox::Ok + | QDialogButtonBox::Cancel); + QList buttons = button_box->buttons (); + for (int i = 0; i < buttons.count (); i++) + buttons.at (i)->setShortcut (QKeySequence ()); + connect(button_box, SIGNAL (accepted ()), _dialog, SLOT (accept ())); + connect(button_box, SIGNAL (rejected ()), _dialog, SLOT (reject ())); + box->addWidget (button_box); + + _dialog->setLayout (box); + + connect (direct, SIGNAL (stateChanged (int)), + _edit_actual, SLOT (handle_direct_shortcut (int))); + connect (_dialog, SIGNAL (finished (int)), + this, SLOT (shortcut_dialog_finished (int))); + + } + + _edit_actual->setText (_sc.at (index).actual_sc[_selected_set]); + _label_default->setText (_sc.at (index).default_sc[_selected_set]); + _handled_index = index; + + _edit_actual->setFocus (); + _dialog->setFocusProxy (_edit_actual); + _dialog->exec (); +} + +void +shortcut_manager::shortcut_dialog_finished (int result) +{ + if (result == QDialog::Rejected) + return; + + // check for duplicate + + // get the widget for which this shortcut is defined + QString widget = _sc.at (_handled_index).settings_key.section ('_',0,0); + // and look for shortcut + QString sep = ":"; + if (_selected_set) + sep = "_1:"; + + int double_index = _shortcut_hash[widget + sep + _edit_actual->text()] - 1; + + if (double_index >= 0 && double_index != _handled_index) + { + int ret = QMessageBox::warning(this, tr("Double Shortcut"), + tr ("The chosen shortcut\n \"%1\"\n" + "is already used for the action\n \"%2\".\n" + "Do you want to use the shortcut anyhow removing it " + "from the previous action?") + .arg (_edit_actual->text()) + .arg (_sc.at (double_index).description), + QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); + + if (ret == QMessageBox::Yes) + { + shortcut_t double_shortcut = _sc.at (double_index); + double_shortcut.actual_sc[_selected_set] = QKeySequence (); + _sc.replace (double_index, double_shortcut); + _index_item_hash[double_index]->setText ((_selected_set + 1)*2, QKeySequence ()); + } + else + return; + } + + shortcut_t shortcut = _sc.at (_handled_index); + if (! shortcut.actual_sc[_selected_set].isEmpty ()) + _shortcut_hash.remove (widget + sep + shortcut.actual_sc[_selected_set].toString ()); + shortcut.actual_sc[_selected_set] = _edit_actual->text(); + _sc.replace (_handled_index, shortcut); + + _index_item_hash[_handled_index]->setText ((_selected_set + 1)*2, + shortcut.actual_sc[_selected_set]); + + if (! shortcut.actual_sc[_selected_set].isEmpty ()) + _shortcut_hash[widget + sep + shortcut.actual_sc[_selected_set].toString ()] = + _handled_index + 1; +} + +void +shortcut_manager::shortcut_dialog_set_default () +{ + _edit_actual->setText (_label_default->text ()); +} + +// import a shortcut set from a given settings file and refresh the tree view +void +shortcut_manager::import_shortcuts (int set, QSettings *settings) +{ + for (int i = 0; i < _sc.count (); i++) + { + // update the list of all shortcuts + shortcut_t sc = _sc.at (i); // make a copy + sc.actual_sc[set-1] = QKeySequence ( // get new shortcut from settings + settings->value ("shortcuts/"+sc.settings_key,sc.actual_sc[set-1]). + toString ()); // and use the old one as default + _sc.replace (i,sc); // replace the old with the new one + + // update the tree view + QTreeWidgetItem* tree_item = _index_item_hash[i]; // get related tree item + tree_item->setText (2*set, sc.actual_sc [set-1]); // display new shortcut + } +} + +// import or export of shortcut sets, +// called from settings dialog when related buttons are clicked +void +shortcut_manager::do_import_export (bool import, int set) +{ + QString file; + + // get the file name to read or write the shortcuts, + // the default extension is .osc (octave shortcuts) + if (import) + { + file = QFileDialog::getOpenFileName (this, + tr ("Import shortcut set %1 from file ...").arg (set), QString (), + tr ("Octave Shortcut Files (*.osc);;All Files (*)")); + } + else + { + file = QFileDialog::getSaveFileName (this, + tr ("Export shortcut set %1 into file ...").arg (set), QString (), + tr ("Octave Shortcut Files (*.osc);;All Files (*)")); + } + + // create a settings object related to this file + QSettings *osc_settings = new QSettings (file, QSettings::IniFormat); + if (osc_settings) + { + // the settings object was successfully created: carry on + if (import) + import_shortcuts (set, osc_settings); // import (special action) + else + do_write_shortcuts (set, osc_settings); // export, like saving settings + } + else + qWarning () << tr ("Failed to open %1 as octave shortcut file"). arg (file); + +} + + +// enter_shortcut: +// class derived from QLineEdit for directly entering key sequences which +enter_shortcut::enter_shortcut (QWidget *p) : QLineEdit (p) +{ + _direct_shortcut = true; // the shortcut is directly entered +} + +enter_shortcut::~enter_shortcut () +{ +} + +// slot for checkbox whether the shortcut is directly entered or not +void +enter_shortcut::handle_direct_shortcut (int state) +{ + if (state) + _direct_shortcut = true; // the shortcut is directly entered + else + _direct_shortcut = false; // the shortcut has to be written as text +} + +// new keyPressEvent +void +enter_shortcut::keyPressEvent (QKeyEvent *e) +{ + if (! _direct_shortcut) + { + QLineEdit::keyPressEvent (e); + return; + } + + if (e->type () == QEvent::KeyPress) + { + int key = e->key (); + + if (key == Qt::Key_unknown || key == 0) + return; + + Qt::KeyboardModifiers modifiers = e->modifiers (); + + if(modifiers & Qt::ShiftModifier) + key += Qt::SHIFT; + if(modifiers & Qt::ControlModifier) + key += Qt::CTRL; + if(modifiers & Qt::AltModifier) + key += Qt::ALT; + if(modifiers & Qt::MetaModifier) + key += Qt::META; + + setText (QKeySequence(key)); + } +} diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/shortcut-manager.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libgui/src/shortcut-manager.h Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,150 @@ +/* + +Copyright (C) 2014 Torsten + +This file is part of Octave. + +Octave is free software; you can redistribute it and/or modify it +under the terms of the GNU General Public License as published by the +Free Software Foundation; either version 3 of the License, or (at your +option) any later version. + +Octave is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Octave; see the file COPYING. If not, see +. + +*/ + +#ifndef SHORTCUT_MANAGER_H +#define SHORTCUT_MANAGER_H + +#include +#include +#include +#include +#include +#include + +class enter_shortcut : public QLineEdit +{ + Q_OBJECT + +public: + enter_shortcut (QWidget *p = 0); + ~enter_shortcut (); + + virtual void keyPressEvent (QKeyEvent *e); + +public slots: + void handle_direct_shortcut (int); + +private: + bool _direct_shortcut; + +}; + + +class shortcut_manager : public QWidget +{ + Q_OBJECT + +public: + shortcut_manager (); + ~shortcut_manager (); + + static void init_data () + { + if (instance_ok ()) + instance->do_init_data (); + } + + static void write_shortcuts (int set, QSettings *settings) + { + if (instance_ok ()) + instance->do_write_shortcuts (set, settings); + } + + static void set_shortcut (QAction *action, const QString& key) + { + if (instance_ok ()) + instance->do_set_shortcut (action, key); + } + + static void fill_treewidget (QTreeWidget *tree_view) + { + if (instance_ok ()) + instance->do_fill_treewidget (tree_view); + } + + static void import_export (bool import, int set) + { + if (instance_ok ()) + instance->do_import_export (import, set); + } + +public slots: + +signals: + +protected: + +protected slots: + + void handle_double_clicked (QTreeWidgetItem*, int); + void shortcut_dialog_finished (int); + void shortcut_dialog_set_default (); + +private: + + static shortcut_manager *instance; + static void cleanup_instance (void) { delete instance; instance = 0; } + + // No copying! + + shortcut_manager (const shortcut_manager&); + shortcut_manager& operator = (const shortcut_manager&); + + static bool instance_ok (void); + + void init (QString, QString, QKeySequence); + void do_init_data (); + void do_write_shortcuts (int set, QSettings *settings); + void do_set_shortcut (QAction *action, const QString& key); + void do_fill_treewidget (QTreeWidget *tree_view); + void do_import_export (bool import, int set); + void shortcut_dialog (int); + void import_shortcuts (int set, QSettings *settings); + + struct shortcut_t + { + QString description; + QString settings_key; + QKeySequence actual_sc[2]; + QKeySequence default_sc[2]; + QTreeWidgetItem *tree_item; + }; + + QList _sc; + QHash _shortcut_hash; + QHash _action_hash; + QHash _level_hash; + QHash _index_item_hash; + QHash _item_index_hash; + + QDialog *_dialog; + enter_shortcut *_edit_actual; + QLabel *_label_default; + int _handled_index; + + QSettings *_settings; + int _selected_set; + +}; + + +#endif // SHORTCUT_MANAGER_H diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/workspace-model.cc --- a/libgui/src/workspace-model.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/workspace-model.cc Fri Jan 23 15:23:09 2015 -0500 @@ -39,7 +39,7 @@ _columnNames.append (tr ("Class")); _columnNames.append (tr ("Dimension")); _columnNames.append (tr ("Value")); - _columnNames.append (tr ("Storage Class")); + _columnNames.append (tr ("Attribute")); for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) _storage_class_colors.append (QColor (Qt::white)); @@ -244,8 +244,6 @@ _complex_flags = complex_flags; update_table (); - - emit model_changed (); } void @@ -253,8 +251,6 @@ { clear_data (); update_table (); - - emit model_changed (); } void diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/workspace-view.cc --- a/libgui/src/workspace-view.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/workspace-view.cc Fri Jan 23 15:23:09 2015 -0500 @@ -35,9 +35,12 @@ #include #include #include +#include +#include #include "workspace-view.h" #include "resource-manager.h" +#include "symtab.h" workspace_view::workspace_view (QWidget *p) : octave_dock_widget (p), view (new QTableView (this)) @@ -47,8 +50,26 @@ set_title (tr ("Workspace")); setStatusTip (tr ("View the variables in the active workspace.")); + _filter = new QComboBox (this); + _filter->setToolTip (tr ("Enter text to filter the workspace")); + _filter->setEditable (true); + _filter->setMaxCount (MaxFilterHistory); + _filter->setInsertPolicy (QComboBox::NoInsert); + _filter->setSizeAdjustPolicy ( + QComboBox::AdjustToMinimumContentsLengthWithIcon); + QSizePolicy sizePol (QSizePolicy::Expanding, QSizePolicy::Maximum); + _filter->setSizePolicy (sizePol); + _filter->completer ()->setCaseSensitivity (Qt::CaseSensitive); + + QLabel *filter_label = new QLabel (tr ("Filter")); + + _filter_checkbox = new QCheckBox (); + view->setWordWrap (false); view->setContextMenuPolicy (Qt::CustomContextMenu); + view->setShowGrid (false); + (view->verticalHeader) ()->hide (); + view->setAlternatingRowColors (true); view_previous_row_count = 0; // Set an empty widget, so we can assign a layout to it. @@ -56,6 +77,11 @@ // Create a new layout and add widgets to it. QVBoxLayout *vbox_layout = new QVBoxLayout (); + QHBoxLayout *hbox_layout = new QHBoxLayout (); + hbox_layout->addWidget (filter_label); + hbox_layout->addWidget (_filter_checkbox); + hbox_layout->addWidget (_filter); + vbox_layout->addLayout (hbox_layout); vbox_layout->addWidget (view); vbox_layout->setMargin (2); @@ -67,12 +93,26 @@ QSettings *settings = resource_manager::get_settings (); // Initialize column order and width of the workspace - view->horizontalHeader ()->restoreState ( settings->value ("workspaceview/column_state").toByteArray ()); + // Init state of the filter + _filter->addItems (settings->value ("workspaceview/mru_list").toStringList ()); + + bool filter_state = + settings->value ("workspaceview/filter_active", false).toBool (); + _filter_checkbox->setChecked (filter_state); + filter_activate (filter_state); + // Connect signals and slots. + connect (_filter, SIGNAL (editTextChanged (const QString&)), + this, SLOT (filter_update (const QString&))); + connect (_filter_checkbox, SIGNAL (toggled (bool)), + this, SLOT (filter_activate (bool))); + connect (_filter->lineEdit (), SIGNAL (editingFinished ()), + this, SLOT (update_filter_history ())); + connect (view, SIGNAL (customContextMenuRequested (const QPoint&)), this, SLOT (contextmenu_requested (const QPoint&))); @@ -87,13 +127,23 @@ settings->setValue ("workspaceview/column_state", view->horizontalHeader ()->saveState ()); + settings->setValue ("workspaceview/filter_active", + _filter_checkbox->isChecked ()); + + QStringList mru; + for (int i = 0; i < _filter->count (); i++) + mru.append (_filter->itemText (i)); + settings->setValue ("workspaceview/mru_list", mru); settings->sync (); } void workspace_view::setModel (workspace_model *model) { - view->setModel (model); + _filter_model.setSourceModel (model); + _filter_model.setFilterKeyColumn(0); + + view->setModel (&_filter_model); _model = model; } @@ -105,28 +155,69 @@ } void +workspace_view::filter_update (const QString& expression) +{ + _filter_model.setFilterWildcard (expression); + handle_model_changed (); +} + +void +workspace_view::filter_activate (bool state) +{ + _filter->setEnabled (state); + _filter_model.setDynamicSortFilter (state); + + if (state) + filter_update (_filter->currentText ()); + else + filter_update (QString ()); +} + +void +workspace_view::update_filter_history () +{ + QString text = _filter->currentText (); // get current text + int index = _filter->findText (text); // and its actual index + + if (index > -1) + _filter->removeItem (index); // remove if already existing + + _filter->insertItem (0, text); // (re)insert at beginning + _filter->setCurrentIndex (0); +} + +QString +workspace_view::get_var_name (QModelIndex index) +{ + index = index.sibling (index.row (), 0); + QAbstractItemModel *m = view->model (); + QMap item_data = m->itemData (index); + + return item_data[0].toString (); +} + +void workspace_view::contextmenu_requested (const QPoint& qpos) { QMenu menu (this); QModelIndex index = view->indexAt (qpos); - QAbstractItemModel *m = view->model (); // if it isnt Local, Glocal etc, allow the ctx menu if (index.isValid () && index.column () == 0) { - index = index.sibling (index.row (), 0); - - QMap item_data = m->itemData (index); + QString var_name = get_var_name (index); - QString var_name = item_data[0].toString (); + menu.addAction (tr ("Copy name"), this, + SLOT (handle_contextmenu_copy ())); - menu.addAction (tr ("Copy"), this, - SLOT (handle_contextmenu_copy ())); + menu.addAction (tr ("Copy value"), this, + SLOT (handle_contextmenu_copy_value ())); QAction *rename = menu.addAction (tr ("Rename"), this, SLOT (handle_contextmenu_rename ())); + QAbstractItemModel *m = view->model (); const workspace_model *wm = static_cast (m); if (! wm->is_top_level ()) @@ -157,13 +248,7 @@ if (index.isValid ()) { - index = index.sibling (index.row (), 0); - - QAbstractItemModel *m = view->model (); - - QMap item_data = m->itemData (index); - - QString var_name = item_data[0].toString (); + QString var_name = get_var_name (index); QClipboard *clipboard = QApplication::clipboard (); @@ -172,19 +257,31 @@ } void +workspace_view::handle_contextmenu_copy_value (void) +{ + QModelIndex index = view->currentIndex (); + + if (index.isValid ()) + { + QString var_name = get_var_name (index); + + octave_value val = symbol_table::varval (var_name.toStdString ()); + std::ostringstream buf; + val.print_raw (buf, true); + + QClipboard *clipboard = QApplication::clipboard (); + clipboard->setText (QString::fromStdString (buf.str ())); + } +} + +void workspace_view::handle_contextmenu_rename (void) { QModelIndex index = view->currentIndex (); if (index.isValid ()) { - index = index.sibling (index.row (), 0); - - QAbstractItemModel *m = view->model (); - - QMap item_data = m->itemData (index); - - QString var_name = item_data[0].toString (); + QString var_name = get_var_name (index); QInputDialog* inputDialog = new QInputDialog (); @@ -197,7 +294,10 @@ QLineEdit::Normal, var_name, &ok); if (ok && ! new_name.isEmpty ()) - m->setData (index, new_name, Qt::EditRole); + { + QAbstractItemModel *m = view->model (); + m->setData (index, new_name, Qt::EditRole); + } } } @@ -226,13 +326,7 @@ if (index.isValid ()) { - index = index.sibling (index.row (), 0); - - QAbstractItemModel *m = view->model (); - - QMap item_data = m->itemData (index); - - QString var_name = item_data[0].toString (); + QString var_name = get_var_name (index); emit command_requested (cmdname + " (" + var_name + ");"); } @@ -241,11 +335,12 @@ void workspace_view::handle_model_changed (void) { +// view->resizeRowsToContents (); // Just modify those rows that have been added rather than go through // the whole list. For-loop test will handle when number of rows reduced. QFontMetrics fm = view->fontMetrics (); int row_height = fm.height (); - int new_row_count = view->model ()->rowCount (); + int new_row_count = _filter_model.rowCount (); for (int i = view_previous_row_count; i < new_row_count; i++) view->setRowHeight (i, row_height); view_previous_row_count = new_row_count; @@ -257,16 +352,22 @@ _model->notice_settings (settings); // update colors of model first QString tool_tip; - tool_tip = QString (tr ("View the variables in the active workspace.
")); - tool_tip += QString (tr ("Colors for the storage class:")); - for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) + + if (!settings->value ("workspaceview/hide_tool_tips",false).toBool ()) { - tool_tip += - QString ("

%2
") - .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.
")); + tool_tip += QString (tr ("Colors for variable attributes:")); + for (int i = 0; i < resource_manager::storage_class_chars ().length (); i++) + { + tool_tip += + QString ("
%2
") + .arg (_model->storage_class_color (i).name ()) + .arg (resource_manager::storage_class_names ().at (i)); + } } + setToolTip (tool_tip); + } void @@ -276,3 +377,10 @@ handle_contextmenu_copy (); } +void +workspace_view::selectAll () +{ + if (view->hasFocus ()) + view->selectAll (); +} + diff -r 75a671fcdd73 -r 844448ae53f3 libgui/src/workspace-view.h --- a/libgui/src/workspace-view.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libgui/src/workspace-view.h Fri Jan 23 15:23:09 2015 -0500 @@ -27,6 +27,9 @@ #include #include #include +#include +#include +#include #include "octave-dock-widget.h" #include "workspace-model.h" @@ -62,6 +65,7 @@ // context menu slots void handle_contextmenu_copy (void); + void handle_contextmenu_copy_value (void); void handle_contextmenu_rename (void); void handle_contextmenu_disp (void); void handle_contextmenu_plot (void); @@ -70,14 +74,25 @@ void handle_model_changed (void); void copyClipboard (); + void selectAll (); + + void filter_update (const QString& expression); + void filter_activate (bool enable); + void update_filter_history (); private: void relay_contextmenu_command (const QString& cmdname); + QString get_var_name (QModelIndex index); QTableView *view; int view_previous_row_count; workspace_model *_model; + + QSortFilterProxyModel _filter_model; + QCheckBox *_filter_checkbox; + QComboBox *_filter; + enum { MaxFilterHistory = 10 }; }; #endif diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/data.cc --- a/libinterp/corefcn/data.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/data.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1207,7 +1207,7 @@ else if (str == "double") isdouble = true; else - error ("sum: unrecognized string argument"); + error ("cumsum: unrecognized string argument"); nargin --; } } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/debug.cc --- a/libinterp/corefcn/debug.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/debug.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1485,3 +1485,38 @@ return retval; } + +DEFUN (db_next_breakpoint_quiet, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} db_next_breakpoint_quiet ()\n\ +@deftypefnx {Built-in Function} {} db_next_breakpoint_quiet (@var{flag})\n\ +Disable line info printing at the next breakpoint. With a logical\n\ +argument, set the state on or off.\n\ +@end deftypefn") +{ + octave_value retval; + + int nargin = args.length (); + + if (nargin == 0 || nargin == 1) + { + bool state = true; + + if (nargin == 1) + { + state = args(0).bool_value (); + + if (error_state) + { + gripe_wrong_type_arg ("db_next_breakpoint", args(0), true); + return retval; + } + } + + tree_evaluator::quiet_breakpoint_flag = state; + } + else + print_usage (); + + return retval; +} diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/error.cc --- a/libinterp/corefcn/error.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/error.cc Fri Jan 23 15:23:09 2015 -0500 @@ -61,7 +61,7 @@ // TRUE means that Octave will try to display a stack trace when a // warning is encountered. -static bool Vbacktrace_on_warning = false; +static bool Vbacktrace_on_warning = true; // TRUE means that Octave will print a verbose warning. Currently unused. static bool Vverbose_warning; @@ -1225,6 +1225,7 @@ @deftypefnx {Built-in Function} {} warning (\"off\", @var{id})\n\ @deftypefnx {Built-in Function} {} warning (\"query\", @var{id})\n\ @deftypefnx {Built-in Function} {} warning (\"error\", @var{id})\n\ +@deftypefnx {Built-in Function} {} warning (@var{state}, \"backtrace\")\n\ @deftypefnx {Built-in Function} {} warning (@var{state}, @var{id}, \"local\")\n\ Format the optional arguments under the control of the template string\n\ @var{template} using the same rules as the @code{printf} family of\n\ @@ -1255,6 +1256,11 @@ @end group\n\ @end example\n\ \n\ +If the state is @qcode{\"on\"} or @qcode{\"off\"} and the third argument\n\ +is @qcode{\"backtrace\"}, then a stack trace is printed along with the\n\ +warning message when warnings occur inside function calls. This option\n\ +is enabled by default.\n\ +\n\ If the state is @qcode{\"on\"}, @qcode{\"off\"}, or @qcode{\"error\"}\n\ and the third argument is @qcode{\"local\"}, then the warning state\n\ will be set temporarily, until the end of the current function.\n\ @@ -1636,9 +1642,6 @@ disable_warning ("Octave:str-to-num"); disable_warning ("Octave:mixed-string-concat"); disable_warning ("Octave:variable-switch-label"); - - // This should be an error unless we are in maximum braindamage mode. - set_warning_state ("Octave:noninteger-range-as-index", "error"); } DEFUN (lasterror, args, , @@ -2008,6 +2011,12 @@ return Vlast_error_id; } +octave_map +last_error_stack (void) +{ + return Vlast_error_stack; +} + std::string last_warning_message (void) { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/error.h --- a/libinterp/corefcn/error.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/error.h Fri Jan 23 15:23:09 2015 -0500 @@ -26,6 +26,7 @@ #include #include +class octave_map; class octave_value_list; class unwind_protect; @@ -137,6 +138,7 @@ // Helper functions to pass last error and warning messages and ids extern OCTINTERP_API std::string last_error_message (void); extern OCTINTERP_API std::string last_error_id (void); +extern OCTINTERP_API octave_map last_error_stack (void); extern OCTINTERP_API std::string last_warning_message (void); extern OCTINTERP_API std::string last_warning_id (void); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/file-io.cc --- a/libinterp/corefcn/file-io.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/file-io.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1548,14 +1548,14 @@ The optional argument @var{arch} is a string specifying the data format\n\ for the file. Valid values are\n\ \n\ -@table @code\n\ +@table @asis\n\ @item @qcode{\"native\"}\n\ The format of the current machine.\n\ \n\ -@item \"ieee-be\"\n\ +@item @qcode{\"ieee-be\"}\n\ IEEE big endian.\n\ \n\ -@item \"ieee-le\"\n\ +@item @qcode{\"ieee-le\"}\n\ IEEE little endian.\n\ @end table\n\ \n\ diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/find.cc --- a/libinterp/corefcn/find.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/find.cc Fri Jan 23 15:23:09 2015 -0500 @@ -88,9 +88,8 @@ { octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ()); - + octave_idx_type nr = v.rows (); octave_idx_type nc = v.cols (); - octave_idx_type nr = v.rows (); octave_idx_type nz = v.nnz (); // Search in the default range. @@ -138,21 +137,20 @@ count = (n_to_find > v.cidx (end_nc) - v.cidx (start_nc) ? v.cidx (end_nc) - v.cidx (start_nc) : n_to_find); - // If the original argument was a row vector, force a row vector of - // the overall indices to be returned. But see below for scalar - // case... + octave_idx_type result_nr; + octave_idx_type result_nc; - octave_idx_type result_nr = count; - octave_idx_type result_nc = 1; - - bool scalar_arg = false; - - if (v.rows () == 1) + // Default case is to return a column vector, however, if the original + // argument was a row vector, then force return of a row vector. + if (nr == 1) { result_nr = 1; result_nc = count; - - scalar_arg = (v.columns () == 1); + } + else + { + result_nr = count; + result_nc = 1; } Matrix idx (result_nr, result_nc); @@ -164,9 +162,8 @@ if (count > 0) { - // Search for elements to return. Only search the region where - // there are elements to be found using the count that we want - // to find. + // Search for elements to return. Only search the region where there + // are elements to be found using the count that we want to find. for (octave_idx_type j = start_nc, cx = 0; j < end_nc; j++) for (octave_idx_type i = v.cidx (j); i < v.cidx (j+1); i++ ) { @@ -182,14 +179,19 @@ break; } } - else if (scalar_arg) + else { - idx.resize (0, 0); + // No items found. Fixup return dimensions for Matlab compatibility. + // The behavior to match is documented in Array.cc (Array::find). + if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1)) + { + idx.resize (0, 0); - i_idx.resize (0, 0); - j_idx.resize (0, 0); + i_idx.resize (0, 0); + j_idx.resize (0, 0); - val.resize (dim_vector (0, 0)); + val.resize (dim_vector (0, 0)); + } } switch (nargout) @@ -231,6 +233,7 @@ // There are far fewer special cases to handle for a PermMatrix. octave_value_list retval ((nargout == 0 ? 1 : nargout), Matrix ()); + octave_idx_type nr = v.rows (); octave_idx_type nc = v.cols (); octave_idx_type start_nc, count; @@ -252,8 +255,6 @@ count = n_to_find; } - bool scalar_arg = (v.rows () == 1 && v.cols () == 1); - Matrix idx (count, 1); Matrix i_idx (count, 1); Matrix j_idx (count, 1); @@ -291,13 +292,23 @@ } } } - else if (scalar_arg) + else { - // Same odd compatibility case as the other overrides. - idx.resize (0, 0); - i_idx.resize (0, 0); - j_idx.resize (0, 0); - val.resize (dim_vector (0, 0)); + // FIXME: Is this case even possible? A scalar permutation matrix seems + // to devolve to a scalar full matrix, at least from the Octave command + // line. Perhaps this function could be called internally from C++ with + // such a matrix. + // No items found. Fixup return dimensions for Matlab compatibility. + // The behavior to match is documented in Array.cc (Array::find). + if ((nr == 0 && nc == 0) || (nr == 1 && nc == 1)) + { + idx.resize (0, 0); + + i_idx.resize (0, 0); + j_idx.resize (0, 0); + + val.resize (dim_vector (0, 0)); + } } switch (nargout) diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/gl-render.h --- a/libinterp/corefcn/gl-render.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/gl-render.h Fri Jan 23 15:23:09 2015 -0500 @@ -40,6 +40,12 @@ #include #endif +#ifdef HAVE_GL_GLEXT_H +#include +#elif defined HAVE_OPENGL_GLEXT_H || defined HAVE_FRAMEWORK_OPENGL +#include +#endif + #include "graphics.h" #include "txt-eng-ft.h" diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/graphics.cc --- a/libinterp/corefcn/graphics.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/graphics.cc Fri Jan 23 15:23:09 2015 -0500 @@ -9585,16 +9585,6 @@ gtk_manager *gtk_manager::instance = 0; -gtk_manager::gtk_manager (void) - : dtk (), available_toolkits (), loaded_toolkits () -{ -#if defined (HAVE_FLTK) - dtk = display_info::display_available () ? "fltk" : "gnuplot"; -#else - dtk = "gnuplot"; -#endif -} - void gtk_manager::create_instance (void) { @@ -9639,6 +9629,45 @@ return retval; } +void +gtk_manager::do_register_toolkit (const std::string& name) +{ + if (dtk.empty () || name == "qt" + || (name == "fltk" + && available_toolkits.find ("qt") == available_toolkits.end ())) + dtk = name; + + available_toolkits.insert (name); +} + +void +gtk_manager::do_unregister_toolkit (const std::string& name) +{ + available_toolkits.erase (name); + + if (dtk == name) + { + if (available_toolkits.empty ()) + dtk.clear (); + else + { + const_available_toolkits_iterator pa = available_toolkits.begin (); + + dtk = *pa++; + + while (pa != available_toolkits.end ()) + { + std::string toolkit = *pa++; + + if (toolkit == "qt" + || (toolkit == "fltk" + && available_toolkits.find ("qt") == available_toolkits.end ())) + dtk = toolkit; + } + } + } +} + DEFUN (available_graphics_toolkits, , , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} available_graphics_toolkits ()\n\ diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/graphics.in.h --- a/libinterp/corefcn/graphics.in.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/graphics.in.h Fri Jan 23 15:23:09 2015 -0500 @@ -2273,7 +2273,7 @@ private: - gtk_manager (void); + gtk_manager (void) { } ~gtk_manager (void) { } @@ -2322,15 +2322,9 @@ graphics_toolkit do_get_toolkit (void) const; - void do_register_toolkit (const std::string& name) - { - available_toolkits.insert (name); - } - - void do_unregister_toolkit (const std::string& name) - { - available_toolkits.erase (name); - } + void do_register_toolkit (const std::string& name); + + void do_unregister_toolkit (const std::string& name); void do_load_toolkit (const graphics_toolkit& tk) { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/input.cc --- a/libinterp/corefcn/input.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/input.cc Fri Jan 23 15:23:09 2015 -0500 @@ -188,6 +188,9 @@ if (! eof && retval.empty ()) retval = "\n"; + if (command_editor::interrupt (false)) + retval = ""; + return retval; } @@ -508,10 +511,12 @@ { unwind_protect frame; + bool silent = tree_evaluator::quiet_breakpoint_flag; + tree_evaluator::quiet_breakpoint_flag = false; + octave_user_code *caller = octave_call_stack::caller_user_code (); std::string nm; - - int curr_debug_line = octave_call_stack::current_line (); + int curr_debug_line; bool have_file = false; @@ -523,9 +528,11 @@ nm = caller->name (); else have_file = true; + + curr_debug_line = octave_call_stack::caller_user_code_line (); } else - curr_debug_line = -1; + curr_debug_line = octave_call_stack::current_line (); std::ostringstream buf; @@ -543,10 +550,13 @@ // that we are stopped on the no-op command that marks the // end of a function or script. - buf << "stopped in " << nm; + if (! silent) + { + buf << "stopped in " << nm; - if (curr_debug_line > 0) - buf << " at line " << curr_debug_line; + if (curr_debug_line > 0) + buf << " at line " << curr_debug_line; + } if (have_file) { @@ -557,15 +567,21 @@ frame.add_fcn (execute_in_debugger_handler, std::pair (nm, curr_debug_line)); - std::string line_buf - = get_file_line (nm, curr_debug_line); + if (! silent) + { + std::string line_buf + = get_file_line (nm, curr_debug_line); - if (! line_buf.empty ()) - buf << "\n" << curr_debug_line << ": " << line_buf; + if (! line_buf.empty ()) + buf << "\n" << curr_debug_line << ": " << line_buf; + } } } } + if (silent) + command_editor::erase_empty_line (true); + std::string msg = buf.str (); if (! msg.empty ()) @@ -594,7 +610,7 @@ if (command_editor::interrupt (false)) break; - else + else { if (retval == 0 && curr_parser.stmt_list) { @@ -909,6 +925,7 @@ octave_call_stack::goto_frame_relative (0); tree_evaluator::debug_mode = true; + tree_evaluator::quiet_breakpoint_flag = false; tree_evaluator::current_frame = octave_call_stack::current_frame (); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/jit-typeinfo.cc --- a/libinterp/corefcn/jit-typeinfo.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/jit-typeinfo.cc Fri Jan 23 15:23:09 2015 -0500 @@ -916,7 +916,7 @@ bool jit_operation::signature_cmp -::operator() (const signature_vec *lhs, const signature_vec *rhs) +::operator() (const signature_vec *lhs, const signature_vec *rhs) const { const signature_vec& l = *lhs; const signature_vec& r = *rhs; diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/jit-typeinfo.h --- a/libinterp/corefcn/jit-typeinfo.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/jit-typeinfo.h Fri Jan 23 15:23:09 2015 -0500 @@ -372,7 +372,7 @@ struct signature_cmp { - bool operator() (const signature_vec *lhs, const signature_vec *rhs); + bool operator() (const signature_vec *lhs, const signature_vec *rhs) const; }; typedef std::map diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/load-save.cc --- a/libinterp/corefcn/load-save.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/load-save.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1224,7 +1224,7 @@ char headertext[128]; time (&now); - bdt = *gmtime (&now); + bdt = *gnulib::gmtime (&now); memset (headertext, ' ', 124); // ISO 8601 format date nstrftime (headertext, 124, "MATLAB 5.0 MAT-file, written by Octave " diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/max.cc diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/module.mk --- a/libinterp/corefcn/module.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/module.mk Fri Jan 23 15:23:09 2015 -0500 @@ -75,7 +75,6 @@ corefcn/ls-utils.h \ corefcn/mex.h \ corefcn/mexproto.h \ - corefcn/mxarray.in.h \ corefcn/oct-errno.h \ corefcn/oct-fstrm.h \ corefcn/oct-handle.h \ diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/pr-output.cc --- a/libinterp/corefcn/pr-output.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/pr-output.cc Fri Jan 23 15:23:09 2015 -0500 @@ -85,7 +85,7 @@ static bool plus_format = false; // First char for > 0, second for < 0, third for == 0. -static std::string plus_format_chars = "+ "; +static std::string plus_format_chars = "+- "; // TRUE means always print in a rational approximation static bool rat_format = false; @@ -3764,7 +3764,7 @@ } } else - plus_format_chars = "+ "; + plus_format_chars = "+- "; init_format_state (); plus_format = true; @@ -3904,13 +3904,14 @@ @itemx + @var{chars}\n\ @itemx plus\n\ @itemx plus @var{chars}\n\ -Print a @samp{+} symbol for nonzero matrix elements and a space for zero\n\ -matrix elements. This format can be very useful for examining the\n\ -structure of a large sparse matrix.\n\ +Print a @samp{+} symbol for matrix elements greater than zero, a\n\ +@samp{-} symbol for elements less than zero and a space for zero matrix\n\ +elements. This format can be very useful for examining the structure\n\ +of a large sparse matrix.\n\ \n\ The optional argument @var{chars} specifies a list of 3 characters to use\n\ for printing values greater than zero, less than zero and equal to zero.\n\ -For example, with the @samp{+ \"+-.\"} format, @code{[1, 0, -1; -1, 0, 1]}\n\ +For example, with the @samp{\"+\" \"+-.\"} format, @code{[1, 0, -1; -1, 0, 1]}\n\ is displayed as\n\ \n\ @example\n\ diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/profiler.cc --- a/libinterp/corefcn/profiler.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/profiler.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1,5 +1,6 @@ /* +Copyright (C) 2014 Julien Bect Copyright (C) 2012-2013 Daniel Kraft This file is part of Octave. @@ -32,29 +33,6 @@ #include "pager.h" #include "profiler.h" -profile_data_accumulator::enter::enter (profile_data_accumulator& a, - const std::string& f) - : acc (a) -{ - // FIXME: Add test for f != "" to prevent a blank line showing up - // in profiler statistics. See bug #39524. The root cause - // is that the function name is not set for the recurring readline - // hook function. - if (acc.is_active () && f != "") - { - fcn = f; - acc.enter_function (fcn); - } - else - fcn = ""; -} - -profile_data_accumulator::enter::~enter () -{ - if (fcn != "") - acc.exit_function (fcn); -} - profile_data_accumulator::stats::stats () : time (0.0), calls (0), recursive (false), parents (), children () diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/profiler.h --- a/libinterp/corefcn/profiler.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/profiler.h Fri Jan 23 15:23:09 2015 -0500 @@ -1,5 +1,6 @@ /* +Copyright (C) 2014 Julien Bect Copyright (C) 2012-2013 Daniel Kraft This file is part of Octave. @@ -39,17 +40,40 @@ // This is a utility class that can be used to call the enter/exit // functions in a manner protected from stack unwinding. - class enter + template class enter { private: profile_data_accumulator& acc; std::string fcn; + bool is_active; public: - enter (profile_data_accumulator&, const std::string&); - virtual ~enter (void); + enter (profile_data_accumulator& a, const T& t) : acc (a) + { + // A profiling block cannot be active if the profiler is not + is_active = acc.is_active (); + + if (is_active) + { + fcn = t.profiler_name (); + + // NOTE: The test f != "" must be kept to prevent a blank line showing + // up in profiler statistics. See bug #39524. The root cause is that + // the function name is not set for the recurring readline hook function. + if (fcn == "") + is_active = false; // Inactive profiling block + else + acc.enter_function (fcn); + } + } + + ~enter () + { + if (is_active) + acc.exit_function (fcn); + } private: @@ -181,10 +205,12 @@ extern OCTINTERP_API profile_data_accumulator profiler; // Helper macro to profile a block of code. -#define BEGIN_PROFILER_BLOCK(name) \ + +#define BEGIN_PROFILER_BLOCK(classname) \ { \ - profile_data_accumulator::enter pe (profiler, (name)); + profile_data_accumulator::enter pe (profiler, *this); + #define END_PROFILER_BLOCK \ - } + } // end of block => call pe's destructor #endif diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/sysdep.cc --- a/libinterp/corefcn/sysdep.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/sysdep.cc Fri Jan 23 15:23:09 2015 -0500 @@ -169,13 +169,21 @@ { w32_set_quiet_shutdown (); } + +static void +w32_init (void) +{ + w32_set_octave_home (); + + command_editor::prefer_env_winsize (true); +} #endif #if defined (__MINGW32__) static void MINGW_init (void) { - w32_set_octave_home (); + w32_init (); } #endif @@ -183,7 +191,7 @@ static void MSVC_init (void) { - w32_set_octave_home (); + w32_init (); } #endif diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/toplev.cc --- a/libinterp/corefcn/toplev.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/toplev.cc Fri Jan 23 15:23:09 2015 -0500 @@ -263,6 +263,29 @@ return retval; } +bool +octave_call_stack::do_all_scripts (void) const +{ + bool retval = true; + + const_iterator p = cs.end (); + + while (p != cs.begin ()) + { + const call_stack_elt& elt = *(--p); + + octave_function *f = elt.fcn; + + if (f && ! f->is_user_script ()) + { + retval = false; + break; + } + } + + return retval; +} + // Use static fields for the best efficiency. // NOTE: C++0x will allow these two to be merged into one. static const char *bt_fieldnames[] = { "file", "name", "line", @@ -446,7 +469,7 @@ octave_function *f = elt.fcn; - if (frame == 0 || (f && f->is_user_code ())) + if (elt.scope == cs[0].scope || (f && f->is_user_code ())) { if (! skipped) // We found the current user code frame, so skip it. @@ -1289,7 +1312,6 @@ { false, "F77", OCTAVE_CONF_F77 }, { false, "F77_FLOAT_STORE_FLAG", OCTAVE_CONF_F77_FLOAT_STORE_FLAG }, { false, "F77_INTEGER_8_FLAG", OCTAVE_CONF_F77_INTEGER_8_FLAG }, - { false, "FC", OCTAVE_CONF_FC }, { false, "FFLAGS", OCTAVE_CONF_FFLAGS }, { false, "FFTW3_CPPFLAGS", OCTAVE_CONF_FFTW3_CPPFLAGS }, { false, "FFTW3_LDFLAGS", OCTAVE_CONF_FFTW3_LDFLAGS }, diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/toplev.h --- a/libinterp/corefcn/toplev.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/toplev.h Fri Jan 23 15:23:09 2015 -0500 @@ -206,6 +206,12 @@ return instance_ok () ? instance->do_caller_user_code (nskip) : 0; } + // Return TRUE if all elements on the call stack are scripts. + static bool all_scripts (void) + { + return instance_ok () ? instance->do_all_scripts () : false; + } + static void push (octave_function *f, symbol_table::scope_id scope = symbol_table::current_scope (), @@ -352,6 +358,8 @@ octave_user_code *do_caller_user_code (size_t nskip) const; + bool do_all_scripts (void) const; + void do_push (octave_function *f, symbol_table::scope_id scope, symbol_table::context_id context) { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/utils.cc --- a/libinterp/corefcn/utils.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/corefcn/utils.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1306,9 +1306,6 @@ { unwind_protect frame; - frame.protect_var (Vallow_noninteger_range_as_index); - Vallow_noninteger_range_as_index = false; - frame.protect_var (error_state); frame.protect_var (discard_error_messages); @@ -1316,7 +1313,8 @@ try { - idx_vector idx = args(0).index_vector (); + idx_vector idx = args(0).index_vector (true); + if (! error_state) { if (nargin == 2) diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/corefcn/variables.cc diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/dldfcn/__fltk_uigetfile__.cc --- a/libinterp/dldfcn/__fltk_uigetfile__.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/dldfcn/__fltk_uigetfile__.cc Fri Jan 23 15:23:09 2015 -0500 @@ -123,10 +123,10 @@ } if (multi_type == Fl_File_Chooser::DIRECTORY) - retval(0) = std::string (fc.value ()); + retval(0) = file_ops::native_separator_path (std::string (fc.value ())); else { - retval(1) = std::string (fc.directory ()) + sep; + retval(1) = file_ops::native_separator_path (std::string (fc.directory ()) + sep); retval(2) = fc.filter_value () + 1; } } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-base-diag.cc --- a/libinterp/octave-value/ov-base-diag.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-base-diag.cc Fri Jan 23 15:23:09 2015 -0500 @@ -412,9 +412,9 @@ template idx_vector -octave_base_diag::index_vector (void) const +octave_base_diag::index_vector (bool require_integers) const { - return to_dense ().index_vector (); + return to_dense ().index_vector (require_integers); } template diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-base-diag.h --- a/libinterp/octave-value/ov-base-diag.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-base-diag.h Fri Jan 23 15:23:09 2015 -0500 @@ -133,7 +133,7 @@ double scalar_value (bool frc_str_conv = false) const { return double_value (frc_str_conv); } - idx_vector index_vector (void) const; + idx_vector index_vector (bool /* require_integers */ = false) const; Matrix matrix_value (bool = false) const; diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-base-mat.cc --- a/libinterp/octave-value/ov-base-mat.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-base-mat.cc Fri Jan 23 15:23:09 2015 -0500 @@ -476,7 +476,10 @@ octave_print_internal (buf, matrix(j*nr+i)); std::string tmp = buf.str (); size_t pos = tmp.find_first_not_of (" "); - os << tmp.substr (pos); + if (pos != std::string::npos) + os << tmp.substr (pos); + else if (! tmp.empty ()) + os << tmp[0]; if (++elts >= max_elts) goto done; diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-base-scalar.cc --- a/libinterp/octave-value/ov-base-scalar.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-base-scalar.cc Fri Jan 23 15:23:09 2015 -0500 @@ -176,7 +176,10 @@ octave_print_internal (buf, scalar); std::string tmp = buf.str (); size_t pos = tmp.find_first_not_of (" "); - os << tmp.substr (pos); + if (pos != std::string::npos) + os << tmp.substr (pos); + else if (! tmp.empty ()) + os << tmp[0]; } template diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-base.cc --- a/libinterp/octave-value/ov-base.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-base.cc Fri Jan 23 15:23:09 2015 -0500 @@ -214,7 +214,7 @@ } idx_vector -octave_base_value::index_vector (void) const +octave_base_value::index_vector (bool /* require_integers */) const { std::string nm = type_name (); error ("%s type invalid as index value", nm.c_str ()); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-base.h Fri Jan 23 15:23:09 2015 -0500 @@ -287,7 +287,7 @@ const std::list& idx, const octave_value& rhs); - virtual idx_vector index_vector (void) const; + virtual idx_vector index_vector (bool require_integers = false) const; virtual dim_vector dims (void) const { return dim_vector (); } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-bool-mat.h --- a/libinterp/octave-value/ov-bool-mat.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-bool-mat.h Fri Jan 23 15:23:09 2015 -0500 @@ -88,8 +88,10 @@ octave_base_value *try_narrowing_conversion (void); - idx_vector index_vector (void) const - { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); } + idx_vector index_vector (bool /* require_integers */ = false) const + { + return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); + } builtin_type_t builtin_type (void) const { return btyp_bool; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-bool-sparse.h --- a/libinterp/octave-value/ov-bool-sparse.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-bool-sparse.h Fri Jan 23 15:23:09 2015 -0500 @@ -86,8 +86,10 @@ octave_base_value *try_narrowing_conversion (void); // FIXME Adapt idx_vector to allow sparse logical indexing without overflow!! - idx_vector index_vector (void) const - { return idx_vector (matrix); } + idx_vector index_vector (bool /* require_integers */ = false) const + { + return idx_vector (matrix); + } builtin_type_t builtin_type (void) const { return btyp_bool; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-bool.h --- a/libinterp/octave-value/ov-bool.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-bool.h Fri Jan 23 15:23:09 2015 -0500 @@ -72,7 +72,7 @@ octave_value do_index_op (const octave_value_list& idx, bool resize_ok = false); - idx_vector index_vector (void) const { return idx_vector (scalar); } + idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); } builtin_type_t builtin_type (void) const { return btyp_bool; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-builtin.cc --- a/libinterp/octave-value/ov-builtin.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-builtin.cc Fri Jan 23 15:23:09 2015 -0500 @@ -127,7 +127,7 @@ try { - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_builtin) retval = (*f) (args, nargout); // Do not allow null values to be returned from functions. diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-ch-mat.cc --- a/libinterp/octave-value/ov-ch-mat.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-ch-mat.cc Fri Jan 23 15:23:09 2015 -0500 @@ -42,7 +42,7 @@ template class octave_base_matrix; idx_vector -octave_char_matrix::index_vector (void) const +octave_char_matrix::index_vector (bool /* require_integers */) const { const char *p = matrix.data (); if (numel () == 1 && *p == ':') diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-ch-mat.h --- a/libinterp/octave-value/ov-ch-mat.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-ch-mat.h Fri Jan 23 15:23:09 2015 -0500 @@ -87,7 +87,7 @@ octave_base_value *empty_clone (void) const { return new octave_char_matrix (); } - idx_vector index_vector (void) const; + idx_vector index_vector (bool require_integers = false) const; builtin_type_t builtin_type (void) const { return btyp_char; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-class.cc --- a/libinterp/octave-value/ov-class.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-class.cc Fri Jan 23 15:23:09 2015 -0500 @@ -991,7 +991,7 @@ } idx_vector -octave_class::index_vector (void) const +octave_class::index_vector (bool require_integers) const { idx_vector retval; @@ -1014,7 +1014,7 @@ // add one to the value returned as the index_vector method // expects it to be one based. retval = do_binary_op (octave_value::op_add, tmp (0), - octave_value (1.0)).index_vector (); + octave_value (1.0)).index_vector (require_integers); } } else @@ -2016,33 +2016,113 @@ %!error class () */ -DEFUN (__isa_parent__, args, , +DEFUN (isa, args, , "-*- texinfo -*-\n\ -@deftypefn {Built-in Function} {} __isa_parent__ (@var{class}, @var{name})\n\ -Undocumented internal function.\n\ +@deftypefn {Function File} {} isa (@var{obj}, @var{classname})\n\ +Return true if @var{obj} is an object from the class @var{classname}.\n\ +\n\ +@var{classname} may also be one of the following class categories:\n\ +\n\ +@table @asis\n\ +@item @qcode{\"float\"}\n\ +Floating point value comprising classes @qcode{\"double\"} and\n\ +@qcode{\"single\"}.\n\ +\n\ +@item @qcode{\"integer\"}\n\ +Integer value comprising classes (u)int8, (u)int16, (u)int32, (u)int64.\n\ +\n\ +@item @qcode{\"numeric\"}\n\ +Numeric value comprising either a floating point or integer value.\n\ +@end table\n\ +\n\ +If @var{classname} is a cell array of string, a logical array of the same\n\ +size is returned, containing true for each class to which @var{obj}\n\ +belongs to.\n\ +\n\ +@seealso{class, typeinfo}\n\ @end deftypefn") { - octave_value retval = false; - - if (args.length () == 2) + octave_value retval; + + if (args.length () != 2) + { + print_usage (); + return retval; + } + + octave_value obj = args(0); // not const because of find_parent_class () + const Array cls = args(1).cellstr_value (); + if (error_state) + { + error ("isa: CLASSNAME must be a string or cell attay of strings"); + return retval; + } + + boolNDArray matches (cls.dims (), false); + const octave_idx_type n = cls.numel (); + for (octave_idx_type idx = 0; idx < n; idx++) { - octave_value cls = args(0); - octave_value nm = args(1); - - if (! error_state) - { - if (cls.find_parent_class (nm.string_value ())) - retval = true; - } - else - error ("__isa_parent__: expecting arguments to be character strings"); + const std::string cl = cls(idx); + if ((cl == "float" && obj.is_float_type ()) || + (cl == "integer" && obj.is_integer_type ()) || + (cl == "numeric" && obj.is_numeric_type ()) || + obj.class_name () == cl || obj.find_parent_class (cl)) + matches(idx) = true; } - else - print_usage (); - - return retval; + return octave_value (matches); } +/* +%!assert (isa ("char", "float"), false) +%!assert (isa (logical (1), "float"), false) +%!assert (isa (double (13), "float"), true) +%!assert (isa (single (13), "float"), true) +%!assert (isa (int8 (13), "float"), false) +%!assert (isa (int16 (13), "float"), false) +%!assert (isa (int32 (13), "float"), false) +%!assert (isa (int64 (13), "float"), false) +%!assert (isa (uint8 (13), "float"), false) +%!assert (isa (uint16 (13), "float"), false) +%!assert (isa (uint32 (13), "float"), false) +%!assert (isa (uint64 (13), "float"), false) +%!assert (isa ("char", "numeric"), false) +%!assert (isa (logical (1), "numeric"), false) +%!assert (isa (double (13), "numeric"), true) +%!assert (isa (single (13), "numeric"), true) +%!assert (isa (int8 (13), "numeric"), true) +%!assert (isa (int16 (13), "numeric"), true) +%!assert (isa (int32 (13), "numeric"), true) +%!assert (isa (int64 (13), "numeric"), true) +%!assert (isa (uint8 (13), "numeric"), true) +%!assert (isa (uint16 (13), "numeric"), true) +%!assert (isa (uint32 (13), "numeric"), true) +%!assert (isa (uint64 (13), "numeric"), true) +%!assert (isa (uint8 (13), "integer"), true) +%!assert (isa (double (13), "integer"), false) +%!assert (isa (single (13), "integer"), false) +%!assert (isa (single (13), {"integer", "float", "single"}), [false true true]) + +%!assert (isa (double (13), "double")) +%!assert (isa (single (13), "single")) +%!assert (isa (int8 (13), "int8")) +%!assert (isa (int16 (13), "int16")) +%!assert (isa (int32 (13), "int32")) +%!assert (isa (int64 (13), "int64")) +%!assert (isa (uint8 (13), "uint8")) +%!assert (isa (uint16 (13), "uint16")) +%!assert (isa (uint32 (13), "uint32")) +%!assert (isa (uint64 (13), "uint64")) +%!assert (isa ("string", "char")) +%!assert (isa (true, "logical")) +%!assert (isa (false, "logical")) +%!assert (isa ({1, 2}, "cell")) +%!assert (isa ({1, 2}, {"numeric", "integer", "cell"}), [false false true]) + +%!test +%! a.b = 1; +%! assert (isa (a, "struct")); +*/ + DEFUN (__parent_classes__, args, , "-*- texinfo -*-\n\ @deftypefn {Built-in Function} {} __parent_classes__ (@var{x})\n\ diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-class.h --- a/libinterp/octave-value/ov-class.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-class.h Fri Jan 23 15:23:09 2015 -0500 @@ -115,7 +115,7 @@ const std::list& idx, const octave_value& rhs); - idx_vector index_vector (void) const; + idx_vector index_vector (bool require_integers = false) const; dim_vector dims (void) const { return map.dims (); } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-colon.h --- a/libinterp/octave-value/ov-colon.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-colon.h Fri Jan 23 15:23:09 2015 -0500 @@ -59,7 +59,7 @@ octave_base_value *empty_clone (void) const { return new octave_magic_colon (); } - idx_vector index_vector (void) const { return idx_vector (':'); } + idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (':'); } bool is_defined (void) const { return true; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-complex.h --- a/libinterp/octave-value/ov-complex.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-complex.h Fri Jan 23 15:23:09 2015 -0500 @@ -80,7 +80,7 @@ bool resize_ok = false); // Use this to give a more specific error message - idx_vector index_vector (void) const + idx_vector index_vector (bool /* require_integers */ = false) const { error ("attempted to use a complex scalar as an index\n" " (forgot to initialize i or j?)"); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-float.h --- a/libinterp/octave-value/ov-float.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-float.h Fri Jan 23 15:23:09 2015 -0500 @@ -77,7 +77,7 @@ octave_value do_index_op (const octave_value_list& idx, bool resize_ok = false); - idx_vector index_vector (void) const { return idx_vector (scalar); } + idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); } octave_value any (int = 0) const { return (scalar != 0 && ! lo_ieee_isnan (scalar)); } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-flt-re-mat.h --- a/libinterp/octave-value/ov-flt-re-mat.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-flt-re-mat.h Fri Jan 23 15:23:09 2015 -0500 @@ -89,8 +89,10 @@ octave_base_value *try_narrowing_conversion (void); - idx_vector index_vector (void) const - { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); } + idx_vector index_vector (bool /* require_integers */ = false) const + { + return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); + } builtin_type_t builtin_type (void) const { return btyp_float; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-intx.h --- a/libinterp/octave-value/ov-intx.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-intx.h Fri Jan 23 15:23:09 2015 -0500 @@ -303,8 +303,10 @@ matrix_ref ().changesign (); } - idx_vector index_vector (void) const - { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); } + idx_vector index_vector (bool /* require_integers */ = false) const + { + return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); + } int write (octave_stream& os, int block_size, oct_data_conv::data_type output_type, int skip, @@ -606,7 +608,7 @@ scalar -= OCTAVE_INT_T (1); } - idx_vector index_vector (void) const { return idx_vector (scalar); } + idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); } int write (octave_stream& os, int block_size, oct_data_conv::data_type output_type, octave_idx_type skip, diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-lazy-idx.h --- a/libinterp/octave-value/ov-lazy-idx.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-lazy-idx.h Fri Jan 23 15:23:09 2015 -0500 @@ -59,8 +59,7 @@ octave_value full_value (void) const { return make_value (); } - idx_vector index_vector (void) const - { return index; } + idx_vector index_vector (bool /* require_integers */ = false) const { return index; } builtin_type_t builtin_type (void) const { return btyp_double; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-mex-fcn.cc --- a/libinterp/octave-value/ov-mex-fcn.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-mex-fcn.cc Fri Jan 23 15:23:09 2015 -0500 @@ -148,8 +148,10 @@ try { - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_mex_function) + retval = call_mex (have_fmex, mex_fcn_ptr, args, nargout, this); + END_PROFILER_BLOCK } catch (octave_execution_exception) diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-perm.cc --- a/libinterp/octave-value/ov-perm.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-perm.cc Fri Jan 23 15:23:09 2015 -0500 @@ -245,9 +245,9 @@ FORWARD_MATRIX_VALUE (charNDArray, char_array) idx_vector -octave_perm_matrix::index_vector (void) const +octave_perm_matrix::index_vector (bool require_integers) const { - return to_dense ().index_vector (); + return to_dense ().index_vector (require_integers); } octave_value diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-perm.h --- a/libinterp/octave-value/ov-perm.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-perm.h Fri Jan 23 15:23:09 2015 -0500 @@ -131,7 +131,7 @@ double scalar_value (bool frc_str_conv = false) const { return double_value (frc_str_conv); } - idx_vector index_vector (void) const; + idx_vector index_vector (bool require_integers = false) const; PermMatrix perm_matrix_value (void) const { return matrix; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-range.cc --- a/libinterp/octave-value/ov-range.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-range.cc Fri Jan 23 15:23:09 2015 -0500 @@ -46,7 +46,7 @@ #include "ls-utils.h" // If TRUE, allow ranges with non-integer elements as array indices. -bool Vallow_noninteger_range_as_index = false; +static bool Vallow_noninteger_range_as_index = true; DEFINE_OCTAVE_ALLOCATOR (octave_range); @@ -148,13 +148,14 @@ } idx_vector -octave_range::index_vector (void) const +octave_range::index_vector (bool require_integers) const { if (idx_cache) return *idx_cache; else { - if (! Vallow_noninteger_range_as_index + if (require_integers + || ! Vallow_noninteger_range_as_index || range.all_elements_are_ints ()) return set_idx_cache (idx_vector (range)); else @@ -690,6 +691,14 @@ The original variable value is restored when exiting the function.\n\ @end deftypefn") { + static bool warned = false; + if (! warned) + { + warned = true; + warning_with_id ("Octave:deprecated-function", + "allow_noninteger_range_as_index is obsolete and will be removed from a future version of Octave"); + } + return SET_INTERNAL_VARIABLE (allow_noninteger_range_as_index); } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-range.h --- a/libinterp/octave-value/ov-range.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-range.h Fri Jan 23 15:23:09 2015 -0500 @@ -104,7 +104,7 @@ octave_value do_index_op (const octave_value_list& idx, bool resize_ok = false); - idx_vector index_vector (void) const; + idx_vector index_vector (bool require_integers = false) const; dim_vector dims (void) const { @@ -317,7 +317,4 @@ DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA }; -// If TRUE, allow ranges with non-integer elements as array indices. -extern bool Vallow_noninteger_range_as_index; - #endif diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-re-mat.h --- a/libinterp/octave-value/ov-re-mat.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-re-mat.h Fri Jan 23 15:23:09 2015 -0500 @@ -104,7 +104,7 @@ octave_base_value *try_narrowing_conversion (void); - idx_vector index_vector (void) const + idx_vector index_vector (bool /* require_integers */ = false) const { return idx_cache ? *idx_cache : set_idx_cache (idx_vector (matrix)); } builtin_type_t builtin_type (void) const { return btyp_double; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-re-sparse.cc --- a/libinterp/octave-value/ov-re-sparse.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-re-sparse.cc Fri Jan 23 15:23:09 2015 -0500 @@ -55,7 +55,7 @@ "double"); idx_vector -octave_sparse_matrix::index_vector (void) const +octave_sparse_matrix::index_vector (bool /* require_integers */) const { if (matrix.numel () == matrix.nnz ()) return idx_vector (array_value ()); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-re-sparse.h --- a/libinterp/octave-value/ov-re-sparse.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-re-sparse.h Fri Jan 23 15:23:09 2015 -0500 @@ -92,7 +92,7 @@ octave_base_value *try_narrowing_conversion (void); - idx_vector index_vector (void) const; + idx_vector index_vector (bool require_integers = false) const; builtin_type_t builtin_type (void) const { return btyp_double; } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-scalar.h --- a/libinterp/octave-value/ov-scalar.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-scalar.h Fri Jan 23 15:23:09 2015 -0500 @@ -76,7 +76,7 @@ type_conv_info numeric_demotion_function (void) const; - idx_vector index_vector (void) const { return idx_vector (scalar); } + idx_vector index_vector (bool /* require_integers */ = false) const { return idx_vector (scalar); } octave_value any (int = 0) const { return (scalar != 0 && ! lo_ieee_isnan (scalar)); } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov-usr-fcn.cc --- a/libinterp/octave-value/ov-usr-fcn.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov-usr-fcn.cc Fri Jan 23 15:23:09 2015 -0500 @@ -149,8 +149,10 @@ frame.protect_var (tree_evaluator::statement_context); tree_evaluator::statement_context = tree_evaluator::script; - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_user_script) + cmd_list->accept (*current_evaluator); + END_PROFILER_BLOCK if (tree_return_command::returning) @@ -574,7 +576,7 @@ frame.protect_var (tree_evaluator::statement_context); tree_evaluator::statement_context = tree_evaluator::function; - BEGIN_PROFILER_BLOCK (profiler_name ()) + BEGIN_PROFILER_BLOCK (octave_user_function) if (is_special_expr ()) { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave-value/ov.h Fri Jan 23 15:23:09 2015 -0500 @@ -455,8 +455,10 @@ octave_value& assign (assign_op, const octave_value& rhs); - idx_vector index_vector (void) const - { return rep->index_vector (); } + idx_vector index_vector (bool require_integers = false) const + { + return rep->index_vector (require_integers); + } // Size. diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/octave.cc --- a/libinterp/octave.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/octave.cc Fri Jan 23 15:23:09 2015 -0500 @@ -482,25 +482,21 @@ FPS1 (octave_value (">> ")); FPS2 (octave_value ("")); FPS4 (octave_value ("")); - Fallow_noninteger_range_as_index (octave_value (true)); Fbeep_on_error (octave_value (true)); Fconfirm_recursive_rmdir (octave_value (false)); Fcrash_dumps_octave_core (octave_value (false)); Fsave_default_options (octave_value ("-mat-binary")); - Fdo_braindead_shortcircuit_evaluation (octave_value (true)); Ffixed_point_format (octave_value (true)); Fhistory_timestamp_format_string (octave_value ("%%-- %D %I:%M %p --%%")); Fpage_screen_output (octave_value (false)); Fprint_empty_dimensions (octave_value (false)); + Fstruct_levels_to_print (octave_value (0)); disable_warning ("Octave:abbreviated-property-match"); disable_warning ("Octave:fopen-file-in-path"); disable_warning ("Octave:function-name-clash"); disable_warning ("Octave:load-file-in-path"); disable_warning ("Octave:possible-matlab-short-circuit-operator"); - - // Initialized to "error" by default. - set_warning_state ("Octave:noninteger-range-as-index", "on"); } // EMBEDDED is declared int instead of bool because this function is diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/lex.h --- a/libinterp/parse-tree/lex.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/lex.h Fri Jan 23 15:23:09 2015 -0500 @@ -268,9 +268,9 @@ input_line_number (1), current_input_column (1), bracketflag (0), braceflag (0), looping (0), defining_func (0), looking_at_function_handle (0), - block_comment_nesting_level (0), token_count (0), - current_input_line (), comment_text (), help_text (), - string_text (), string_line (0), string_column (0), + block_comment_nesting_level (0), command_arg_paren_count (0), + token_count (0), current_input_line (), comment_text (), + help_text (), string_text (), string_line (0), string_column (0), fcn_file_name (), fcn_file_full_name (), looking_at_object_index (), parsed_function_name (), pending_local_variables (), symtab_context (), nesting_level (), tokens () @@ -389,6 +389,9 @@ // nestng level for blcok comments. int block_comment_nesting_level; + // Parenthesis count for command argument parsing. + int command_arg_paren_count; + // Count of tokens recognized by this lexer since initialized or // since the last reset. size_t token_count; diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/lex.ll --- a/libinterp/parse-tree/lex.ll Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/lex.ll Fri Jan 23 15:23:09 2015 -0500 @@ -43,7 +43,7 @@ } -%s COMMAND_START +%x COMMAND_START %s MATRIX_START %x INPUT_FILE_START @@ -167,7 +167,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); \ @@ -243,6 +244,27 @@ } \ while (0) +// When a command argument boundary is detected, push out the +// current argument being built. This one seems like a good +// candidate for a function call. + +#define COMMAND_ARG_FINISH \ + do \ + { \ + if (curr_lexer->string_text.empty ()) \ + break; \ + \ + int retval = curr_lexer->handle_token (curr_lexer->string_text, \ + SQ_STRING); \ + \ + curr_lexer->string_text = ""; \ + curr_lexer->command_arg_paren_count = 0; \ + \ + yyless (0); \ + \ + return retval; \ + } \ + while (0) static bool Vdisplay_tokens = false; @@ -307,54 +329,129 @@ // Help and other command-style functions. %} -{NL} { - curr_lexer->lexer_debug ("{NL}"); +%{ +// Commands can be continued on a second line using the ellipsis. +// If an argument is in construction, it is completed. +%} + +(\.\.\.){ANY_EXCEPT_NL}*{NL} { + curr_lexer->lexer_debug ("(\\.\\.\\.){ANY_EXCEPT_NL}*{NL}"); + + COMMAND_ARG_FINISH; + + curr_lexer->input_line_number++; + curr_lexer->current_input_column = 1; + + HANDLE_STRING_CONTINUATION; + } + +%{ +// Commands normally end at the end of a line or a semicolon. +%} + +({CCHAR}{ANY_EXCEPT_NL}*)?{NL} { + curr_lexer->lexer_debug ("({CCHAR}{ANY_EXCEPT_NL}*)?{NL}"); + + COMMAND_ARG_FINISH; curr_lexer->input_line_number++; curr_lexer->current_input_column = 1; - curr_lexer->looking_for_object_index = false; curr_lexer->at_beginning_of_statement = true; - curr_lexer->pop_start_state (); - return curr_lexer->count_token ('\n'); + return curr_lexer->handle_token ('\n'); + } + +[\,\;] { + curr_lexer->lexer_debug ("[\\,\\;]"); + + if (yytext[0] != ',' || curr_lexer->command_arg_paren_count == 0) + { + COMMAND_ARG_FINISH; + curr_lexer->looking_for_object_index = false; + curr_lexer->at_beginning_of_statement = true; + curr_lexer->pop_start_state (); + return curr_lexer->handle_token (yytext[0]); + } + else + curr_lexer->string_text += yytext; + + curr_lexer->current_input_column += yyleng; } -[\;\,] { - curr_lexer->lexer_debug ("[\\;\\,]"); - - curr_lexer->looking_for_object_index = false; - curr_lexer->at_beginning_of_statement = true; - - curr_lexer->pop_start_state (); - - if (strcmp (yytext, ",") == 0) - return curr_lexer->handle_token (','); - else - return curr_lexer->handle_token (';'); +%{ +// Unbalanced parentheses serve as pseudo-quotes: they are included in +// the final argument string, but they cause parentheses and quotes to +// be slurped into that argument as well. +%} + +[\(\[\{]* { + curr_lexer->lexer_debug ("[\\(\\[\\{]+"); + + curr_lexer->command_arg_paren_count += yyleng; + curr_lexer->string_text += yytext; + curr_lexer->current_input_column += yyleng; } +[\)\]\}]* { + curr_lexer->lexer_debug ("[\\)\\]\\}]+"); + + curr_lexer->command_arg_paren_count -= yyleng; + curr_lexer->string_text += yytext; + curr_lexer->current_input_column += yyleng; +} + +%{ +// Handle quoted strings. Quoted strings that are not separated by +// whitespace from other argument text are combined with that previous +// text. For instance, +// +// command 'text1'"text2" +// +// has a single argument text1text2, not two separate arguments. +// That's why we must test to see if we are in command argument mode +// when processing the end of a string. +%} + [\"\'] { curr_lexer->lexer_debug ("[\\\"\\']"); - curr_lexer->at_beginning_of_statement = false; - - curr_lexer->current_input_column++; - - curr_lexer->begin_string (yytext[0] == '"' - ? DQ_STRING_START : SQ_STRING_START); + if (curr_lexer->command_arg_paren_count == 0) + curr_lexer->begin_string (yytext[0] == '"' + ? DQ_STRING_START : SQ_STRING_START); + else + curr_lexer->string_text += yytext; + + curr_lexer->current_input_column += yyleng; } -[^#% \t\r\n\;\,\"\'][^ \t\r\n\;\,]*{S}* { - curr_lexer->lexer_debug ("[^#% \\t\\r\\n\\;\\,\\\"\\'][^ \\t\\r\\n\\;\\,]*{S}*"); - - std::string tok = strip_trailing_whitespace (yytext); - - curr_lexer->looking_for_object_index = false; - curr_lexer->at_beginning_of_statement = false; - - return curr_lexer->handle_token (tok, SQ_STRING); +%{ +// In standard command argument processing, whitespace separates +// arguments. In the presence of unbalanced parentheses, it is +// incorporated into the argument. +%} + +{S}* { + curr_lexer->lexer_debug ("{S}*"); + + if (curr_lexer->command_arg_paren_count == 0) + COMMAND_ARG_FINISH; + else + curr_lexer->string_text += yytext; + + curr_lexer->current_input_column += yyleng; + } + +%{ +// Everything else is slurped into the command arguments. +%} + +([\.]|[^#% \t\r\n\.\,\;\"\'\(\[\{\}\]\)]*) { + curr_lexer->lexer_debug ("([\\.]|[^#% \\t\\r\\n\\.\\,\\;\\\"\\'\\(\\[\\{\\}\\]\\)]*"); + + curr_lexer->string_text += yytext; + curr_lexer->current_input_column += yyleng; } {S}* { @@ -702,17 +799,20 @@ curr_lexer->pop_start_state (); - curr_lexer->looking_for_object_index = true; - curr_lexer->at_beginning_of_statement = false; - - curr_lexer->push_token (new token (DQ_STRING, - curr_lexer->string_text, - curr_lexer->string_line, - curr_lexer->string_column)); - - curr_lexer->string_text = ""; - - return curr_lexer->count_token_internal (DQ_STRING); + if (curr_lexer->start_state() != COMMAND_START) + { + curr_lexer->looking_for_object_index = true; + curr_lexer->at_beginning_of_statement = false; + + curr_lexer->push_token (new token (DQ_STRING, + curr_lexer->string_text, + curr_lexer->string_line, + curr_lexer->string_column)); + + curr_lexer->string_text = ""; + + return curr_lexer->count_token_internal (DQ_STRING); + } } \\[0-7]{1,3} { @@ -883,17 +983,20 @@ curr_lexer->pop_start_state (); - curr_lexer->looking_for_object_index = true; - curr_lexer->at_beginning_of_statement = false; - - curr_lexer->push_token (new token (SQ_STRING, - curr_lexer->string_text, - curr_lexer->string_line, - curr_lexer->string_column)); - - curr_lexer->string_text = ""; - - return curr_lexer->count_token_internal (SQ_STRING); + if (curr_lexer->start_state() != COMMAND_START) + { + curr_lexer->looking_for_object_index = true; + curr_lexer->at_beginning_of_statement = false; + + curr_lexer->push_token (new token (SQ_STRING, + curr_lexer->string_text, + curr_lexer->string_line, + curr_lexer->string_column)); + + curr_lexer->string_text = ""; + + return curr_lexer->count_token_internal (SQ_STRING); + } } [^\'\n\r]+ { @@ -1889,6 +1992,7 @@ fcn_file_full_name = ""; looking_at_object_index.clear (); looking_at_object_index.push_front (false); + command_arg_paren_count = 0; while (! parsed_function_name.empty ()) parsed_function_name.pop (); @@ -3294,12 +3398,7 @@ if (! input_buf.empty ()) status = input_buf.copy_chunk (buf, max_size); else - { - status = YY_NULL; - - if (! input_buf.at_eof ()) - fatal_error ("octave_base_lexer::fill_flex_buffer failed"); - } + status = YY_NULL; return status; } @@ -3315,12 +3414,8 @@ if (! input_buf.empty ()) status = input_buf.copy_chunk (buf, max_size); else - { - status = YY_NULL; - - if (! input_buf.at_eof ()) - fatal_error ("octave_base_lexer::fill_flex_buffer failed"); - } + status = YY_NULL; return status; } + diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/oct-parse.in.yy --- a/libinterp/parse-tree/oct-parse.in.yy Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/oct-parse.in.yy Fri Jan 23 15:23:09 2015 -0500 @@ -940,7 +940,7 @@ if_cmd_list1 : expression stmt_begin opt_sep opt_list { - $1->mark_braindead_shortcircuit (lexer.fcn_file_full_name); + $1->mark_braindead_shortcircuit (); $$ = parser.start_if_command ($1, $4); } @@ -953,7 +953,7 @@ elseif_clause : ELSEIF stash_comment opt_sep expression stmt_begin opt_sep opt_list { - $4->mark_braindead_shortcircuit (lexer.fcn_file_full_name); + $4->mark_braindead_shortcircuit (); $$ = parser.make_elseif_clause ($1, $4, $7, $2); } @@ -1015,7 +1015,7 @@ loop_command : WHILE stash_comment expression stmt_begin opt_sep opt_list END { - $3->mark_braindead_shortcircuit (lexer.fcn_file_full_name); + $3->mark_braindead_shortcircuit (); if (! ($$ = parser.make_while_command ($1, $3, $6, $7, $2))) { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/octave.gperf diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-binop.cc --- a/libinterp/parse-tree/pt-binop.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-binop.cc Fri Jan 23 15:23:09 2015 -0500 @@ -36,7 +36,7 @@ // TRUE means we mark | and & expressions for braindead short-circuit // behavior. -static bool Vdo_braindead_shortcircuit_evaluation; +static bool Vdo_braindead_shortcircuit_evaluation = true; // Binary expressions. @@ -54,6 +54,16 @@ return retval; } +void +tree_binary_expression::matlab_style_short_circuit_warning (const char *op) +{ + warning_with_id ("Octave:possible-matlab-short-circuit-operator", + "Matlab-style short-circuit operation performed for operator %s", + op); + + braindead_shortcircuit_warning_issued = true; +} + octave_value tree_binary_expression::rvalue1 (int) { @@ -83,6 +93,7 @@ { if (etype == octave_value::op_el_or) { + matlab_style_short_circuit_warning ("|"); result = true; goto done; } @@ -90,7 +101,10 @@ else { if (etype == octave_value::op_el_and) - goto done; + { + matlab_style_short_circuit_warning ("&"); + goto done; + } } if (op_rhs) @@ -121,7 +135,7 @@ if (! error_state && b.is_defined ()) { - BEGIN_PROFILER_BLOCK ("binary " + oper ()) + BEGIN_PROFILER_BLOCK (tree_binary_expression) // Note: The profiler does not catch the braindead // short-circuit evaluation code above, but that should be @@ -298,6 +312,14 @@ The original variable value is restored when exiting the function.\n\ @end deftypefn") { + static bool warned = false; + if (! warned) + { + warned = true; + warning_with_id ("Octave:deprecated-function", + "do_braindead_shortcircuit_evaluation is obsolete and will be removed from a future version of Octave"); + } + return SET_INTERNAL_VARIABLE (do_braindead_shortcircuit_evaluation); } diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-binop.h --- a/libinterp/parse-tree/pt-binop.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-binop.h Fri Jan 23 15:23:09 2015 -0500 @@ -46,14 +46,16 @@ octave_value::binary_op t = octave_value::unknown_binary_op) : tree_expression (l, c), op_lhs (0), op_rhs (0), etype (t), - eligible_for_braindead_shortcircuit (false) { } + eligible_for_braindead_shortcircuit (false), + braindead_shortcircuit_warning_issued (false) { } tree_binary_expression (tree_expression *a, tree_expression *b, int l = -1, int c = -1, octave_value::binary_op t = octave_value::unknown_binary_op) : tree_expression (l, c), op_lhs (a), op_rhs (b), etype (t), - eligible_for_braindead_shortcircuit (false) { } + eligible_for_braindead_shortcircuit (false), + braindead_shortcircuit_warning_issued (false) { } ~tree_binary_expression (void) { @@ -61,23 +63,14 @@ delete op_rhs; } - void mark_braindead_shortcircuit (const std::string& file) + void mark_braindead_shortcircuit (void) { if (etype == octave_value::op_el_and || etype == octave_value::op_el_or) { - if (file.empty ()) - warning_with_id ("Octave:possible-matlab-short-circuit-operator", - "possible Matlab-style short-circuit operator at line %d, column %d", - line (), column ()); - else - warning_with_id ("Octave:possible-matlab-short-circuit-operator", - "%s: possible Matlab-style short-circuit operator at line %d, column %d", - file.c_str (), line (), column ()); - eligible_for_braindead_shortcircuit = true; - op_lhs->mark_braindead_shortcircuit (file); - op_rhs->mark_braindead_shortcircuit (file); + op_lhs->mark_braindead_shortcircuit (); + op_rhs->mark_braindead_shortcircuit (); } } @@ -107,6 +100,9 @@ void accept (tree_walker& tw); + std::string profiler_name (void) const { return "binary " + oper (); } + + protected: // The operands for the expression. @@ -122,6 +118,12 @@ // or WHILE statement. bool eligible_for_braindead_shortcircuit; + // TRUE if we have already issued a warning about short circuiting + // for this operator. + bool braindead_shortcircuit_warning_issued; + + void matlab_style_short_circuit_warning (const char *op); + // No copying! tree_binary_expression (const tree_binary_expression&); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-eval.cc --- a/libinterp/parse-tree/pt-eval.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-eval.cc Fri Jan 23 15:23:09 2015 -0500 @@ -57,6 +57,8 @@ bool tree_evaluator::debug_mode = false; +bool tree_evaluator::quiet_breakpoint_flag = false; + tree_evaluator::stmt_list_type tree_evaluator::statement_context = tree_evaluator::other; @@ -694,13 +696,12 @@ if (! Vdebugging) octave_call_stack::set_location (stmt.line (), stmt.column ()); - // FIXME: we need to distinguish functions from scripts - // to get this right. if ((statement_context == script - && ((Vecho_executing_commands & ECHO_SCRIPTS) - || (Vecho_executing_commands & ECHO_FUNCTIONS))) + && ((Vecho_executing_commands & ECHO_SCRIPTS + && octave_call_stack::all_scripts ()) + || Vecho_executing_commands & ECHO_FUNCTIONS)) || (statement_context == function - && (Vecho_executing_commands & ECHO_FUNCTIONS))) + && Vecho_executing_commands & ECHO_FUNCTIONS)) stmt.echo_code (); } @@ -925,6 +926,7 @@ err.assign ("message", last_error_message ()); err.assign ("identifier", last_error_id ()); + err.assign ("stack", last_error_stack ()); if (! error_state) ult.assign (octave_value::op_asn_eq, err); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-eval.h --- a/libinterp/parse-tree/pt-eval.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-eval.h Fri Jan 23 15:23:09 2015 -0500 @@ -149,6 +149,8 @@ static bool debug_mode; + static bool quiet_breakpoint_flag; + // Possible types of evaluation contexts. enum stmt_list_type { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-exp.h --- a/libinterp/parse-tree/pt-exp.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-exp.h Fri Jan 23 15:23:09 2015 -0500 @@ -100,7 +100,7 @@ virtual std::string original_text (void) const; - virtual void mark_braindead_shortcircuit (const std::string&) { } + virtual void mark_braindead_shortcircuit (void) { } tree_expression *mark_in_parens (void) { diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-pr-code.cc --- a/libinterp/parse-tree/pt-pr-code.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-pr-code.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1218,6 +1218,9 @@ os << alt_txt; else { + // Print prefix for blank lines. + indent (); + os << "\n"; beginning_of_line = true; @@ -1268,7 +1271,13 @@ if (c == '\n') { if (prev_char_was_newline) - os << "##"; + { + printed_something = true; + + indent (); + + os << "##"; + } newline (); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-unop.cc --- a/libinterp/parse-tree/pt-unop.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-unop.cc Fri Jan 23 15:23:09 2015 -0500 @@ -73,7 +73,7 @@ if (! error_state) { - BEGIN_PROFILER_BLOCK ("prefix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_prefix_expression) ref.do_unary_op (etype); @@ -89,7 +89,7 @@ if (! error_state && val.is_defined ()) { - BEGIN_PROFILER_BLOCK ("prefix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_prefix_expression) // Attempt to do the operation in-place if it is unshared // (a temporary expression). @@ -162,8 +162,10 @@ { retval = ref.value (); - BEGIN_PROFILER_BLOCK ("postfix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_postfix_expression) + ref.do_unary_op (etype); + END_PROFILER_BLOCK } } @@ -173,7 +175,7 @@ if (! error_state && val.is_defined ()) { - BEGIN_PROFILER_BLOCK ("postfix " + oper ()) + BEGIN_PROFILER_BLOCK (tree_postfix_expression) retval = ::do_unary_op (etype, val); diff -r 75a671fcdd73 -r 844448ae53f3 libinterp/parse-tree/pt-unop.h --- a/libinterp/parse-tree/pt-unop.h Fri Jan 23 15:21:25 2015 -0500 +++ b/libinterp/parse-tree/pt-unop.h Fri Jan 23 15:23:09 2015 -0500 @@ -108,6 +108,9 @@ void accept (tree_walker& tw); + std::string profiler_name (void) const { return "prefix " + oper (); } + + private: // No copying! @@ -145,6 +148,8 @@ void accept (tree_walker& tw); + std::string profiler_name (void) const { return "postfix " + oper (); } + private: // No copying! diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/Array-b.cc --- a/liboctave/array/Array-b.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/Array-b.cc Fri Jan 23 15:23:09 2015 -0500 @@ -52,7 +52,8 @@ // FIXME: This is essentially a simple bucket sort. // Can it be efficiently done by std::partition? OCTAVE_LOCAL_BUFFER (octave_idx_type, jdx, nel); - octave_idx_type k = 0, l = 0; + octave_idx_type k = 0; + octave_idx_type l = 0; for (octave_idx_type i = 0; i < nel; i++) { if (data[i] == desc) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/Array-util.cc --- a/liboctave/array/Array-util.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/Array-util.cc Fri Jan 23 15:23:09 2015 -0500 @@ -423,9 +423,11 @@ dim_vector zero_dims_inquire (const Array& ia, const dim_vector& rhdv) { - int ial = ia.length (), rhdvl = rhdv.length (); + int ial = ia.length (); + int rhdvl = rhdv.length (); dim_vector rdv = dim_vector::alloc (ial); - bool *scalar = new bool [ial], *colon = new bool [ial]; + bool *scalar = new bool [ial]; + bool *colon = new bool [ial]; // Mark scalars and colons, count non-scalar indices. int nonsc = 0; bool all_colons = true; @@ -479,7 +481,8 @@ zero_dims_inquire (const idx_vector& i, const idx_vector& j, const dim_vector& rhdv) { - bool icol = i.is_colon (), jcol = j.is_colon (); + bool icol = i.is_colon (); + bool jcol = j.is_colon (); dim_vector rdv; if (icol && jcol && rhdv.length () == 2) { @@ -563,10 +566,12 @@ else if (all_ranges && clen != 0) { // All ranges case - the result is a range. - octave_idx_type start = 0, step = 0; + octave_idx_type start = 0; + octave_idx_type step = 0; for (octave_idx_type i = len - 1; i >= 0; i--) { - octave_idx_type xstart = idxa(i)(0), xstep = idxa(i)(1) - xstart; + octave_idx_type xstart = idxa(i)(0); + octave_idx_type xstep = idxa(i)(1) - xstart; start = start * dvx(i) + xstart; step = step * dvx(i) + xstep; } @@ -597,7 +602,8 @@ Array ind2sub (const dim_vector& dv, const idx_vector& idx) { - octave_idx_type len = idx.length (0), n = dv.length (); + octave_idx_type len = idx.length (0); + octave_idx_type n = dv.length (); Array retval (dim_vector (n, 1)); octave_idx_type numel = dv.numel (); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/Array.cc --- a/liboctave/array/Array.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/Array.cc Fri Jan 23 15:23:09 2015 -0500 @@ -270,7 +270,9 @@ Array Array::page (octave_idx_type k) const { - octave_idx_type r = dimensions(0), c = dimensions (1), p = r*c; + octave_idx_type r = dimensions(0); + octave_idx_type c = dimensions(1); + octave_idx_type p = r*c; #ifdef BOUNDS_CHECKING if (k < 0 || k > dimensions.numel (2)) gripe_index_out_of_range (3, 3, k+1, dimensions.numel (2)); @@ -393,7 +395,8 @@ { if (lev == 0) { - octave_idx_type step = stride[0], len = dim[0]; + octave_idx_type step = stride[0]; + octave_idx_type len = dim[0]; if (step == 1) { copy_or_memcpy (len, src, dest); @@ -411,7 +414,8 @@ dest = blk_trans (src, dest, dim[1], dim[0]); else { - octave_idx_type step = stride[lev], len = dim[lev]; + octave_idx_type step = stride[lev]; + octave_idx_type len = dim[lev]; for (octave_idx_type i = 0, j = 0; i < len; i++, j+= step) dest = do_permute (src + i * step, dest, lev-1); } @@ -568,7 +572,8 @@ dest += idx[0].index (src, dim[0], dest); else { - octave_idx_type nn = idx[lev].length (dim[lev]), d = cdim[lev]; + octave_idx_type nn = idx[lev].length (dim[lev]); + octave_idx_type d = cdim[lev]; for (octave_idx_type i = 0; i < nn; i++) dest = do_index (src + d*idx[lev].xelem (i), dest, lev-1); } @@ -584,7 +589,8 @@ src += idx[0].assign (src, dim[0], dest); else { - octave_idx_type nn = idx[lev].length (dim[lev]), d = cdim[lev]; + octave_idx_type nn = idx[lev].length (dim[lev]); + octave_idx_type d = cdim[lev]; for (octave_idx_type i = 0; i < nn; i++) src = do_assign (src, dest + d*idx[lev].xelem (i), lev-1); } @@ -600,7 +606,8 @@ idx[0].fill (val, dim[0], dest); else { - octave_idx_type nn = idx[lev].length (dim[lev]), d = cdim[lev]; + octave_idx_type nn = idx[lev].length (dim[lev]); + octave_idx_type d = cdim[lev]; for (octave_idx_type i = 0; i < nn; i++) do_fill (val, dest + d*idx[lev].xelem (i), lev-1); } @@ -655,7 +662,8 @@ sext = cext + n; dext = sext + n; - octave_idx_type sld = ld, dld = ld; + octave_idx_type sld = ld; + octave_idx_type dld = ld; for (int j = 0; j < n; j++) { cext[j] = std::min (ndv(i+j), odv(i+j)); @@ -680,7 +688,9 @@ } else { - octave_idx_type sd = sext[lev-1], dd = dext[lev-1], k; + octave_idx_type sd = sext[lev-1]; + octave_idx_type dd = dext[lev-1]; + octave_idx_type k; for (k = 0; k < cext[lev]; k++) do_resize_fill (src + k * sd, dest + k * dd, rfv, lev - 1); @@ -771,7 +781,8 @@ { // Get dimensions, allowing Fortran indexing in the 2nd dim. dim_vector dv = dimensions.redim (2); - octave_idx_type r = dv(0), c = dv(1); + octave_idx_type r = dv(0); + octave_idx_type c = dv(1); Array retval; if (i.is_colon () && j.is_colon ()) @@ -786,7 +797,9 @@ if (j.extent (c) != c) gripe_index_out_of_range (2, 2, j.extent (c), c); // throws - octave_idx_type n = numel (), il = i.length (r), jl = j.length (c); + octave_idx_type n = numel (); + octave_idx_type il = i.length (r); + octave_idx_type jl = j.length (c); idx_vector ii (i); @@ -957,7 +970,8 @@ Array tmp = Array (dv); T *dest = tmp.fortran_vec (); - octave_idx_type n0 = std::min (n, nx), n1 = n - n0; + octave_idx_type n0 = std::min (n, nx); + octave_idx_type n1 = n - n0; copy_or_memcpy (n0, data (), dest); fill_or_memset (n1, rfv, dest + n0); @@ -975,14 +989,17 @@ { if (r >= 0 && c >= 0 && ndims () == 2) { - octave_idx_type rx = rows (), cx = columns (); + octave_idx_type rx = rows (); + octave_idx_type cx = columns (); if (r != rx || c != cx) { Array tmp = Array (dim_vector (r, c)); T *dest = tmp.fortran_vec (); - octave_idx_type r0 = std::min (r, rx), r1 = r - r0; - octave_idx_type c0 = std::min (c, cx), c1 = c - c0; + octave_idx_type r0 = std::min (r, rx); + octave_idx_type r1 = r - r0; + octave_idx_type c0 = std::min (c, cx); + octave_idx_type c1 = c - c0; const T *src = data (); if (r == rx) { @@ -1042,7 +1059,8 @@ Array tmp = *this; if (resize_ok) { - octave_idx_type n = numel (), nx = i.extent (n); + octave_idx_type n = numel (); + octave_idx_type nx = i.extent (n); if (n != nx) { if (i.is_scalar ()) @@ -1067,8 +1085,10 @@ if (resize_ok) { dim_vector dv = dimensions.redim (2); - octave_idx_type r = dv(0), c = dv(1); - octave_idx_type rx = i.extent (r), cx = j.extent (c); + octave_idx_type r = dv(0); + octave_idx_type c = dv(1); + octave_idx_type rx = i.extent (r); + octave_idx_type cx = j.extent (c); if (r != rx || c != cx) { if (i.is_scalar () && j.is_scalar ()) @@ -1119,7 +1139,8 @@ void Array::assign (const idx_vector& i, const Array& rhs, const T& rfv) { - octave_idx_type n = numel (), rhl = rhs.numel (); + octave_idx_type n = numel (); + octave_idx_type rhl = rhs.numel (); if (rhl == 1 || i.length (n) == rhl) { @@ -1190,7 +1211,8 @@ } bool isfill = rhs.numel () == 1; - octave_idx_type il = i.length (rdv(0)), jl = j.length (rdv(1)); + octave_idx_type il = i.length (rdv(0)); + octave_idx_type jl = j.length (rdv(1)); rhdv.chop_all_singletons (); bool match = (isfill || (rhdv.length () == 2 && il == rhdv(0) && jl == rhdv(1))); @@ -1228,7 +1250,9 @@ else { // The actual work. - octave_idx_type n = numel (), r = dv (0), c = dv (1); + octave_idx_type n = numel (); + octave_idx_type r = dv(0); + octave_idx_type c = dv(1); idx_vector ii (i); const T* src = rhs.data (); @@ -1299,10 +1323,13 @@ } // Check whether LHS and RHS match, up to singleton dims. - bool match = true, all_colons = true, isfill = rhs.numel () == 1; + bool match = true; + bool all_colons = true; + bool isfill = rhs.numel () == 1; rhdv.chop_all_singletons (); - int j = 0, rhdvl = rhdv.length (); + int j = 0; + int rhdvl = rhdv.length (); for (int i = 0; i < ial; i++) { all_colons = all_colons && ia(i).is_colon_equiv (rdv(i)); @@ -1427,7 +1454,9 @@ if (i.is_cont_range (n, l, u)) { // Special case deleting a contiguous range. - octave_idx_type nd = n + l - u, dl = 1, du = 1; + octave_idx_type nd = n + l - u; + octave_idx_type dl = 1; + octave_idx_type du = 1; dim_vector rdv = dimensions; rdv(dim) = nd; for (int k = 0; k < dim; k++) dl *= dimensions(k); @@ -1776,7 +1805,8 @@ { // copy and partition out NaNs. // FIXME: impact on integer types noticeable? - octave_idx_type kl = 0, ku = ns; + octave_idx_type kl = 0; + octave_idx_type ku = ns; for (octave_idx_type i = 0; i < ns; i++) { T tmp = ov[i]; @@ -1820,7 +1850,8 @@ // gather and partition out NaNs. // FIXME: impact on integer types noticeable? - octave_idx_type kl = 0, ku = ns; + octave_idx_type kl = 0; + octave_idx_type ku = ns; for (octave_idx_type i = 0; i < ns; i++) { T tmp = ov[i*stride + offset]; @@ -1898,7 +1929,8 @@ { // copy and partition out NaNs. // FIXME: impact on integer types noticeable? - octave_idx_type kl = 0, ku = ns; + octave_idx_type kl = 0; + octave_idx_type ku = ns; for (octave_idx_type i = 0; i < ns; i++) { T tmp = ov[i]; @@ -1956,7 +1988,8 @@ // gather and partition out NaNs. // FIXME: impact on integer types noticeable? - octave_idx_type kl = 0, ku = ns; + octave_idx_type kl = 0; + octave_idx_type ku = ns; for (octave_idx_type i = 0; i < ns; i++) { T tmp = ov[i*stride + offset]; @@ -2056,7 +2089,8 @@ octave_sort lsort (safe_comparator (mode, *this, true)); - octave_idx_type r = rows (), c = cols (); + octave_idx_type r = rows (); + octave_idx_type c = cols (); idx = Array (dim_vector (r, 1)); @@ -2072,7 +2106,8 @@ { octave_sort lsort; - octave_idx_type r = rows (), c = cols (); + octave_idx_type r = rows (); + octave_idx_type c = cols (); if (r <= 1 || c == 0) return mode ? mode : ASCENDING; @@ -2086,7 +2121,8 @@ octave_idx_type i; for (i = 0; i < cols (); i++) { - T l = elem (0, i), u = elem (rows () - 1, i); + T l = elem (0, i); + T u = elem (rows () - 1, i); if (compare (l, u)) { if (mode == DESCENDING) @@ -2150,7 +2186,8 @@ Array Array::lookup (const Array& values, sortmode mode) const { - octave_idx_type n = numel (), nval = values.numel (); + octave_idx_type n = numel (); + octave_idx_type nval = values.numel (); octave_sort lsort; Array idx (values.dims ()); @@ -2194,7 +2231,8 @@ Array::nnz (void) const { const T *src = data (); - octave_idx_type nel = nelem (), retval = 0; + octave_idx_type nel = nelem (); + octave_idx_type retval = 0; const T zero = T (); for (octave_idx_type i = 0; i < nel; i++) if (src[i] != zero) @@ -2233,7 +2271,8 @@ if (backward) { // Do the search as a series of successive single-element searches. - octave_idx_type k = 0, l = nel - 1; + octave_idx_type k = 0; + octave_idx_type l = nel - 1; for (; k < n; k++) { for (; l >= 0 && src[l] == zero; l--) ; @@ -2250,7 +2289,8 @@ else { // Do the search as a series of successive single-element searches. - octave_idx_type k = 0, l = 0; + octave_idx_type k = 0; + octave_idx_type l = 0; for (; k < n; k++) { for (; l != nel && src[l] == zero; l++) ; @@ -2369,7 +2409,8 @@ for (octave_idx_type j = 0; j < iter; j++) { - octave_idx_type kl = 0, ku = ns; + octave_idx_type kl = 0; + octave_idx_type ku = ns; if (stride == 1) { diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/CDiagMatrix.cc --- a/liboctave/array/CDiagMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/CDiagMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -448,7 +448,8 @@ ComplexDiagMatrix c (a_nr, b_nc); - octave_idx_type len = c.length (), lenm = len < a_nc ? len : a_nc; + octave_idx_type len = c.length (); + octave_idx_type lenm = len < a_nc ? len : a_nc; for (octave_idx_type i = 0; i < lenm; i++) c.dgxelem (i) = a.dgelem (i) * b.dgelem (i); @@ -549,7 +550,8 @@ ComplexDiagMatrix::rcond (void) const { ColumnVector av = extract_diag (0).map (std::abs); - double amx = av.max (), amn = av.min (); + double amx = av.max (); + double amn = av.min (); return amx == 0 ? 0.0 : amn / amx; } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/CMatrix.cc --- a/liboctave/array/CMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/CMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -3765,8 +3765,10 @@ { ComplexMatrix retval; - bool tra = transa != blas_no_trans, trb = transb != blas_no_trans; - bool cja = transa == blas_conj_trans, cjb = transb == blas_conj_trans; + bool tra = transa != blas_no_trans; + bool trb = transb != blas_no_trans; + bool cja = transa == blas_conj_trans; + bool cjb = transb == blas_conj_trans; octave_idx_type a_nr = tra ? a.cols () : a.rows (); octave_idx_type a_nc = tra ? a.rows () : a.cols (); @@ -3822,8 +3824,10 @@ } else { - octave_idx_type lda = a.rows (), tda = a.cols (); - octave_idx_type ldb = b.rows (), tdb = b.cols (); + octave_idx_type lda = a.rows (); + octave_idx_type tda = a.cols (); + octave_idx_type ldb = b.rows (); + octave_idx_type tdb = b.cols (); retval = ComplexMatrix (a_nr, b_nc, 0.0); Complex *c = retval.fortran_vec (); @@ -3902,7 +3906,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (c, m (i, j)); + result(i, j) = xmin (c, m(i, j)); } return result; @@ -3922,7 +3926,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (m (i, j), c); + result(i, j) = xmin (m(i, j), c); } return result; @@ -3951,7 +3955,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a (i, j)) != 0.0 || std::imag (b (i, j)) != 0.0) + if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) { columns_are_real_only = 0; break; @@ -3961,14 +3965,14 @@ if (columns_are_real_only) { for (octave_idx_type i = 0; i < nr; i++) - result (i, j) = xmin (std::real (a (i, j)), std::real (b (i, j))); + result(i, j) = xmin (std::real (a(i, j)), std::real (b(i, j))); } else { for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (a (i, j), b (i, j)); + result(i, j) = xmin (a(i, j), b(i, j)); } } } @@ -3990,7 +3994,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (c, m (i, j)); + result(i, j) = xmax (c, m(i, j)); } return result; @@ -4010,7 +4014,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (m (i, j), c); + result(i, j) = xmax (m(i, j), c); } return result; @@ -4039,7 +4043,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a (i, j)) != 0.0 || std::imag (b (i, j)) != 0.0) + if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) { columns_are_real_only = 0; break; @@ -4051,7 +4055,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (std::real (a (i, j)), std::real (b (i, j))); + result(i, j) = xmax (std::real (a(i, j)), std::real (b(i, j))); } } else @@ -4059,7 +4063,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (a (i, j), b (i, j)); + result(i, j) = xmax (a(i, j), b(i, j)); } } } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/CSparse.cc --- a/liboctave/array/CSparse.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/CSparse.cc Fri Jan 23 15:23:09 2015 -0500 @@ -160,7 +160,8 @@ SparseComplexMatrix::SparseComplexMatrix (const ComplexDiagMatrix& a) : MSparse (a.rows (), a.cols (), a.length ()) { - octave_idx_type j = 0, l = a.length (); + octave_idx_type j = 0; + octave_idx_type l = a.length (); for (octave_idx_type i = 0; i < l; i++) { cidx (i) = j; @@ -348,7 +349,7 @@ found[i] = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = cidx(j); i < cidx(j+1); i++) + for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) if (found[ridx (i)] == -j) found[ridx (i)] = -j - 1; @@ -505,7 +506,7 @@ found[i] = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = cidx(j); i < cidx(j+1); i++) + for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) if (found[ridx (i)] == -j) found[ridx (i)] = -j - 1; @@ -777,7 +778,8 @@ if (calccond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nr; i++) { double tmp = std::abs (v[i]); @@ -1321,7 +1323,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = std::abs (data (i)); @@ -1412,7 +1415,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = std::abs (data (i)); @@ -1473,7 +1477,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nr; i++) { double tmp = std::abs (data (i)); @@ -1564,7 +1569,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = std::abs (data (i)); @@ -4320,7 +4326,7 @@ { for (octave_idx_type i = 0; i < b_nr; i++) - Bx[i] = b (i,j); + Bx[i] = b(i,j); F77_XFCN (zgttrs, ZGTTRS, (F77_CONST_CHAR_ARG2 (&job, 1), @@ -5307,7 +5313,7 @@ { for (octave_idx_type i = 0; i < b_nr; i++) - Bx[i] = b (i,j); + Bx[i] = b(i,j); F77_XFCN (zpbtrs, ZPBTRS, (F77_CONST_CHAR_ARG2 (&job, 1), @@ -6589,7 +6595,7 @@ for (octave_idx_type j = 0; j < b_nc; j++) { for (octave_idx_type i = 0; i < b_nr; i++) - Bx[i] = b (i,j); + Bx[i] = b(i,j); status = UMFPACK_ZNAME (solve) (UMFPACK_A, Ap, Ai, diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/MDiagArray2.cc --- a/liboctave/array/MDiagArray2.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/MDiagArray2.cc Fri Jan 23 15:23:09 2015 -0500 @@ -38,7 +38,8 @@ bool retval = this->rows () == this->cols (); if (retval) { - octave_idx_type len = this->length (), i = 0; + octave_idx_type len = this->length (); + octave_idx_type i = 0; for (; i < len; i++) if (DiagArray2::elem (i, i) != val) break; retval = i == len; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/MatrixType.cc --- a/liboctave/array/MatrixType.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/MatrixType.cc Fri Jan 23 15:23:09 2015 -0500 @@ -91,7 +91,8 @@ { for (octave_idx_type i = 0; i < j; i++) { - double aij = a.elem (i,j), aji = a.elem (j,i); + double aij = a.elem (i,j); + double aji = a.elem (j,i); lower = lower && (aij == zero); upper = upper && (aji == zero); hermitian = hermitian && (aij == aji @@ -149,7 +150,8 @@ { for (octave_idx_type i = 0; i < j; i++) { - std::complex aij = a.elem (i,j), aji = a.elem (j,i); + std::complex aij = a.elem (i,j); + std::complex aji = a.elem (j,i); lower = lower && (aij == zero); upper = upper && (aji == zero); hermitian = hermitian && (aij == std::conj (aji) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/PermMatrix.cc --- a/liboctave/array/PermMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/PermMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -119,7 +119,8 @@ for (octave_idx_type i = 0; i < len; i++) { - octave_idx_type j = p[i], k = q[i]; + octave_idx_type j = p[i]; + octave_idx_type k = q[i]; if (j != i) { p[k] = p[i]; @@ -191,7 +192,8 @@ PermMatrix operator *(const PermMatrix& a, const PermMatrix& b) { - const Array ia = a.pvec (), ib = b.pvec (); + const Array ia = a.pvec (); + const Array ib = b.pvec (); PermMatrix r; octave_idx_type n = a.columns (); if (n != b.rows ()) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/Sparse.cc --- a/liboctave/array/Sparse.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/Sparse.cc Fri Jan 23 15:23:09 2015 -0500 @@ -144,7 +144,8 @@ { if (remove_zeros) { - octave_idx_type i = 0, k = 0; + octave_idx_type i = 0; + octave_idx_type k = 0; for (octave_idx_type j = 1; j <= ncols; j++) { octave_idx_type u = c[j]; @@ -303,7 +304,9 @@ dimensions = dim_vector (nr, nc); - octave_idx_type n = a.numel (), rl = r.length (nr), cl = c.length (nc); + octave_idx_type n = a.numel (); + octave_idx_type rl = r.length (nr); + octave_idx_type cl = c.length (nc); bool a_scalar = n == 1; if (a_scalar) { @@ -324,9 +327,9 @@ if (n == 1 && a(0) != T ()) { change_capacity (nzm > 1 ? nzm : 1); - xcidx(0) = 0; - xridx(0) = r(0); - xdata(0) = a(0); + xcidx (0) = 0; + xridx (0) = r(0); + xdata (0) = a(0); for (octave_idx_type j = 0; j < nc; j++) xcidx (j+1) = j >= c(0); @@ -361,7 +364,8 @@ octave_quit (); - octave_idx_type k = -1, l = -1; + octave_idx_type k = -1; + octave_idx_type l = -1; if (sum_terms) { @@ -395,8 +399,10 @@ } else { - idx_vector rr = r, cc = c; - const octave_idx_type *rd = rr.raw (), *cd = cc.raw (); + idx_vector rr = r; + idx_vector cc = c; + const octave_idx_type *rd = rr.raw (); + const octave_idx_type *cd = cc.raw (); OCTAVE_LOCAL_BUFFER_INIT (octave_idx_type, ci, nc+1, 0); ci[0] = 0; // Bin counts of column indices. @@ -425,7 +431,8 @@ for (octave_idx_type j = 0; j < nc; j++) { std::sort (sidx + ci[j], sidx + ci[j+1]); - octave_idx_type l = -1, nzj = 0; + octave_idx_type l = -1; + octave_idx_type nzj = 0; // Count. for (octave_idx_type i = ci[j]; i < ci[j+1]; i++) { @@ -490,15 +497,16 @@ octave_quit (); - const octave_idx_type *rd = rs.raw (), *rdi = rsi.data (); + const octave_idx_type *rd = rs.raw (); + const octave_idx_type *rdi = rsi.data (); // Count unique indices. octave_idx_type new_nz = 1; for (octave_idx_type i = 1; i < n; i++) new_nz += rd[i-1] != rd[i]; // Allocate result. change_capacity (nzm > new_nz ? nzm : new_nz); - xcidx(0) = 0; - xcidx(1) = new_nz; + xcidx (0) = 0; + xcidx (1) = new_nz; octave_idx_type *rri = ridx (); T *rrd = data (); @@ -537,8 +545,10 @@ } else { - idx_vector rr = r, cc = c; - const octave_idx_type *rd = rr.raw (), *cd = cc.raw (); + idx_vector rr = r; + idx_vector cc = c; + const octave_idx_type *rd = rr.raw (); + const octave_idx_type *cd = cc.raw (); OCTAVE_LOCAL_BUFFER_INIT (octave_idx_type, ci, nc+1, 0); ci[0] = 0; // Bin counts of column indices. @@ -572,7 +582,8 @@ for (octave_idx_type j = 0; j < nc; j++) { std::sort (spairs + ci[j], spairs + ci[j+1]); - octave_idx_type l = -1, nzj = 0; + octave_idx_type l = -1; + octave_idx_type nzj = 0; // Count. for (octave_idx_type i = ci[j]; i < ci[j+1]; i++) { @@ -905,7 +916,8 @@ void Sparse::resize1 (octave_idx_type n) { - octave_idx_type nr = rows (), nc = cols (); + octave_idx_type nr = rows (); + octave_idx_type nc = cols (); if (nr == 0) resize (1, std::max (nc, n)); @@ -954,7 +966,8 @@ if (r < rows ()) { - octave_idx_type i = 0, k = 0; + octave_idx_type i = 0; + octave_idx_type k = 0; for (octave_idx_type j = 1; j <= rep->ncols; j++) { octave_idx_type u = xcidx (j); @@ -1187,7 +1200,9 @@ OCTAVE_LOCAL_BUFFER (T, data_new, nz); idx_vector sidx = idx.sorted (true); const octave_idx_type *sj = sidx.raw (); - octave_idx_type sl = sidx.length (nel), nz_new = 0, j = 0; + octave_idx_type sl = sidx.length (nel); + octave_idx_type nz_new = 0; + octave_idx_type j = 0; for (octave_idx_type i = 0; i < nz; i++) { octave_idx_type r = tmp.ridx (i); @@ -1270,8 +1285,8 @@ else { const Sparse tmp = *this; - octave_idx_type lbi = tmp.cidx(lb); - octave_idx_type ubi = tmp.cidx(ub); + octave_idx_type lbi = tmp.cidx (lb); + octave_idx_type ubi = tmp.cidx (ub); octave_idx_type new_nz = nz - (ubi - lbi); *this = Sparse (nr, nc - (ub - lb), new_nz); @@ -1314,20 +1329,20 @@ tmpl.nnz () + tmpu.nnz ()); for (octave_idx_type j = 0, k = 0; j < nc; j++) { - for (octave_idx_type i = tmpl.cidx(j); i < tmpl.cidx(j+1); + for (octave_idx_type i = tmpl.cidx (j); i < tmpl.cidx (j+1); i++) { - xdata(k) = tmpl.data(i); - xridx(k++) = tmpl.ridx(i); + xdata (k) = tmpl.data (i); + xridx (k++) = tmpl.ridx (i); } - for (octave_idx_type i = tmpu.cidx(j); i < tmpu.cidx(j+1); + for (octave_idx_type i = tmpu.cidx (j); i < tmpu.cidx (j+1); i++) { - xdata(k) = tmpu.data(i); - xridx(k++) = tmpu.ridx(i) + lb; + xdata (k) = tmpu.data (i); + xridx (k++) = tmpu.ridx (i) + lb; } - xcidx(j+1) = k; + xcidx (j+1) = k; } } } @@ -1492,7 +1507,8 @@ ? idx.as_array ().transpose () : idx.as_array ()); - octave_idx_type new_nr = idxa.rows (), new_nc = idxa.cols (); + octave_idx_type new_nr = idxa.rows (); + octave_idx_type new_nc = idxa.cols (); // Lookup. // FIXME: Could specialize for sorted idx? @@ -1540,7 +1556,9 @@ else if (idx.is_cont_range (nel, lb, ub)) { // Special-case a contiguous range. - octave_idx_type lbi = cidx (lb), ubi = cidx (ub), new_nz = ubi - lbi; + octave_idx_type lbi = cidx (lb); + octave_idx_type ubi = cidx (ub); + octave_idx_type new_nz = ubi - lbi; retval = Sparse (1, ub - lb, new_nz); copy_or_memcpy (new_nz, data () + lbi, retval.data ()); fill_or_memset (new_nz, static_cast (0), @@ -1625,7 +1643,9 @@ else if (idx_j.is_cont_range (nc, lb, ub)) { // Special-case a contiguous range. - octave_idx_type lbi = cidx (lb), ubi = cidx (ub), new_nz = ubi - lbi; + octave_idx_type lbi = cidx (lb); + octave_idx_type ubi = cidx (ub); + octave_idx_type new_nz = ubi - lbi; retval = Sparse (nr, ub - lb, new_nz); copy_or_memcpy (new_nz, data () + lbi, retval.data ()); copy_or_memcpy (new_nz, ridx () + lbi, retval.ridx ()); @@ -1756,7 +1776,8 @@ octave_idx_type jj = idx_j(j); octave_idx_type lj = cidx (jj); octave_idx_type nzj = cidx (jj+1) - cidx (jj); - octave_idx_type li = retval.xcidx (j), uj = lj + nzj - 1; + octave_idx_type li = retval.xcidx (j); + octave_idx_type uj = lj + nzj - 1; for (octave_idx_type i = 0; i < nzj; i++) { retval.xdata (li + i) = data (uj - i); // Copy in reverse order. @@ -1863,7 +1884,8 @@ // Look-up indices first. octave_idx_type li = lblookup (ridx (), nz, lb); octave_idx_type ui = lblookup (ridx (), nz, ub); - octave_idx_type rnz = rhs.nnz (), new_nz = nz - (ui - li) + rnz; + octave_idx_type rnz = rhs.nnz (); + octave_idx_type new_nz = nz - (ui - li) + rnz; if (new_nz >= nz && new_nz <= capacity ()) { @@ -2043,8 +2065,10 @@ else if (idx_j.is_cont_range (nc, lb, ub)) { // Special-case a contiguous range. - octave_idx_type li = cidx (lb), ui = cidx (ub); - octave_idx_type rnz = rhs.nnz (), new_nz = nz - (ui - li) + rnz; + octave_idx_type li = cidx (lb); + octave_idx_type ui = cidx (ub); + octave_idx_type rnz = rhs.nnz (); + octave_idx_type new_nz = nz - (ui - li) + rnz; if (new_nz >= nz && new_nz <= capacity ()) { @@ -2133,7 +2157,9 @@ // Merge columns. for (octave_idx_type i = 0; i < nc; i++) { - octave_idx_type l = xcidx (i), u = xcidx (i+1), j = jsav[i]; + octave_idx_type l = xcidx (i); + octave_idx_type u = xcidx (i+1); + octave_idx_type j = jsav[i]; if (j >= 0) { // from rhs @@ -2609,7 +2635,8 @@ if (spi.is_empty ()) continue; - octave_idx_type kl = spi.cidx (j), ku = spi.cidx (j+1); + octave_idx_type kl = spi.cidx (j); + octave_idx_type ku = spi.cidx (j+1); for (octave_idx_type k = kl; k < ku; k++, l++) { retval.xridx (l) = spi.ridx (k) + rcum; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/Sparse.h --- a/liboctave/array/Sparse.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/Sparse.h Fri Jan 23 15:23:09 2015 -0500 @@ -300,13 +300,15 @@ T& xelem (octave_idx_type n) { - octave_idx_type i = n % rows (), j = n / rows (); + octave_idx_type i = n % rows (); + octave_idx_type j = n / rows (); return xelem (i, j); } T xelem (octave_idx_type n) const { - octave_idx_type i = n % rows (), j = n / rows (); + octave_idx_type i = n % rows (); + octave_idx_type j = n / rows (); return xelem (i, j); } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/boolSparse.cc --- a/liboctave/array/boolSparse.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/boolSparse.cc Fri Jan 23 15:23:09 2015 -0500 @@ -143,7 +143,9 @@ SparseBoolMatrix::any (int dim) const { Sparse retval; - octave_idx_type nr = rows (), nc = cols (), nz = nnz (); + octave_idx_type nr = rows (); + octave_idx_type nc = cols (); + octave_idx_type nz = nnz (); if (dim == -1) dim = (nr == 1 && nc != 1) ? 1 : 0; @@ -188,7 +190,9 @@ SparseBoolMatrix::sum (int dim) const { Sparse retval; - octave_idx_type nr = rows (), nc = cols (), nz = nnz (); + octave_idx_type nr = rows (); + octave_idx_type nc = cols (); + octave_idx_type nz = nnz (); if (dim == -1) dim = (nr == 1 && nc != 1) ? 1 : 0; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/dDiagMatrix.cc --- a/liboctave/array/dDiagMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/dDiagMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -329,7 +329,8 @@ DiagMatrix c (a_nr, b_nc); - octave_idx_type len = c.length (), lenm = len < a_nc ? len : a_nc; + octave_idx_type len = c.length (); + octave_idx_type lenm = len < a_nc ? len : a_nc; for (octave_idx_type i = 0; i < lenm; i++) c.dgxelem (i) = a.dgelem (i) * b.dgelem (i); @@ -364,7 +365,8 @@ DiagMatrix::rcond (void) const { ColumnVector av = extract_diag (0).map (fabs); - double amx = av.max (), amn = av.min (); + double amx = av.max (); + double amn = av.min (); return amx == 0 ? 0.0 : amn / amx; } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/dMatrix.cc --- a/liboctave/array/dMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/dMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -2012,7 +2012,9 @@ static Matrix stack_complex_matrix (const ComplexMatrix& cm) { - octave_idx_type m = cm.rows (), n = cm.cols (), nel = m*n; + octave_idx_type m = cm.rows (); + octave_idx_type n = cm.cols (); + octave_idx_type nel = m*n; Matrix retval (m, 2*n); const Complex *cmd = cm.data (); double *rd = retval.fortran_vec (); @@ -2027,7 +2029,9 @@ static ComplexMatrix unstack_complex_matrix (const Matrix& sm) { - octave_idx_type m = sm.rows (), n = sm.cols () / 2, nel = m*n; + octave_idx_type m = sm.rows (); + octave_idx_type n = sm.cols () / 2; + octave_idx_type nel = m*n; ComplexMatrix retval (m, n); const double *smd = sm.data (); Complex *rd = retval.fortran_vec (); @@ -3180,7 +3184,8 @@ { Matrix retval; - bool tra = transa != blas_no_trans, trb = transb != blas_no_trans; + bool tra = transa != blas_no_trans; + bool trb = transb != blas_no_trans; octave_idx_type a_nr = tra ? a.cols () : a.rows (); octave_idx_type a_nc = tra ? a.rows () : a.cols (); @@ -3215,8 +3220,10 @@ } else { - octave_idx_type lda = a.rows (), tda = a.cols (); - octave_idx_type ldb = b.rows (), tdb = b.cols (); + octave_idx_type lda = a.rows (); + octave_idx_type tda = a.cols (); + octave_idx_type ldb = b.rows (); + octave_idx_type tdb = b.cols (); retval = Matrix (a_nr, b_nc); double *c = retval.fortran_vec (); @@ -3285,7 +3292,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (d, m (i, j)); + result(i, j) = xmin (d, m(i, j)); } return result; @@ -3305,7 +3312,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (m (i, j), d); + result(i, j) = xmin (m(i, j), d); } return result; @@ -3332,7 +3339,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (a (i, j), b (i, j)); + result(i, j) = xmin (a(i, j), b(i, j)); } return result; @@ -3352,7 +3359,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (d, m (i, j)); + result(i, j) = xmax (d, m(i, j)); } return result; @@ -3372,7 +3379,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (m (i, j), d); + result(i, j) = xmax (m(i, j), d); } return result; @@ -3399,7 +3406,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (a (i, j), b (i, j)); + result(i, j) = xmax (a(i, j), b(i, j)); } return result; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/dSparse.cc --- a/liboctave/array/dSparse.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/dSparse.cc Fri Jan 23 15:23:09 2015 -0500 @@ -165,7 +165,8 @@ SparseMatrix::SparseMatrix (const DiagMatrix& a) : MSparse (a.rows (), a.cols (), a.length ()) { - octave_idx_type j = 0, l = a.length (); + octave_idx_type j = 0; + octave_idx_type l = a.length (); for (octave_idx_type i = 0; i < l; i++) { cidx (i) = j; @@ -360,7 +361,7 @@ found[i] = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = cidx(j); i < cidx(j+1); i++) + for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) if (found[ridx (i)] == -j) found[ridx (i)] = -j - 1; @@ -511,7 +512,7 @@ found[i] = 0; for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = cidx(j); i < cidx(j+1); i++) + for (octave_idx_type i = cidx (j); i < cidx (j+1); i++) if (found[ridx (i)] == -j) found[ridx (i)] = -j - 1; @@ -877,7 +878,8 @@ if (calccond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nr; i++) { double tmp = fabs (v[i]); @@ -1412,7 +1414,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = fabs (data (i)); @@ -1502,7 +1505,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = fabs (data (i)); @@ -1562,7 +1566,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = fabs (data (i)); @@ -1652,7 +1657,8 @@ if (calc_cond) { - double dmax = 0., dmin = octave_Inf; + double dmax = 0.; + double dmin = octave_Inf; for (octave_idx_type i = 0; i < nm; i++) { double tmp = fabs (data (i)); @@ -4418,7 +4424,7 @@ for (octave_idx_type i = 0; i < b_nr; i++) { - Complex c = b (i,j); + Complex c = b(i,j); Bx[i] = std::real (c); Bz[i] = std::imag (c); } @@ -5175,7 +5181,7 @@ { for (octave_idx_type i = 0; i < b_nr; i++) { - Complex c = b (i,j); + Complex c = b(i,j); Bx[i] = std::real (c); Bz[i] = std::imag (c); } @@ -5325,7 +5331,7 @@ { for (octave_idx_type i = 0; i < nr; i++) { - Complex c = b (i, j); + Complex c = b(i, j); Bx[i] = std::real (c); Bz[i] = std::imag (c); } @@ -5480,7 +5486,7 @@ for (octave_idx_type i = 0; i < b_nr; i++) { - Complex c = b (i,j); + Complex c = b(i,j); Bx[i] = std::real (c); Bz[i] = std::imag (c); } @@ -6496,7 +6502,7 @@ { for (octave_idx_type i = 0; i < b_nr; i++) { - Complex c = b (i,j); + Complex c = b(i,j); Bx[i] = std::real (c); Bz[i] = std::imag (c); } @@ -6751,7 +6757,7 @@ { for (octave_idx_type i = 0; i < b_nr; i++) { - Complex c = b (i,j); + Complex c = b(i,j); Bx[i] = std::real (c); Bz[i] = std::imag (c); } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/dSparse.h --- a/liboctave/array/dSparse.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/dSparse.h Fri Jan 23 15:23:09 2015 -0500 @@ -120,10 +120,13 @@ friend OCTAVE_API SparseMatrix real (const SparseComplexMatrix& a); friend OCTAVE_API SparseMatrix imag (const SparseComplexMatrix& a); - friend OCTAVE_API SparseMatrix atan2 (const double& x, const SparseMatrix& y); - friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, const double& y); + friend OCTAVE_API SparseMatrix atan2 (const double& x, const SparseMatrix& y) + GCC_ATTR_DEPRECATED ; + friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, const double& y) + GCC_ATTR_DEPRECATED ; friend OCTAVE_API SparseMatrix atan2 (const SparseMatrix& x, - const SparseMatrix& y); + const SparseMatrix& y) + GCC_ATTR_DEPRECATED ; SparseMatrix transpose (void) const { diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/dim-vector.cc --- a/liboctave/array/dim-vector.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/dim-vector.cc Fri Jan 23 15:23:09 2015 -0500 @@ -176,7 +176,8 @@ bool dim_vector::concat (const dim_vector& dvb, int dim) { - int orig_nd = ndims (), ndb = dvb.ndims (); + int orig_nd = ndims (); + int ndb = dvb.ndims (); int new_nd = dim < ndb ? ndb : dim + 1; if (new_nd > orig_nd) resize (new_nd, 1); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/fCDiagMatrix.cc --- a/liboctave/array/fCDiagMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/fCDiagMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -452,7 +452,8 @@ FloatComplexDiagMatrix c (a_nr, b_nc); - octave_idx_type len = c.length (), lenm = len < a_nc ? len : a_nc; + octave_idx_type len = c.length (); + octave_idx_type lenm = len < a_nc ? len : a_nc; for (octave_idx_type i = 0; i < lenm; i++) c.dgxelem (i) = a.dgelem (i) * b.dgelem (i); @@ -553,7 +554,8 @@ FloatComplexDiagMatrix::rcond (void) const { FloatColumnVector av = extract_diag (0).map (std::abs); - float amx = av.max (), amn = av.min (); + float amx = av.max (); + float amn = av.min (); return amx == 0 ? 0.0f : amn / amx; } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/fCMatrix.cc --- a/liboctave/array/fCMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/fCMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -3789,8 +3789,10 @@ { FloatComplexMatrix retval; - bool tra = transa != blas_no_trans, trb = transb != blas_no_trans; - bool cja = transa == blas_conj_trans, cjb = transb == blas_conj_trans; + bool tra = transa != blas_no_trans; + bool trb = transb != blas_no_trans; + bool cja = transa == blas_conj_trans; + bool cjb = transb == blas_conj_trans; octave_idx_type a_nr = tra ? a.cols () : a.rows (); octave_idx_type a_nc = tra ? a.rows () : a.cols (); @@ -3846,8 +3848,10 @@ } else { - octave_idx_type lda = a.rows (), tda = a.cols (); - octave_idx_type ldb = b.rows (), tdb = b.cols (); + octave_idx_type lda = a.rows (); + octave_idx_type tda = a.cols (); + octave_idx_type ldb = b.rows (); + octave_idx_type tdb = b.cols (); retval = FloatComplexMatrix (a_nr, b_nc, 0.0); FloatComplex *c = retval.fortran_vec (); @@ -3927,7 +3931,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (c, m (i, j)); + result(i, j) = xmin (c, m(i, j)); } return result; @@ -3947,7 +3951,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (m (i, j), c); + result(i, j) = xmin (m(i, j), c); } return result; @@ -3976,7 +3980,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a (i, j)) != 0.0 || std::imag (b (i, j)) != 0.0) + if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) { columns_are_real_only = 0; break; @@ -3986,14 +3990,14 @@ if (columns_are_real_only) { for (octave_idx_type i = 0; i < nr; i++) - result (i, j) = xmin (std::real (a (i, j)), std::real (b (i, j))); + result(i, j) = xmin (std::real (a(i, j)), std::real (b(i, j))); } else { for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (a (i, j), b (i, j)); + result(i, j) = xmin (a(i, j), b(i, j)); } } } @@ -4015,7 +4019,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (c, m (i, j)); + result(i, j) = xmax (c, m(i, j)); } return result; @@ -4035,7 +4039,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (m (i, j), c); + result(i, j) = xmax (m(i, j), c); } return result; @@ -4064,7 +4068,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - if (std::imag (a (i, j)) != 0.0 || std::imag (b (i, j)) != 0.0) + if (std::imag (a(i, j)) != 0.0 || std::imag (b(i, j)) != 0.0) { columns_are_real_only = 0; break; @@ -4076,7 +4080,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (std::real (a (i, j)), std::real (b (i, j))); + result(i, j) = xmax (std::real (a(i, j)), std::real (b(i, j))); } } else @@ -4084,7 +4088,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (a (i, j), b (i, j)); + result(i, j) = xmax (a(i, j), b(i, j)); } } } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/fDiagMatrix.cc --- a/liboctave/array/fDiagMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/fDiagMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -329,7 +329,8 @@ FloatDiagMatrix c (a_nr, b_nc); - octave_idx_type len = c.length (), lenm = len < a_nc ? len : a_nc; + octave_idx_type len = c.length (); + octave_idx_type lenm = len < a_nc ? len : a_nc; for (octave_idx_type i = 0; i < lenm; i++) c.dgxelem (i) = a.dgelem (i) * b.dgelem (i); @@ -364,7 +365,8 @@ FloatDiagMatrix::rcond (void) const { FloatColumnVector av = extract_diag (0).map (fabsf); - float amx = av.max (), amn = av.min (); + float amx = av.max (); + float amn = av.min (); return amx == 0 ? 0.0f : amn / amx; } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/fMatrix.cc --- a/liboctave/array/fMatrix.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/fMatrix.cc Fri Jan 23 15:23:09 2015 -0500 @@ -2026,7 +2026,9 @@ static FloatMatrix stack_complex_matrix (const FloatComplexMatrix& cm) { - octave_idx_type m = cm.rows (), n = cm.cols (), nel = m*n; + octave_idx_type m = cm.rows (); + octave_idx_type n = cm.cols (); + octave_idx_type nel = m*n; FloatMatrix retval (m, 2*n); const FloatComplex *cmd = cm.data (); float *rd = retval.fortran_vec (); @@ -2041,7 +2043,9 @@ static FloatComplexMatrix unstack_complex_matrix (const FloatMatrix& sm) { - octave_idx_type m = sm.rows (), n = sm.cols () / 2, nel = m*n; + octave_idx_type m = sm.rows (); + octave_idx_type n = sm.cols () / 2; + octave_idx_type nel = m*n; FloatComplexMatrix retval (m, n); const float *smd = sm.data (); FloatComplex *rd = retval.fortran_vec (); @@ -3197,7 +3201,8 @@ { FloatMatrix retval; - bool tra = transa != blas_no_trans, trb = transb != blas_no_trans; + bool tra = transa != blas_no_trans; + bool trb = transb != blas_no_trans; octave_idx_type a_nr = tra ? a.cols () : a.rows (); octave_idx_type a_nc = tra ? a.rows () : a.cols (); @@ -3232,8 +3237,10 @@ } else { - octave_idx_type lda = a.rows (), tda = a.cols (); - octave_idx_type ldb = b.rows (), tdb = b.cols (); + octave_idx_type lda = a.rows (); + octave_idx_type tda = a.cols (); + octave_idx_type ldb = b.rows (); + octave_idx_type tdb = b.cols (); retval = FloatMatrix (a_nr, b_nc); float *c = retval.fortran_vec (); @@ -3302,7 +3309,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (d, m (i, j)); + result(i, j) = xmin (d, m(i, j)); } return result; @@ -3322,7 +3329,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (m (i, j), d); + result(i, j) = xmin (m(i, j), d); } return result; @@ -3349,7 +3356,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmin (a (i, j), b (i, j)); + result(i, j) = xmin (a(i, j), b(i, j)); } return result; @@ -3369,7 +3376,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (d, m (i, j)); + result(i, j) = xmax (d, m(i, j)); } return result; @@ -3389,7 +3396,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (m (i, j), d); + result(i, j) = xmax (m(i, j), d); } return result; @@ -3416,7 +3423,7 @@ for (octave_idx_type i = 0; i < nr; i++) { octave_quit (); - result (i, j) = xmax (a (i, j), b (i, j)); + result(i, j) = xmax (a(i, j), b(i, j)); } return result; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/idx-vector.cc --- a/liboctave/array/idx-vector.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/idx-vector.cc Fri Jan 23 15:23:09 2015 -0500 @@ -440,7 +440,7 @@ octave_idx_type nr = bnda.rows (); for (octave_idx_type j = 0; j < nc; j++) - for (octave_idx_type i = bnda.cidx(j); i < bnda.cidx(j+1); i++) + for (octave_idx_type i = bnda.cidx (j); i < bnda.cidx (j+1); i++) if (bnda.data (i)) d[k++] = j * nr + bnda.ridx (i); @@ -595,7 +595,8 @@ for (octave_idx_type i = 0; i < len; i++) { - octave_idx_type j = data[i], k = cnt[j]++; + octave_idx_type j = data[i]; + octave_idx_type k = cnt[j]++; new_data[k] = j; idx_data[k] = i; } @@ -836,7 +837,8 @@ { // (i:k:end,:) reduces to a range if i <= k and k divides n. idx_range_rep * r = dynamic_cast (rep); - octave_idx_type s = r->get_start (), l = r->length (n); + octave_idx_type s = r->get_start (); + octave_idx_type l = r->length (n); octave_idx_type t = r->get_step (); if (l*t == n) { @@ -860,7 +862,8 @@ idx_range_rep * rj = dynamic_cast (j.rep); if (rj->get_step () == 1) { - octave_idx_type sj = rj->get_start (), lj = rj->length (nj); + octave_idx_type sj = rj->get_start (); + octave_idx_type lj = rj->length (nj); *this = new idx_range_rep (sj * n, lj * n, 1, DIRECT); reduced = true; } @@ -873,7 +876,8 @@ idx_scalar_rep * r = dynamic_cast (rep); idx_range_rep * rj = dynamic_cast (j.rep); octave_idx_type k = r->get_data (); - octave_idx_type sj = rj->get_start (), lj = rj->length (nj); + octave_idx_type sj = rj->get_start (); + octave_idx_type lj = rj->length (nj); octave_idx_type tj = rj->get_step (); *this = new idx_range_rep (n * sj + k, lj, n * tj, DIRECT); reduced = true; @@ -885,10 +889,12 @@ // (i:k:end,p:q) reduces to a range if i <= k and k divides n. // (ones (1, m), ones (1, n)) reduces to (ones (1, m*n)) idx_range_rep * r = dynamic_cast (rep); - octave_idx_type s = r->get_start (), l = r->length (n); + octave_idx_type s = r->get_start (); + octave_idx_type l = r->length (n); octave_idx_type t = r->get_step (); idx_range_rep * rj = dynamic_cast (j.rep); - octave_idx_type sj = rj->get_start (), lj = rj->length (nj); + octave_idx_type sj = rj->get_start (); + octave_idx_type lj = rj->length (nj); octave_idx_type tj = rj->get_step (); if ((l*t == n && tj == 1) || (t == 0 && tj == 0)) { @@ -922,7 +928,8 @@ // (i:d:j,k) reduces to a range. idx_range_rep * r = dynamic_cast (rep); idx_scalar_rep * rj = dynamic_cast (j.rep); - octave_idx_type s = r->get_start (), l = r->length (nj); + octave_idx_type s = r->get_start (); + octave_idx_type l = r->length (nj); octave_idx_type t = r->get_step (); octave_idx_type k = rj->get_data (); *this = new idx_range_rep (n * k + s, l, t, DIRECT); @@ -989,7 +996,8 @@ case class_mask: { idx_mask_rep * r = dynamic_cast (rep); - octave_idx_type ext = r->extent (0), len = r->length (0); + octave_idx_type ext = r->extent (0); + octave_idx_type len = r->length (0); if (ext == len) { l = 0; @@ -1062,7 +1070,8 @@ case class_range: { idx_range_rep * r = dynamic_cast (rep); - octave_idx_type start = r->get_start (), step = r->get_step (); + octave_idx_type start = r->get_start (); + octave_idx_type step = r->get_step (); octave_idx_type i, j; if (step == 1) for (i = start, j = start + len; i < j; i++) *data++ = i; @@ -1116,7 +1125,8 @@ if (idx_class () == class_mask) { idx_mask_rep * r = dynamic_cast (rep); - octave_idx_type nz = r->length (0), ext = r->extent (0); + octave_idx_type nz = r->length (0); + octave_idx_type ext = r->extent (0); Array mask (dim_vector (n, 1)); const bool *data = r->get_data (); bool *ndata = mask.fortran_vec (); @@ -1207,7 +1217,8 @@ { idx_mask_rep * r = dynamic_cast (rep); const bool *data = r->get_data (); - octave_idx_type ext = r->extent (0), len = r->length (0); + octave_idx_type ext = r->extent (0); + octave_idx_type len = r->length (0); octave_idx_type *idata = new octave_idx_type [len]; for (octave_idx_type i = 0, j = 0; i < ext; i++) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/array/idx-vector.h --- a/liboctave/array/idx-vector.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/array/idx-vector.h Fri Jan 23 15:23:09 2015 -0500 @@ -637,7 +637,8 @@ case class_range: { idx_range_rep * r = dynamic_cast (rep); - octave_idx_type start = r->get_start (), step = r->get_step (); + octave_idx_type start = r->get_start (); + octave_idx_type step = r->get_step (); const T *ssrc = src + start; if (step == 1) copy_or_memcpy (len, ssrc, dest); @@ -710,7 +711,8 @@ case class_range: { idx_range_rep * r = dynamic_cast (rep); - octave_idx_type start = r->get_start (), step = r->get_step (); + octave_idx_type start = r->get_start (); + octave_idx_type step = r->get_step (); T *sdest = dest + start; if (step == 1) copy_or_memcpy (len, src, sdest); @@ -781,7 +783,8 @@ case class_range: { idx_range_rep * r = dynamic_cast (rep); - octave_idx_type start = r->get_start (), step = r->get_step (); + octave_idx_type start = r->get_start (); + octave_idx_type step = r->get_step (); T *sdest = dest + start; if (step == 1) std::fill (sdest, sdest + len, val); @@ -850,7 +853,8 @@ case class_range: { idx_range_rep * r = dynamic_cast (rep); - octave_idx_type start = r->get_start (), step = r->get_step (); + octave_idx_type start = r->get_start (); + octave_idx_type step = r->get_step (); octave_idx_type i, j; if (step == 1) for (i = start, j = start + len; i < j; i++) body (i); @@ -921,7 +925,8 @@ case class_range: { idx_range_rep * r = dynamic_cast (rep); - octave_idx_type start = r->get_start (), step = r->get_step (); + octave_idx_type start = r->get_start (); + octave_idx_type step = r->get_step (); octave_idx_type i, j; if (step == 1) for (i = start, j = start + len; i < j && body (i); i++) ; @@ -954,7 +959,8 @@ { idx_mask_rep * r = dynamic_cast (rep); const bool *data = r->get_data (); - octave_idx_type ext = r->extent (0), j = 0; + octave_idx_type ext = r->extent (0); + octave_idx_type j = 0; for (octave_idx_type i = 0; i < ext; i++) { if (data[i]) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/CmplxLU.cc --- a/liboctave/numeric/CmplxLU.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/CmplxLU.cc Fri Jan 23 15:23:09 2015 -0500 @@ -100,7 +100,8 @@ if (u.length () == m && v.length () == n) { - ComplexColumnVector utmp = u, vtmp = v; + ComplexColumnVector utmp = u; + ComplexColumnVector vtmp = v; F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); } @@ -124,7 +125,8 @@ { for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - ComplexColumnVector utmp = u.column (i), vtmp = v.column (i); + ComplexColumnVector utmp = u.column (i); + ComplexColumnVector vtmp = v.column (i); F77_XFCN (zlu1up, ZLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); @@ -149,7 +151,8 @@ if (u.length () == m && v.length () == n) { - ComplexColumnVector utmp = u, vtmp = v; + ComplexColumnVector utmp = u; + ComplexColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (Complex, w, m); for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (), @@ -180,7 +183,8 @@ for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - ComplexColumnVector utmp = u.column (i), vtmp = v.column (i); + ComplexColumnVector utmp = u.column (i); + ComplexColumnVector vtmp = v.column (i); F77_XFCN (zlup1up, ZLUP1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, ipvt.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/CmplxQR.cc --- a/liboctave/numeric/CmplxQR.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/CmplxQR.cc Fri Jan 23 15:23:09 2015 -0500 @@ -137,7 +137,8 @@ void ComplexQR::form (octave_idx_type n, ComplexMatrix& afact, Complex *tau, qr_type_t qr_type) { - octave_idx_type m = afact.rows (), min_mn = std::min (m, n); + octave_idx_type m = afact.rows (); + octave_idx_type min_mn = std::min (m, n); octave_idx_type info; if (qr_type == qr_type_raw) @@ -213,7 +214,8 @@ if (u.length () == m && v.length () == n) { - ComplexColumnVector utmp = u, vtmp = v; + ComplexColumnVector utmp = u; + ComplexColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (Complex, w, k); OCTAVE_LOCAL_BUFFER (double, rw, k); F77_XFCN (zqr1up, ZQR1UP, (m, n, k, q.fortran_vec (), @@ -238,7 +240,8 @@ OCTAVE_LOCAL_BUFFER (double, rw, k); for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - ComplexColumnVector utmp = u.column (i), vtmp = v.column (i); + ComplexColumnVector utmp = u.column (i); + ComplexColumnVector vtmp = v.column (i); F77_XFCN (zqr1up, ZQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/DASPK-opts.in --- a/liboctave/numeric/DASPK-opts.in Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/DASPK-opts.in Fri Jan 23 15:23:09 2015 -0500 @@ -212,7 +212,7 @@ in the equation set. This option is required by the -@qcode{compute consistent initial condition\"} and +@qcode{\"compute consistent initial condition\"} and @qcode{\"exclude algebraic variables from error test\"} options. END_DOC_ITEM diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/base-qr.cc --- a/liboctave/numeric/base-qr.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/base-qr.cc Fri Jan 23 15:23:09 2015 -0500 @@ -30,8 +30,10 @@ base_qr::base_qr (const qr_type& q_arg, const qr_type& r_arg) : q (q_arg), r (r_arg) { - octave_idx_type q_nr = q.rows (), q_nc = q.columns (); - octave_idx_type r_nr = r.rows (), r_nc = r.columns (); + octave_idx_type q_nr = q.rows (); + octave_idx_type q_nc = q.columns (); + octave_idx_type r_nr = r.rows (); + octave_idx_type r_nc = r.columns (); if (! (q_nc == r_nr && (q_nr == q_nc || (q_nr > q_nc && r_nr == r_nc)))) { diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/bsxfun-defs.cc --- a/liboctave/numeric/bsxfun-defs.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/bsxfun-defs.cc Fri Jan 23 15:23:09 2015 -0500 @@ -41,14 +41,16 @@ void (*op_vs) (size_t, R *, const X *, Y)) { int nd = std::max (x.ndims (), y.ndims ()); - dim_vector dvx = x.dims ().redim (nd), dvy = y.dims ().redim (nd); + dim_vector dvx = x.dims ().redim (nd); + dim_vector dvy = y.dims ().redim (nd); // Construct the result dimensions. dim_vector dvr; dvr.resize (nd); for (int i = 0; i < nd; i++) { - octave_idx_type xk = dvx(i), yk = dvy(i); + octave_idx_type xk = dvx(i); + octave_idx_type yk = dvy(i); if (xk == 1) dvr(i) = yk; else if (yk == 1 || xk == yk) @@ -84,7 +86,8 @@ else { // Determine the type of the low-level loop. - bool xsing = false, ysing = false; + bool xsing = false; + bool ysing = false; if (ldr == 1) { xsing = dvx(start) == 1; @@ -95,7 +98,8 @@ start++; } } - dim_vector cdvx = dvx.cumulative (), cdvy = dvy.cumulative (); + dim_vector cdvx = dvx.cumulative (); + dim_vector cdvy = dvy.cumulative (); // Nullify singleton dims to achieve a spread effect. for (int i = std::max (start, octave_idx_type (1)); i < nd; i++) { @@ -139,7 +143,8 @@ void (*op_vv) (size_t, R *, const X *), void (*op_vs) (size_t, R *, X)) { - dim_vector dvr = r.dims (), dvx = x.dims (); + dim_vector dvr = r.dims (); + dim_vector dvx = x.dims (); octave_idx_type nd = r.ndims (); dvx.redim (nd); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/bsxfun.h --- a/liboctave/numeric/bsxfun.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/bsxfun.h Fri Jan 23 15:23:09 2015 -0500 @@ -38,7 +38,8 @@ { for (int i = 0; i < std::min (dx.length (), dy.length ()); i++) { - octave_idx_type xk = dx(i), yk = dy(i); + octave_idx_type xk = dx(i); + octave_idx_type yk = dy(i); // Check the three conditions for valid bsxfun dims if (! ( (xk == yk) || (xk == 1 && yk > 1) || (xk > 1 && yk == 1))) return false; @@ -59,13 +60,15 @@ is_valid_inplace_bsxfun (const std::string& name, const dim_vector& dr, const dim_vector& dx) { - octave_idx_type drl = dr.length (), dxl = dx.length (); + octave_idx_type drl = dr.length (); + octave_idx_type dxl = dx.length (); if (drl < dxl) return false; for (int i = 0; i < drl; i++) { - octave_idx_type rk = dr(i), xk = dx(i); + octave_idx_type rk = dr(i); + octave_idx_type xk = dx(i); // Only two valid canditions to check; can't stretch rk if (! ( (rk == xk) || (rk > 1 && xk == 1))) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/dbleLU.cc --- a/liboctave/numeric/dbleLU.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/dbleLU.cc Fri Jan 23 15:23:09 2015 -0500 @@ -99,7 +99,8 @@ if (u.length () == m && v.length () == n) { - ColumnVector utmp = u, vtmp = v; + ColumnVector utmp = u; + ColumnVector vtmp = v; F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); } @@ -123,7 +124,8 @@ { for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - ColumnVector utmp = u.column (i), vtmp = v.column (i); + ColumnVector utmp = u.column (i); + ColumnVector vtmp = v.column (i); F77_XFCN (dlu1up, DLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); @@ -147,7 +149,8 @@ if (u.length () == m && v.length () == n) { - ColumnVector utmp = u, vtmp = v; + ColumnVector utmp = u; + ColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (double, w, m); for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (), @@ -178,7 +181,8 @@ for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - ColumnVector utmp = u.column (i), vtmp = v.column (i); + ColumnVector utmp = u.column (i); + ColumnVector vtmp = v.column (i); F77_XFCN (dlup1up, DLUP1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, ipvt.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/dbleQR.cc --- a/liboctave/numeric/dbleQR.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/dbleQR.cc Fri Jan 23 15:23:09 2015 -0500 @@ -138,7 +138,8 @@ void QR::form (octave_idx_type n, Matrix& afact, double *tau, qr_type_t qr_type) { - octave_idx_type m = afact.rows (), min_mn = std::min (m, n); + octave_idx_type m = afact.rows (); + octave_idx_type min_mn = std::min (m, n); octave_idx_type info; if (qr_type == qr_type_raw) @@ -214,7 +215,8 @@ if (u.length () == m && v.length () == n) { - ColumnVector utmp = u, vtmp = v; + ColumnVector utmp = u; + ColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (double, w, 2*k); F77_XFCN (dqr1up, DQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k, @@ -236,7 +238,8 @@ OCTAVE_LOCAL_BUFFER (double, w, 2*k); for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - ColumnVector utmp = u.column (i), vtmp = v.column (i); + ColumnVector utmp = u.column (i); + ColumnVector vtmp = v.column (i); F77_XFCN (dqr1up, DQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/fCmplxLU.cc --- a/liboctave/numeric/fCmplxLU.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/fCmplxLU.cc Fri Jan 23 15:23:09 2015 -0500 @@ -100,7 +100,8 @@ if (u.length () == m && v.length () == n) { - FloatComplexColumnVector utmp = u, vtmp = v; + FloatComplexColumnVector utmp = u; + FloatComplexColumnVector vtmp = v; F77_XFCN (clu1up, CLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); } @@ -125,7 +126,8 @@ { for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - FloatComplexColumnVector utmp = u.column (i), vtmp = v.column (i); + FloatComplexColumnVector utmp = u.column (i); + FloatComplexColumnVector vtmp = v.column (i); F77_XFCN (clu1up, CLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); @@ -150,7 +152,8 @@ if (u.length () == m && v.length () == n) { - FloatComplexColumnVector utmp = u, vtmp = v; + FloatComplexColumnVector utmp = u; + FloatComplexColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (FloatComplex, w, m); for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment F77_XFCN (clup1up, CLUP1UP, (m, n, l.fortran_vec (), @@ -182,7 +185,8 @@ for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - FloatComplexColumnVector utmp = u.column (i), vtmp = v.column (i); + FloatComplexColumnVector utmp = u.column (i); + FloatComplexColumnVector vtmp = v.column (i); F77_XFCN (clup1up, CLUP1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, ipvt.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/fCmplxQR.cc --- a/liboctave/numeric/fCmplxQR.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/fCmplxQR.cc Fri Jan 23 15:23:09 2015 -0500 @@ -140,7 +140,8 @@ void FloatComplexQR::form (octave_idx_type n, FloatComplexMatrix& afact, FloatComplex *tau, qr_type_t qr_type) { - octave_idx_type m = afact.rows (), min_mn = std::min (m, n); + octave_idx_type m = afact.rows (); + octave_idx_type min_mn = std::min (m, n); octave_idx_type info; if (qr_type == qr_type_raw) @@ -217,7 +218,8 @@ if (u.length () == m && v.length () == n) { - FloatComplexColumnVector utmp = u, vtmp = v; + FloatComplexColumnVector utmp = u; + FloatComplexColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (FloatComplex, w, k); OCTAVE_LOCAL_BUFFER (float, rw, k); F77_XFCN (cqr1up, CQR1UP, (m, n, k, q.fortran_vec (), @@ -243,7 +245,8 @@ OCTAVE_LOCAL_BUFFER (float, rw, k); for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - FloatComplexColumnVector utmp = u.column (i), vtmp = v.column (i); + FloatComplexColumnVector utmp = u.column (i); + FloatComplexColumnVector vtmp = v.column (i); F77_XFCN (cqr1up, CQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/floatLU.cc --- a/liboctave/numeric/floatLU.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/floatLU.cc Fri Jan 23 15:23:09 2015 -0500 @@ -99,7 +99,8 @@ if (u.length () == m && v.length () == n) { - FloatColumnVector utmp = u, vtmp = v; + FloatColumnVector utmp = u; + FloatColumnVector vtmp = v; F77_XFCN (slu1up, SLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); @@ -124,7 +125,8 @@ { for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - FloatColumnVector utmp = u.column (i), vtmp = v.column (i); + FloatColumnVector utmp = u.column (i); + FloatColumnVector vtmp = v.column (i); F77_XFCN (slu1up, SLU1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec ())); @@ -149,7 +151,8 @@ if (u.length () == m && v.length () == n) { - FloatColumnVector utmp = u, vtmp = v; + FloatColumnVector utmp = u; + FloatColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (float, w, m); for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment F77_XFCN (slup1up, SLUP1UP, (m, n, l.fortran_vec (), @@ -180,7 +183,8 @@ for (octave_idx_type i = 0; i < m; i++) ipvt(i) += 1; // increment for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - FloatColumnVector utmp = u.column (i), vtmp = v.column (i); + FloatColumnVector utmp = u.column (i); + FloatColumnVector vtmp = v.column (i); F77_XFCN (slup1up, SLUP1UP, (m, n, l.fortran_vec (), m, r.fortran_vec (), k, ipvt.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/floatQR.cc --- a/liboctave/numeric/floatQR.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/floatQR.cc Fri Jan 23 15:23:09 2015 -0500 @@ -136,7 +136,8 @@ void FloatQR::form (octave_idx_type n, FloatMatrix& afact, float *tau, qr_type_t qr_type) { - octave_idx_type m = afact.rows (), min_mn = std::min (m, n); + octave_idx_type m = afact.rows (); + octave_idx_type min_mn = std::min (m, n); octave_idx_type info; if (qr_type == qr_type_raw) @@ -212,7 +213,8 @@ if (u.length () == m && v.length () == n) { - FloatColumnVector utmp = u, vtmp = v; + FloatColumnVector utmp = u; + FloatColumnVector vtmp = v; OCTAVE_LOCAL_BUFFER (float, w, 2*k); F77_XFCN (sqr1up, SQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k, @@ -234,7 +236,8 @@ OCTAVE_LOCAL_BUFFER (float, w, 2*k); for (volatile octave_idx_type i = 0; i < u.cols (); i++) { - FloatColumnVector utmp = u.column (i), vtmp = v.column (i); + FloatColumnVector utmp = u.column (i); + FloatColumnVector vtmp = v.column (i); F77_XFCN (sqr1up, SQR1UP, (m, n, k, q.fortran_vec (), m, r.fortran_vec (), k, utmp.fortran_vec (), vtmp.fortran_vec (), diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/lo-mappers.cc --- a/liboctave/numeric/lo-mappers.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/lo-mappers.cc Fri Jan 23 15:23:09 2015 -0500 @@ -522,14 +522,16 @@ rc_log (double x) { const double pi = 3.14159265358979323846; - return x < 0.0 ? Complex (log (-x), pi) : Complex (log (x)); + return x < 0.0 ? Complex (gnulib::log (-x), pi) : Complex (gnulib::log (x)); } FloatComplex rc_log (float x) { const float pi = 3.14159265358979323846f; - return x < 0.0f ? FloatComplex (logf (-x), pi) : FloatComplex (logf (x)); + return (x < 0.0f + ? FloatComplex (gnulib::logf (-x), pi) + : FloatComplex (gnulib::logf (x))); } Complex diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/lo-specfun.cc --- a/liboctave/numeric/lo-specfun.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/lo-specfun.cc Fri Jan 23 15:23:09 2015 -0500 @@ -633,7 +633,7 @@ retval = 2 * (s + 1) * u; } else - retval = log (1 + x); + retval = gnulib::log (1 + x); return retval; } @@ -685,14 +685,14 @@ if (ax < 0.2) { // approximation log (1+x) ~ 2*sum ((x/(2+x)).^ii ./ ii), ii = 1:2:2n+1 - float u = x / (2 + x), t = 1, s = 0; + float u = x / (2 + x), t = 1.0f, s = 0; for (int i = 2; i < 12; i += 2) s += (t *= u*u) / (i+1); - retval = 2 * (s + 1) * u; + retval = 2 * (s + 1.0f) * u; } else - retval = log (1 + x); + retval = gnulib::logf (1.0f + x); return retval; } @@ -2698,7 +2698,7 @@ for (octave_idx_type i = 0; i < nel; i++) { - result (i) = gammainc (x, a(i), err); + result(i) = gammainc (x, a(i), err); if (err) goto done; @@ -2724,7 +2724,7 @@ for (octave_idx_type i = 0; i < nel; i++) { - result (i) = gammainc (x(i), a, err); + result(i) = gammainc (x(i), a, err); if (err) goto done; @@ -2754,7 +2754,7 @@ for (octave_idx_type i = 0; i < nel; i++) { - result (i) = gammainc (x(i), a(i), err); + result(i) = gammainc (x(i), a(i), err); if (err) goto done; @@ -2903,7 +2903,7 @@ for (octave_idx_type i = 0; i < nel; i++) { - result (i) = gammainc (x, a(i), err); + result(i) = gammainc (x, a(i), err); if (err) goto done; @@ -2929,7 +2929,7 @@ for (octave_idx_type i = 0; i < nel; i++) { - result (i) = gammainc (x(i), a, err); + result(i) = gammainc (x(i), a, err); if (err) goto done; @@ -2959,7 +2959,7 @@ for (octave_idx_type i = 0; i < nel; i++) { - result (i) = gammainc (x(i), a(i), err); + result(i) = gammainc (x(i), a(i), err); if (err) goto done; @@ -2986,14 +2986,17 @@ Complex rc_log1p (double x) { const double pi = 3.14159265358979323846; - return x < -1.0 ? Complex (log (-(1.0 + x)), pi) : Complex (log1p (x)); + return (x < -1.0 + ? Complex (gnulib::log (-(1.0 + x)), pi) + : Complex (log1p (x))); } FloatComplex rc_log1p (float x) { const float pi = 3.14159265358979323846f; - return x < -1.0f ? FloatComplex (logf (-(1.0f + x)), pi) - : FloatComplex (log1pf (x)); + return (x < -1.0f + ? FloatComplex (gnulib::logf (-(1.0f + x)), pi) + : FloatComplex (log1pf (x))); } // This algorithm is due to P. J. Acklam. @@ -3046,7 +3049,7 @@ else if (ax < 1.0) { // Tail region. - const double q = sqrt (-2*log (0.5*(1-ax))); + const double q = sqrt (-2*gnulib::log (0.5*(1-ax))); const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; y = yn / yd * signum (-x); @@ -3124,10 +3127,16 @@ else if (x > 0.0 && x < 2.0) { // Tail region. - const double q = x < 1 ? sqrt (-2*log (0.5*x)) : sqrt (-2*log (0.5*(2-x))); + const double q = (x < 1 + ? sqrt (-2*gnulib::log (0.5*x)) + : sqrt (-2*gnulib::log (0.5*(2-x)))); + const double yn = ((((c[0]*q + c[1])*q + c[2])*q + c[3])*q + c[4])*q + c[5]; + const double yd = (((d[0]*q + d[1])*q + d[2])*q + d[3])*q + 1.0; + y = yn / yd; + if (x < pbreak_lo) y = -y; } @@ -3243,8 +3252,8 @@ if (temp <= acu && temp <= acu * value) { - value = value * exp (pp * log (xx) - + (qq - 1.0) * log (cx) - beta) / pp; + value = value * exp (pp * gnulib::log (xx) + + (qq - 1.0) * gnulib::log (cx) - beta) / pp; if (indx) { @@ -3342,7 +3351,7 @@ // Calculate the initial approximation. - r = sqrt (- log (a * a)); + r = sqrt (- gnulib::log (a * a)); ycur = r - (2.30753 + 0.27061 * r) / (1.0 + (0.99229 + 0.04481 * r) * r); @@ -3363,7 +3372,7 @@ if (t <= 0.0) { - value = 1.0 - exp ((log ((1.0 - a) * qq) + beta) / qq); + value = 1.0 - exp ((gnulib::log ((1.0 - a) * qq) + beta) / qq); } else { @@ -3371,7 +3380,7 @@ if (t <= 1.0) { - value = exp ((log (a * pp) + beta) / pp); + value = exp ((gnulib::log (a * pp) + beta) / pp); } else { @@ -3413,7 +3422,7 @@ } xin = value; - ycur = (ycur - a) * exp (beta + r * log (xin) + t * log (1.0 - xin)); + ycur = (ycur - a) * exp (beta + r * gnulib::log (xin) + t * gnulib::log (1.0 - xin)); if (ycur * yprev <= 0.0) { diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/oct-convn.cc --- a/liboctave/numeric/oct-convn.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/oct-convn.cc Fri Jan 23 15:23:09 2015 -0500 @@ -116,7 +116,8 @@ return MArray (); int nd = std::max (a.ndims (), b.ndims ()); - const dim_vector adims = a.dims ().redim (nd), bdims = b.dims ().redim (nd); + const dim_vector adims = a.dims ().redim (nd); + const dim_vector bdims = b.dims ().redim (nd); dim_vector cdims = dim_vector::alloc (nd); for (int i = 0; i < nd; i++) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/oct-norm.cc --- a/liboctave/numeric/oct-norm.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/oct-norm.cc Fri Jan 23 15:23:09 2015 -0500 @@ -327,7 +327,9 @@ for (octave_idx_type i = 0; i < nsamp; i++) { octave_quit (); - R fi = i*M_PI/nsamp, lambda1 = cos (fi), mu1 = sin (fi); + R fi = i*M_PI/nsamp; + R lambda1 = cos (fi); + R mu1 = sin (fi); R lmnr = std::pow (std::pow (std::abs (lambda1), p) + std::pow (std::abs (mu1), p), 1/p); lambda1 /= lmnr; mu1 /= lmnr; @@ -358,7 +360,9 @@ for (octave_idx_type i = 0; i < nsamp; i++) { octave_quit (); - R fi = i*M_PI/nsamp, lambda1 = cos (fi), mu1 = sin (fi); + R fi = i*M_PI/nsamp; + R lambda1 = cos (fi); + R mu1 = sin (fi); R lmnr = std::pow (std::pow (std::abs (lambda1), p) + std::pow (std::abs (mu1), p), 1/p); lambda1 /= lmnr; mu1 /= lmnr; @@ -415,7 +419,8 @@ // the OSE part VectorT y(m.rows (), 1, 0), z(m.rows (), 1); typedef typename VectorT::element_type RR; - RR lambda = 0, mu = 1; + RR lambda = 0; + RR mu = 1; for (octave_idx_type k = 0; k < m.columns (); k++) { octave_quit (); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/numeric/sparse-dmsolve.cc --- a/liboctave/numeric/sparse-dmsolve.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/numeric/sparse-dmsolve.cc Fri Jan 23 15:23:09 2015 -0500 @@ -43,7 +43,8 @@ octave_idx_type cend, octave_idx_type maxnz = -1, bool lazy = false) { - octave_idx_type nr = rend - rst, nc = cend - cst; + octave_idx_type nr = rend - rst; + octave_idx_type nc = cend - cst; maxnz = (maxnz < 0 ? A.nnz () : maxnz); octave_idx_type nz; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/operators/mx-inlines.cc --- a/liboctave/operators/mx-inlines.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/operators/mx-inlines.cc Fri Jan 23 15:23:09 2015 -0500 @@ -365,7 +365,8 @@ void (*op2) (size_t, R *, const X *, Y) throw (), const char *opname) { - dim_vector dx = x.dims (), dy = y.dims (); + dim_vector dx = x.dims (); + dim_vector dy = y.dims (); if (dx == dy) { Array r (dx); @@ -410,7 +411,8 @@ void (*op1) (size_t, R *, X) throw (), const char *opname) { - dim_vector dr = r.dims (), dx = x.dims (); + dim_vector dr = r.dims (); + dim_vector dx = x.dims (); if (dr == dx) { op (r.length (), r.fortran_vec (), x.data ()); @@ -856,7 +858,8 @@ { \ if (! n) return; \ T tmp = v[0]; \ - octave_idx_type i = 1, j = 0; \ + octave_idx_type i = 1; \ + octave_idx_type j = 0; \ if (xisnan (tmp)) \ { \ for (; i < n && xisnan (v[i]); i++) ; \ @@ -876,7 +879,8 @@ { \ if (! n) return; \ T tmp = v[0]; octave_idx_type tmpi = 0; \ - octave_idx_type i = 1, j = 0; \ + octave_idx_type i = 1; \ + octave_idx_type j = 0; \ if (xisnan (tmp)) \ { \ for (; i < n && xisnan (v[i]); i++) ; \ @@ -1330,7 +1334,9 @@ inline void twosum_accum (T& s, T& e, const T& x) { - T s1 = s + x, t = s1 - s, e1 = (s - (s1 - t)) + (x - t); + T s1 = s + x; + T t = s1 - s; + T e1 = (s - (s1 - t)) + (x - t); s = s1; e += e1; } @@ -1339,7 +1345,8 @@ inline T mx_inline_xsum (const T *v, octave_idx_type n) { - T s = 0, e = 0; + T s = 0; + T e = 0; for (octave_idx_type i = 0; i < n; i++) twosum_accum (s, e, v[i]); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/operators/mx-op-defs.h --- a/liboctave/operators/mx-op-defs.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/operators/mx-op-defs.h Fri Jan 23 15:23:09 2015 -0500 @@ -599,7 +599,8 @@ #define PMM_MULTIPLY_OP(PM, M) \ M operator * (const PM& p, const M& x) \ { \ - octave_idx_type nr = x.rows (), nc = x.columns (); \ + octave_idx_type nr = x.rows (); \ + octave_idx_type nc = x.columns (); \ M result; \ if (p.columns () != nr) \ gripe_nonconformant ("operator *", p.rows (), p.columns (), nr, nc); \ @@ -620,7 +621,8 @@ #define MPM_MULTIPLY_OP(M, PM) \ M operator * (const M& x, const PM& p) \ { \ - octave_idx_type nr = x.rows (), nc = x.columns (); \ + octave_idx_type nr = x.rows (); \ + octave_idx_type nc = x.columns (); \ M result; \ if (p.rows () != nc) \ gripe_nonconformant ("operator *", nr, nc, p.rows (), p.columns ()); \ diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/system/file-ops.cc --- a/liboctave/system/file-ops.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/system/file-ops.cc Fri Jan 23 15:23:09 2015 -0500 @@ -362,6 +362,27 @@ : dir + dir_sep_char () + file); } +std::string +file_ops::native_separator_path (const std::string& path) +{ + std::string retval; + + if (dir_sep_char () == '/') + retval = path; + else + { + size_t n = path.length (); + for (size_t i = 0; i < n; i++) + { + if (path[i] == '/') + retval += dir_sep_char(); + else + retval += path[i]; + } + } + + return retval; +} int octave_mkdir (const std::string& nm, mode_t md) @@ -689,8 +710,6 @@ std::string retval; -#if defined (HAVE_CANONICALIZE_FILE_NAME) - char *tmp = gnulib::canonicalize_file_name (name.c_str ()); if (tmp) @@ -699,98 +718,6 @@ free (tmp); } -#elif defined (HAVE_RESOLVEPATH) - -#if !defined (errno) -extern int errno; -#endif - -#if !defined (__set_errno) -# define __set_errno(Val) errno = (Val) -#endif - - if (name.empty ()) - { - __set_errno (ENOENT); - return retval; - } - - // All known hosts with resolvepath (e.g. Solaris 7) don't turn - // relative names into absolute ones, so prepend the working - // directory if the path is not absolute. - - std::string absolute_name = octave_env::make_absolute (name); - - size_t resolved_size = absolute_name.length (); - - while (true) - { - resolved_size = 2 * resolved_size + 1; - - OCTAVE_LOCAL_BUFFER (char, resolved, resolved_size); - - int resolved_len - = resolvepath (absolute_name.c_str (), resolved, resolved_size); - - if (resolved_len < 0) - break; - - if (resolved_len < resolved_size) - { - retval = resolved; - break; - } - } - -#elif defined (__WIN32__) - - int n = 1024; - - std::string win_path (n, '\0'); - - while (true) - { - int status = GetFullPathName (name.c_str (), n, &win_path[0], 0); - - if (status == 0) - break; - else if (status < n) - { - win_path.resize (status); - retval = win_path; - break; - } - else - { - n *= 2; - win_path.resize (n); - } - } - -#elif defined (HAVE_REALPATH) - -#if !defined (__set_errno) -# define __set_errno(Val) errno = (Val) -#endif - - if (name.empty ()) - { - __set_errno (ENOENT); - return retval; - } - - OCTAVE_LOCAL_BUFFER (char, buf, PATH_MAX); - - if (::realpath (name.c_str (), buf)) - retval = buf; - -#else - - // FIXME: provide replacement here... - retval = name; - -#endif - if (retval.empty ()) msg = gnulib::strerror (errno); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/system/file-ops.h --- a/liboctave/system/file-ops.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/system/file-ops.h Fri Jan 23 15:23:09 2015 -0500 @@ -95,6 +95,9 @@ return path.substr (ipos); } + // convert path from UNIX type separators to whatever is the system separators + static std::string native_separator_path (const std::string& path); + private: static file_ops *instance; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/system/oct-time.cc --- a/liboctave/system/oct-time.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/system/oct-time.cc Fri Jan 23 15:23:09 2015 -0500 @@ -235,7 +235,7 @@ time_t t = ot.unix_time (); - octave_base_tm::init (localtime (&t)); + octave_base_tm::init (gnulib::localtime (&t)); } void @@ -245,7 +245,7 @@ time_t t = ot.unix_time (); - octave_base_tm::init (gmtime (&t)); + octave_base_tm::init (gnulib::gmtime (&t)); } void diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/caseless-str.h --- a/liboctave/util/caseless-str.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/caseless-str.h Fri Jan 23 15:23:09 2015 -0500 @@ -54,7 +54,8 @@ while (p1 != end () && p2 != s.end ()) { - char lp1 = std::tolower (*p1), lp2 = std::tolower (*p2); + char lp1 = std::tolower (*p1); + char lp2 = std::tolower (*p2); if ( lp1 > lp2 ) return false; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/cmd-edit.cc --- a/liboctave/util/cmd-edit.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/cmd-edit.cc Fri Jan 23 15:23:09 2015 -0500 @@ -100,12 +100,16 @@ void do_resize_terminal (void); + void do_set_screen_size (int ht, int wd); + std::string newline_chars (void); void do_restore_terminal_state (void); void do_blink_matching_paren (bool flag); + bool do_erase_empty_line (bool flag); + void do_set_basic_word_break_characters (const std::string& s); void do_set_completer_word_break_characters (const std::string& s); @@ -179,6 +183,8 @@ bool do_filename_quoting_desired (bool); + bool do_prefer_env_winsize (bool); + void do_interrupt (bool); static int operate_and_get_next (int, int); @@ -351,6 +357,12 @@ ::octave_rl_resize_terminal (); } +void +gnu_readline::do_set_screen_size (int ht, int wd) +{ + ::octave_rl_set_screen_size (ht, wd); +} + std::string gnu_readline::newline_chars (void) { @@ -369,6 +381,12 @@ ::octave_rl_enable_paren_matching (flag ? 1 : 0); } +bool +gnu_readline::do_erase_empty_line (bool flag) +{ + return ::octave_rl_erase_empty_line (flag ? 1 : 0); +} + void gnu_readline::do_set_basic_word_break_characters (const std::string& s) { @@ -651,6 +669,12 @@ return ::octave_rl_filename_quoting_desired (arg); } +bool +gnu_readline::do_prefer_env_winsize (bool arg) +{ + return ::octave_rl_prefer_env_winsize (arg); +} + void gnu_readline::do_interrupt (bool arg) { @@ -1112,6 +1136,13 @@ instance->do_resize_terminal (); } +void +command_editor::set_screen_size (int ht, int wd) +{ + if (instance_ok ()) + instance->do_set_screen_size (ht, wd); +} + std::string command_editor::decode_prompt_string (const std::string& s) { @@ -1154,6 +1185,12 @@ instance->do_blink_matching_paren (flag); } +bool +command_editor::erase_empty_line (bool flag) +{ + return instance_ok () ? instance->do_erase_empty_line (flag) : false; +} + void command_editor::set_basic_word_break_characters (const std::string& s) { @@ -1447,6 +1484,13 @@ } bool +command_editor::prefer_env_winsize (bool arg) +{ + return (instance_ok ()) + ? instance->do_prefer_env_winsize (arg) : false; +} + +bool command_editor::interrupt (bool arg) { bool retval; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/cmd-edit.h --- a/liboctave/util/cmd-edit.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/cmd-edit.h Fri Jan 23 15:23:09 2015 -0500 @@ -83,12 +83,16 @@ static void resize_terminal (void); + static void set_screen_size (int ht, int wd); + static std::string decode_prompt_string (const std::string& s); static void restore_terminal_state (void); static void blink_matching_paren (bool flag); + static bool erase_empty_line (bool flag); + static void set_basic_word_break_characters (const std::string& s); static void set_completer_word_break_characters (const std::string& s); @@ -161,6 +165,8 @@ static bool filename_quoting_desired (bool); + static bool prefer_env_winsize (bool); + static bool interrupt (bool = true); static int current_command_number (void); @@ -248,6 +254,8 @@ virtual void do_resize_terminal (void) { } + virtual void do_set_screen_size (int, int) { } + virtual std::string do_decode_prompt_string (const std::string&); virtual std::string newline_chars (void) { return "\n"; } @@ -256,6 +264,8 @@ virtual void do_blink_matching_paren (bool) { } + virtual bool do_erase_empty_line (bool) { return false; } + virtual void do_set_basic_word_break_characters (const std::string&) { } virtual void do_set_completer_word_break_characters (const std::string&) { } @@ -329,6 +339,8 @@ virtual bool do_filename_quoting_desired (bool) { return false; } + virtual bool do_prefer_env_winsize (bool) { return false; } + virtual void do_interrupt (bool) { } int do_insert_initial_input (void); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/kpse.cc --- a/liboctave/util/kpse.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/kpse.cc Fri Jan 23 15:23:09 2015 -0500 @@ -1612,7 +1612,10 @@ static int brace_gobbler (const std::string& text, int& indx, int satisfy) { - int c = 0, level = 0, quoted = 0, pass_next = 0; + int c = 0; + int level = 0; + int quoted = 0; + int pass_next = 0; size_t text_len = text.length (); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/lo-cieee.c --- a/liboctave/util/lo-cieee.c Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,279 +0,0 @@ -/* - -Copyright (C) 2002-2013 John W. Eaton - -This file is part of Octave. - -Octave is free software; you can redistribute it and/or modify it -under the terms of the GNU General Public License as published by the -Free Software Foundation; either version 3 of the License, or (at your -option) any later version. - -Octave is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -for more details. - -You should have received a copy of the GNU General Public License -along with Octave; see the file COPYING. If not, see -. - -*/ - -#ifdef HAVE_CONFIG_H -#include -#endif - -#include - -#if defined (HAVE_FLOATINGPOINT_H) -#include -#endif - -#if defined (HAVE_IEEEFP_H) -#include -#endif - -#include "lo-ieee.h" -#include "lo-math.h" - -#if ! defined (HAVE_ISNAN) && defined (HAVE__ISNAN) -#define isnan _isnan -#define HAVE_ISNAN 1 -#endif - -#if ! defined (HAVE_FINITE) && defined (HAVE__FINITE) -#define finite _finite -#define HAVE_FINITE 1 -#endif - -#if defined (_AIX) && defined (__GNUG__) -#undef finite -#define finite(x) ((x) < DBL_MAX && (x) > -DBL_MAX) -#endif - -/* Octave's idea of infinity. */ -double octave_Inf; -float octave_Float_Inf; - -/* Octave's idea of a missing value. */ -double octave_NA; -float octave_Float_NA; - -/* Octave's idea of not a number. */ -double octave_NaN; -float octave_Float_NaN; - -int lo_ieee_hw; -int lo_ieee_lw; - -int -__lo_ieee_isnan (double x) -{ -#if defined (HAVE_ISNAN) - return isnan (x); -#else - return 0; -#endif -} - -int -__lo_ieee_finite (double x) -{ -#if defined (HAVE_FINITE) - return finite (x) != 0 && ! __lo_ieee_isnan (x); -#elif defined (HAVE_ISINF) - return (! isinf (x) && ! __lo_ieee_isnan (x)); -#else - return ! __lo_ieee_isnan (x); -#endif -} - -int -__lo_ieee_isinf (double x) -{ -#if defined (HAVE_ISINF) - return isinf (x); -#elif defined (HAVE_FINITE) - return (! (finite (x) || __lo_ieee_isnan (x))); -#else - return 0; -#endif -} - -int -__lo_ieee_is_NA (double x) -{ -#if defined (HAVE_ISNAN) - lo_ieee_double t; - t.value = x; - return (isnan (x) && t.word[lo_ieee_hw] == LO_IEEE_NA_HW - && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0; -#else - return 0; -#endif -} - -int -__lo_ieee_is_old_NA (double x) -{ -#if defined (HAVE_ISNAN) - lo_ieee_double t; - t.value = x; - return (isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW_OLD - && t.word[lo_ieee_hw] == LO_IEEE_NA_HW_OLD) ? 1 : 0; -#else - return 0; -#endif -} - -double -__lo_ieee_replace_old_NA (double x) -{ - if (__lo_ieee_is_old_NA (x)) - return lo_ieee_na_value (); - else - return x; -} - -int -__lo_ieee_is_NaN_or_NA (double x) -{ - return __lo_ieee_isnan (x); -} - -double -lo_ieee_inf_value (void) -{ - return octave_Inf; -} - -double -lo_ieee_na_value (void) -{ - return octave_NA; -} - -double -lo_ieee_nan_value (void) -{ - return octave_NaN; -} - -#if ! (defined (signbit) || defined (HAVE_DECL_SIGNBIT)) && defined (HAVE_SIGNBIT) -extern int signbit (double); -#endif - -int -__lo_ieee_signbit (double x) -{ - /* In the following definitions, only check x < 0 explicitly to avoid - a function call when it looks like signbit or copysign are actually - functions. */ - -#if defined (signbit) - return signbit (x); -#elif defined (HAVE_SIGNBIT) - return (x < 0 || signbit (x)); -#elif defined (copysign) - return (copysign (1.0, x) < 0); -#elif defined (HAVE_COPYSIGN) - return (x < 0 || copysign (1.0, x) < 0); -#else - return x < 0; -#endif -} - -int -__lo_ieee_float_isnan (float x) -{ -#if defined (HAVE_ISNAN) - return isnan (x); -#else - return 0; -#endif -} - -int -__lo_ieee_float_finite (float x) -{ -#if defined (HAVE_FINITE) - return finite (x) != 0 && ! __lo_ieee_float_isnan (x); -#elif defined (HAVE_ISINF) - return (! isinf (x) && ! __lo_ieee_float_isnan (x)); -#else - return ! __lo_ieee_float_isnan (x); -#endif -} - -int -__lo_ieee_float_isinf (float x) -{ -#if defined (HAVE_ISINF) - return isinf (x); -#elif defined (HAVE_FINITE) - return (! (finite (x) || __lo_ieee_float_isnan (x))); -#else - return 0; -#endif -} - -int -__lo_ieee_float_is_NA (float x) -{ -#if defined (HAVE_ISNAN) - lo_ieee_float t; - t.value = x; - return (isnan (x) && (t.word == LO_IEEE_NA_FLOAT)) ? 1 : 0; -#else - return 0; -#endif -} - -int -__lo_ieee_float_is_NaN_or_NA (float x) -{ - return __lo_ieee_float_isnan (x); -} - -float -lo_ieee_float_inf_value (void) -{ - return octave_Float_Inf; -} - -float -lo_ieee_float_na_value (void) -{ - return octave_Float_NA; -} - -float -lo_ieee_float_nan_value (void) -{ - return octave_Float_NaN; -} - -#if ! (defined (signbit) || defined (HAVE_DECL_SIGNBIT)) && defined (HAVE_SIGNBIT) -extern int signbit (float); -#endif - -int -__lo_ieee_float_signbit (float x) -{ - /* In the following definitions, only check x < 0 explicitly to avoid - a function call when it looks like signbit or copysign are actually - functions. */ - -#if defined (signbit) - return signbit (x); -#elif defined (HAVE_SIGNBIT) - return (x < 0 || signbit (x)); -#elif defined (copysign) - return (copysign (1.0, x) < 0); -#elif defined (HAVE_COPYSIGN) - return (x < 0 || copysign (1.0, x) < 0); -#else - return x < 0; -#endif -} diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/lo-ieee.cc --- a/liboctave/util/lo-ieee.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/lo-ieee.cc Fri Jan 23 15:23:09 2015 -0500 @@ -24,63 +24,268 @@ #include #endif +#include +#include #include #include +static double lo_inf; +static double lo_nan; +static double lo_na; + +static float lo_float_inf; +static float lo_float_nan; +static float lo_float_na; + +static int lo_ieee_hw; +static int lo_ieee_lw; + #include "lo-error.h" #include "lo-ieee.h" +#include "lo-math.h" #include "mach-info.h" +int +__lo_ieee_isnan (double x) +{ +#if defined (HAVE_CMATH_ISNAN) + return std::isnan (x); +#else + // Gnulib provides. + return isnan (x); +#endif +} + +int +__lo_ieee_finite (double x) +{ +#if defined (HAVE_CMATH_ISFINITE) + return std::isfinite (x); +#else + // Gnulib provides. + return finite (x); +#endif +} + +int +__lo_ieee_isinf (double x) +{ +#if defined (HAVE_CMATH_ISINF) + return std::isinf (x); +#else + // Gnulib provides. + return isinf (x); +#endif +} + +int +__lo_ieee_is_NA (double x) +{ + lo_ieee_double t; + t.value = x; + return (__lo_ieee_isnan (x) && t.word[lo_ieee_hw] == LO_IEEE_NA_HW + && t.word[lo_ieee_lw] == LO_IEEE_NA_LW) ? 1 : 0; +} + +int +__lo_ieee_is_old_NA (double x) +{ + lo_ieee_double t; + t.value = x; + return (__lo_ieee_isnan (x) && t.word[lo_ieee_lw] == LO_IEEE_NA_LW_OLD + && t.word[lo_ieee_hw] == LO_IEEE_NA_HW_OLD) ? 1 : 0; +} + +double +__lo_ieee_replace_old_NA (double x) +{ + if (__lo_ieee_is_old_NA (x)) + return lo_ieee_na_value (); + else + return x; +} + +int +__lo_ieee_is_NaN_or_NA (double x) +{ + return __lo_ieee_isnan (x); +} + +double +lo_ieee_inf_value (void) +{ + octave_ieee_init (); + + return lo_inf; +} + +double +lo_ieee_na_value (void) +{ + octave_ieee_init (); + + return lo_na; +} + +double +lo_ieee_nan_value (void) +{ + octave_ieee_init (); + + return lo_nan; +} + +int +__lo_ieee_signbit (double x) +{ +#if defined (HAVE_CMATH_SIGNBIT) + return std::signbit (x); +#else + // Gnulib provides. + return signbit (x); +#endif +} + +int +__lo_ieee_float_isnan (float x) +{ +#if defined (HAVE_CMATH_ISNAN) + return std::isnan (x); +#else + // Gnulib provides. + return isnan (x); +#endif +} + +int +__lo_ieee_float_finite (float x) +{ +#if defined (HAVE_CMATH_ISFINITE) + return std::isfinite (x) != 0 && ! __lo_ieee_float_isnan (x); +#else + // Gnulib provides. + return finite (x); +#endif +} + +int +__lo_ieee_float_isinf (float x) +{ +#if defined (HAVE_CMATH_ISINF) + return std::isinf (x); +#else + // Gnulib provides. + return isinf (x); +#endif +} + +int +__lo_ieee_float_is_NA (float x) +{ + lo_ieee_float t; + t.value = x; + return (__lo_ieee_float_isnan (x) && (t.word == LO_IEEE_NA_FLOAT)) ? 1 : 0; +} + +int +__lo_ieee_float_is_NaN_or_NA (float x) +{ + return __lo_ieee_float_isnan (x); +} + +float +lo_ieee_float_inf_value (void) +{ + octave_ieee_init (); + + return lo_float_inf; +} + +float +lo_ieee_float_na_value (void) +{ + octave_ieee_init (); + + return lo_float_na; +} + +float +lo_ieee_float_nan_value (void) +{ + octave_ieee_init (); + + return lo_float_nan; +} + +int +__lo_ieee_float_signbit (float x) +{ +#if defined (HAVE_CMATH_SIGNBIT) + return std::signbit (x); +#else + // Gnulib provides. + return signbit (x); +#endif +} + void octave_ieee_init (void) { - oct_mach_info::float_format ff = oct_mach_info::native_float_format (); - - switch (ff) - { - case oct_mach_info::flt_fmt_ieee_big_endian: - case oct_mach_info::flt_fmt_ieee_little_endian: - { - octave_NaN = std::numeric_limits::quiet_NaN (); - octave_Inf = std::numeric_limits::infinity (); + bool initialized = false; - octave_Float_NaN = std::numeric_limits::quiet_NaN (); - octave_Float_Inf = std::numeric_limits::infinity (); - - // The following is patterned after code in R. + if (! initialized) + { + oct_mach_info::float_format ff = oct_mach_info::native_float_format (); - if (ff == oct_mach_info::flt_fmt_ieee_big_endian) - { - lo_ieee_hw = 0; - lo_ieee_lw = 1; - } - else + switch (ff) + { + case oct_mach_info::flt_fmt_ieee_big_endian: + case oct_mach_info::flt_fmt_ieee_little_endian: { - lo_ieee_hw = 1; - lo_ieee_lw = 0; - } + lo_nan = std::numeric_limits::quiet_NaN (); + lo_inf = std::numeric_limits::infinity (); + + lo_float_nan = std::numeric_limits::quiet_NaN (); + lo_float_inf = std::numeric_limits::infinity (); + + // The following is patterned after code in R. - lo_ieee_double t; - t.word[lo_ieee_hw] = LO_IEEE_NA_HW; - t.word[lo_ieee_lw] = LO_IEEE_NA_LW; - - octave_NA = t.value; + if (ff == oct_mach_info::flt_fmt_ieee_big_endian) + { + lo_ieee_hw = 0; + lo_ieee_lw = 1; + } + else + { + lo_ieee_hw = 1; + lo_ieee_lw = 0; + } - lo_ieee_float tf; - tf.word = LO_IEEE_NA_FLOAT; - octave_Float_NA = tf.value; - } - break; + lo_ieee_double t; + t.word[lo_ieee_hw] = LO_IEEE_NA_HW; + t.word[lo_ieee_lw] = LO_IEEE_NA_LW; + + lo_na = t.value; + + lo_ieee_float tf; + tf.word = LO_IEEE_NA_FLOAT; + + lo_float_na = tf.value; + } + break; - default: - // If the format is unknown, then you will probably not have a - // useful system, so we will abort here. Anyone wishing to - // experiment with building Octave on a system without IEEE - // floating point should be capable of removing this check and - // the configure test. - (*current_liboctave_error_handler) - ("lo_ieee_init: floating point format is not IEEE! Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?"); - abort (); + default: + // If the format is unknown, then you will probably not have a + // useful system, so we will abort here. Anyone wishing to + // experiment with building Octave on a system without IEEE + // floating point should be capable of removing this check and + // the configure test. + (*current_liboctave_error_handler) + ("lo_ieee_init: floating point format is not IEEE! Maybe DLAMCH is miscompiled, or you are using some strange system without IEEE floating point math?"); + abort (); + } + + initialized = true; } } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/lo-ieee.h --- a/liboctave/util/lo-ieee.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/lo-ieee.h Fri Jan 23 15:23:09 2015 -0500 @@ -28,29 +28,26 @@ #endif /* Octave's idea of infinity. */ -extern OCTAVE_API double octave_Inf; +#define octave_Inf (lo_ieee_inf_value ()) /* Octave's idea of a missing value. */ -extern OCTAVE_API double octave_NA; +#define octave_NA (lo_ieee_na_value ()) /* Octave's idea of not a number. */ -extern OCTAVE_API double octave_NaN; +#define octave_NaN (lo_ieee_nan_value ()) /* Octave's idea of infinity. */ -extern OCTAVE_API float octave_Float_Inf; +#define octave_Float_Inf (lo_ieee_float_inf_value ()) /* Octave's idea of a missing value. */ -extern OCTAVE_API float octave_Float_NA; +#define octave_Float_NA (lo_ieee_float_na_value ()) /* Octave's idea of not a number. */ -extern OCTAVE_API float octave_Float_NaN; +#define octave_Float_NaN (lo_ieee_float_nan_value ()) /* FIXME -- this code assumes that a double has twice the number of bits as an int */ -extern OCTAVE_API int lo_ieee_hw; -extern OCTAVE_API int lo_ieee_lw; - typedef union { double value; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/lo-utils.cc --- a/liboctave/util/lo-utils.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/lo-utils.cc Fri Jan 23 15:23:09 2015 -0500 @@ -322,7 +322,8 @@ std::complex octave_read_cx_fp_value (std::istream& is) { - T re = 0.0, im = 0.0; + T re = 0.0; + T im = 0.0; std::complex cx = 0.0; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/module.mk --- a/liboctave/util/module.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/module.mk Fri Jan 23 15:23:09 2015 -0500 @@ -47,7 +47,6 @@ UTIL_C_SRC = \ util/f2c-main.c \ - util/lo-cieee.c \ util/lo-cutils.c \ util/oct-rl-edit.c \ util/oct-rl-hist.c diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-binmap.h --- a/liboctave/util/oct-binmap.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-binmap.h Fri Jan 23 15:23:09 2015 -0500 @@ -167,7 +167,8 @@ Array binmap (const Array& xa, const Array& ya, F fcn, const char *name) { - dim_vector xad = xa.dims (), yad = ya.dims (); + dim_vector xad = xa.dims (); + dim_vector yad = ya.dims (); if (xa.numel () == 1) return binmap (xa(0), ya, fcn); else if (ya.numel () == 1) diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-cmplx.h --- a/liboctave/util/oct-cmplx.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-cmplx.h Fri Jan 23 15:23:09 2015 -0500 @@ -40,10 +40,12 @@ template \ inline bool operator OP (const std::complex& a, const std::complex& b) \ { \ - FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \ + FLOAT_TRUNCATE const T ax = std::abs (a); \ + FLOAT_TRUNCATE const T bx = std::abs (b); \ if (ax == bx) \ { \ - FLOAT_TRUNCATE const T ay = std::arg (a), by = std::arg (b); \ + FLOAT_TRUNCATE const T ay = std::arg (a); \ + FLOAT_TRUNCATE const T by = std::arg (b); \ return ay OP by; \ } \ else \ @@ -52,7 +54,8 @@ template \ inline bool operator OP (const std::complex& a, T b) \ { \ - FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \ + FLOAT_TRUNCATE const T ax = std::abs (a); \ + FLOAT_TRUNCATE const T bx = std::abs (b); \ if (ax == bx) \ { \ FLOAT_TRUNCATE const T ay = std::arg (a); \ @@ -64,7 +67,8 @@ template \ inline bool operator OP (T a, const std::complex& b) \ { \ - FLOAT_TRUNCATE const T ax = std::abs (a), bx = std::abs (b); \ + FLOAT_TRUNCATE const T ax = std::abs (a); \ + FLOAT_TRUNCATE const T bx = std::abs (b); \ if (ax == bx) \ { \ FLOAT_TRUNCATE const T by = std::arg (b); \ diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-inttypes.cc --- a/liboctave/util/oct-inttypes.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-inttypes.cc Fri Jan 23 15:23:09 2015 -0500 @@ -280,7 +280,8 @@ octave_int_arith_base::mul_internal (uint64_t x, uint64_t y) { // Get upper words - uint64_t ux = x >> 32, uy = y >> 32; + uint64_t ux = x >> 32; + uint64_t uy = y >> 32; uint64_t res; if (ux) { @@ -288,21 +289,25 @@ goto overflow; else { - uint64_t ly = static_cast (y), uxly = ux*ly; + uint64_t ly = static_cast (y); + uint64_t uxly = ux*ly; if (uxly >> 32) goto overflow; uxly <<= 32; // never overflows - uint64_t lx = static_cast (x), lxly = lx*ly; + uint64_t lx = static_cast (x); + uint64_t lxly = lx*ly; res = add (uxly, lxly); } } else if (uy) { - uint64_t lx = static_cast (x), uylx = uy*lx; + uint64_t lx = static_cast (x); + uint64_t uylx = uy*lx; if (uylx >> 32) goto overflow; uylx <<= 32; // never overflows - uint64_t ly = static_cast (y), lylx = ly*lx; + uint64_t ly = static_cast (y); + uint64_t lylx = ly*lx; res = add (uylx, lylx); } else @@ -330,11 +335,13 @@ // (as above) and impose the sign. // FIXME: can we do something faster if we HAVE_FAST_INT_OPS? - uint64_t usx = octave_int_abs (x), usy = octave_int_abs (y); + uint64_t usx = octave_int_abs (x); + uint64_t usy = octave_int_abs (y); bool positive = (x < 0) == (y < 0); // Get upper words - uint64_t ux = usx >> 32, uy = usy >> 32; + uint64_t ux = usx >> 32; + uint64_t uy = usy >> 32; uint64_t res; if (ux) { @@ -342,11 +349,13 @@ goto overflow; else { - uint64_t ly = static_cast (usy), uxly = ux*ly; + uint64_t ly = static_cast (usy); + uint64_t uxly = ux*ly; if (uxly >> 32) goto overflow; uxly <<= 32; // never overflows - uint64_t lx = static_cast (usx), lxly = lx*ly; + uint64_t lx = static_cast (usx); + uint64_t lxly = lx*ly; res = uxly + lxly; if (res < uxly) goto overflow; @@ -354,11 +363,13 @@ } else if (uy) { - uint64_t lx = static_cast (usx), uylx = uy*lx; + uint64_t lx = static_cast (usx); + uint64_t uylx = uy*lx; if (uylx >> 32) goto overflow; uylx <<= 32; // never overflows - uint64_t ly = static_cast (usy), lylx = ly*lx; + uint64_t ly = static_cast (usy); + uint64_t lylx = ly*lx; res = uylx + lylx; if (res < uylx) goto overflow; @@ -496,11 +507,14 @@ static void umul128 (uint64_t x, uint64_t y, uint32_t w[4]) { - uint64_t lx = static_cast (x), ux = x >> 32; - uint64_t ly = static_cast (y), uy = y >> 32; + uint64_t lx = static_cast (x); + uint64_t ux = x >> 32; + uint64_t ly = static_cast (y); + uint64_t uy = y >> 32; uint64_t a = lx * ly; w[0] = a; a >>= 32; - uint64_t uxly = ux*ly, uylx = uy*lx; + uint64_t uxly = ux*ly; + uint64_t uylx = uy*lx; a += static_cast (uxly); uxly >>= 32; a += static_cast (uylx); uylx >>= 32; w[1] = a; a >>= 32; diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-inttypes.h --- a/liboctave/util/oct-inttypes.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-inttypes.h Fri Jan 23 15:23:09 2015 -0500 @@ -81,7 +81,8 @@ class NM \ { \ public: \ - static const bool ltval = (0 OP 1), gtval = (1 OP 0); \ + static const bool ltval = (0 OP 1); \ + static const bool gtval = (1 OP 0); \ template \ static bool op (T x, T y) { return x OP y; } \ } @@ -92,7 +93,8 @@ class NM \ { \ public: \ - static const bool ltval = value, gtval = value; \ + static const bool ltval = value; \ + static const bool gtval = value; \ template \ static bool op (T, T) { return value; } \ } @@ -268,7 +270,9 @@ // An exhaustive test whether the max and/or min check can be omitted. static const bool t_is_signed = std::numeric_limits::is_signed; static const bool s_is_signed = std::numeric_limits::is_signed; - static const int t_size = sizeof (T), s_size = sizeof (S); + static const int t_size = sizeof (T); + static const int s_size = sizeof (S); + static const bool omit_chk_min = (! s_is_signed || (t_is_signed && t_size >= s_size)); static const bool omit_chk_max = @@ -420,7 +424,8 @@ { if (y != 0) { - T z = x / y, w = x % y; + T z = x / y; + T w = x % y; if (w >= y-w) z += 1; return z; } @@ -610,7 +615,8 @@ // compiler from interfering. Also, the signed operations on small types // actually return int. T u = static_cast (x) + static_cast (y); - T ux = u ^ x, uy = u ^ y; + T ux = u ^ x; + T uy = u ^ y; if ((ux & uy) < 0) { u = octave_int_base::max_val () + __signbit (~u); @@ -651,7 +657,8 @@ // compiler from interfering. Also, the signed operations on small types // actually return int. T u = static_cast (x) - static_cast (y); - T ux = u ^ x, uy = u ^ ~y; + T ux = u ^ x; + T uy = u ^ ~y; if ((ux & uy) < 0) { u = octave_int_base::max_val () + __signbit (~u); @@ -1286,7 +1293,8 @@ octave_int xmax (const octave_int& x, const octave_int& y) { - const T xv = x.value (), yv = y.value (); + const T xv = x.value (); + const T yv = y.value (); return octave_int (xv >= yv ? xv : yv); } @@ -1294,7 +1302,8 @@ octave_int xmin (const octave_int& x, const octave_int& y) { - const T xv = x.value (), yv = y.value (); + const T xv = x.value (); + const T yv = y.value (); return octave_int (xv <= yv ? xv : yv); } diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-rl-edit.c --- a/liboctave/util/oct-rl-edit.c Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-rl-edit.c Fri Jan 23 15:23:09 2015 -0500 @@ -74,6 +74,14 @@ rl_variable_bind ("blink-matching-paren", val ? "1" : "0"); } +int +octave_rl_erase_empty_line (int val) +{ + int retval = rl_erase_empty_line; + rl_erase_empty_line = val; + return retval; +} + /* It would be much simpler if we could just call _rl_clear_screen to only clear the screen, but it is not a public function, and on some systems, it is not exported from shared library versions of @@ -117,6 +125,12 @@ } void +octave_rl_set_screen_size (int ht, int wd) +{ + rl_set_screen_size (ht, wd); +} + +void octave_rl_restore_terminal_state () { if (rl_deprep_term_function) @@ -242,6 +256,14 @@ return retval; } +int +octave_rl_prefer_env_winsize (int arg) +{ + int retval = rl_prefer_env_winsize; + rl_prefer_env_winsize = arg; + return retval; +} + void octave_rl_done (int arg) { diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-rl-edit.h --- a/liboctave/util/oct-rl-edit.h Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-rl-edit.h Fri Jan 23 15:23:09 2015 -0500 @@ -56,12 +56,18 @@ extern void octave_rl_enable_paren_matching (int); +extern int octave_rl_erase_empty_line (int); + extern void octave_rl_init (void); extern void octave_rl_clear_screen (int skip_redisplay); extern void octave_rl_resize_terminal (void); +extern void octave_rl_resize_terminal (void); + +extern void octave_rl_set_screen_size (int ht, int wd); + extern void octave_rl_restore_terminal_state (void); extern char *octave_rl_copy_line (void); @@ -98,6 +104,8 @@ extern int octave_rl_filename_quoting_desired (int); +extern int octave_rl_prefer_env_winsize (int); + extern void octave_rl_done (int); extern char *octave_rl_filename_completion_function (const char *, int); diff -r 75a671fcdd73 -r 844448ae53f3 liboctave/util/oct-sort.cc --- a/liboctave/util/oct-sort.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/liboctave/util/oct-sort.cc Fri Jan 23 15:23:09 2015 -0500 @@ -158,7 +158,8 @@ for (; start < nel; ++start) { /* set l to where *start belongs */ - octave_idx_type l = 0, r = start; + octave_idx_type l = 0; + octave_idx_type r = start; T pivot = data[start]; /* Invariants: * pivot >= all in [lo, l). @@ -202,7 +203,8 @@ for (; start < nel; ++start) { /* set l to where *start belongs */ - octave_idx_type l = 0, r = start; + octave_idx_type l = 0; + octave_idx_type r = start; T pivot = data[start]; /* Invariants: * pivot >= all in [lo, l). @@ -1694,7 +1696,8 @@ { // Not the final column. assert (n > 1); - const T *hi = lo + n, *lst = lo; + const T *hi = lo + n; + const T *lst = lo; for (lo++; lo < hi; lo++) { if (comp (*lst, *lo)) @@ -1756,7 +1759,8 @@ octave_sort::lookup (const T *data, octave_idx_type nel, const T& value, Comp comp) { - octave_idx_type lo = 0, hi = nel; + octave_idx_type lo = 0; + octave_idx_type hi = nel; while (lo < hi) { @@ -1834,7 +1838,8 @@ { if (rev) { - octave_idx_type i = 0, j = nvalues - 1; + octave_idx_type i = 0; + octave_idx_type j = nvalues - 1; if (nvalues > 0 && nel > 0) { @@ -1856,7 +1861,8 @@ } else { - octave_idx_type i = 0, j = 0; + octave_idx_type i = 0; + octave_idx_type j = 0; if (nvalues > 0 && nel > 0) { diff -r 75a671fcdd73 -r 844448ae53f3 m4/acinclude.m4 --- a/m4/acinclude.m4 Fri Jan 23 15:21:25 2015 -0500 +++ b/m4/acinclude.m4 Fri Jan 23 15:23:09 2015 -0500 @@ -478,6 +478,69 @@ fi ]) dnl +dnl Check whether the Qt QTabWidget::setMovable() function exists. +dnl This function was added in Qt 4.5. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QTABWIDGET_SETMOVABLE], [ + AC_CACHE_CHECK([whether Qt has the QTabWidget::setMovable() function], + [octave_cv_func_qtabwidget_setmovable], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + class tab_widget : public QTabWidget + { + public: + tab_widget (QWidget *parent = 0) : QTabWidget (parent) { this->setMovable (true); } + ~tab_widget () {} + }; + ]], [[ + tab_widget tw; + ]])], + octave_cv_func_qtabwidget_setmovable=yes, + octave_cv_func_qtabwidget_setmovable=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qtabwidget_setmovable = yes; then + AC_DEFINE(HAVE_QTABWIDGET_SETMOVABLE, 1, + [Define to 1 if Qt has the QTabWidget::setMovable() function.]) + fi +]) +dnl +dnl Check whether the QsciScintilla::findFirstInSelection () function exists. +dnl This function was added in QScintilla 2.7. +dnl +AC_DEFUN([OCTAVE_CHECK_FUNC_QSCI_FINDSELECTION], [ + AC_CACHE_CHECK([whether QSci has the QsciScintilla::findFirstInSelection () function], + [octave_cv_func_qsci_findfirstinselection], + [AC_LANG_PUSH(C++) + ac_octave_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$QT_CPPFLAGS $CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + class qsci : public QsciScintilla + { + public: + qsci (QWidget *parent = 0) : QsciScintilla (parent) + { this->findFirstInSelection (QString ("x"),true,true,true,true,true); } + ~qsci () {} + }; + ]], [[ + qsci edit; + ]])], + octave_cv_func_qsci_findfirstinselection=yes, + octave_cv_func_qsci_findfirstinselection=no) + CPPFLAGS="$ac_octave_save_CPPFLAGS" + AC_LANG_POP(C++) + ]) + if test $octave_cv_func_qsci_findfirstinselection = yes; then + AC_DEFINE(HAVE_QSCI_FINDSELECTION, 1, + [Define to 1 if Qsci has the QsciScintilla::findFirstInSelection () function.]) + fi +]) +dnl dnl Check whether HDF5 library has version 1.6 API functions. dnl AC_DEFUN([OCTAVE_CHECK_HDF5_HAS_VER_16_API], [ @@ -898,6 +961,16 @@ ]) if test $have_opengl_incs = yes; then + AC_CHECK_HEADERS([GL/glext.h OpenGL/glext.h], [], [], [ +#ifdef HAVE_WINDOWS_H +# include +#endif +#if defined (HAVE_GL_GL_H) +# include +#elif defined (HAVE_OPENGL_GL_H) +# include +#endif + ]) case $canonical_host_type in *-*-mingw32* | *-*-msdosmsvc) save_LIBS="$LIBS" diff -r 75a671fcdd73 -r 844448ae53f3 m4/ax_blas.m4 --- a/m4/ax_blas.m4 Fri Jan 23 15:21:25 2015 -0500 +++ b/m4/ax_blas.m4 Fri Jan 23 15:23:09 2015 -0500 @@ -63,12 +63,13 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 12 +#serial 14 AU_ALIAS([ACX_BLAS], [AX_BLAS]) AC_DEFUN([AX_BLAS], [ AC_PREREQ(2.50) AC_REQUIRE([AC_F77_LIBRARY_LDFLAGS]) +AC_REQUIRE([AC_CANONICAL_HOST]) ax_blas_ok=no AC_ARG_WITH(blas, @@ -107,6 +108,12 @@ LIBS="$save_LIBS" fi +# BLAS in OpenBLAS library? (http://xianyi.github.com/OpenBLAS/) +if test $ax_blas_ok = no; then + AC_CHECK_LIB(openblas, $sgemm, [ax_blas_ok=yes + BLAS_LIBS="-lopenblas"]) +fi + # BLAS in ATLAS library? (http://math-atlas.sourceforge.net/) if test $ax_blas_ok = no; then AC_CHECK_LIB(atlas, ATL_xerbla, @@ -130,6 +137,36 @@ # BLAS in Intel MKL library? if test $ax_blas_ok = no; then + # MKL for gfortran + if test x"$ac_cv_fc_compiler_gnu" = xyes; then + # 64 bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_gf_lp64, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32 bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_gf, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_gf -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_gf -lmkl_sequential -lmkl_core -lpthread]) + fi + # MKL for other compilers (Intel, PGI, ...?) + else + # 64-bit + if test $host_cpu = x86_64; then + AC_CHECK_LIB(mkl_intel_lp64, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel_lp64 -lmkl_sequential -lmkl_core -lpthread]) + # 32-bit + elif test $host_cpu = i686; then + AC_CHECK_LIB(mkl_intel, $sgemm, + [ax_blas_ok=yes;BLAS_LIBS="-lmkl_intel -lmkl_sequential -lmkl_core -lpthread"],, + [-lmkl_intel -lmkl_sequential -lmkl_core -lpthread]) + fi + fi +fi +# Old versions of MKL +if test $ax_blas_ok = no; then AC_CHECK_LIB(mkl, $sgemm, [ax_blas_ok=yes;BLAS_LIBS="-lmkl -lguide -lpthread"],,[-lguide -lpthread]) fi diff -r 75a671fcdd73 -r 844448ae53f3 m4/ax_blas_f77_func.m4 --- a/m4/ax_blas_f77_func.m4 Fri Jan 23 15:21:25 2015 -0500 +++ b/m4/ax_blas_f77_func.m4 Fri Jan 23 15:23:09 2015 -0500 @@ -55,21 +55,20 @@ #serial 8 AU_ALIAS([ACX_BLAS_F77_FUNC], [AX_BLAS_F77_FUNC]) - AC_DEFUN([AX_BLAS_F77_FUNC], [ - AC_PREREQ(2.50) - AC_REQUIRE([AX_BLAS]) +AC_PREREQ(2.50) +AC_REQUIRE([AX_BLAS]) - ## F77 call-compatibility checks - if test "$cross_compiling" = yes ; then - ifelse($3, ,$1,$3) - elif test x"$ax_blas_ok" = xyes; then - save_ax_blas_f77_func_LIBS="$LIBS" - LIBS="$BLAS_LIBS $LIBS" - AC_LANG_PUSH(Fortran 77) - ## LSAME check (LOGICAL return values) - AC_MSG_CHECKING([whether LSAME is called correctly from Fortran]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ +# F77 call-compatibility checks +if test "$cross_compiling" = yes ; then + ifelse($3, ,$1,$3) +elif test x"$ax_blas_ok" = xyes; then + save_ax_blas_f77_func_LIBS="$LIBS" + LIBS="$BLAS_LIBS $LIBS" + AC_LANG_PUSH(Fortran 77) +# LSAME check (LOGICAL return values) + AC_MSG_CHECKING([whether LSAME is called correctly from Fortran]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ logical lsame,w external lsame character c1,c2 @@ -79,13 +78,12 @@ if (w) stop 1 w = lsame(c1,c1) if (.not. w) stop 1 - ]])], - [ax_blas_lsame_fcall_ok=yes], - [ax_blas_lsame_fcall_ok=no]) - AC_MSG_RESULT([$ax_blas_lsame_fcall_ok]) - ## ISAMAX check (INTEGER return values) - AC_MSG_CHECKING([whether ISAMAX is called correctly from Fortran]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ + ]]),[ax_blas_lsame_fcall_ok=yes], + [ax_blas_lsame_fcall_ok=no]) + AC_MSG_RESULT([$ax_blas_lsame_fcall_ok]) +# ISAMAX check (INTEGER return values) + AC_MSG_CHECKING([whether ISAMAX is called correctly from Fortran]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ integer isamax,i external isamax real a(2) @@ -93,73 +91,68 @@ a(2) = -2e0 i = isamax(2,a,1) if (i.ne.2) stop 1 - ]])], - [ax_blas_isamax_fcall_ok=yes], - [ax_blas_isamax_fcall_ok=no]) - AC_MSG_RESULT([$ax_blas_isamax_fcall_ok]) - ## SDOT check (REAL return values) - AC_MSG_CHECKING([whether SDOT is called correctly from Fortran]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ + ]]),[ax_blas_isamax_fcall_ok=yes], + [ax_blas_isamax_fcall_ok=no]) + AC_MSG_RESULT([$ax_blas_isamax_fcall_ok]) +# SDOT check (REAL return values) + AC_MSG_CHECKING([whether SDOT is called correctly from Fortran]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ real sdot,a(1),b(1),w external sdot a(1) = 1e0 b(1) = 2e0 w = sdot(1,a,1,b,1) if (w .ne. a(1)*b(1)) stop 1 - ]])], - [ax_blas_sdot_fcall_ok=yes], - [ax_blas_sdot_fcall_ok=no]) - AC_MSG_RESULT([$ax_blas_sdot_fcall_ok]) - ## DDOT check (DOUBLE return values) - AC_MSG_CHECKING([whether DDOT is called correctly from Fortran]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ + ]]),[ax_blas_sdot_fcall_ok=yes], + [ax_blas_sdot_fcall_ok=no]) + AC_MSG_RESULT([$ax_blas_sdot_fcall_ok]) +# DDOT check (DOUBLE return values) + AC_MSG_CHECKING([whether DDOT is called correctly from Fortran]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ double precision ddot,a(1),b(1),w external ddot a(1) = 1d0 b(1) = 2d0 w = ddot(1,a,1,b,1) if (w .ne. a(1)*b(1)) stop 1 - ]])], - [ax_blas_ddot_fcall_ok=yes], - [ax_blas_ddot_fcall_ok=no]) - AC_MSG_RESULT([$ax_blas_ddot_fcall_ok]) - ## CDOTU check (COMPLEX return values) - AC_MSG_CHECKING([whether CDOTU is called correctly from Fortran]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ + ]]),[ax_blas_ddot_fcall_ok=yes], + [ax_blas_ddot_fcall_ok=no]) + AC_MSG_RESULT([$ax_blas_ddot_fcall_ok]) +# CDOTU check (COMPLEX return values) + AC_MSG_CHECKING([whether CDOTU is called correctly from Fortran]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ complex cdotu,a(1),b(1),w external cdotu a(1) = cmplx(1e0,1e0) b(1) = cmplx(1e0,2e0) w = cdotu(1,a,1,b,1) if (w .ne. a(1)*b(1)) stop 1 - ]])], - [ax_blas_cdotu_fcall_ok=yes], - [ax_blas_cdotu_fcall_ok=no]) - AC_MSG_RESULT([$ax_blas_cdotu_fcall_ok]) - ## ZDOTU check (DOUBLE COMPLEX return values) - AC_MSG_CHECKING([whether ZDOTU is called correctly from Fortran]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ + ]]),[ax_blas_cdotu_fcall_ok=yes], + [ax_blas_cdotu_fcall_ok=no]) + AC_MSG_RESULT([$ax_blas_cdotu_fcall_ok]) +# ZDOTU check (DOUBLE COMPLEX return values) + AC_MSG_CHECKING([whether ZDOTU is called correctly from Fortran]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ double complex zdotu,a(1),b(1),w external zdotu a(1) = dcmplx(1d0,1d0) b(1) = dcmplx(1d0,2d0) w = zdotu(1,a,1,b,1) if (w .ne. a(1)*b(1)) stop 1 - ]])], - [ax_blas_zdotu_fcall_ok=yes], - [ax_blas_zdotu_fcall_ok=no]) - AC_MSG_RESULT([$ax_blas_zdotu_fcall_ok]) - ## Check for correct integer size - ## FIXME: this may fail with things like -ftrapping-math. - AC_MSG_CHECKING([whether the integer size is correct]) - AC_RUN_IFELSE([AC_LANG_PROGRAM([], [[ + ]]),[ax_blas_zdotu_fcall_ok=yes], + [ax_blas_zdotu_fcall_ok=no]) + AC_MSG_RESULT([$ax_blas_zdotu_fcall_ok]) +# Check for correct integer size +# FIXME: this may fail with things like -ftrapping-math. + AC_MSG_CHECKING([whether the integer size is correct]) + AC_RUN_IFELSE(AC_LANG_PROGRAM(,[[ integer n,nn(3) real s,a(1),b(1),sdot a(1) = 1.0 b(1) = 1.0 -c Generate -2**32 + 1, if possible +c Generate -2**33 + 1, if possible n = 2 - n = -4 ** (n ** 30) + n = -4 * (n ** 30) n = n + 1 if (n >= 0) goto 1 c This means we're on 64-bit integers. Check whether the BLAS is, too. @@ -173,40 +166,39 @@ nn(3) = -1 s = sdot(nn(2),a,1,b,1) if (s .ne. 1.0) stop 1 - ]])], - [ax_blas_integer_size_ok=yes], - [ax_blas_integer_size_ok=no]) - AC_MSG_RESULT([$ax_blas_integer_size_ok]) + ]]),[ax_blas_integer_size_ok=yes], + [ax_blas_integer_size_ok=no]) + AC_MSG_RESULT([$ax_blas_integer_size_ok]) - AC_LANG_POP(Fortran 77) + AC_LANG_POP(Fortran 77) - ## if any of the tests failed, reject the BLAS library - if test $ax_blas_lsame_fcall_ok = yes \ - -a $ax_blas_sdot_fcall_ok = yes \ - -a $ax_blas_ddot_fcall_ok = yes \ - -a $ax_blas_cdotu_fcall_ok = yes \ - -a $ax_blas_zdotu_fcall_ok = yes \ - -a $ax_blas_integer_size_ok = yes; then - ax_blas_f77_func_ok=yes; - $1 - else - ax_blas_f77_func_ok=no; - $2 - fi - LIBS="$save_ax_blas_f77_func_LIBS" - fi +# if any of the tests failed, reject the BLAS library + if test $ax_blas_lsame_fcall_ok = yes \ + -a $ax_blas_sdot_fcall_ok = yes \ + -a $ax_blas_ddot_fcall_ok = yes \ + -a $ax_blas_cdotu_fcall_ok = yes \ + -a $ax_blas_zdotu_fcall_ok = yes \ + -a $ax_blas_integer_size_ok = yes; then + ax_blas_f77_func_ok=yes; + $1 + else + ax_blas_f77_func_ok=no; + $2 + fi + LIBS="$save_ax_blas_f77_func_LIBS" +fi + ])dnl AX_BLAS_F77_FUNC AC_DEFUN([AX_BLAS_WITH_F77_FUNC], [ - AC_PREREQ(2.50) - AX_BLAS([# disable special action], []) - if test x$ax_blas_ok = xyes ; then - AX_BLAS_F77_FUNC( - [ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])], - [ax_blas_ok=no; BLAS_LIBS=], - [$3]) - fi - if test x$ax_blas_ok = xno ; then - $2 - fi +AC_PREREQ(2.50) +AX_BLAS([# disable special action], []) +if test x$ax_blas_ok = xyes ; then + AX_BLAS_F77_FUNC( + [ifelse([$1],,AC_DEFINE(HAVE_BLAS,1,[Define if you have a BLAS library.]),[$1])], + [ax_blas_ok=no; BLAS_LIBS=]) +fi +if test x$ax_blas_ok = xno ; then + $2 +fi ])dnl AX_BLAS_WITH_F77_FUNC diff -r 75a671fcdd73 -r 844448ae53f3 m4/ax_pthread.m4 --- a/m4/ax_pthread.m4 Fri Jan 23 15:21:25 2015 -0500 +++ b/m4/ax_pthread.m4 Fri Jan 23 15:23:09 2015 -0500 @@ -82,7 +82,7 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 18 +#serial 21 AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) AC_DEFUN([AX_PTHREAD], [ @@ -103,8 +103,8 @@ save_LIBS="$LIBS" LIBS="$PTHREAD_LIBS $LIBS" AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS]) - AC_TRY_LINK_FUNC(pthread_join, ax_pthread_ok=yes) - AC_MSG_RESULT($ax_pthread_ok) + AC_TRY_LINK_FUNC([pthread_join], [ax_pthread_ok=yes]) + AC_MSG_RESULT([$ax_pthread_ok]) if test x"$ax_pthread_ok" = xno; then PTHREAD_LIBS="" PTHREAD_CFLAGS="" @@ -164,6 +164,20 @@ ;; esac +# Clang doesn't consider unrecognized options an error unless we specify +# -Werror. We throw in some extra Clang-specific options to ensure that +# this doesn't happen for GCC, which also accepts -Werror. + +AC_MSG_CHECKING([if compiler needs -Werror to reject unknown flags]) +save_CFLAGS="$CFLAGS" +ax_pthread_extra_flags="-Werror" +CFLAGS="$CFLAGS $ax_pthread_extra_flags -Wunknown-warning-option -Wsizeof-array-argument" +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int foo(void);],[foo()])], + [AC_MSG_RESULT([yes])], + [ax_pthread_extra_flags= + AC_MSG_RESULT([no])]) +CFLAGS="$save_CFLAGS" + if test x"$ax_pthread_ok" = xno; then for flag in $ax_pthread_flags; do @@ -178,7 +192,7 @@ ;; pthread-config) - AC_CHECK_PROG(ax_pthread_config, pthread-config, yes, no) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) if test x"$ax_pthread_config" = xno; then continue; fi PTHREAD_CFLAGS="`pthread-config --cflags`" PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" @@ -193,7 +207,7 @@ save_LIBS="$LIBS" save_CFLAGS="$CFLAGS" LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS $ax_pthread_extra_flags" # Check for various functions. We must include pthread.h, # since some functions may be macros. (On the Sequent, we @@ -219,7 +233,7 @@ LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" - AC_MSG_RESULT($ax_pthread_ok) + AC_MSG_RESULT([$ax_pthread_ok]) if test "x$ax_pthread_ok" = xyes; then break; fi @@ -245,9 +259,9 @@ [attr_name=$attr; break], []) done - AC_MSG_RESULT($attr_name) + AC_MSG_RESULT([$attr_name]) if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then - AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name, + AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], [$attr_name], [Define to necessary symbol if this constant uses a non-standard name on your system.]) fi @@ -261,45 +275,54 @@ if test "$GCC" = "yes"; then flag="-D_REENTRANT" else + # TODO: What about Clang on Solaris? flag="-mt -D_REENTRANT" fi ;; esac - AC_MSG_RESULT(${flag}) + AC_MSG_RESULT([$flag]) if test "x$flag" != xno; then PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS" fi AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], - ax_cv_PTHREAD_PRIO_INHERIT, [ - AC_LINK_IFELSE([ - AC_LANG_PROGRAM([[#include ]], [[int i = PTHREAD_PRIO_INHERIT;]])], + [ax_cv_PTHREAD_PRIO_INHERIT], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[int i = PTHREAD_PRIO_INHERIT;]])], [ax_cv_PTHREAD_PRIO_INHERIT=yes], [ax_cv_PTHREAD_PRIO_INHERIT=no]) ]) AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes"], - AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], 1, [Have PTHREAD_PRIO_INHERIT.])) + [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.])]) LIBS="$save_LIBS" CFLAGS="$save_CFLAGS" - # More AIX lossage: must compile with xlc_r or cc_r - if test x"$GCC" != xyes; then - AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC}) - else - PTHREAD_CC=$CC + # More AIX lossage: compile with *_r variant + if test "x$GCC" != xyes; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], + [#handle absolute path differently from PATH based program lookup + AS_CASE(["x$CC"], + [x/*], + [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], + [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + ;; + esac fi -else - PTHREAD_CC="$CC" fi -AC_SUBST(PTHREAD_LIBS) -AC_SUBST(PTHREAD_CFLAGS) -AC_SUBST(PTHREAD_CC) +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + +AC_SUBST([PTHREAD_LIBS]) +AC_SUBST([PTHREAD_CFLAGS]) +AC_SUBST([PTHREAD_CC]) # Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: if test x"$ax_pthread_ok" = xyes; then - ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1]) + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) : else ax_pthread_ok=no diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/__error_text__.m --- a/scripts/deprecated/__error_text__.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -## Copyright (C) 2012-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} __error_text__ (@var{msg}, @var{msgid}) -## This function has been deprecated. Use @code{lasterr} instead. -## @seealso{lasterr} -## @end deftypefn - -function [msg, msgid] = __error_text__ (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "__error_text__ is obsolete and will be removed from a future version of Octave, please use lasterr instead"); - endif - - [msg, msgid] = lasterr (varargin{:}); - -endfunction - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/cor.m --- a/scripts/deprecated/cor.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,54 +0,0 @@ -## Copyright (C) 1995-2013 Kurt Hornik -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} cor (@var{x}) -## @deftypefnx {Function File} {} cor (@var{x}, @var{y}) -## Compute matrix of correlation coefficients. -## -## This is an alias for @code{corrcoef}. -## @seealso{corrcoef} -## @end deftypefn - -function retval = cor (x, y = x) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "cor is obsolete and will be removed from a future version of Octave; please use corr instead"); - endif - - if (nargin < 1 || nargin > 2) - print_usage (); - endif - - retval = corrcoef (x, y); - -endfunction - - -%!test -%! x = rand (10, 2); -%! assert (cor (x), corrcoef (x), 5*eps); -%! assert (cor (x(:,1), x(:,2)) == corrcoef (x(:,1), x(:,2))); - -%% Test input validation -%!error corrcoef (); -%!error corrcoef (1, 2, 3); - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/corrcoef.m --- a/scripts/deprecated/corrcoef.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,119 +0,0 @@ -## Copyright (C) 1996-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} corrcoef (@var{x}) -## @deftypefnx {Function File} {} corrcoef (@var{x}, @var{y}) -## Compute matrix of correlation coefficients. -## -## If each row of @var{x} and @var{y} is an observation and each column is -## a variable, then the @w{(@var{i}, @var{j})-th} entry of -## @code{corrcoef (@var{x}, @var{y})} is the correlation between the -## @var{i}-th variable in @var{x} and the @var{j}-th variable in @var{y}. -## @tex -## $$ -## {\rm corrcoef}(x,y) = {{\rm cov}(x,y) \over {\rm std}(x) {\rm std}(y)} -## $$ -## @end tex -## @ifnottex -## -## @example -## corrcoef(x,y) = cov(x,y)/(std(x)*std(y)) -## @end example -## -## @end ifnottex -## If called with one argument, compute @code{corrcoef (@var{x}, @var{x})}, -## the correlation between the columns of @var{x}. -## @seealso{cov} -## @end deftypefn - -## Author: Kurt Hornik -## Created: March 1993 -## Adapted-By: jwe - -function retval = corrcoef (x, y = []) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "corrcoef is not equivalent to Matlab and will be removed from a future version of Octave; for similar functionality see corr"); - endif - - if (nargin < 1 || nargin > 2) - print_usage (); - endif - - ## Input validation is done by cov.m. Don't repeat tests here - - ## Special case, scalar is always 100% correlated with itself - if (isscalar (x)) - if (isa (x, 'single')) - retval = single (1); - else - retval = 1; - endif - return; - endif - - ## No check for division by zero error, which happens only when - ## there is a constant vector and should be rare. - if (nargin == 2) - c = cov (x, y); - s = std (x)' * std (y); - retval = c ./ s; - else - c = cov (x); - s = sqrt (diag (c)); - retval = c ./ (s * s'); - endif - -endfunction - - -%!test -%! x = rand (10); -%! cc1 = corrcoef (x); -%! cc2 = corrcoef (x, x); -%! assert (size (cc1) == [10, 10] && size (cc2) == [10, 10]); -%! assert (cc1, cc2, sqrt (eps)); - -%!test -%! x = [1:3]'; -%! y = [3:-1:1]'; -%! assert (corrcoef (x,y), -1, 5*eps) -%! assert (corrcoef (x,flipud (y)), 1, 5*eps) -%! assert (corrcoef ([x, y]), [1 -1; -1 1], 5*eps) - -%!test -%! x = single ([1:3]'); -%! y = single ([3:-1:1]'); -%! assert (corrcoef (x,y), single (-1), 5*eps) -%! assert (corrcoef (x,flipud (y)), single (1), 5*eps) -%! assert (corrcoef ([x, y]), single ([1 -1; -1 1]), 5*eps) - -%!assert (corrcoef (5), 1); -%!assert (corrcoef (single(5)), single(1)); - -%% Test input validation -%!error corrcoef (); -%!error corrcoef (1, 2, 3); -%!error corrcoef ([1; 2], ["A", "B"]); -%!error corrcoef (ones (2,2,2)); -%!error corrcoef (ones (2,2), ones (2,2,2)); - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/cut.m --- a/scripts/deprecated/cut.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,72 +0,0 @@ -## Copyright (C) 1996-2013 Kurt Hornik -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} cut (@var{x}, @var{breaks}) -## Create categorical data from numerical or continuous data by -## cutting into intervals. -## -## If @var{breaks} is a scalar, the data is cut into that many -## equal-width intervals. If @var{breaks} is a vector of break points, -## the category has @code{length (@var{breaks}) - 1} groups. -## -## The returned value is a vector of the same size as @var{x} telling -## which group each point in @var{x} belongs to. Groups are labelled -## from 1 to the number of groups; points outside the range of -## @var{breaks} are labelled by @code{NaN}. -## @seealso{histc} -## @end deftypefn - -## Author: KH -## Description: Cut data into intervals - -function group = cut (x, breaks) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "cut is obsolete and will be removed from a future version of Octave; please use histc instead"); - endif - - if (nargin != 2) - print_usage (); - endif - - if (!isvector (x)) - error ("cut: X must be a vector"); - endif - if (isscalar (breaks)) - breaks = linspace (min (x), max (x), breaks + 1); - breaks(1) = breaks(1) - 1; - elseif (isvector (breaks)) - breaks = sort (breaks); - else - error ("cut: BREAKS must be a scalar or vector"); - endif - - group = NaN (size (x)); - m = length (breaks); - if (any (k = find ((x >= min (breaks)) & (x < max (breaks))))) - n = length (k); - group(k) = sum ((ones (m, 1) * reshape (x(k), 1, n)) - >= (reshape (breaks, m, 1) * ones (1, n))); - endif - -endfunction - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/default_save_options.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/error_text.m --- a/scripts/deprecated/error_text.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -## Copyright (C) 2012-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Built-in Function} {[@var{msg}, @var{msgid}] =} error_text (@var{msg}, @var{msgid}) -## This function has been deprecated. Use @code{lasterr} instead. -## @seealso{lasterr} -## @end deftypefn - -function [msg, msgid] = error_text (varargin) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "error_text is obsolete and will be removed from a future version of Octave, please use lasterr instead"); - endif - - [msg, msgid] = lasterr (varargin{:}); - -endfunction - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/interp1q.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/isequalwithequalnans.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/java_convert_matrix.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/java_debug.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/java_invoke.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/java_unsigned_conversion.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/javafields.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/javamethods.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/module.mk --- a/scripts/deprecated/module.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/deprecated/module.mk Fri Jan 23 15:23:09 2015 -0500 @@ -1,12 +1,7 @@ FCN_FILE_DIRS += deprecated deprecated_FCN_FILES = \ - deprecated/__error_text__.m \ - deprecated/cor.m \ - deprecated/corrcoef.m \ - deprecated/cut.m \ deprecated/default_save_options.m \ - deprecated/error_text.m \ deprecated/gen_doc_cache.m \ deprecated/interp1q.m \ deprecated/isequalwithequalnans.m \ @@ -18,13 +13,9 @@ deprecated/java_unsigned_conversion.m \ deprecated/javafields.m \ deprecated/javamethods.m \ - deprecated/polyderiv.m \ deprecated/re_read_readline_init_file.m \ deprecated/read_readline_init_file.m \ - deprecated/saving_history.m \ - deprecated/shell_cmd.m \ - deprecated/studentize.m \ - deprecated/sylvester_matrix.m + deprecated/saving_history.m FCN_FILES += $(deprecated_FCN_FILES) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/polyderiv.m --- a/scripts/deprecated/polyderiv.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,109 +0,0 @@ -## Copyright (C) 1994-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} polyderiv (@var{p}) -## @deftypefnx {Function File} {[@var{k}] =} polyderiv (@var{a}, @var{b}) -## @deftypefnx {Function File} {[@var{q}, @var{d}] =} polyderiv (@var{b}, @var{a}) -## Return the coefficients of the derivative of the polynomial whose -## coefficients are given by the vector @var{p}. If a pair of polynomials -## is given, return the derivative of the product @math{@var{a}*@var{b}}. -## If two inputs and two outputs are given, return the derivative of the -## polynomial quotient @math{@var{b}/@var{a}}. The quotient numerator is -## in @var{q} and the denominator in @var{d}. -## @seealso{poly, polyint, polyreduce, roots, conv, deconv, residue, -## filter, polygcd, polyval, polyvalm} -## @end deftypefn - -## Author: Tony Richardson -## Created: June 1994 -## Adapted-By: jwe - -function [q, d] = polyderiv (p, a) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "polyderiv is obsolete and will be removed from a future version of Octave; please use polyder instead"); - endif - - if (nargin == 1 || nargin == 2) - if (! isvector (p)) - error ("polyderiv: argument must be a vector"); - endif - if (nargin == 2) - if (! isvector (a)) - error ("polyderiv: argument must be a vector"); - endif - if (nargout == 1) - ## derivative of p*a returns a single polynomial - q = polyderiv (conv (p, a)); - else - ## derivative of p/a returns numerator and denominator - d = conv (a, a); - if (numel (p) == 1) - q = -p * polyderiv (a); - elseif (numel (a) == 1) - q = a * polyderiv (p); - else - q = conv (polyderiv (p), a) - conv (p, polyderiv (a)); - q = polyreduce (q); - endif - - ## remove common factors from numerator and denominator - x = polygcd (q, d); - if (length(x) != 1) - q = deconv (q, x); - d = deconv (d, x); - endif - - ## move all the gain into the numerator - q = q/d(1); - d = d/d(1); - endif - else - lp = numel (p); - if (lp == 1) - q = 0; - return; - elseif (lp == 0) - q = []; - return; - endif - - ## Force P to be a row vector. - p = p(:).'; - - q = p(1:(lp-1)) .* [(lp-1):-1:1]; - endif - else - print_usage (); - endif - -endfunction - - -%!assert(all (all (polyderiv ([1, 2, 3]) == [2, 2]))); - -%!assert(polyderiv (13) == 0); - -%!error polyderiv ([]); - -%!error polyderiv ([1, 2; 3, 4]); - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/saving_history.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/shell_cmd.m --- a/scripts/deprecated/shell_cmd.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -## Copyright (C) 2012-2013 Rik Wehbring -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## "-*- texinfo -*- -## @deftypefn {Built-in Function} {} shell_cmd (@var{string}) -## @deftypefnx {Built-in Function} {} shell_cmd (@var{string}, @var{return_output}) -## @deftypefnx {Built-in Function} {} shell_cmd (@var{string}, @var{return_output}, @var{type}) -## @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} shell_cmd (@dots{}) -## @deftypefnx {Built-in Function} {[@var{status}, @var{output}] =} shell_cmd (@var{string}, @var{return_output}, @var{type}) -## Execute a shell command specified by @var{string}. -## If the optional argument @var{type} is @qcode{"async"}, the process -## is started in the background and the process id of the child process -## is returned immediately. Otherwise, the process is started and -## Octave waits until it exits. If the @var{type} argument is omitted, it -## defaults to a value of @qcode{"sync"}. -## -## If the optional argument @var{return_output} is true and the subprocess -## is started synchronously, or if @var{shell_cmd} is called with one input -## argument and one or more output arguments, then the output from the command -## is returned. Otherwise, if the subprocess is executed synchronously, its -## output is sent to the standard output. -## -## The @code{shell_cmd} function can return two values. The first is the -## exit status of the command and the second is any output from the -## command that was written to the standard output stream. For example, -## -## @example -## [status, output] = shell_cmd ("echo foo; exit 2"); -## @end example -## -## @noindent -## will set the variable @code{output} to the string @samp{foo}, and the -## variable @code{status} to the integer @samp{2}. -## -## For commands run asynchronously, @var{status} is the process id of the -## command shell that is started to run the command. -## @seealso{system, unix, dos} -## @end deftypefn - -## Deprecated in version 3.6 - -function [status, output] = shell_cmd (varargin) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "shell_cmd is obsolete and will be removed from a future version of Octave; please use system instead"); - endif - - [status, output] = system (varargin{:}); - -endfunction - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/studentize.m --- a/scripts/deprecated/studentize.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,95 +0,0 @@ -## Copyright (C) 1995-2013 Kurt Hornik -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} studentize (@var{x}) -## @deftypefnx {Function File} {} studentize (@var{x}, @var{dim}) -## If @var{x} is a vector, subtract its mean and divide by its standard -## deviation. -## -## If @var{x} is a matrix, do the above along the first non-singleton -## dimension. -## If the optional argument @var{dim} is given, operate along this dimension. -## @seealso{center} -## @end deftypefn - -## Author: KH -## Description: Subtract mean and divide by standard deviation - -function t = studentize (x, dim) - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "studentize is obsolete and will be removed from a future version of Octave; please use zscore instead"); - endif - - if (nargin != 1 && nargin != 2) - print_usage (); - endif - - if (! isnumeric(x)) - error ("studentize: X must be a numeric vector or matrix"); - endif - - if (isinteger (x)) - x = double (x); - endif - - nd = ndims (x); - sz = size (x); - if (nargin != 2) - ## Find the first non-singleton dimension. - dim = find (sz > 1, 1); - if (isempty (dim)) - dim = 1; - endif - else - if (!(isscalar (dim) && dim == fix (dim)) - || !(1 <= dim && dim <= nd)) - error ("studentize: DIM must be an integer and a valid dimension"); - endif - endif - - c = sz(dim); - if (c == 0) - t = x; - else - idx = ones (1, nd); - idx(dim) = c; - t = x - repmat (mean (x, dim), idx); - t = t ./ repmat (max (cat (dim, std(t, [], dim), ! any (t, dim)), [], dim), idx); - endif - -endfunction - - -%!assert(studentize ([1,2,3]), [-1,0,1]) -%!assert(studentize (int8 ([1,2,3])), [-1,0,1]) -#%!assert(studentize (ones (3,2,0,2)), zeros (3,2,0,2)) -%!assert(studentize ([2,0,-2;0,2,0;-2,-2,2]), [1,0,-1;0,1,0;-1,-1,1]) - -%% Test input validation -%!error studentize () -%!error studentize (1, 2, 3) -%!error studentize ([true true]) -%!error studentize (1, ones(2,2)) -%!error studentize (1, 1.5) -%!error studentize (1, 0) -%!error studentize (1, 3) - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/deprecated/sylvester_matrix.m --- a/scripts/deprecated/sylvester_matrix.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,70 +0,0 @@ -## Copyright (C) 1996-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} sylvester_matrix (@var{k}) -## Return the Sylvester matrix of order -## @tex -## $n = 2^k$. -## @end tex -## @ifnottex -## n = 2^@var{k}. -## @end ifnottex -## -## @seealso{toeplitz, hankel} -## @end deftypefn - -## Author: jwe - -function retval = sylvester_matrix (k) - - persistent warned = false; - if (! warned) - warned = true; - warning ("Octave:deprecated-function", - "sylvester_matrix is obsolete and will be removed from a future version of Octave; please use hadamard(2^k) instead"); - endif - - if (nargin != 1) - print_usage (); - endif - - if (isscalar (k)) - if (k < 1) - retval = 1; - else - tmp = sylvester_matrix (k-1); - retval = [tmp, tmp; tmp, -tmp]; - endif - else - error ("sylvester_matrix: expecting scalar argument"); - endif - -endfunction - - -%!assert((sylvester_matrix (1) == [1, 1; 1, -1] -%! && (sylvester_matrix (2) -%! == [1, 1, 1, 1; 1, -1, 1, -1; 1, 1, -1, -1; 1, -1, -1, 1]))); - -%!error sylvester_matrix ([1, 2; 3, 4]); - -%!error sylvester_matrix (); - -%!error sylvester_matrix (1, 2); - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/general/isa.m --- a/scripts/general/isa.m Fri Jan 23 15:21:25 2015 -0500 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,110 +0,0 @@ -## Copyright (C) 2004-2013 John W. Eaton -## -## This file is part of Octave. -## -## Octave is free software; you can redistribute it and/or modify it -## under the terms of the GNU General Public License as published by -## the Free Software Foundation; either version 3 of the License, or (at -## your option) any later version. -## -## Octave is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with Octave; see the file COPYING. If not, see -## . - -## -*- texinfo -*- -## @deftypefn {Function File} {} isa (@var{obj}, @var{classname}) -## Return true if @var{obj} is an object from the class @var{classname}. -## -## @var{classname} may also be one of the following class categories: -## -## @table @asis -## @item @qcode{"float"} -## Floating point value comprising classes @qcode{"double"} and -## @qcode{"single"}. -## -## @item @qcode{"integer"} -## Integer value comprising classes (u)int8, (u)int16, (u)int32, (u)int64. -## -## @item @qcode{"numeric"} -## Numeric value comprising either a floating point or integer value. -## @end table -## @seealso{class, typeinfo} -## @end deftypefn - -## Author: Paul Kienzle -## Adapted-by: jwe - -function retval = isa (obj, classname) - - if (nargin != 2) - print_usage (); - endif - - if (strcmp (classname, "float")) - retval = isfloat (obj); - elseif (strcmp (classname, "integer")) - retval = isinteger (obj); - elseif (strcmp (classname, "numeric")) - retval = isnumeric (obj); - else - class_of_obj = class (obj); - retval = strcmp (class_of_obj, classname); - if (! retval && isobject (obj)) - retval = __isa_parent__ (obj, classname); - endif - endif - -endfunction - - -%!assert (isa ("char", "float"), false) -%!assert (isa (logical (1), "float"), false) -%!assert (isa (double (13), "float"), true) -%!assert (isa (single (13), "float"), true) -%!assert (isa (int8 (13), "float"), false) -%!assert (isa (int16 (13), "float"), false) -%!assert (isa (int32 (13), "float"), false) -%!assert (isa (int64 (13), "float"), false) -%!assert (isa (uint8 (13), "float"), false) -%!assert (isa (uint16 (13), "float"), false) -%!assert (isa (uint32 (13), "float"), false) -%!assert (isa (uint64 (13), "float"), false) -%!assert (isa ("char", "numeric"), false) -%!assert (isa (logical (1), "numeric"), false) -%!assert (isa (double (13), "numeric"), true) -%!assert (isa (single (13), "numeric"), true) -%!assert (isa (int8 (13), "numeric"), true) -%!assert (isa (int16 (13), "numeric"), true) -%!assert (isa (int32 (13), "numeric"), true) -%!assert (isa (int64 (13), "numeric"), true) -%!assert (isa (uint8 (13), "numeric"), true) -%!assert (isa (uint16 (13), "numeric"), true) -%!assert (isa (uint32 (13), "numeric"), true) -%!assert (isa (uint64 (13), "numeric"), true) -%!assert (isa (uint8 (13), "integer"), true) -%!assert (isa (double (13), "integer"), false) -%!assert (isa (single (13), "integer"), false) - -%!assert (isa (double (13), "double")) -%!assert (isa (single (13), "single")) -%!assert (isa (int8 (13), "int8")) -%!assert (isa (int16 (13), "int16")) -%!assert (isa (int32 (13), "int32")) -%!assert (isa (int64 (13), "int64")) -%!assert (isa (uint8 (13), "uint8")) -%!assert (isa (uint16 (13), "uint16")) -%!assert (isa (uint32 (13), "uint32")) -%!assert (isa (uint64 (13), "uint64")) -%!assert (isa ("string", "char")) -%!assert (isa (true, "logical")) -%!assert (isa (false, "logical")) -%!assert (isa ({1, 2}, "cell")) -%!test -%! a.b = 1; -%! assert (isa (a, "struct")); - diff -r 75a671fcdd73 -r 844448ae53f3 scripts/general/module.mk --- a/scripts/general/module.mk Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/general/module.mk Fri Jan 23 15:23:09 2015 -0500 @@ -40,7 +40,6 @@ general/interp3.m \ general/interpn.m \ general/interpft.m \ - general/isa.m \ general/iscolumn.m \ general/isdir.m \ general/isequal.m \ @@ -82,6 +81,7 @@ general/subsindex.m \ general/triplequad.m \ general/trapz.m \ + general/validateattributes.m \ $(general_PRIVATE_FCN_FILES) FCN_FILES += $(general_FCN_FILES) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/general/postpad.m --- a/scripts/general/postpad.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/general/postpad.m Fri Jan 23 15:23:09 2015 -0500 @@ -30,6 +30,9 @@ ## ## If the optional argument @var{dim} is given, operate along this ## dimension. +## +## If @var{dim} is larger than the dimensions of @var{x}, the result will +## have @var{dim} dimensions. ## @seealso{prepad, cat, resize} ## @end deftypefn @@ -56,8 +59,7 @@ ## Find the first non-singleton dimension. (dim = find (sz > 1, 1)) || (dim = 1); else - if (!(isscalar (dim) && dim == fix (dim)) - || !(1 <= dim && dim <= nd)) + if (!(isscalar (dim) && dim == fix (dim) && dim >= 1)) error ("postpad: DIM must be an integer and a valid dimension"); endif endif @@ -89,9 +91,10 @@ %!assert (postpad ([1,2], 4, 2), [1,2,2,2]) %!assert (postpad ([1;2], 4, 2), [1;2;2;2]) %!assert (postpad ([1,2], 2, 2, 1), [1,2;2,2]) +%!assert (postpad ([1;2], 2, 2, 3), reshape ([1;2;2;2], 2, 1, 2)) +%!assert (postpad ([1,2], 2, 2, 3), reshape ([1,2,2,2], 1, 2, 2)) %!error postpad () %!error postpad (1) %!error postpad (1,2,3,4,5) -%!error postpad ([1,2], 2, 2,3) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/general/prepad.m --- a/scripts/general/prepad.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/general/prepad.m Fri Jan 23 15:23:09 2015 -0500 @@ -30,6 +30,9 @@ ## ## If the optional argument @var{dim} is given, operate along this ## dimension. +## +## If @var{dim} is larger than the dimensions of @var{x}, the result will +## have @var{dim} dimensions. ## @seealso{postpad, cat, resize} ## @end deftypefn @@ -56,8 +59,7 @@ ## Find the first non-singleton dimension. (dim = find (sz > 1, 1)) || (dim = 1); else - if (!(isscalar (dim) && dim == fix (dim)) - || !(1 <= dim && dim <= nd)) + if (!(isscalar (dim) && dim == fix (dim) && dim >= 1)) error ("prepad: DIM must be an integer and a valid dimension"); endif endif @@ -92,6 +94,9 @@ %!assert (prepad ([1,2], 2, 2, 1), [2,2;1,2]) +%!assert (prepad ([1,2], 2, 2, 3), reshape ([2,2,1,2], 1, 2, 2)) +%!assert (prepad ([1;2], 2, 2, 3), reshape ([2;2;1;2], 2, 1, 2)) + ## FIXME -- we need tests for multidimensional arrays. %!error prepad () @@ -100,7 +105,6 @@ %!error prepad ([1,2], 2, ones (2)) %!error prepad ([1,2], 2, 2, ones (3)) %!error prepad ([1,2], 2, 2, 1.1) -%!error prepad ([1,2], 2, 2, 3) %!error prepad ([1,2], ones (2)) %!error prepad ([1,2], -1) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/general/validateattributes.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/general/validateattributes.m Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,432 @@ +## Copyright (C) 2013 Carnë Draug +## +## This file is part of Octave. +## +## Octave is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## Octave is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Octave; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} validateattributes (@var{A}, @var{classes}, @var{attributes}) +## @deftypefnx {Function File} {} validateattributes (@var{A}, @var{classes}, @var{attributes}, @var{arg_idx}) +## @deftypefnx {Function File} {} validateattributes (@var{A}, @var{classes}, @var{attributes}, @var{func_name}) +## @deftypefnx {Function File} {} validateattributes (@var{A}, @var{classes}, @var{attributes}, @var{func_name}, @var{arg_name}) +## @deftypefnx {Function File} {} validateattributes (@var{A}, @var{classes}, @var{attributes}, @var{func_name}, @var{arg_name}, @var{arg_idx}) +## Check validity of input argument. +## +## Confirms that the argument @var{A} is valid by belonging to one of +## @var{classes}, and holding all of the @var{attributes}. If it does not, +## an error is thrown, with a message formatted accordingly. The error +## message can be made further complete by the function name @var{fun_name}, +## the argument name @var{arg_name}, and its position in the input +## @var{arg_idx}. +## +## @var{classes} must be a cell array of strings (an empty cell array is +## allowed) with the name of classes (remember that a class name is case +## sensitive). In addition to the class name, the following categories +## names are also valid: +## +## @table @asis +## @item @qcode{"float"} +## Floating point value comprising classes @qcode{"double"} and +## @qcode{"single"}. +## +## @item @qcode{"integer"} +## Integer value comprising classes (u)int8, (u)int16, (u)int32, (u)int64. +## +## @item @qcode{"numeric"} +## Numeric value comprising either a floating point or integer value. +## +## @end table +## +## @var{attributes} must be a cell array with names of checks for @var{A}. +## Some of them require an additional value to be supplied right after the +## name (see details for each below). +## +## @table @asis +## @item @qcode{"<="} +## All values are less than or equal to the following value in @var{attributes}. +## +## @item @qcode{"<"} +## All values are less than the following value in @var{attributes}. +## +## @item @qcode{">="} +## All values are greater than or equal to the following value in +## @var{attributes}. +## +## @item @qcode{">"} +## All values are greater than the following value in @var{attributes}. +## +## @item @qcode{"2d"} +## A 2-dimensional matrix. Note that vectors and empty matrices have +## 2 dimensions, one of them being of length 1, or both length 0. +## +## @item @qcode{"3d"} +## Has no more than 3 dimensions. A 2-dimensional matrix is a 3-D matrix +## whose 3rd dimension is of length 1. +## +## @item @qcode{"binary"} +## All values are either 1 or 0. +## +## @item @qcode{"column"} +## Values are arranged in a single column. +## +## @item @qcode{"decreasing"} +## No value is @var{NaN}, and each is less than the preceding one. +## +## @item @qcode{"even"} +## All values are even numbers. +## +## @item @qcode{"finite"} +## All values are finite. +## +## @item @qcode{"increasing"} +## No value is @var{NaN}, and each is greater than the preceding one. +## +## @item @qcode{"integer"} +## All values are integer. This is different than using @code{isinteger} +## which only checks its an integer type. This checks that each value in +## @var{A} is an integer value, i.e., it has no decimal part. +## +## @item @qcode{"ncols"} +## Has exactly as many columns as the next value in @var{attributes}. +## +## @item @qcode{"ndims"} +## Has exactly as many dimensions as the next value in @var{attributes}. +## +## @item @qcode{"nondecreasing"} +## No value is @var{NaN}, and each is greater than or equal to the preceding +## one. +## +## @item @qcode{"nonempty"} +## It is not empty. +## +## @item @qcode{"nonincreasing"} +## No value is @var{NaN}, and each is less than or equal to the preceding one. +## +## @item @qcode{"nonnan"} +## No value is a @code{NaN}. +## +## @item @qcode{"non-negative"} +## All values are non negative. +## +## @item @qcode{"nonsparse"} +## It is not a sparse matrix. +## +## @item @qcode{"nonzero"} +## No value is zero. +## +## @item @qcode{"nrows"} +## Has exactly as many rows as the next value in @var{attributes}. +## +## @item @qcode{"numel"} +## Has exactly as many elements as the next value in @var{attributes}. +## +## @item @qcode{"odd"} +## All values are odd numbers. +## +## @item @qcode{"positive"} +## All values are positive. +## +## @item @qcode{"real"} +## It is a non-complex matrix. +## +## @item @qcode{"row"} +## Values are arranged in a single row. +## +## @item @qcode{"scalar"} +## It is a scalar. +## +## @item @qcode{"size"} +## Its size has length equal to the values of the next in @var{attributes}. +## The next value must is an array with the length for each dimension. To +## ignore the check for a certain dimension, the value of @code{NaN} can be +## used. +## +## @item @qcode{"square"} +## Is a square matrix. +## +## @item @qcode{"vector"} +## Values are arranged in a single vector (column or vector). +## +## @end table +## +## @seealso{nargin, varargin, isa, validatestring} +## @end deftypefn + +function validateattributes (A, cls, attr, varargin) + if (nargin < 3 || nargin > 6) + print_usage (); + elseif (! iscellstr (cls)) + error ("validateattributes: CLASSES must be a cell array of strings"); + elseif (! iscell (attr)) + error ("validateattributes: ATTRIBUTES must be a cell array"); + endif + + ## Built start of error message from the extra optional arguments + func_name = ""; + var_name = "input"; + if (nargin > 3) + fourth = varargin{1}; + if (ischar (fourth)) + func_name = [fourth ": "]; + elseif (nargin == 4 && valid_arg_idx (fourth)) + var_name = sprintf ("input %d", fourth); + else + error ("validateattributes: 4th input argument must be ARG_IDX or FUNC_NAME"); + endif + + if (nargin > 4) + var_name = varargin{2}; + if (! ischar (var_name)) + error ("validateattributes: VAR_NAME must be a string"); + endif + + if (nargin > 5) + arg_idx = varargin{3}; + if (! valid_arg_idx (arg_idx)) + error ("validateattributes: ARG_IDX must be a positive integer"); + endif + var_name = sprintf ("%s (argument #%i)", var_name, arg_idx); + endif + endif + endif + err_ini = [func_name var_name]; + + check_cl = isa (A, cls); + if (! isempty (check_cl) && ! any (check_cl)) + ## Allowing for an empty list of classes is Matlab incompatible but + ## that should count as a just a Matlab bug, not an incompatibility. + + ## Replace the category names with the classes that belong to it. + integer = { "int8" "int16" "int32" "int64" ... + "uint8" "uint16" "uint32" "uint64"}; + float = {"single" "double"}; + numeric = {integer{:} float{:}}; + cls = replace_cl_group (cls, "integer", integer); + cls = replace_cl_group (cls, "float", float ); + cls = replace_cl_group (cls, "numeric", numeric); + cls = unique (cls); + + classes = sprintf (" %s", cls{:}); + error ("%s must be of class:\n\n %s\n\nbut was of class %s", + err_ini, classes, class (A)); + endif + + ## We use a while loop because some attributes require the following value + ## in the cell array. Also, we can't just get the boolean value for the + ## test and check at the end the error message since some of the tests + ## require some more complex error message. + + ## It may look like that we don't perform enough input check in this + ## function (e.g., we don't check if there's a value after the size + ## attribute). The reasoning is that this will be a function mostly used + ## by developers with fairly static input so any problem would be caught + ## immediately during that functino development, it's no dependent on the + ## final user input. In addition, it can be called so many times at the + ## start of every function, we want it to run specially fast. + idx = 1; + problem = false; # becomes true when one of the tests fails + while (idx <= numel (attr)) + ## TODO: once we use this in Octave core, it might be worthy to find + ## which attributes are checked more often, and place them in that + ## order inside the switch block. + switch (tolower (attr{idx++})) + case "2d", problem = ndims (A) != 2; + case "3d", problem = ndims (A) > 3; + case "column", problem = ! iscolumn (A); + case "row", problem = ! isrow (A); + case "scalar", problem = ! isscalar (A); + case "vector", problem = ! isvector (A); + case "square", problem = ! issquare (A); + case "nonempty", problem = isempty (A); + case "nonsparse", problem = issparse (A); + case "binary", problem = ! islogical (A) && ... + any ((A(:) != 1) & (A(:) != 0)); + case "even", problem = any (rem (A(:), 2) != 0); + case "odd", problem = any (mod (A(:), 2) != 1); + case "integer", problem = ! isinteger (A) && ... + any (ceil (A(:)) != A(:)); + case "real", problem = ! isreal (A); + case "finite", problem = ! isinteger (A) && ... + ! all (isfinite (A(:))); + case "nonnan", problem = ! isinteger (A) && ... + any (isnan (A(:))); + case "nonnegative", problem = any (A(:) < 0); + case "nonzero", problem = any (A(:) == 0); + case "positive", problem = any (A(:) <= 0); + case "decreasing", problem = (any (isnan (A(:))) || + any (diff (A(:)) >= 0)); + case "increasing", problem = (any (isnan (A(:))) || + any (diff (A(:)) <= 0)); + case "nondecreasing", problem = (any (isnan (A(:))) || + any (diff (A(:)) < 0)); + case "nonincreasing", problem = (any (isnan (A(:))) || + any (diff (A(:)) > 0)); + case "size", + A_size = size (A); + w_size = attr{idx++}; + A_size(isnan (w_size)) = NaN; + if (! isequaln (A_size, w_size)) + A_size_str = sprintf ("%dx", size (A))(1:end-1); + w_size_str = sprintf ("%ix", w_size)(1:end-1); + w_size_str = strrep (w_size_str, "NaN", "N"); + error ("%s must be of size %s but was %s", err_ini, w_size_str, A_size_str); + endif + case "numel", + if (numel (A) != attr{idx++}) + error ("%s must have %d elements", err_ini, attr{idx-1}); + endif + case "ncols", + if (columns (A) != attr{idx++}) + error ("%s must have %d columns", err_ini, attr{idx-1}); + endif + case "nrows", + if (rows (A) != attr{idx++}) + error ("%s must have %d rows", err_ini, attr{idx-1}); + endif + case "ndims", + ## Note that a [4 5 1] matrix is not considered to have ndims == 3 + ## but is ok for "3d". This is not a bug. + if (ndims (A) != attr{idx++}) + error ("%s must have %d dimensions", err_ini, attr{idx-1}); + endif + case ">" + if (! all (A(:) > attr{idx++})) + error ("%s must be greater than %f", err_ini, attr{idx-1}); + endif + case ">=" + if (! all (A(:) >= attr{idx++})) + error ("%s must be greater than or equal to %f", err_ini, attr{idx-1}); + endif + case "<" + if (! all (A(:) < attr{idx++})) + error ("%s must be less than %f", err_ini, attr{idx-1}); + endif + case "<=" + if (! all (A(:) <= attr{idx++})) + error ("%s must be less than or equal to %f", err_ini, attr{idx-1}); + endif + otherwise + error ("validateattributes: unknown ATTRIBUTE %s", attr{idx-1}); + endswitch + if (problem) + error ("%s must be %s", err_ini, attr{idx-1}); + endif + endwhile +endfunction + +function retval = valid_arg_idx (arg) + retval = isnumeric (arg) && isscalar (arg) && arg > 0 && ceil (arg) == arg; +endfunction + +function cls = replace_cl_group (cls, name, group) + num_pos = strcmpi (cls, name); + if (any (num_pos)) + cls(num_pos) = []; + cls(end+1:end+numel(group)) = group; + endif +endfunction + +%!error validateattributes (rand (5), {"uint8"}, {}) +%!error validateattributes (uint8 (rand (5)), {"float"}, {}) +%!error <2d> validateattributes (rand (5, 5, 5), {}, {"2d"}) +%!error <3d> validateattributes (rand (5, 5, 5, 7), {}, {"3d"}) +%!error validateattributes (rand (5, 5), {}, {"column"}) +%!error validateattributes (rand (1, 5), {}, {"column"}) +%!error validateattributes (rand (5, 5), {}, {"row"}) +%!error validateattributes (rand (5, 1), {}, {"row"}) +%!error validateattributes (rand (1, 5), {}, {"scalar"}) +%!error validateattributes (rand (5), {}, {"vector"}) +%!error validateattributes (rand (5, 6), {}, {"square"}) +%!error validateattributes ([], {}, {"nonempty"}) +%!error validateattributes (sparse(rand(5)), {}, {"nonsparse"}) +%!error validateattributes ("text", {}, {"binary"}) +%!error validateattributes ([0 1 0 3 0], {}, {"binary"}) +%!error validateattributes ([2 3 6 8], {}, {"even"}) +%!error validateattributes ([2 NaN], {}, {"even"}) +%!error validateattributes ([3 4 7 5], {}, {"odd"}) +%!error validateattributes ([5 NaN], {}, {"odd"}) +%!error validateattributes ([5 5.2 5.7], {}, {"integer"}) +%!error validateattributes ([5i 8 9], {}, {"real"}) +%!error validateattributes ([5i Inf 8], {}, {"finite"}) +%!error validateattributes ([NaN Inf 8], {}, {"nonnan"}) +%!error validateattributes ([7 8 -9], {}, {"nonnegative"}) +%!error validateattributes ([7 8 0], {}, {"nonzero"}) +%!error validateattributes ([7 0 8], {}, {"positive"}) +%!error validateattributes ([7 8 4 3 -5], {}, {"decreasing"}) +%!error validateattributes ([7 NaN 4 3 -5], {}, {"decreasing"}) +%!error validateattributes ([7 8 4 9 20], {}, {"increasing"}) +%!error validateattributes ([7 8 NaN 9 20], {}, {"increasing"}) +%!error validateattributes ([7 8 4 9 20], {}, {"nonincreasing"}) +%!error validateattributes ([7 8 NaN 9 20], {}, {"nonincreasing"}) +%!error validateattributes ([7 8 4 3 -5], {}, {"nondecreasing"}) +%!error validateattributes ([7 NaN 4 3 -5], {}, {"nondecreasing"}) +%!error validateattributes (ones (5, 3, 6), {}, {"size", [5 4 7]}) +%!error validateattributes (ones (5, 3, 6), {}, {"size", [5 NaN 7]}) +%!error validateattributes (ones (5, 3, 6), {}, {"size", [5 3 6 2]}) +%!error validateattributes (ones (6, 3), {}, {"numel", 12}) +%!error validateattributes (ones (6, 2), {}, {"ncols", 3}) +%!error validateattributes (ones (6, 2), {}, {"nrows", 3}) +%!error validateattributes (ones (6, 2, 6, 3), {}, {"ndims", 3}) +%!error validateattributes ([6 7 8 5], {}, {">", 5}) +%!error validateattributes ([6 7 8 5], {}, {">=", 6}) +%!error validateattributes ([6 7 8 5], {}, {"<", 8}) +%!error validateattributes ([6 7 8 5], {}, {"<=", 7}) + +%!test +%! validateattributes (rand (5), {"numeric"}, {}) +%! validateattributes (rand (5), {"float"}, {}) +%! validateattributes (rand (5), {"double"}, {}) +%! validateattributes ("text", {"char"}, {}) +%! validateattributes (rand (5), {}, {"2d"}) +%! validateattributes (rand (5), {}, {"3d"}) +%! validateattributes (rand (5, 5, 5), {}, {"3d"}) +%! validateattributes (rand (5, 1), {}, {"column"}) +%! validateattributes (rand (1, 5), {}, {"row"}) +%! validateattributes ("a", {}, {"scalar"}) +%! validateattributes (5, {}, {"scalar"}) +%! validateattributes (rand (1, 5), {}, {"vector"}) +%! validateattributes (rand (5, 1), {}, {"vector"}) +%! validateattributes (rand (5), {}, {"square"}) +%! validateattributes (rand (5), {}, {"nonempty"}) +%! validateattributes (rand (5), {}, {"nonsparse"}) +%! validateattributes ([0 1 0 1 0], {}, {"binary"}) +%! validateattributes (rand (5) > 0.5, {}, {"binary"}) +%! validateattributes ([8 4 0 6], {}, {"even"}) +%! validateattributes ([-1 3 5], {}, {"odd"}) +%! validateattributes ([8 4 0 6], {}, {"real"}) +%! validateattributes ([8 4i 0 6], {}, {"finite"}) +%! validateattributes (uint8 ([8 4]), {}, {"finite"}) +%! validateattributes ([8 Inf], {}, {"nonnan"}) +%! validateattributes ([0 7 4], {}, {"nonnegative"}) +%! validateattributes ([-8 7 4], {}, {"nonzero"}) +%! validateattributes ([8 7 4], {}, {"positive"}) +%! validateattributes ([8 7 4 -5], {}, {"decreasing"}) +%! validateattributes ([-8 -7 4 5], {}, {"increasing"}) +%! validateattributes ([8 4 4 -5], {}, {"nonincreasing"}) +%! validateattributes ([-8 -8 4 5], {}, {"nondecreasing"}) +%! validateattributes (rand (4, 6, 7, 2), {}, {"size", [4 6 7 2]}) +%! validateattributes (rand (4, 6, 7, 2), {}, {"size", [4 NaN 7 2]}) +%! validateattributes (rand (4, 6, 7, 2), {}, {"size", [4 6 NaN 2 NaN]}) +%! validateattributes (rand (6, 2), {}, {"numel", 12}) +%! validateattributes (rand (6, 2), {}, {"ncols", 2}) +%! validateattributes (rand (6, 2), {}, {"nrows", 6}) +%! validateattributes (rand (6, 2, 4, 5), {}, {"ndims", 4}) +%! validateattributes ([4 5 6 7], {}, {">", 3}) +%! validateattributes ([4 5 6 7], {}, {">=", 4}) +%! validateattributes ([4 5 6 7], {}, {"<", 8}) +%! validateattributes ([4 5 6 7], {}, {"<=", 7}) + +%!test +%! validateattributes ([0 1 0 1], {"double", "uint8"}, {"binary", "size", [NaN 4], "nonnan"}) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/gui/private/__file_filter__.m --- a/scripts/gui/private/__file_filter__.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/gui/private/__file_filter__.m Fri Jan 23 15:23:09 2015 -0500 @@ -53,7 +53,7 @@ if (! strcmp (fname, "*")) defname = strcat (fname, fext); endif - if (length (fext) > 0) + if ((length (fext) > 0) && (! strcmp(fext, '.*'))) fext = strcat ("*", fext); retval = {fext, __default_filtername__(fext)}; endif diff -r 75a671fcdd73 -r 844448ae53f3 scripts/gui/uiputfile.m --- a/scripts/gui/uiputfile.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/gui/uiputfile.m Fri Jan 23 15:23:09 2015 -0500 @@ -125,6 +125,19 @@ [retfile, retpath, retindex] = feval (funcname, outargs{:}); endif + # add extension to the name it isnt already added + + if ischar (retfile) + ext = outargs{1}{retindex}; + ext = strrep (ext, '*', ''); + + if length (retfile) >= length (ext) + if ! strcmp (retfile(end-length (ext)+1:end), ext) + retfile = [retfile ext]; + endif + endif + endif + endfunction diff -r 75a671fcdd73 -r 844448ae53f3 scripts/gui/waitbar.m --- a/scripts/gui/waitbar.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/gui/waitbar.m Fri Jan 23 15:23:09 2015 -0500 @@ -106,7 +106,8 @@ ## Save and restore current figure cf = get (0, "currentfigure"); - hf = figure ("position", [250, 500, 400, 100], + hf = figure ("units", "pixels", + "position", [250, 500, 400, 100], "numbertitle", "off", "menubar", "none", "toolbar", "none", "integerhandle", "off", diff -r 75a671fcdd73 -r 844448ae53f3 scripts/help/__unimplemented__.m --- a/scripts/help/__unimplemented__.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/help/__unimplemented__.m Fri Jan 23 15:23:09 2015 -0500 @@ -822,7 +822,6 @@ "unloadlibrary", "unmesh", "userpath", - "validateattributes", "verctrl", "verLessThan", "viewmtx", diff -r 75a671fcdd73 -r 844448ae53f3 scripts/help/help.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/io/strread.m --- a/scripts/io/strread.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/io/strread.m Fri Jan 23 15:23:09 2015 -0500 @@ -409,7 +409,7 @@ if (! isempty (white_spaces)) ## Check if trailing "\n" might signal padding output arrays to equal size ## before it is trimmed away below - if ((str(end) == 10) && (nargout > 1)) + if (str(end) == "\n" && nargout > 1) pad_out = 1; endif ## Condense all repeated whitespace into one single space @@ -417,7 +417,7 @@ rxp_wsp = sprintf ("[%s]+", white_spaces); str = regexprep (str, rxp_wsp, ' '); ## Remove possible leading space at string - if (str(1) == 32) + if (str(1) == " ") str = str(2:end); endif ## Check for single delimiter followed/preceded by whitespace diff -r 75a671fcdd73 -r 844448ae53f3 scripts/java/org/octave/JDialogBox.java --- a/scripts/java/org/octave/JDialogBox.java Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/java/org/octave/JDialogBox.java Fri Jan 23 15:23:09 2015 -0500 @@ -1,5 +1,6 @@ /* +Copyright (C) 2014 Colin Foster Copyright (C) 2010, 2013 Martin Hepperle This file is part of Octave. @@ -551,24 +552,28 @@ { lst[i] = theTranslator.replace (list[i]); } + + JScrollPane scrollPane = new JScrollPane(); m_List = new JList (lst); + scrollPane.setViewportView(m_List); + // replace ugly monospaced font - m_List.setFont (p.getFont ()); + scrollPane.setFont (p.getFont ()); - m_List.setMinimumSize (new Dimension (Math.max (1, - Integer.parseInt (RowsCols[0].toString ())), - Math.max (1, - Integer.parseInt (RowsCols[1].toString ())))); - m_List.setPreferredSize (new Dimension (Math.max (1, - Integer.parseInt (RowsCols[1].toString ())), - Math.max (1, - Integer.parseInt (RowsCols[0].toString ())))); - m_List.setBorder (new javax.swing.border.EtchedBorder ()); + scrollPane.setMinimumSize ( + new Dimension ( + Math.max (1, Integer.parseInt (RowsCols[0].toString ())), + Math.max (1, Integer.parseInt (RowsCols[1].toString ())))); + scrollPane.setPreferredSize ( + new Dimension ( + Math.max (1, Integer.parseInt (RowsCols[1].toString ())), + Math.max (1, Integer.parseInt (RowsCols[0].toString ())))); + scrollPane.setBorder (new javax.swing.border.EtchedBorder ()); gbc.gridy = message.length; gbc.fill = GridBagConstraints.HORIZONTAL; - p.add (m_List, gbc); + p.add (scrollPane, gbc); if (on.toLowerCase ().equals ("single")) { diff -r 75a671fcdd73 -r 844448ae53f3 scripts/miscellaneous/edit.m --- a/scripts/miscellaneous/edit.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/miscellaneous/edit.m Fri Jan 23 15:23:09 2015 -0500 @@ -284,7 +284,7 @@ endif ## If the file includes a path, it may be an overloaded function. - if (! index (file, "@") && index (file, filesep)) + if (! index (file, "@") && strchr (file, '/\')) ## No "@" at the beginning of the file, add to the list. numfiles = numel (filelist); for n = 1:numfiles diff -r 75a671fcdd73 -r 844448ae53f3 scripts/miscellaneous/ls.m --- a/scripts/miscellaneous/ls.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/miscellaneous/ls.m Fri Jan 23 15:23:09 2015 -0500 @@ -63,6 +63,10 @@ if (ispc () && ! isunix ()) ## shell (cmd.exe) on MinGW uses '^' as escape character args = regexprep (args, '([^\w.*? -])', '^$1'); + ## Strip UNIX directory character which looks like an option to dir cmd. + if (args{end}(end) == '/') + args{end}(end) = ""; + endif else args = regexprep (args, '([^\w.*?-])', '\\$1'); endif diff -r 75a671fcdd73 -r 844448ae53f3 scripts/miscellaneous/what.m --- a/scripts/miscellaneous/what.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/miscellaneous/what.m Fri Jan 23 15:23:09 2015 -0500 @@ -30,17 +30,19 @@ if (nargin == 0) d = pwd (); - elseif (isempty (strfind (d, filesep ()))) - ## Find the appropriate directory on the path. - p = strtrim (ostrsplit (path (), pathsep ())); - d = p{find (cellfun (@(x) ! isempty (strfind (x, d)), p))(end)}; else - [status, msg, msgid] = fileattrib (d); - if (status != 1) - error ("what: could not find the file or path %s", d); - else - d = msg.Name; + dtmp = canonicalize_file_name (d); + if (isempty (dtmp)) + ## Search for directory name in path + if (d(end) == '/' || d(end) == '\') + d(end) = []; + endif + dtmp = find_dir_in_path (d); + if (isempty (dtmp)) + error ("what: could not find the directory %s", d); + endif endif + d = dtmp; endif files = dir (d); @@ -60,7 +62,7 @@ continue; else ## Ignore mdl and p files - [dummy, f, e] = fileparts (n); + [~, f, e] = fileparts (n); if (strcmp (e, ".m")) w.m{end+1} = n; elseif (strcmp (e, ".oct")) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/pkg/pkg.m --- a/scripts/pkg/pkg.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/pkg/pkg.m Fri Jan 23 15:23:09 2015 -0500 @@ -540,6 +540,23 @@ case "update" if (nargout == 0) installed_pkgs_lst = installed_packages (local_list, global_list); + if (length (files) > 0) + update_lst = {}; + for i = 1:length (files) + is_installed = false; + for j = 1:length (installed_pkgs_lst) + if (strcmp (files{i}, installed_pkgs_lst{j}.name)) + update_lst = { update_lst{:}, installed_pkgs_lst{j} }; + is_installed = true; + endif + endfor + if (is_installed == false) + s = sprintf ("Package %s is not installed - not updating this package", files{i}); + warning (s); + endif + endfor + installed_pkgs_lst = update_lst; + endif for i = 1:length (installed_pkgs_lst) installed_pkg_name = installed_pkgs_lst{i}.name; installed_pkg_version = installed_pkgs_lst{i}.version; diff -r 75a671fcdd73 -r 844448ae53f3 scripts/plot/draw/fill.m --- a/scripts/plot/draw/fill.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/plot/draw/fill.m Fri Jan 23 15:23:09 2015 -0500 @@ -93,16 +93,16 @@ for i = 1 : length (iargs) cdata = varargin{iargs(i) + 2}; - - ## Matlab uses flat/interp shading based on orientation of cdata. - if (isnumeric (cdata) && isrow (cdata)) - popt = ["facecolor", "flat", opts]; - else - popt = opts; + ## For Matlab compatibility, replicate cdata to match size of data + if (iscolumn (cdata)) + sz = size (varargin{iargs(i)}); + if (all (sz > 1)) + cdata = repmat (cdata, [1, sz(2)]); + endif endif [htmp, fail] = __patch__ (hax, varargin{iargs(i)+(0:1)}, cdata, - popt{:}); + opts{:}); if (fail) print_usage (); endif @@ -145,7 +145,7 @@ endif elseif (isnumeric (arg)) ## Assume any numeric argument is correctly formatted cdata. - ## Let patch worry about the multple different input formats + ## Let patch worry about the multple different input formats. retval = true; endif endfunction diff -r 75a671fcdd73 -r 844448ae53f3 scripts/plot/util/close.m --- a/scripts/plot/util/close.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/plot/util/close.m Fri Jan 23 15:23:09 2015 -0500 @@ -105,5 +105,4 @@ %!error close ({"all"}) %!error close ("all_and_more") %!error close (-1) -%!error close "all" hid" - +%!error close all hid diff -r 75a671fcdd73 -r 844448ae53f3 scripts/plot/util/findobj.m --- a/scripts/plot/util/findobj.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/plot/util/findobj.m Fri Jan 23 15:23:09 2015 -0500 @@ -119,6 +119,7 @@ regularexpression = []; property = []; logicaloperator = {}; + extranegation = []; pname = {}; pvalue = {}; np = 1; @@ -128,6 +129,9 @@ while (na <= numel (args)) regularexpression(np) = 0; property(np) = 0; + if (numel (extranegation) < np) + extranegation(np) = false; + endif logicaloperator{np} = "and"; if (ischar (args{na})) if (strcmpi (args{na}, "-regexp")) @@ -177,10 +181,8 @@ error ("findobj: inconsistent number of arguments"); endif else - ## This is sloppy ... but works like Matlab. if (strcmpi (args{na}, "-not")) - h = []; - return; + extranegation(np) = true; endif na = na + 1; endif @@ -241,6 +243,9 @@ else match(nh,np) = false; endif + if (extranegation(np)) + match(nh,np) = ! match(nh,np); + endif endfor endfor diff -r 75a671fcdd73 -r 844448ae53f3 scripts/plot/util/private/__ghostscript__.m diff -r 75a671fcdd73 -r 844448ae53f3 scripts/plot/util/private/__print_parse_opts__.m --- a/scripts/plot/util/private/__print_parse_opts__.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/plot/util/private/__print_parse_opts__.m Fri Jan 23 15:23:09 2015 -0500 @@ -43,7 +43,7 @@ arg_st.ghostscript.debug = false; arg_st.ghostscript.device = ""; arg_st.ghostscript.epscrop = true; - arg_st.ghostscript.level = []; + arg_st.ghostscript.level = 2; arg_st.ghostscript.output = ""; arg_st.ghostscript.papersize = ""; arg_st.ghostscript.pageoffset = []; @@ -298,13 +298,6 @@ arg_st.devopt = aliases.(arg_st.devopt); endif - ## FIXME - eps2 & epsc2 needs to be handled - if (strcmp (arg_st.devopt, "pswrite")) - arg_st.ghostscript.level = 1; - elseif (strcmp (arg_st.devopt, "ps2write")) - arg_st.ghostscript.level = 2; - endif - if ((any (strcmp (arg_st.devopt, gs_device_list)) && ! arg_st.formatted_for_printing) || any (strcmp (arg_st.devopt, {"pswrite", "ps2write", "pdfwrite"}))) @@ -622,15 +615,15 @@ endfunction function device_list = gs_device_list (); - ## Graphics formats/languages, not priners. + ## Graphics formats/languages, not printers. device_list = {"bmp16"; "bmp16m"; "bmp256"; "bmp32b"; "bmpgray"; ... "epswrite"; "jpeg"; "jpegcymk"; "jpeggray"; "pbm"; ... "pbmraw"; "pcx16"; "pcx24b"; "pcx256"; "pcx2up"; ... "pcxcmyk"; "pcxgray"; "pcxmono"; "pdfwrite"; "pgm"; ... "pgmraw"; "pgnm"; "pgnmraw"; "png16"; "png16m"; ... "png256"; "png48"; "pngalpha"; "pnggray"; "pngmono"; ... - "pnm"; "pnmraw"; "ppm"; "ppmraw"; "ps2write"; ... - "pswrite"; "tiff12nc"; "tiff24nc"; "tiff32nc"; ... + "pnm"; "pnmraw"; "ppm"; "ppmraw"; "pswrite"; ... + "ps2write"; "tiff12nc"; "tiff24nc"; "tiff32nc"; ... "tiffcrle"; "tiffg3"; "tiffg32d"; "tiffg4"; ... "tiffgray"; "tifflzw"; "tiffpack"; "tiffsep"}; endfunction @@ -641,14 +634,14 @@ ## ## eps, epsc, eps2, epsc2 are not included here because those are ## are generated by the graphics toolkit. - aliases.bmp = "bmp32b"; - aliases.pdf = "pdfwrite"; - aliases.png = "png16m"; - aliases.ps = "pswrite"; - aliases.ps2 = "ps2write"; - aliases.psc = "pswrite"; - aliases.psc2 = "ps2write"; - aliases.tiff = "tiff24nc"; + aliases.bmp = "bmp32b"; + aliases.pdf = "pdfwrite"; + aliases.png = "png16m"; + aliases.ps = "ps2write"; + aliases.ps2 = "ps2write"; + aliases.psc = "ps2write"; + aliases.psc2 = "ps2write"; + aliases.tiff = "tiff24nc"; aliases.tiffn = "tiff24nc"; endfunction diff -r 75a671fcdd73 -r 844448ae53f3 scripts/polynomial/polyeig.m --- a/scripts/polynomial/polyeig.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/polynomial/polyeig.m Fri Jan 23 15:23:09 2015 -0500 @@ -26,68 +26,77 @@ ## @code{@var{C}(s) = @var{C0} + @var{C1} s + @dots{} + @var{Cl} s^l} ## polyeig solves the eigenvalue problem ## @code{(@var{C0} + @var{C1} + @dots{} + @var{Cl})v = 0}. +## ## Note that the eigenvalues @var{z} are the zeros of the matrix polynomial. -## @var{z} is an @var{lxn} vector and @var{v} is an (@var{n} x @var{n})l matrix -## with columns that correspond to the eigenvectors. +## @var{z} is a row vector with @var{n*l} elements. @var{v} is a matrix +## (@var{n} x @var{n}*@var{l}) with columns that correspond to the +## eigenvectors. ## ## @seealso{eig, eigs, compan} ## @end deftypefn ## Author: Fotios Kasolis -function [ z, varargout ] = polyeig (varargin) +function [z, v] = polyeig (varargin) - if ( nargout > 2 ) + if (nargin < 1 || nargout > 2) print_usage (); endif nin = numel (varargin); - - n = zeros (1, nin); + n = rows (varargin{1}); - for cnt = 1 : nin - if (! issquare (varargin{cnt})) - error ("polyeig: coefficients must be square matrices"); + for i = 1 : nin + if (! issquare (varargin{i})) + error ("polyeig: coefficients must be square matrices"); endif - n(cnt) = size (varargin{cnt}, 1); + if (rows (varargin{i}) != n) + error ("polyeig: coefficients must have the same dimensions"); + endif endfor - if (numel (unique (n)) > 1) - error ("polyeig: coefficients must have the same dimensions"); - endif - n = unique (n); - ## matrix polynomial degree l = nin - 1; ## form needed matrices C = [ zeros(n * (l - 1), n), eye(n * (l - 1)); - -cell2mat(varargin(1 : end - 1)) ]; + -cell2mat(varargin(1:end-1)) ]; D = [ eye(n * (l - 1)), zeros(n * (l - 1), n); zeros(n, n * (l - 1)), varargin{end} ]; ## solve generalized eigenvalue problem - if ( isequal (nargout, 1) ) - z = eig (C, D); - else - [ z, v ] = eig (C, D); - varargout{1} = v; - ## return n-element eigenvectors normalized so - ## that the infinity-norm = 1 + if (nargout == 2) + [z, v] = eig (C, D); + v = diag (v); + ## return n-element eigenvectors normalized so that the infinity-norm = 1 z = z(1:n,:); ## max() takes the abs if complex: t = max (z); z /= diag (t); + else + z = eig (C, D); endif endfunction +%!shared C0, C1 +%! C0 = [8, 0; 0, 4]; C1 = [1, 0; 0, 1]; + %!test -%! C0 = [8, 0; 0, 4]; C1 = [1, 0; 0, 1]; +%! z = polyeig (C0, C1); +%! assert (z, [-8; -4]); + +%!test %! [v,z] = polyeig (C0, C1); -%! assert (isequal (z(1), -8), true); +%! assert (z, [-8; -4]); +%! z = diag (z); %! d = C0*v + C1*v*z; -%! assert (isequal (norm(d), 0.0), true); +%! assert (norm (d), 0.0); +%% Input validation tests +%!error polyeig () +%!error [a,b,c] = polyeig (1) +%!error polyeig (ones (3,2)) +%!error polyeig (ones (3,3), ones (2,2)) diff -r 75a671fcdd73 -r 844448ae53f3 scripts/startup/inputrc --- a/scripts/startup/inputrc Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/startup/inputrc Fri Jan 23 15:23:09 2015 -0500 @@ -24,3 +24,8 @@ ## \C-q should still be available for quoted insert. "\C-v": "" + +## In windows, disable audiable bell which is enabled by default +$if term=cygwin + set bell-style none +$endif diff -r 75a671fcdd73 -r 844448ae53f3 scripts/testfun/rundemos.m --- a/scripts/testfun/rundemos.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/testfun/rundemos.m Fri Jan 23 15:23:09 2015 -0500 @@ -36,20 +36,17 @@ dirs = ostrsplit (path (), pathsep ()); do_class_dirs = true; elseif (nargin == 1) - if (is_absolute_filename (directory)) - dirs = {directory}; - elseif (is_rooted_relative_filename (directory)) - dirs = {canonicalize_file_name(directory)}; - else - if (directory(end) == filesep ()) - directory = directory(1:end-1); + dirs = {canonicalize_file_name(directory)}; + if (isempty (dirs{1})) + ## Search for directory name in path + if (directory(end) == '/' || directory(end) == '\') + directory(end) = []; endif fullname = find_dir_in_path (directory); - if (! isempty (fullname)) - dirs = {fullname}; - else + if (isempty (fullname)) error ("rundemos: DIRECTORY argument must be a valid pathname"); endif + dirs = {fullname}; endif do_class_dirs = false; else diff -r 75a671fcdd73 -r 844448ae53f3 scripts/testfun/runtests.m --- a/scripts/testfun/runtests.m Fri Jan 23 15:21:25 2015 -0500 +++ b/scripts/testfun/runtests.m Fri Jan 23 15:23:09 2015 -0500 @@ -36,20 +36,17 @@ dirs = ostrsplit (path (), pathsep ()); do_class_dirs = true; elseif (nargin == 1) - if (is_absolute_filename (directory)) - dirs = {directory}; - elseif (is_rooted_relative_filename (directory)) - dirs = {canonicalize_file_name(directory)}; - else - if (directory(end) == filesep ()) - directory = directory(1:end-1); + dirs = {canonicalize_file_name(directory)}; + if (isempty (dirs{1})) + ## Search for directory name in path + if (directory(end) == '/' || directory(end) == '\') + directory(end) = []; endif fullname = find_dir_in_path (directory); - if (! isempty (fullname)) - dirs = {fullname}; - else + if (isempty (fullname)) error ("runtests: DIRECTORY argument must be a valid pathname"); endif + dirs = {fullname}; endif do_class_dirs = false; else diff -r 75a671fcdd73 -r 844448ae53f3 src/main.in.cc --- a/src/main.in.cc Fri Jan 23 15:21:25 2015 -0500 +++ b/src/main.in.cc Fri Jan 23 15:23:09 2015 -0500 @@ -493,14 +493,22 @@ { int retval = 0; - bool start_gui = false; - bool gui_libs = false; + bool start_gui = true; + bool gui_libs = true; std::string octave_bindir = get_octave_bindir (); std::string octave_archlibdir = get_octave_archlibdir (); +#if defined (HAVE_OCTAVE_GUI) + // The Octave version number is already embedded in the + // octave_archlibdir directory name so we don't need to append it to + // the octave-gui file name. + + std::string file = octave_archlibdir + dir_sep_char + "octave-gui"; +#else std::string file - = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION;; + = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION; +#endif char **new_argv = new char * [argc + 1]; @@ -510,22 +518,7 @@ for (int i = 1; i < argc; i++) { - if (! strcmp (argv[i], "--force-gui")) - { - start_gui = true; - gui_libs = true; -#if defined (HAVE_OCTAVE_GUI) - // The Octave version number is already embedded in the - // octave_archlibdir directory name so we don't need to - // append it to the octave-gui file name. - - file = octave_archlibdir + dir_sep_char + "octave-gui"; -#else - file = octave_bindir + dir_sep_char + "octave-cli-" OCTAVE_VERSION; -#endif - new_argv[k++] = argv[i]; - } - else if (! strcmp (argv[i], "--no-gui-libs")) + if (! strcmp (argv[i], "--no-gui-libs")) { // Run the version of Octave that is not linked with any GUI // libraries. It may not be possible to do plotting or any @@ -533,7 +526,9 @@ // require less memory. Don't pass the --no-gui-libs option // on as that option is not recognized by Octave. - // This is the default for 3.8 release. + start_gui = false; + gui_libs = false; + file = octave_bindir + dir_sep_char + "octave-cli"; } else if (! strcmp (argv[i], "--no-gui")) { @@ -543,10 +538,11 @@ // even if the --no-gui option is given, we may be asked to do // some plotting or ui* calls. - // This option calls the cli executable for the 3.8 release. + start_gui = false; + new_argv[k++] = argv[i]; } - else if (! strcmp (argv[i], "--silent") || ! strcmp (argv[i], "-q") - || ! strcmp (argv[i], "--quiet")) + else if (! strcmp (argv[i], "--silent") || ! strcmp (argv[i], "--quiet") + || ! strcmp (argv[i], "-q")) { warn_display = false; new_argv[k++] = argv[i]; diff -r 75a671fcdd73 -r 844448ae53f3 test/command.tst --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/command.tst Fri Jan 23 15:23:09 2015 -0500 @@ -0,0 +1,154 @@ +## Don't alter the spacing in the command_test lines. These are +## specifically testing for possible differences in things like +## A(X) or A( X ) or A (X) or A ( X ) + +%!function command_test (varargin) +%! assignin ('caller', 'cmd_out', ['|', sprintf('%s|', varargin{:})]); +%!endfunction + +%!function gobble_command (varargin) +%!endfunction + +## 0, 1, 2, 3 simple arguments +%!test +%! command_test +%! assert (cmd_out, '|') +%!test +%! command_test a +%! assert (cmd_out, '|a|') +%!test +%! command_test aa b +%! assert (cmd_out, '|aa|b|') +%!test +%! command_test aaa bb c +%! assert (cmd_out, '|aaa|bb|c|') + +## continuation +%!test +%! command_test a... +%! bb ccc +%! assert (cmd_out, '|a|bb|ccc|') +%!test +%! command_test a ... +%! bb ccc +%! assert (cmd_out, '|a|bb|ccc|') +%!test +%! command_test aa(... +%! bb cc +%! assert (cmd_out, '|aa(|bb|cc|') +%!test +%! command_test aa( ... +%! bb cc +%! assert (cmd_out, '|aa( |bb|cc|') + +## comments +%!test +%! command_test aa bb cc%comment +%! assert (cmd_out, '|aa|bb|cc|') +%!test +%! command_test aa bb cc#comment +%! assert (cmd_out, '|aa|bb|cc|') +%!test +%! command_test aa bb cc %comment +%! assert (cmd_out, '|aa|bb|cc|') +%!test +%! command_test aa bb cc #comment +%! assert (cmd_out, '|aa|bb|cc|') +%!test +%! command_test aa bb cc( %comment +%! assert (cmd_out, '|aa|bb|cc( |') +%!test +%! command_test aa bb cc( #comment +%! assert (cmd_out, '|aa|bb|cc( |') + +## semicolons and commas; multiple commands +%!test +%! command_test aa bb, gobble_command cc +%! assert (cmd_out, '|aa|bb|') +%!test +%! command_test aa bb ; gobble_command cc +%! assert (cmd_out, '|aa|bb|') +%!test +%! command_test aa bb ; command_test cc dd +%! assert (cmd_out, '|cc|dd|') +%!test +%! command_test aa bb +%!test +%! command_test cc dd +%! assert (cmd_out, '|cc|dd|') + +## parenthesis matching +%!test +%! command_test aa(bb,cc,dd) ee(ff,gg) hh +%! assert (cmd_out, '|aa(bb,cc,dd)|ee(ff,gg)|hh|') +%!test +%! command_test aa([bb,cc)] +%! assert (cmd_out, '|aa([bb,cc)]|') +%!test +%! command_test aa(,@!$@"bb"'cc' +%! assert (cmd_out, '|aa(,@!$@"bb"''cc''|') +%!test +%! command_test aa(bb,cc,dd) +%! assert (cmd_out, '|aa(bb,cc,dd)|') +%!test +%! command_test aa( bb,cc,dd ) +%! assert (cmd_out, '|aa( bb,cc,dd )|') +%!test +%! command_test aa (bb,cc,dd) +%! assert (cmd_out, '|aa|(bb,cc,dd)|') +%!test +%! command_test aa ( bb,cc,dd ) +%! assert (cmd_out, '|aa|( bb,cc,dd )|') +%!test +%! command_test aa(bb, cc, dd) +%! assert (cmd_out, '|aa(bb, cc, dd)|') +%!test +%! command_test aa( bb, cc, dd ) +%! assert (cmd_out, '|aa( bb, cc, dd )|') +%!test +%! command_test aa (bb, cc, dd) +%! assert (cmd_out, '|aa|(bb, cc, dd)|') +%!test +%! command_test aa ( bb, cc, dd ) +%! assert (cmd_out, '|aa|( bb, cc, dd )|') + +## single and double quotes +%!test +%! command_test "aa" 'bb' cc +%! assert (cmd_out, '|aa|bb|cc|') +%!test +%! command_test "aa"'bb'cc +%! assert (cmd_out, '|aabbcc|') +%!test +%! command_test aa'bb'"cc" +%! assert (cmd_out, '|aabbcc|') +%!test +%! command_test "aa"bb'cc' +%! assert (cmd_out, '|aabbcc|') + +## CVX-inspired +%!test +%! command_test Z(n,n) hermitian toeplitz +%! assert (cmd_out, '|Z(n,n)|hermitian|toeplitz|') +%!test +%! command_test X( n, n ) symmetric +%! assert (cmd_out, '|X( n, n )|symmetric|') +%!test +%! command_test xw( nm-1, nv ); +%! assert (cmd_out, '|xw( nm-1, nv )|') +%!test +%! command_test x( sx ) y( sx ) z( sx ) +%! assert (cmd_out, '|x( sx )|y( sx )|z( sx )|') +%!test +%! command_test coeffs(deg+1) complex; +%! assert (cmd_out, '|coeffs(deg+1)|complex|') +%!test +%! command_test w( 1, npairs * nv ) v( 1, npairs * nv ) +%! assert (cmd_out, '|w( 1, npairs * nv )|v( 1, npairs * nv )|') +%!test +%! command_test w(m,1) % edge weights +%! assert (cmd_out, '|w(m,1)|') +%!test +%! command_test x2( size( x ) ) +%! assert (cmd_out, '|x2( size( x ) )|') + diff -r 75a671fcdd73 -r 844448ae53f3 test/io.tst --- a/test/io.tst Fri Jan 23 15:21:25 2015 -0500 +++ b/test/io.tst Fri Jan 23 15:23:09 2015 -0500 @@ -74,7 +74,9 @@ %! %! ret = 0; %! -%! files = {"text.mat", "binary.mat", "mat5.mat", "mat7.mat"}; +%! files = cellfun (@fullfile, {P_tmpdir}, +%! {"text.mat", "binary.mat", "mat5.mat", "mat7.mat"}, +%! "UniformOutput", false); %! opts = {"-z -text", "-z -binary", "-z -mat", "-v7"}; %! tols = {2*eps, 0, 0, 0}; %! @@ -197,8 +199,9 @@ %! STR.struct_fld.x = 0; %! STR.struct_fld.y = 1; %! -%! save struct.dat -struct STR; -%! STR = load ("struct.dat"); +%! struct_dat = fullfile (P_tmpdir, "struct.dat"); +%! save (struct_dat, "-struct", "STR"); +%! STR = load (struct_dat); %! %! assert (STR.scalar_fld == 1 && ... %! STR.matrix_fld == [1.1,2;3,4] && ... @@ -207,8 +210,9 @@ %! STR.struct_fld.y == 1 ); %! %! -%! save -binary struct.dat -struct STR matrix_fld str*_fld; -%! STR = load ("struct.dat"); +%! save ("-binary", struct_dat, +%! "-struct", "STR", "matrix_fld", "str*_fld"); +%! STR = load (struct_dat); %! %! assert (!isfield (STR,"scalar_fld") && ... %! STR.matrix_fld == [1.1,2;3,4] && ... @@ -216,15 +220,16 @@ %! STR.struct_fld.x == 0 && ... %! STR.struct_fld.y == 1); %! -%! delete struct.dat; +%! delete (struct_dat); %!test %! matrix1 = rand (100, 2); -%! save -ascii matrix.ascii matrix1 -%! matrix2 = load ("matrix.ascii"); +%! matrix_ascii = fullfile (P_tmpdir, "matrix.ascii"); +%! save ("-ascii", matrix_ascii, "matrix1") +%! matrix2 = load (matrix_ascii); %! assert (matrix1, matrix2, 1e-9); %! -%! delete matrix.ascii; +%! delete (matrix_ascii); %!error load ("")