📄 helpwindow.m
字号:
'HorizontalAlignment','left', ...
'Tag','SeeAlsoPop', ...
'Value',1);
HomeBtn = uicontrol('Parent',fig, ...
'CallBack','helpwindow(''HelpwinHome'');', ...
'Units','Points', ...
'Position',[2*wid2+3*spc pos(4)-frmht+4 wid2 ht], ...
'String','Home', ...
'Tag','HomeBtn');
BackBtn = uicontrol('Parent',fig, ...
'CallBack','helpwindow(''HelpwinBack'');', ...
'Units','Points', ...
'Position',[spc pos(4)-frmht+4 wid2 ht], ...
'String','Back', ...
'UserData',0, ...
'Tag','BackBtn');
ForwardBtn = uicontrol('Parent',fig, ...
'CallBack','helpwindow(''HelpwinForward'');', ...
'Units','Points', ...
'Position',[wid2+2*spc pos(4)-frmht+4 wid2 ht], ...
'String','Forward', ...
'Tag','ForwardBtn');
HelpDeskBtn = uicontrol('Parent',fig, ...
'Units','Points', ...
'Position',[figwidth-2*(wid2+spc) pos(4)-frmht+ht+8 2*wid2+spc ht], ...
'Style','Pushbutton', ...
'HorizontalAlignment','center', ...
'String','Go to Help Desk', ...
'Tag','HelpDeskBtn', ...
'Callback','helpwindow(''HelpwinHelpDesk'');');
HelpBtn = uicontrol('Parent',fig, ...
'CallBack','helpwindow(''helpinfo'');', ...
'Units','Points', ...
'Position',[figwidth-2*(wid2+spc) pos(4)-frmht+4 wid2 ht], ...
'String','Tips', ...
'Tag','HelpBtn');
CloseBtn = uicontrol('Parent',fig, ...
'CallBack','set(gcbf,''visible'',''off'')', ...
'Units','Points', ...
'Position',[figwidth-(wid2+spc) pos(4)-frmht+4 wid2 ht], ...
'String','Close', ...
'Tag','CloseBtn');
% Set 'Busy Action, Queue' and 'Interruptible, Off' on all objects.
set(findobj(fig),'BusyAction','queue','Interruptible','off');
else
figure(fig);
ListBox = findobj(fig,'tag','ListBox');
CurHelpEdit = findobj(fig,'tag','CurHelpEdit');
SeeAlsoPop = findobj(fig,'tag','SeeAlsoPop');
HomeBtn = findobj(fig,'tag','HomeBtn');
BackBtn = findobj(fig,'tag','BackBtn');
ForwardBtn = findobj(fig,'tag','ForwardBtn');
HelpDeskBtn = findobj(fig,'tag','HelpDeskBtn');
end
% Turn on figure visiblity.
set(fig,'visible','on');
% Create Page popup if not necessary and non-existent. Otherwise, simply
% load up the help string with the help text for the requested topic.
if multi_page_text
% Get the help text for the requested topic from the cell array.
if nargin < 2
pagetitle = topic{1,1};
elseif isempty(pagetitle)
pagetitle = topic{1,1};
end
ind = strmatch(pagetitle,topic(:,1),'exact');
if isempty(ind), ind = 1; end
helpstr = char(topic{ind,2});
slash_n = find(helpstr==CR);
if slash_n
% Replace pipes with '!' for display if necessary,
% replace the carriage returns in the help string with pipes
% so that the list box can correctly interpret them.
% Add one extra line to top of display.
helpstr(find(helpstr == '|')) = '!';
helpstr(slash_n) = '|';
helpstr = ['|' helpstr];
else
% Add one extra line to top of display.
helpstr = str2mat('',helpstr);
end
% Set the popup string.
ref = [{'Topics'}; topic(:,1)];
if length(ref) < 2
set(SeeAlsoPop,'string',ref,...
'enable','off');
else
set(SeeAlsoPop,'string',ref, ...
'callback','helpwindow(''HelpwinPage'');', ...
'enable','on',...
'value',1,...
'userdata',topic);
end
% Set the current topic.
pgtitle = topic{ind,1};
elseif (iscell(topic) | any(find(topic==32)) | ...
size(topic,1) > 1 | any(find(topic==CR)))
helpstr = char(topic);
slash_n = find(helpstr==CR);
if slash_n
% Replace pipes with '!' for display if necessary,
% replace the carriage returns in the help string with pipes
% so that the list box can correctly interpret them.
% Add one extra line to top of display.
helpstr(find(helpstr == '|')) = '!';
helpstr(slash_n) = '|';
helpstr = ['|' helpstr];
else
% Add one extra line to top of display.
helpstr = str2mat('',helpstr);
end
if nargin < 2
pgtitle = 'MATLAB Help';
else
if isempty(pagetitle)
pgtitle = 'MATLAB Help';
else
pgtitle = pagetitle;
end
end
else
% Get the help text for the requested topic.
helpstr = help(topic);
slash_n = 1;
pgtitle = topic;
% Error handling. If topic not found, send an error message to the window.
if isempty(helpstr)
helpstr = [CR ' Topic ''' pgtitle ''' was not found.'];
end
% Replace pipes with '!' for display if necessary,
% replace the carriage returns in the help string with pipes
% so that the list box can correctly interpret them.
% Add one extra line to top of display.
helpstr(find(helpstr == '|')) = '!';
helpstr(find(helpstr==CR)) = '|';
helpstr = ['|' helpstr];
end
% Store the arguments in the userdata of the figure. This is a stack
% which enables the Back button to work for the last few selections.
fud = get(fig,'UserData');
curArg = struct('topic',{[]},'pagetitle',{[]},'helptitle',{[]});
curArg.topic = topic;
curArg.pagetitle = pgtitle;
if nargin >= 3
curArg.helptitle = helptitle;
end
if isempty(fud)
fud = curArg; % protects for first time through code.
else
backflag = get(BackBtn,'UserData'); % flag to indicate that Back/Forw button was
if backflag == 0 % pressed.
str = get(CurHelpEdit,'string');
if str(1) == ' ', str(1) = []; end; % remove first char is space
match = strmatch(str,{fud.pagetitle},'exact');
if ~isempty(match)
fud(1:match-1) = []; % eliminate the items 'above' the selected items
end
fud = [curArg fud];
if length(fud) >= 7 % limits stack to 6 elements
fud(7) = []; % or 5 Back button presses
end
else
set(BackBtn,'UserData',0); % clear backflag
end
end
set(fig,'UserData',fud);
% Check to see whether the Back and Forward buttons should be disabled.
match = strmatch(pgtitle,{fud.pagetitle},'exact');
if max(match) == length(fud)
set(BackBtn,'enable','off');
else
set(BackBtn,'enable','on');
end
if min(match) == 1
set(ForwardBtn,'enable','off');
else
set(ForwardBtn,'enable','on');
end
% Replace all tabs with single spaces.
helpstr(find(helpstr==9)) = ' ';
% Set the listbox string to the help string and set the topic name in the
% edit box.
set(CurHelpEdit,'string',[' ' pgtitle]); % extra space for better display.
set(ListBox,'value',[],'string',helpstr,'ListBoxTop',1);
if any(slash_n) & ~multi_page_text
% Set up the string for the See Also pop-up
cnt=1;
ref={'See also'};
if ~(any(find(pgtitle==filesep)) | ...
any(find(pgtitle=='/')) | ...
any(find(pgtitle(2:end)==' ')))
ref = {'See also' ['More ' pgtitle ' help (HTML)']};
cnt = cnt + 1;
end
% Enable links to the related topics found after the 'See Also'.
seealso=max(findstr(helpstr,'See also')); % Finds LAST 'See Also'.
overind = max(findstr(helpstr,'| Overloaded methods'));
if ~isempty(seealso)
p=seealso+8;
lmask=[zeros(1,p-1) isletter(helpstr(p:end))];
umask=helpstr==upper(helpstr);
undmask=helpstr=='_';
nmask = [zeros(1,p-1) ...
((helpstr(p:end) >= '0') & (helpstr(p:end) <= '9'))];
rmask=lmask&umask | undmask | nmask;
ln=length(helpstr);
if ~isempty(overind), ln=overind-1; end
while 1
q=p;
while ~rmask(p) & p<ln
p=p+1;
end
q=p+1;
if q>=ln, break; end
while rmask(q)
q=q+1;
end
cnt=cnt+1;
if q>p+1, % Protects against single letter references.
ref{cnt}=lower(helpstr(p:q-1));
end
p=q;
end
end
% Enable link to overloaded methods.
if ~isempty(overind)
ln = length(helpstr);
eol = find(helpstr(overind+1:ln)=='|');
p = findstr(helpstr(overind:ln),'help ');
for i=1:length(p)
cnt = cnt + 1;
ref{cnt} = helpstr(overind+p(i)+4:overind+eol(i+1)-1);
end
end
% Set the See Also popup values.
set(SeeAlsoPop,'value',1);
if size(ref,2) < 2
set(SeeAlsoPop,'string',ref,...
'enable','off');
else
set(SeeAlsoPop,'string',ref, ...
'callback','helpwindow(''HelpwinSeealso'');', ...
'enable','on');
end
elseif ~multi_page_text
set(SeeAlsoPop,'string',{'See also'},...
'enable','off');
end
% Set the figure title if supplied.
if nargin >= 3
if isempty(helptitle)
set(fig,'Name','MATLAB Help Window');
else
set(fig,'Name',helptitle);
end
else
set(fig,'Name','MATLAB Help Window');
end
% Set any HG properties that were passed in.
if ~isempty(varargin)
narg = length(varargin);
set(ListBox,varargin(1:2:narg),varargin(2:2:narg))
end
end
% Done.
%-----------------Function GOODFONTS-----------------
function [fname,fsize,listboxbdr] = goodfonts(computer)
% Returns a good font for a list box on this platform
% and return the resulting figure width for an 80 column
% display.
% fname - string
% fsize - points
% listboxbdr - pixels for frame
switch computer
case 'PCWIN'
fname = 'Courier';
fsize = 10;
listboxbdr = 0;
case 'MAC2'
fname = 'Monaco';
fsize = 9;
listboxbdr = 3;
otherwise
fname = 'Courier';
fsize = 10;
listboxbdr = 0;
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -