0
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
1 function count = cprintf(style,format,varargin)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
2 % CPRINTF displays styled formatted text in the Command Window
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
3 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
4 % Syntax:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
5 % count = cprintf(style,format,...)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
6 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
7 % Description:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
8 % CPRINTF processes the specified text using the exact same FORMAT
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
9 % arguments accepted by the built-in SPRINTF and FPRINTF functions.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
10 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
11 % CPRINTF then displays the text in the Command Window using the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
12 % specified STYLE argument. The accepted styles are those used for
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
13 % Matlab's syntax highlighting (see: File / Preferences / Colors /
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
14 % M-file Syntax Highlighting Colors), and also user-defined colors.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
15 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
16 % The possible pre-defined STYLE names are:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
17 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
18 % 'Text' - default: black
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
19 % 'Keywords' - default: blue
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
20 % 'Comments' - default: green
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
21 % 'Strings' - default: purple
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
22 % 'UnterminatedStrings' - default: dark red
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
23 % 'SystemCommands' - default: orange
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
24 % 'Errors' - default: light red
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
25 % 'Hyperlinks' - default: underlined blue
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
26 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
27 % 'Black','Cyan','Magenta','Blue','Green','Red','Yellow','White'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
28 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
29 % Note: styles beginning with '-' will be underlined. For example:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
30 % '-Blue' is underlined blue, like 'Hyperlinks';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
31 % '-Comments' is underlined green etc.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
32 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
33 % STYLE also accepts a regular Matlab RGB vector, that can be negated
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
34 % for underlining. For example: -[0,1,1] means underlined cyan.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
35 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
36 % STYLE is case-insensitive and accepts unique partial strings just
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
37 % like handle property names.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
38 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
39 % Examples:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
40 % cprintf('text', 'regular black text');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
41 % cprintf('hyper', 'followed %s','by');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
42 % cprintf('k', '%d colored', 4);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
43 % cprintf('-comment','& underlined');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
44 % cprintf('err', 'elements\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
45 % cprintf('cyan', 'cyan');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
46 % cprintf('-green', 'underlined green');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
47 % cprintf(-[1,0,1], 'underlined magenta');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
48 % cprintf([1,0.5,0],'and multi-\nline orange\n');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
49 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
50 % Bugs and suggestions:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
51 % Please send to Yair Altman (altmany at gmail dot com)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
52 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
53 % Warning:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
54 % This code heavily relies on undocumented and unsupported Matlab
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
55 % functionality. It works on Matlab 7+, but use at your own risk!
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
56 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
57 % A technical description of the implementation can be found at:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
58 % <a href="http://undocumentedmatlab.com/blog/cprintf/">http://UndocumentedMatlab.com/blog/cprintf/</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
59 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
60 % Limitations:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
61 % 1. For unfortunate implementation reasons, a single space character
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
62 % is inserted at the beginning of each CPRINTF text segment.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
63 % I hope to solve this in a future version of CPRINTF.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
64 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
65 % 2. consecutive differently-colored multi-line CPRINTFs sometimes
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
66 % display incorrectly on the bottom line.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
67 % As far as I could tell this is due to a Matlab bug. Examples:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
68 % >> cprintf('-str','under\nline'); cprintf('err','red\n'); % hidden 'red', unhidden '_'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
69 % >> cprintf('str','regu\nlar'); cprintf('err','red\n'); % underline red (not purple) 'lar'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
70 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
71 % 3. Sometimes, non newline ('\n')-terminated segments display unstyled
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
72 % (black) when the command prompt cevron ('>>') regains focus on the
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
73 % continuation of that line (I can't pinpoint when this happens).
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
74 % To fix this, simply newline-terminate all command-prompt messages.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
75 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
76 % 4. Multi-line styles only affect the first line on old Matlab versions
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
77 % (e.g., Matlab 7.1 R14). Single-line styles work as expected.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
78 % R14 also appends a single space after underlined segments.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
79 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
80 % Change log:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
81 % 2009-05-13: First version posted on <a href="http://www.mathworks.com/matlabcentral/fileexchange/authors/27420">MathWorks File Exchange</a>
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
82 %
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
83 % See also:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
84 % sprintf, fprintf
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
85
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
86 % License to use and modify this code is granted freely to all interested, as long as the original author is
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
87 % referenced and attributed as such. The original author maintains the right to be solely associated with this work.
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
88
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
89 % Programmed and Copyright by Yair M. Altman: altmany(at)gmail.com
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
90 % $Revision: 1.2 $ $Date: 2009/08/27 19:31:59 $
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
91
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
92 % The following is for debug use only:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
93 %global docElement txt el
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
94 if ~exist('el','var') || isempty(el), el=handle([]); end %#ok mlint short-circuit error ("used before defined")
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
95 if isempty(style), return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
96 if ishandle(style), dumpElement(style); return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
97
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
98 % Process the text string
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
99 error(nargchk(2, inf, nargin, 'struct'));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
100 str = sprintf(format,varargin{:});
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
101
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
102 % Get the normalized style name and underlining flag
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
103 [underlineFlag, style] = processStyleInfo(style);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
104
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
105 % Set hyperlinking, is so requested
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
106 if underlineFlag
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
107 str = ['<a href=" ">' str '</a>'];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
108 v = version;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
109
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
110 % Matlab 7.1 R14 (possibly a few newer versions as well?)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
111 % have a bug in rendering consecutive hyperlinks
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
112 % This is fixed by appending a single non-linked space
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
113 if str2double(v(1:3)) <= 7.1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
114 str(end+1) = ' ';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
115 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
116 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
117
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
118 % Get the current CW position
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
119 cmdWinDoc = com.mathworks.mde.cmdwin.CmdWinDocument.getInstance;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
120 lastPos = cmdWinDoc.getLength;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
121
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
122 % If not beginning of line
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
123 bolFlag = 0; %#ok
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
124 %if docElement.getEndOffset - docElement.getStartOffset > 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
125 % Display a hyperlink element in order to force element separation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
126 % (otherwise adjacent elements on the same line will me merged)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
127 if ~underlineFlag
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
128 fprintf('<a href=""> </a>');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
129 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
130 fprintf(' ');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
131 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
132 % drawnow;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
133 bolFlag = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
134 %end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
135
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
136 % Get a handle to the Command Window component
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
137 mde = com.mathworks.mde.desk.MLDesktop.getInstance;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
138 cw = mde.getClient('Command Window');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
139 xCmdWndView = cw.getComponent(0).getViewport.getComponent(0);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
140
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
141 % Store the CW background color as a special color pref
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
142 % This way, if the CW bg color changes (via File/Preferences),
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
143 % it will also affect existing rendered strs
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
144 com.mathworks.services.Prefs.setColorPref('CW_BG_Color',xCmdWndView.getBackground);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
145
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
146 % Display the text in the Command Window
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
147 count = fprintf(2,str);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
148 %awtinvoke(cmdWinDoc,'remove',lastPos,1); % TODO: find out how to remove the extra '_'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
149 drawnow;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
150 docElement = cmdWinDoc.getParagraphElement(lastPos+1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
151 if bolFlag && ~underlineFlag
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
152 % Set the leading hyperlink space character ('_') to the bg color, effectively hiding it
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
153 % Note: old Matlab versions have a bug in hyperlinks that need to be accounted for...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
154 %disp(' '); dumpElement(docElement)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
155 setElementStyle(docElement,'CW_BG_Color',1+underlineFlag); %+getUrlsFix(docElement));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
156 %disp(' '); dumpElement(docElement)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
157 el(end+1) = handle(docElement);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
158 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
159
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
160 % Fix a problem with some hidden hyperlinks becoming unhidden...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
161 fixHyperlink(docElement);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
162
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
163 % Get the Document Element(s) corresponding to the latest fprintf operation
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
164 while docElement.getStartOffset < cmdWinDoc.getLength
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
165 % Set the element style according to the current style
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
166 setElementStyle(docElement,style,underlineFlag);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
167 docElement2 = cmdWinDoc.getParagraphElement(docElement.getEndOffset+1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
168 if isequal(docElement,docElement2), break; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
169 docElement = docElement2;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
170 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
171
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
172 % Force a Command-Window repaint
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
173 % Note: this is important in case the rendered str was not '\n'-terminated
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
174 xCmdWndView.repaint;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
175
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
176 % The following is for debug use only:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
177 el(end+1) = handle(docElement); %#ok used in debug only
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
178 %elementStart = docElement.getStartOffset;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
179 %elementLength = docElement.getEndOffset - elementStart;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
180 %txt = cmdWinDoc.getText(elementStart,elementLength);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
181
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
182 return; % debug breakpoint
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
183
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
184 % Process the requested style information
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
185 function [underlineFlag,style] = processStyleInfo(style)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
186 underlineFlag = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
187
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
188 % Style = valid matlab RGB vector
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
189 if isnumeric(style) && length(style)==3 && all(style<=1) && all(abs(style)>=0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
190 if any(style<0)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
191 underlineFlag = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
192 style = abs(style);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
193 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
194 style = getColorStyle(style);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
195
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
196 elseif ~ischar(style)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
197 error('YMA:cprintf:InvalidStyle','Invalid style - see help section for a list of valid style values')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
198
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
199 % Style name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
200 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
201 % Styles starting with '-' should be underlined (using a no-target hyperlink hack)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
202 if style(1)=='-'
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
203 underlineFlag = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
204 style = style(2:end);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
205 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
206
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
207 % Try case-insensitive partial/full match with the accepted style names
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
208 validStyles = {'Text','Keywords','Comments','Strings','UnterminatedStrings','SystemCommands','Errors', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
209 'Black','Cyan','Magenta','Blue','Green','Red','Yellow','White', ...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
210 'Hyperlinks'};
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
211 matches = find(strncmpi(style,validStyles,length(style)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
212
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
213 % No match - error
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
214 if isempty(matches)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
215 error('YMA:cprintf:InvalidStyle','Invalid style - see help section for a list of valid style values')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
216
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
217 % Too many matches (ambiguous) - error
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
218 elseif length(matches) > 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
219 error('YMA:cprintf:AmbigStyle','Ambiguous style name - supply extra characters for uniqueness')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
220
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
221 % Regular text
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
222 elseif matches == 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
223 style = '';
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
224
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
225 % Highlight preference style name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
226 elseif matches < 8
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
227 style = ['Colors_M_' validStyles{matches}];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
228
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
229 % Color name
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
230 elseif matches < length(validStyles)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
231 colors = [0,0,0; 0,1,1; 1,0,1; 0,0,1; 0,1,0; 1,0,0; 1,1,0; 1,1,1];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
232 requestedColor = colors(matches-7,:);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
233 style = getColorStyle(requestedColor);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
234
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
235 % Hyperlink
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
236 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
237 style = 'Colors_HTML_HTMLLinks'; % CWLink
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
238 underlineFlag = 1;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
239 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
240 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
241
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
242 % Convert a Matlab RGB vector into a known style name (e.g., '[255,37,0]')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
243 function styleName = getColorStyle(rgb)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
244 intColor = int32(floor(rgb*255));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
245 javaColor = java.awt.Color(intColor(1), intColor(2), intColor(3));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
246 styleName = sprintf('[%d,%d,%d]',intColor);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
247 com.mathworks.services.Prefs.setColorPref(styleName,javaColor);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
248
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
249 % Fix a bug in some Matlab versions, where the number of URL segments
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
250 % is larger than the number of style segments in a doc element
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
251 function delta = getUrlsFix(docElement) %#ok currently unused
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
252 tokens = docElement.getAttribute('SyntaxTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
253 links = docElement.getAttribute('LinkStartTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
254 if length(links) > length(tokens(1))
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
255 delta = length(links) > length(tokens(1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
256 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
257 delta = 0;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
258 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
259
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
260 % fprintf(2,str) causes all previous '_'s in the line to become red - fix this
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
261 function fixHyperlink(docElement)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
262 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
263 tokens = docElement.getAttribute('SyntaxTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
264 urls = docElement.getAttribute('HtmlLink');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
265 urls = urls(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
266 links = docElement.getAttribute('LinkStartTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
267 offsets = tokens(1);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
268 styles = tokens(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
269 doc = docElement.getDocument;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
270
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
271 % Loop over all segments in this docElement
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
272 for idx = 1 : length(offsets)-1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
273 % If this is a hyperlink with no URL target and starts with ' ' and is collored as an error (red)...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
274 if strcmp(styles(idx).char,'Colors_M_Errors')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
275 character = char(doc.getText(offsets(idx)+docElement.getStartOffset,1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
276 if strcmp(character,' ')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
277 if isempty(urls(idx)) && links(idx)==0
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
278 % Revert the style color to the CW background color (i.e., hide it!)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
279 styles(idx) = java.lang.String('CW_BG_Color');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
280 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
281 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
282 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
283 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
284 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
285 % never mind...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
286 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
287
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
288 % Set an element to a particular style (color)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
289 function setElementStyle(docElement,style,hyperlinkFlag)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
290 %global tokens links urls urlTargets % for debug only
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
291 if nargin<3, hyperlinkFlag=0; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
292 % Set the last Element token to the requested style:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
293 % Colors:
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
294 tokens = docElement.getAttribute('SyntaxTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
295 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
296 styles = tokens(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
297 %hyperlinkFlag = ~isempty(strmatch('CWLink',tokens(2)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
298 %hyperlinkFlag = 0 + any(cellfun(@(c)(~isempty(c)&&strcmp(c,'CWLink')),tokens(2).cell));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
299 styles(end) = java.lang.String('');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
300 styles(end-hyperlinkFlag) = java.lang.String(style); %#ok apparently unused but in reality used by Java
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
301 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
302 % never mind for now
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
303 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
304
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
305 % Underlines (hyperlinks):
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
306 links = docElement.getAttribute('LinkStartTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
307 if isempty(links)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
308 %docElement.addAttribute('LinkStartTokens',repmat(int32(-1),length(tokens(2)),1));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
309 else
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
310 %TODO: remove hyperlink by setting the value to -1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
311 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
312
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
313 % Correct empty URLs to be un-hyperlinkable (only underlined)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
314 urls = docElement.getAttribute('HtmlLink');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
315 if isempty(urls), return; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
316 urlTargets = urls(2);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
317 for urlIdx = 1 : length(urlTargets)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
318 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
319 if urlTargets(urlIdx).length < 1
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
320 urlTargets(urlIdx) = []; % '' => []
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
321 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
322 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
323 % never mind...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
324 a=1; %#ok used for debug breakpoint...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
325 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
326 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
327
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
328 % Display information about element(s)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
329 function dumpElement(docElements)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
330 %return;
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
331 numElements = length(docElements);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
332 for elementIdx = 1 : numElements
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
333 if numElements > 1, fprintf('Element #%d:\n',elementIdx); end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
334 docElement = docElements(elementIdx);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
335 if ~isjava(docElement), docElement = docElement.java; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
336 %docElement.dump(java.lang.System.out,1)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
337 tokens = docElement.getAttribute('SyntaxTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
338 if isempty(tokens), continue; end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
339 links = docElement.getAttribute('LinkStartTokens');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
340 urls = docElement.getAttribute('HtmlLink');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
341 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
342 data = [tokens(2).cell m2c(tokens(1)) m2c(links) m2c(urls(1)) cell(urls(2))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
343 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
344 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
345 data = [tokens(2).cell m2c(tokens(1)) m2c(links)];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
346 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
347 disp([tokens(2).cell m2c(tokens(1))]);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
348 try
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
349 data = [m2c(links) m2c(urls(1)) cell(urls(2))];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
350 catch
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
351 % Mtlab 7.1 only has urls(1)...
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
352 data = [m2c(links) urls.cell];
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
353 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
354 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
355 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
356 disp(' ');
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
357 disp(docElement)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
358 disp(data)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
359 end
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
360
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
361 % Utility function to convert matrix => cell
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
362 function cells = m2c(data)
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
363 datasize = size(data);
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
364 cells = mat2cell(data,ones(1,datasize(1)),ones(1,datasize(2)));
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
365
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
366
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
367 %%%%%%%%%%%%%%%%%%%%%%%%%% TODO %%%%%%%%%%%%%%%%%%%%%%%%%
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
368 % - Fix: Remove leading space char (hidden underline '_')
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
369 % - Fix: Find workaround for multi-line quirks/limitations
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
370 % - Fix: Non-\n-terminated segments are displayed as black
|
Daniele Nicolodi <nicolodi@science.unitn.it>
parents:
diff
changeset
|
371 % - Fix: Check whether the hyperlink fix for 7.1 is also needed on 7.2 etc. |