From efe1f2f04ae42657327300e015ffc91ad7830e28 Mon Sep 17 00:00:00 2001 From: Gabriele Bellomia Date: Wed, 1 Jun 2022 20:02:46 +0200 Subject: [PATCH] Intermediate: some more testing with GNU Octave Tweaked a little the +colorlab procedures to help with Octave compatibility, but unfortunately the palette functions appear to be doomed. Too much problems, Octave does not even access the private folders inside packages, does have very different structure for the groot and other graphics-related objects. I think we can say that no, it would never be fully supported. Let's be happy that at least the +rgb routines do work... :) --- +colorlab/enter.m | 30 +++++++++++++++++++++++++++--- +colorlab/leave.m | 28 ++++++++++++++++++++++++++-- +colorlab/vista.m | 29 ++++++++++++++++++++++++++--- 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/+colorlab/enter.m b/+colorlab/enter.m index af5f30d..0dbf3ae 100644 --- a/+colorlab/enter.m +++ b/+colorlab/enter.m @@ -22,12 +22,18 @@ function enter(quiet) folder = erase(fileparts(mfilename('fullpath')),'+colorlab'); % > COLORLAB initiates itself - COLORLAB = xgenpath(folder,'**/*.git'); + try + COLORLAB = xgenpath(folder,'**/*.git'); + catch + COLORLAB = genpath(folder); + end oldpath = addpath(COLORLAB); printflag = not(isequal(oldpath,path)); - % Better to check for duplicates - find_duplicate(folder); + % Better to check for duplicates (in MATLAB) + if ~isoctave + find_duplicate(folder); + end % Let the user decide if to save or not to save... if printflag && not(quietflag) @@ -40,4 +46,22 @@ function enter(quiet) fprintf(' \n \n') end +end + +% contains + +function bool = isoctave() +%% ISOCTAVE Determines if you are running under GNU Octave or MATLAB +% +% >> isoctave() +% +% ans = +% +% logical +% +% 0 ----> IF running under MATLAB +% 1 ----> IF running under OCTAVE +% +% See also ispc, ismac, isunix, ver + bool = exist('__octave_config_info__','builtin') == 5; end \ No newline at end of file diff --git a/+colorlab/leave.m b/+colorlab/leave.m index 27f9292..f5eb154 100644 --- a/+colorlab/leave.m +++ b/+colorlab/leave.m @@ -22,9 +22,15 @@ function leave(quiet) folder = erase(fileparts(mfilename('fullpath')),'+colorlab'); % > COLORLAB destroys itself - COLORLAB = xgenpath(folder,'**/*.git'); + try + COLORLAB = xgenpath(folder,'**/*.git'); + catch + COLORLAB = genpath(folder); + end oldpath = rmpath(COLORLAB); - addpath(userpath); % Safety-measure + if ~isoctave + addpath(userpath); % Safety-measure + end printflag = not(isequal(oldpath,path)); % Final greetings! @@ -38,3 +44,21 @@ function leave(quiet) fprintf(' \n \n') end end + +% contains + +function bool = isoctave() +%% ISOCTAVE Determines if you are running under GNU Octave or MATLAB +% +% >> isoctave() +% +% ans = +% +% logical +% +% 0 ----> IF running under MATLAB +% 1 ----> IF running under OCTAVE +% +% See also ispc, ismac, isunix, ver + bool = exist('__octave_config_info__','builtin') == 5; +end \ No newline at end of file diff --git a/+colorlab/vista.m b/+colorlab/vista.m index cfd971b..161bd74 100644 --- a/+colorlab/vista.m +++ b/+colorlab/vista.m @@ -8,10 +8,15 @@ function vista() - folder = erase(fileparts(mfilename('fullpath')),'+colorlab'); - % > COLORLAB introspects itself + folder = erase(fileparts(mfilename('fullpath')),'+colorlab'); + % > COLORLAB introspects itself - xpathshow(folder); + if isoctave + p = genpath(folder); + disp(strsplit(p,pathsep)); + else + xpathshow(folder); % Finer MATLAB option + end % Would the user decide to enter... promote it! fprintf('\n') @@ -20,4 +25,22 @@ function vista() fprintf(' > If you are thrilled: colorlab.enter() ✧ \n') fprintf('\n') +end + +% contains + +function bool = isoctave() +%% ISOCTAVE Determines if you are running under GNU Octave or MATLAB +% +% >> isoctave() +% +% ans = +% +% logical +% +% 0 ----> IF running under MATLAB +% 1 ----> IF running under OCTAVE +% +% See also ispc, ismac, isunix, ver + bool = exist('__octave_config_info__','builtin') == 5; end \ No newline at end of file