<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Accessing the Matlab Editor</title> <atom:link href="http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/feed/" rel="self" type="application/rss+xml" /><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/</link> <description>Charting Matlab's unsupported hidden underbelly</description> <lastBuildDate>Thu, 09 Feb 2012 09:23:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.1.1</generator> <item><title>By: Rex</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-70241</link> <dc:creator>Rex</dc:creator> <pubDate>Tue, 10 Jan 2012 01:30:45 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-70241</guid> <description>Hi, Yair
This function works. I want to add a button to the Editor, with the same function. Or change the function of &quot;Run&quot; button.</description> <content:encoded><![CDATA[<p>Hi, Yair<br
/> This function works. I want to add a button to the Editor, with the same function. Or change the function of &#8220;Run&#8221; button.</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-70217</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Mon, 09 Jan 2012 22:45:25 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-70217</guid> <description>@Rex - Windows shortcuts cannot be run via the &lt;i&gt;&lt;b&gt;dos&lt;/b&gt;&lt;/i&gt; function, as far as I know. Instead, you need to refer to the actual file location (not a shortcut). Also, you might need to use &lt;i&gt;&lt;b&gt;winopen&lt;/b&gt;&lt;/i&gt; rather than &lt;i&gt;&lt;b&gt;dos&lt;/b&gt;&lt;/i&gt;.</description> <content:encoded><![CDATA[<p>@Rex &#8211; Windows shortcuts cannot be run via the <i><b>dos</b></i> function, as far as I know. Instead, you need to refer to the actual file location (not a shortcut). Also, you might need to use <i><b>winopen</b></i> rather than <i><b>dos</b></i>.</p> ]]></content:encoded> </item> <item><title>By: Rex Deng</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-70110</link> <dc:creator>Rex Deng</dc:creator> <pubDate>Mon, 09 Jan 2012 03:53:02 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-70110</guid> <description>hi, Yair Altman, i want to add a run function of VBScript codes in the editor, now i just make a shortcut in the matlab desktop like this. can you give me some help? thanks a lot!
&lt;pre lang=&quot;matlab&quot;&gt;
try
% Matlab 7
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jEditor = desktop.getGroupContainer(&#039;Editor&#039;).getTopLevelAncestor;
% we get a com.mathworks.mde.desk.MLMultipleClientFrame object
catch
% Matlab 6
% Unfortunately, we can&#039;t get the Editor handle from the Desktop handle in Matlab 6:
%desktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop;
% So here&#039;s the workaround for Matlab 6:
openDocs = com.mathworks.ide.editor.EditorApplication.getOpenDocuments;  % a java.util.Vector
firstDoc = openDocs.elementAt(0);  % a com.mathworks.ide.editor.EditorViewContainer object
jEditor = firstDoc.getParent.getParent.getParent;
% we get a com.mathworks.mwt.MWTabPanel or com.mathworks.ide.desktop.DTContainer object
end
jEditor.toFront;
title = jEditor.getTitle;
currentFilename = char(title.replaceFirst(&#039;Editor - &#039;,&#039;&#039;));
if isequal(lower(currentFilename(end-3:end)),&#039;.vbs&#039;)
[s,w]=dos(currentFilename);
else
error(&#039;The current file is not *.vbs file!&#039;);
end
&lt;/pre&gt;</description> <content:encoded><![CDATA[<p>hi, Yair Altman, i want to add a run function of VBScript codes in the editor, now i just make a shortcut in the matlab desktop like this. can you give me some help? thanks a lot!</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">try</span>
    <span style="color: #228B22;">% Matlab 7</span>
    desktop = com.<span style="">mathworks</span>.<span style="">mde</span>.<span style="">desk</span>.<span style="">MLDesktop</span>.<span style="">getInstance</span>;
    jEditor = desktop.<span style="">getGroupContainer</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editor'</span><span style="color: #080;">&#41;</span>.<span style="">getTopLevelAncestor</span>;
    <span style="color: #228B22;">% we get a com.mathworks.mde.desk.MLMultipleClientFrame object</span>
<span style="color: #0000FF;">catch</span>
    <span style="color: #228B22;">% Matlab 6</span>
    <span style="color: #228B22;">% Unfortunately, we can't get the Editor handle from the Desktop handle in Matlab 6:</span>
    <span style="color: #228B22;">%desktop = com.mathworks.ide.desktop.MLDesktop.getMLDesktop;</span>
    <span style="color: #228B22;">% So here's the workaround for Matlab 6:</span>
    openDocs = com.<span style="">mathworks</span>.<span style="">ide</span>.<span style="">editor</span>.<span style="">EditorApplication</span>.<span style="">getOpenDocuments</span>;  <span style="color: #228B22;">% a java.util.Vector</span>
    firstDoc = openDocs.<span style="">elementAt</span><span style="color: #080;">&#40;</span><span style="color: #33f;">0</span><span style="color: #080;">&#41;</span>;  <span style="color: #228B22;">% a com.mathworks.ide.editor.EditorViewContainer object</span>
    jEditor = firstDoc.<span style="">getParent</span>.<span style="">getParent</span>.<span style="">getParent</span>;
    <span style="color: #228B22;">% we get a com.mathworks.mwt.MWTabPanel or com.mathworks.ide.desktop.DTContainer object</span>
<span style="color: #0000FF;">end</span>
jEditor.<span style="">toFront</span>;
<span style="color: #0000FF;">title</span> = jEditor.<span style="">getTitle</span>;
currentFilename = <span style="color: #0000FF;">char</span><span style="color: #080;">&#40;</span><span style="color: #0000FF;">title</span>.<span style="">replaceFirst</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editor - '</span>,<span style="color:#A020F0;">''</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">if</span> isequal<span style="color: #080;">&#40;</span><span style="color: #0000FF;">lower</span><span style="color: #080;">&#40;</span>currentFilename<span style="color: #080;">&#40;</span>end-<span style="color: #33f;">3</span><span style="color: #F0F;">:</span><span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span><span style="color: #080;">&#41;</span>,<span style="color:#A020F0;">'.vbs'</span><span style="color: #080;">&#41;</span>
    <span style="color: #080;">&#91;</span>s,w<span style="color: #080;">&#93;</span>=dos<span style="color: #080;">&#40;</span>currentFilename<span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">else</span>
    <span style="color: #0000FF;">error</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'The current file is not *.vbs file!'</span><span style="color: #080;">&#41;</span>;
<span style="color: #0000FF;">end</span></pre></div></div>]]></content:encoded> </item> <item><title>By: kristian svartveit</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-59600</link> <dc:creator>kristian svartveit</dc:creator> <pubDate>Mon, 17 Oct 2011 14:31:02 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-59600</guid> <description>HiWould it be possible to add functionality to the context menu? I would like to be able to evaluate a function with the selected text as input, i.e size() of the variable i right-clicked on.K</description> <content:encoded><![CDATA[<p>Hi</p><p>Would it be possible to add functionality to the context menu? I would like to be able to evaluate a function with the selected text as input, i.e size() of the variable i right-clicked on.</p><p>K</p> ]]></content:encoded> </item> <item><title>By: Punit</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-18975</link> <dc:creator>Punit</dc:creator> <pubDate>Thu, 30 Sep 2010 21:28:37 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-18975</guid> <description>Hi Yair,
Thanks a lot. That article is really helpful
-Punit</description> <content:encoded><![CDATA[<p>Hi Yair,<br
/> Thanks a lot. That article is really helpful<br
/> -Punit</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-18973</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Thu, 30 Sep 2010 21:07:56 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-18973</guid> <description>@Punit - instead of re-parenting the Editor document as you  had attempted, why not use one of the simpler options suggested in &lt;a href=&quot;http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/&quot; rel=&quot;nofollow&quot;&gt;http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/&lt;/a&gt;?-Yair</description> <content:encoded><![CDATA[<p>@Punit &#8211; instead of re-parenting the Editor document as you  had attempted, why not use one of the simpler options suggested in <a
href="http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/" rel="nofollow">http://undocumentedmatlab.com/blog/syntax-highlighted-labels-panels/</a>?</p><p>-Yair</p> ]]></content:encoded> </item> <item><title>By: Punit</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-18970</link> <dc:creator>Punit</dc:creator> <pubDate>Thu, 30 Sep 2010 20:33:11 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-18970</guid> <description>Hi Yair,
Thanks a lot for undocumented matlab articles, those are really helpful.
I&#039;m trying to build a GUI which has matlab editor in the figure. Currently I can use following program to show the editor in my GUE
&lt;pre lang=&quot;matlab&quot;&gt;
edit(&#039;test.m&#039;)
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
editors=desktop.getGroupMembers(&#039;Editor&#039;);
CurrEdit=editors(end);
hedit=javacomponent(CurrEdit,pos,gcf);
&lt;/pre&gt;
but, a blank editor window still remains open, and when I close that window, the program displayed in the matlab figure is also closed. Is there any other way I can bring the editor in a matlab figure? I think this is not impossible because the GUI of s-function editor block in simulink has that facility.
Thanks
-Punit</description> <content:encoded><![CDATA[<p>Hi Yair,<br
/> Thanks a lot for undocumented matlab articles, those are really helpful.<br
/> I&#8217;m trying to build a GUI which has matlab editor in the figure. Currently I can use following program to show the editor in my GUE</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;"><span style="color: #0000FF;">edit</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'test.m'</span><span style="color: #080;">&#41;</span>
desktop = com.<span style="">mathworks</span>.<span style="">mde</span>.<span style="">desk</span>.<span style="">MLDesktop</span>.<span style="">getInstance</span>;
editors=desktop.<span style="">getGroupMembers</span><span style="color: #080;">&#40;</span><span style="color:#A020F0;">'Editor'</span><span style="color: #080;">&#41;</span>;
CurrEdit=editors<span style="color: #080;">&#40;</span><span style="color: #0000FF;">end</span><span style="color: #080;">&#41;</span>;
hedit=javacomponent<span style="color: #080;">&#40;</span>CurrEdit,pos,<span style="color: #0000FF;">gcf</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>but, a blank editor window still remains open, and when I close that window, the program displayed in the matlab figure is also closed. Is there any other way I can bring the editor in a matlab figure? I think this is not impossible because the GUI of s-function editor block in simulink has that facility.<br
/> Thanks<br
/> -Punit</p> ]]></content:encoded> </item> <item><title>By: Yair Altman</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-18808</link> <dc:creator>Yair Altman</dc:creator> <pubDate>Tue, 28 Sep 2010 09:28:16 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-18808</guid> <description>@Ralf - in R2010b (Matlab 7.11), the Java class interface has changed. In R2010b, we get the editor handle as follows:
&lt;pre lang=&quot;matlab&quot;&gt;
editorservices = com.mathworks.mlservices.MLEditorServices;
jEditorApp = editorservices.getEditorApplication;
&lt;/pre&gt;The method names and parameters have also changed from those of the pre-R2010b Java class. Each edited document now has a separate com.mathworks.mde.editor.MatlabEditor object. The jEditorApp.getActiveEditor() method returns the MatlabEditor object for the currently-edited document; the other documents can be retrieved using jEditorApp.getOpenEditors(), which returns a  java.util.Collections.UnmodifiableList of such MatlabEditors.Once you get your desired document (a MatlabEditor reference), its functionality can be accessed via its MatlabEditor&#039;s methods (bringToFront(), close(), goToLine(...), reload(), replaceText(...), setEditable(...) etc.) or properties (e.g. CaretPosition, Document, Language, Length, LongName, ShortName, Selection, Text, etc.). I suggest using my &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/26947-checkclass&quot; rel=&quot;nofollow&quot;&gt;CheckClass&lt;/a&gt; or &lt;a href=&quot;http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methodspropertiescallbacks-of-an-object&quot; rel=&quot;nofollow&quot;&gt;UIInspect&lt;/a&gt; utilities if you want additional information about the supported properties, callbacks and methods. I may also post about this in the upcoming months, since it needs much more space than a simple comment here, so stay tuned.Of course, you can always continue to use the partially-documented/supported &lt;i&gt;&lt;b&gt;editorservices&lt;/b&gt;&lt;/i&gt; object that Mike Katz introduced last year (see &lt;a href=&quot;http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-3536&quot; rel=&quot;nofollow&quot;&gt;his comment above&lt;/a&gt;).-Yair</description> <content:encoded><![CDATA[<p>@Ralf &#8211; in R2010b (Matlab 7.11), the Java class interface has changed. In R2010b, we get the editor handle as follows:</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">editorservices = com.<span style="">mathworks</span>.<span style="">mlservices</span>.<span style="">MLEditorServices</span>;
jEditorApp = editorservices.<span style="">getEditorApplication</span>;</pre></div></div><p>The method names and parameters have also changed from those of the pre-R2010b Java class. Each edited document now has a separate com.mathworks.mde.editor.MatlabEditor object. The jEditorApp.getActiveEditor() method returns the MatlabEditor object for the currently-edited document; the other documents can be retrieved using jEditorApp.getOpenEditors(), which returns a  java.util.Collections.UnmodifiableList of such MatlabEditors.</p><p>Once you get your desired document (a MatlabEditor reference), its functionality can be accessed via its MatlabEditor&#8217;s methods (bringToFront(), close(), goToLine(&#8230;), reload(), replaceText(&#8230;), setEditable(&#8230;) etc.) or properties (e.g. CaretPosition, Document, Language, Length, LongName, ShortName, Selection, Text, etc.). I suggest using my <a
href="http://www.mathworks.com/matlabcentral/fileexchange/26947-checkclass" rel="nofollow">CheckClass</a> or <a
href="http://www.mathworks.com/matlabcentral/fileexchange/17935-uiinspect-display-methodspropertiescallbacks-of-an-object" rel="nofollow">UIInspect</a> utilities if you want additional information about the supported properties, callbacks and methods. I may also post about this in the upcoming months, since it needs much more space than a simple comment here, so stay tuned.</p><p>Of course, you can always continue to use the partially-documented/supported <i><b>editorservices</b></i> object that Mike Katz introduced last year (see <a
href="http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-3536" rel="nofollow">his comment above</a>).</p><p>-Yair</p> ]]></content:encoded> </item> <item><title>By: Ralf</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-18802</link> <dc:creator>Ralf</dc:creator> <pubDate>Tue, 28 Sep 2010 07:15:29 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-18802</guid> <description>Hi Yair,as for MATLAB 7.11 the code&lt;pre lang=&quot;matlab&quot;&gt;
com.mathworks.mlservices.MLEditorServices.newDocument(str,true);
&lt;/pre&gt;does not work anymore. Do you know any workaround?Thank you for your constant efforts digging out the internals of MATLAB and sharing them with us.Ralf.</description> <content:encoded><![CDATA[<p>Hi Yair,</p><p>as for MATLAB 7.11 the code</p><div
class="wp_syntax"><div
class="code"><pre class="matlab" style="font-family:monospace;">com.<span style="">mathworks</span>.<span style="">mlservices</span>.<span style="">MLEditorServices</span>.<span style="">newDocument</span><span style="color: #080;">&#40;</span>str,<span style="color: #0000FF;">true</span><span style="color: #080;">&#41;</span>;</pre></div></div><p>does not work anymore. Do you know any workaround?</p><p>Thank you for your constant efforts digging out the internals of MATLAB and sharing them with us.</p><p>Ralf.</p> ]]></content:encoded> </item> <item><title>By: Omid</title><link>http://undocumentedmatlab.com/blog/accessing-the-matlab-editor/#comment-12864</link> <dc:creator>Omid</dc:creator> <pubDate>Fri, 16 Jul 2010 06:22:49 +0000</pubDate> <guid
isPermaLink="false">http://undocumentedmatlab.com/?p=671#comment-12864</guid> <description>Hi,
I sent this question on MATLAB central but received no answer, so I post it here again in case you&#039;ve not seen it!I have a time tracking software that records the time I spend on each application. It recognizes the applications by their window caption. I&#039;m used to have the MATLAB editor docked into the main window, so all my working time in MATLAB is reported under the name of &quot;MATLAB 7.8.0 (2009a)&quot;. I&#039;m thinking of a way to change the main window title to the name of the document I&#039;m currently working on. Thanks to undocumentedmatlab.com now I know how to get the name of the active document and how to change the window title by accessing related java components. What I need is to code a callback function to be triggered whenever I switch to another document in the editor. However I didn&#039;t find the right callback property. Any idea?P.S. What I said I know works when the editor is undocked which is not what I&#039;m looking for! So I correct that: I don&#039;t even know how to get the title of the active document in the editor when the editor is docked into the main window :(</description> <content:encoded><![CDATA[<p>Hi,<br
/> I sent this question on MATLAB central but received no answer, so I post it here again in case you&#8217;ve not seen it!</p><p>I have a time tracking software that records the time I spend on each application. It recognizes the applications by their window caption. I&#8217;m used to have the MATLAB editor docked into the main window, so all my working time in MATLAB is reported under the name of &#8220;MATLAB 7.8.0 (2009a)&#8221;. I&#8217;m thinking of a way to change the main window title to the name of the document I&#8217;m currently working on. Thanks to undocumentedmatlab.com now I know how to get the name of the active document and how to change the window title by accessing related java components. What I need is to code a callback function to be triggered whenever I switch to another document in the editor. However I didn&#8217;t find the right callback property. Any idea?</p><p>P.S. What I said I know works when the editor is undocked which is not what I&#8217;m looking for! So I correct that: I don&#8217;t even know how to get the title of the active document in the editor when the editor is docked into the main window <img
src='http://undocumentedmatlab.com/blog/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /></p> ]]></content:encoded> </item> </channel> </rss>

<!-- W3 Total Cache: Minify debug info:
Engine:             disk: basic
Theme:              b7666
Template:           single
-->
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: undocumentedmatlab.com @ 2012-02-09 05:10:31 -->

<!-- W3 Total Cache: Page cache debug info:
Engine:             disk: enhanced
Cache key:          blog/accessing-the-matlab-editor/feed/_index.xml_gzip
Caching:            enabled
Status:             not cached
Creation Time:      0.756s
Header info:
X-Pingback:         http://undocumentedmatlab.com/blog/xmlrpc.php
Set-Cookie:         wpgb_visit_last_php-default=1328789430; expires=Fri, 08-Feb-2013 12:10:30 GMT; path=/
Link:               <http://undocumentedmatlab.com/?p=671>; rel=shortlink
Content-Type:       text/xml; charset=UTF-8
Last-Modified:      Thu, 09 Feb 2012 12:10:31 GMT
Vary:               Accept-Encoding, Cookie
Expires:            Thu, 09 Feb 2012 13:10:31 GMT
Pragma:             public
Cache-Control:      public, must-revalidate, proxy-revalidate
Etag:               7bfeb57e65b56bec7f9526ecfe0c3d5f
Content-Encoding:   gzip
-->
