-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm2tex.m
1579 lines (1470 loc) · 54.7 KB
/
m2tex.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function varargout = m2tex()
% This file "m2tex.m" translates a normal m-file into a LaTeX-file, so that
% the layout of both files will look the same.
%
% Features: - recognizes all keywords, strings and comments
% - recognizes all indents and tabs
% - recognizes cell titles
% - writes all recognized objects correct in a tex-file
% - uses original Matlab colors
% - the font looks almost the same as in Matlab Editor
% - tex-file is saved using fontencoding "UTF-8", so that
% German Umlauts will be written correct
% - option for numbered code lines ('num' or 'no_num')
% - recognizes a linebreak, but only with a leading space
% character, i.e. " ..." and only once in a line
% - option for input- and output-file (*.m respectively
% *.tex-file), to specify as input argument
% - execution via GUI or command line
% - option ('bwc') for output in black/white for non-colored code
%
% Application: There are SEVERAL WAYS TO EXECUTE the program.
% 1. Run the file by pressing F5 oder click the "Run" button
% in the Matlab Editor, while the m2tex.m file is open or
% type "m2tex" in the Command Window.
% ==> The program will open the GUI and the rest goes from
% there.
% 2. Call the program from the Command Window or another
% m-file with at least one option. The order of the
% option is not important. For example:
%
% m2tex('num','C:\Programme\MATLAB\work\testfile.m','C:\latex_documents\testfile.tex')
% m2tex('testfile.m','testoutputfile.tex','no_num','bwc')
%
% - If you insert only a filename, m2tex tries to read the
% file from your actual current directory.
% - If you specify no target directory and filename, m2tex
% takes the same path and filename as stated for the
% source m-file.
% - If you have not specified the source or the option for
% numbered code lines, the program will still ask for it.
%
% Input: One m-file.
% Output: A tex-file will be written to look like the m-file after it
% has been set to pdf.
%
% Integration: Include the output.tex file via the following commands:
% - \include{output.tex} or
% - \input{output.tex}
% You also have to include the following package into the
% header of your main LaTeX document:
% - \usepackage{color}
% - \usepackage{fancyvrb}
%
% created on: 09.06.2009 by USL with Matlab 7.5.0 (R2007b)
% Version: 2.1
% finished: 17.06.2009 (1.0)
% last change: 29.09.2009
%
% If there are any suggestions, problems or ideas for missing functions or
% how to improve the program,
% please contact me at Matlab Central, where you've got the file...
%
% VERSION History:
% - 1.0 17.06.09 -> translating m-code to tex
% - 1.1 19.06.09 -> added option 'num' for numbered code lines
% - 1.2 26.06.09 -> recognizes now a linebreak, but only with a
% leading space character, i.e. " ..."
% - 2.0 06.08.09 -> added option for source and target path and or
% filename
% -> added a GUI to the command line application
% -> set paths, filenames and other options via GUI
% - 2.1 29.09.09 -> added option 'bwc' for code in black & white
%
% Comments from the writer of this file: (I'm working on it...)
% - recognizes " ...", but only one in a line without problems and only
% with a leading space character
% - no such string as "$" or "#" is allowed to be in the whole m-file in any way
% --> $,# = variable, which can be replaced in a line, if nessecary
% - only optimized (numbers+their indents) for ?\normalsize?
%
%
%
%
% % % % m2tex M-file for m2tex.fig
% % % % m2tex, by itself, creates a new m2tex or raises the existing
% % % % singleton*.
% % % %
% % % % H = m2tex returns the handle to a new m2tex or the handle to
% % % % the existing singleton*.
% % % %
% % % % m2tex('Property','Value',...) creates a new m2tex using the
% % % % given property value pairs. Unrecognized properties are passed via
% % % % varargin to m2tex_OpeningFcn. This calling syntax produces a
% % % % warning when there is an existing singleton*.
% % % %
% % % % m2tex('CALLBACK') and m2tex('CALLBACK',hObject,...) call the
% % % % local function named CALLBACK in m2tex.M with the given input
% % % % arguments.
% % % %
% % % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% % % % instance to run (singleton)".
% % % %
% % % % See also: GUIDE, GUIDATA, GUIHANDLES
% % %
% % % % Edit the above text to modify the response to help m2tex
% % %
% % % % Last Modified by GUIDE v2.5 17-Sep-2009 11:06:26
%% check the input options
if ~isempty(varargin)
if length(varargin) > 1
% input has to be a real input option for the CLT
if ~ishandle(varargin{2})
% call the the command line tool (CLT)
input = '''';
for i = 1:length(varargin)
input = [input varargin{i},''',''']; %#ok<AGROW>
end
input = input(1:end-2);
eval(['m2tex_CLT(',input,')']);
% finish the execution of this m-file now
return
end
else
% call the the command line tool (CLT)
eval(['m2tex_CLT(''',varargin{1},''')']);
% finish the execution of this m-file now
return
end
end
%% normal gui code starts here
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @m2tex_OpeningFcn, ...
'gui_OutputFcn', @m2tex_OutputFcn, ...
'gui_LayoutFcn', @m2tex_LayoutFcn, ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before m2tex is made visible.
function m2tex_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% % % % % if ~isempty(varargin)
% % % % % condition = varargin{1};
% % % % % clear varargin
% % % % % else
% % % % % condition = 'm2tex_CLT.m_un-active';
% % % % % end
% % % % % set(handles.text1,'UserData',condition)
% Choose default command line output for m2tex
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes m2tex wait for user response (see UIRESUME)
% uiwait(handles.figure1);
uiwait
% --- Outputs from this function are returned to the command line.
% --- Executes during object creation, after setting all properties.
function button_source_Callback(hObject, eventdata, handles)
% hObject handle to button_source (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
[FileName,PathName,FilterIndex] = uigetfile('*.m','Select your m-file');
if FileName ~= 0
set(handles.textfield_source, 'String', [PathName,FileName]);
end
% --- Executes on button press in button_targetfile.
function button_targetfile_Callback(hObject, eventdata, handles)
% hObject handle to button_targetfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
trail.src = get(handles.textfield_source, 'String');
idx = findstr(trail.src,'\');
if isempty(idx)
idx = findstr(trail.src,'/');
end
FileName_tex = [trail.src(idx(end)+1:end-2),'.tex'];
[FileName,PathName,FilterIndex] = uiputfile('*.tex','Select the output destination',FileName_tex);
if FileName ~= 0
if ~strcmp(FileName(end-3:end),'.tex')
FileName = [FileName,'.tex'];
end
set(handles.textfield_targetfile, 'String', PathName);
set(handles.textfield_targetname, 'String', FileName);
end
% --- Executes on button press in reset_savedpath.
function reset_savedpath_Callback(hObject, eventdata, handles)
% hObject handle to reset_savedpath (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if exist('m2tex_prefs.mat','file') == 2
load m2tex_prefs.mat
set(handles.textfield_source, 'String', trail.src);
set(handles.textfield_targetfile, 'String', trail.targetpath);
set(handles.textfield_targetname, 'String', [trail.targetname]);
end
% --- Executes on button press in reset_workdir.
function reset_workdir_Callback(hObject, eventdata, handles)
% hObject handle to reset_workdir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
trail.src = get(handles.textfield_source,'string');
if strcmp(trail.src(end-1:end),'.m')
idx = findstr(trail.src,'\');
if isempty(idx)
idx = findstr(trail.src,'/');
end
FileName = [trail.src(idx(end)+1:end-2),'.tex'];
PathName = trail.src(1:idx(end));
set(handles.textfield_targetfile, 'String',PathName);
set(handles.textfield_targetname, 'String',FileName);
end
% --- Executes on button press in calculate.
function calculate_Callback(hObject, eventdata, handles)
% hObject handle to calculate (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clc
message_error{1} = 'No m-file selected!';
message_error{2} = 'No tex-file selected!';
message_error{3} = 'No target path selected!';
message_error{4} = '';
trail.src = get(handles.textfield_source,'string');
trail.targetpath = get(handles.textfield_targetfile,'string');
trail.targetname = get(handles.textfield_targetname,'string');
if get(handles.checkbox_numb_codelines,'Value')
trail.numb = 'num';
else
trail.numb = 'no_num';
end
if get(handles.checkbox_bwc,'Value')
trail.bwc = 'bwc';
else
trail.bwc = 'color';
end
cond = [strcmp(trail.src(end-1:end),'.m') ...
strcmp(trail.targetname(end-3:end),'.tex') ...
~strcmp(trail.targetpath,'nothing is set')];
if cond(1) == 0, idx.a = 1;else idx.a = 4;end
if cond(2) == 0, idx.b = 2;else idx.b = 4;end
if cond(3) == 0, idx.c = 3;else idx.c = 4;end
if all(cond)
if get(handles.checkbox_saveoptions,'Value')
save('m2tex_prefs.mat','trail','-mat')
disp('Source and Target Path and Name are saved.')
end
uiresume;
disp('m2tex_gui properly executed.')
% call the CLT
eval(['m2tex_CLT(''',trail.numb,''',''',trail.src,''',''',...
[trail.targetpath,trail.targetname],''',''',trail.bwc,''')'])
else
errordlg(sprintf([message_error{idx.a},'\n',message_error{idx.b} ...
,'\n',message_error{idx.c}]),'File Error');
end
%% empty object functions
% --- Executes on button press in checkbox_bwc.
function checkbox_bwc_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_bwc (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hint: get(hObject,'Value') returns toggle state of checkbox_bwc
function checkbox_saveoptions_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_saveoptions (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hint: get(hObject,'Value') returns toggle state of checkbox_saveoptions
function checkbox_numb_codelines_Callback(hObject, eventdata, handles)
% hObject handle to checkbox_numb_codelines (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hint: get(hObject,'Value') returns toggle state of
% checkbox_numb_codelines
% --- Executes when selected object is changed in unitgroup.
function unitgroup_SelectionChangeFcn(hObject, eventdata, handles)
% hObject handle to the selected object in unitgroup
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% --- Executes on button press in save_options.
function save_options_Callback(hObject, eventdata, handles)
% hObject handle to save_options (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hint: get(hObject,'Value') returns toggle state of save_options
function textfield_targetname_Callback(hObject, eventdata, handles)
% hObject handle to textfield_targetname (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hints: get(hObject,'String') returns contents of textfield_targetname as text
% str2double(get(hObject,'String')) returns contents of textfield_targetname as a double
% --- Executes during object creation, after setting all properties.
function textfield_targetname_CreateFcn(hObject, eventdata, handles)
% hObject handle to textfield_targetname (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function textfield_targetfile_CreateFcn(hObject, eventdata, handles)
% hObject handle to textfield_targetfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function textfield_source_CreateFcn(hObject, eventdata, handles)
% hObject handle to textfield_source (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
function textfield_targetfile_Callback(hObject, eventdata, handles)
% hObject handle to textfield_targetfile (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hints: get(hObject,'String') returns contents of textfield_targetfile as text
% str2double(get(hObject,'String')) returns contents of
% textfield_targetfile as a double
% --- Executes during object creation, after setting all properties.
% --- Executes on button press in button_source.
function textfield_source_Callback(hObject, eventdata, handles)
% hObject handle to textfield_source (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Hints: get(hObject,'String') returns contents of textfield_source as text
% str2double(get(hObject,'String')) returns contents of textfield_source as a double
function varargout = m2tex_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%
% Get default command line output from handles structure
% varargout{1} = handles.output;
%% Graphical Part
% --- Creates and returns a handle to the GUI figure.
function h1 = m2tex_LayoutFcn(policy)
% policy - create a new figure or use a singleton. 'new' or 'reuse'.
persistent hsingleton;
if strcmpi(policy, 'reuse') & ishandle(hsingleton)
h1 = hsingleton;
return;
end
appdata = [];
appdata.GUIDEOptions = struct(...
'active_h', [], ...
'taginfo', struct(...
'figure', 2, ...
'pushbutton', 11, ...
'text', 19, ...
'edit', 7, ...
'frame', 4, ...
'radiobutton', 19, ...
'uipanel', 13, ...
'checkbox', 3), ...
'override', 1, ...
'release', 13, ...
'resize', 'none', ...
'accessibility', 'callback', ...
'mfile', 1, ...
'callbacks', 1, ...
'singleton', 1, ...
'syscolorfig', 1, ...
'blocking', 0, ...
'lastSavedFile', 'C:\Dokumente und Einstellungen\Admin\Eigene Dateien\My Dropbox\A_m-files\mcode2tex\Studie\m2tex.m', ...
'lastFilename', 'C:\Dokumente und Einstellungen\Admin\Eigene Dateien\My Dropbox\A_m-files\mcode2tex\m2tex_gui.fig');
appdata.lastValidTag = 'figure1';
appdata.GUIDELayoutEditor = [];
appdata.initTags = struct(...
'handle', [], ...
'tag', 'figure1');
h1 = figure(...
'PaperUnits',get(0,'defaultfigurePaperUnits'),...
'Color',[0.925490196078431 0.913725490196078 0.847058823529412],...
'Colormap',[0 0 0.5625;0 0 0.625;0 0 0.6875;0 0 0.75;0 0 0.8125;0 0 0.875;0 0 0.9375;0 0 1;0 0.0625 1;0 0.125 1;0 0.1875 1;0 0.25 1;0 0.3125 1;0 0.375 1;0 0.4375 1;0 0.5 1;0 0.5625 1;0 0.625 1;0 0.6875 1;0 0.75 1;0 0.8125 1;0 0.875 1;0 0.9375 1;0 1 1;0.0625 1 1;0.125 1 0.9375;0.1875 1 0.875;0.25 1 0.8125;0.3125 1 0.75;0.375 1 0.6875;0.4375 1 0.625;0.5 1 0.5625;0.5625 1 0.5;0.625 1 0.4375;0.6875 1 0.375;0.75 1 0.3125;0.8125 1 0.25;0.875 1 0.1875;0.9375 1 0.125;1 1 0.0625;1 1 0;1 0.9375 0;1 0.875 0;1 0.8125 0;1 0.75 0;1 0.6875 0;1 0.625 0;1 0.5625 0;1 0.5 0;1 0.4375 0;1 0.375 0;1 0.3125 0;1 0.25 0;1 0.1875 0;1 0.125 0;1 0.0625 0;1 0 0;0.9375 0 0;0.875 0 0;0.8125 0 0;0.75 0 0;0.6875 0 0;0.625 0 0;0.5625 0 0],...
'DockControls','off',...
'IntegerHandle','off',...
'InvertHardcopy',get(0,'defaultfigureInvertHardcopy'),...
'MenuBar','none',...
'Name','m2tex_gui',...
'NumberTitle','off',...
'PaperPosition',get(0,'defaultfigurePaperPosition'),...
'PaperSize',[14.840602904 20.974356673],...
'PaperType','A5',...
'Position',[544 485 500 325],...
'Resize','off',...
'UseHG2','off',...
'HandleVisibility','callback',...
'Tag','figure1',...
'UserData',[],...
'Visible','on',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'calculate';
h2 = uicontrol(...
'Parent',h1,...
'Units','characters',...
'Callback','m2tex(''calculate_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'ListboxTop',0,...
'Position',[69.8 1.30769230769231 26.2 5.92307692307692],...
'String','Run',...
'Tag','calculate',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'uipanel1';
h3 = uipanel(...
'Parent',h1,...
'Units','characters',...
'Title','Path Preferences',...
'Tag','uipanel1',...
'UserData',[],...
'Clipping','on',...
'Position',[3.2 8.69230769230769 92.8 11.3076923076923],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'text1';
h4 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[2 8.38461538461539 30.6 1.30769230769231],...
'String','Source Path (m-file)',...
'Style','text',...
'Tag','text1',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'text2';
h5 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[2 4.84615384615385 26.6 1.15384615384615],...
'String','Target Path (tex-file)',...
'Style','text',...
'Tag','text2',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'textfield_source';
h6 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','m2tex(''textfield_source_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[2 7.15384615384615 88.6 1.15384615384615],...
'String','nothing is set',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, 'm2tex(''textfield_source_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','textfield_source',...
'UserData',[]);
appdata = [];
appdata.lastValidTag = 'textfield_targetfile';
h7 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','m2tex(''textfield_targetfile_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[2 3.61538461538462 88.6 1.15384615384615],...
'String','nothing is set',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, 'm2tex(''textfield_targetfile_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','textfield_targetfile',...
'UserData',[]);
appdata = [];
appdata.lastValidTag = 'button_source';
h8 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'Callback','m2tex(''button_source_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[75.8333333333335 8.5576923076923 15 1.33333333333333],...
'String','Browse',...
'Tag','button_source',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'button_targetfile';
h9 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'Callback','m2tex(''button_targetfile_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[75.8333333333335 4.89102564102564 15 1.33333333333333],...
'String','Browse',...
'Tag','button_targetfile',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'textfield_targetname';
h10 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'BackgroundColor',[1 1 1],...
'Callback','m2tex(''textfield_targetname_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[19 1.30769230769231 35.6 1.15384615384615],...
'String','nothing is set',...
'Style','edit',...
'CreateFcn', {@local_CreateFcn, 'm2tex(''textfield_targetname_CreateFcn'',gcbo,[],guidata(gcbo))', appdata} ,...
'Tag','textfield_targetname',...
'UserData',[]);
appdata = [];
appdata.lastValidTag = 'text15';
h11 = uicontrol(...
'Parent',h3,...
'Units','characters',...
'CData',[],...
'HorizontalAlignment','left',...
'ListboxTop',0,...
'Position',[2 1.3525641025641 16.2 1.15384615384615],...
'String','Target Filename',...
'Style','text',...
'Tag','text15',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'unitgroup';
h12 = uibuttongroup(...
'Parent',h1,...
'Units','characters',...
'Title','Options',...
'Tag','unitgroup',...
'Clipping','on',...
'Position',[3.16666666666667 1.1474358974359 28.6666666666667 6.75],...
'SelectedObject',[],...
'SelectionChangeFcn','test_gui_m2tex(''unitgroup_SelectionChangeFcn'',gcbo,[],guidata(gcbo))',...
'OldSelectedObject',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'checkbox_numb_codelines';
h13 = uicontrol(...
'Parent',h12,...
'Units','characters',...
'Callback','m2tex(''checkbox_numb_codelines_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[1.83333333333333 2.10897435897436 25 1.91666666666667],...
'String','Numbered Code Lines',...
'Style','checkbox',...
'Value',1,...
'Tag','checkbox_numb_codelines',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'checkbox_saveoptions';
h14 = uicontrol(...
'Parent',h12,...
'Units','characters',...
'Callback','m2tex(''checkbox_saveoptions_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[1.83333333333333 0.442307692307692 21.6666666666667 1.75],...
'String','Save Paths',...
'Style','checkbox',...
'Value',1,...
'Tag','checkbox_saveoptions',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'checkbox_bwc';
h15 = uicontrol(...
'Parent',h12,...
'Units','characters',...
'Callback','m2tex(''checkbox_bwc_Callback'',gcbo,[],guidata(gcbo))',...
'Position',[1.86666666666667 3.75641025641026 25 1.91666666666667],...
'String','All in Black - No Color',...
'Style','checkbox',...
'Tag','checkbox_bwc',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'uipanel12';
h16 = uipanel(...
'Parent',h1,...
'Units','characters',...
'Title','Restore Target Path & Name to',...
'Tag','uipanel12',...
'Clipping','on',...
'Position',[33.2 1.15384615384615 34.8 6.84615384615385],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'reset_savedpath';
h17 = uicontrol(...
'Parent',h16,...
'Units','characters',...
'Callback','m2tex(''reset_savedpath_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'ListboxTop',0,...
'Position',[7.43333333333334 3.42948717948718 18.5 1.75],...
'String','Saved Ones',...
'Tag','reset_savedpath',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'reset_workdir';
h18 = uicontrol(...
'Parent',h16,...
'Units','characters',...
'Callback','m2tex(''reset_workdir_Callback'',gcbo,[],guidata(gcbo))',...
'CData',[],...
'ListboxTop',0,...
'Position',[7.43333333333334 0.929487179487177 18.5 1.75],...
'String','Source',...
'Tag','reset_workdir',...
'UserData',[],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'uipanel11';
h19 = uipanel(...
'Parent',h1,...
'Units','characters',...
'Title',blanks(0),...
'Tag','uipanel11',...
'Clipping','on',...
'Position',[15 20.8461538461538 70 3.92307692307692],...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'text18';
h20 = uicontrol(...
'Parent',h19,...
'Units','characters',...
'HorizontalAlignment','left',...
'Position',[8.2 0.282051282051283 26.8333333333333 0.916666666666667],...
'String','Version: 2.1',...
'Style','text',...
'Tag','text18',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'text17';
h21 = uicontrol(...
'Parent',h19,...
'Units','characters',...
'HorizontalAlignment','right',...
'Position',[48.2 0.198717948717949 14.1666666666667 1],...
'String','© 2009 USL',...
'Style','text',...
'Tag','text17',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
appdata = [];
appdata.lastValidTag = 'text16';
h22 = uicontrol(...
'Parent',h19,...
'Units','characters',...
'FontSize',19.5,...
'FontWeight','bold',...
'Position',[0.4 1.07692307692308 68.6 2.61538461538462],...
'String','"m2tex.m" Preferences',...
'Style','text',...
'Tag','text16',...
'CreateFcn', {@local_CreateFcn, blanks(0), appdata} );
hsingleton = h1;
% --- Set application data first then calling the CreateFcn.
function local_CreateFcn(hObject, eventdata, createfcn, appdata)
if ~isempty(appdata)
names = fieldnames(appdata);
for i=1:length(names)
name = char(names(i));
setappdata(hObject, name, getfield(appdata,name));
end
end
if ~isempty(createfcn)
eval(createfcn);
end
% --- Handles default GUIDE GUI creation and callback dispatch
function varargout = gui_mainfcn(gui_State, varargin)
gui_StateFields = {'gui_Name'
'gui_Singleton'
'gui_OpeningFcn'
'gui_OutputFcn'
'gui_LayoutFcn'
'gui_Callback'};
gui_Mfile = '';
for i=1:length(gui_StateFields)
if ~isfield(gui_State, gui_StateFields{i})
error('MATLAB:gui_mainfcn:FieldNotFound', 'Could not find field %s in the gui_State struct in GUI M-file %s', gui_StateFields{i}, gui_Mfile);
elseif isequal(gui_StateFields{i}, 'gui_Name')
gui_Mfile = [gui_State.(gui_StateFields{i}), '.m'];
end
end
numargin = length(varargin);
if numargin == 0
% M2TEX
% create the GUI only if we are not in the process of loading it
% already
gui_Create = true;
elseif local_isInvokeActiveXCallback(gui_State, varargin{:})
% M2TEX(ACTIVEX,...)
vin{1} = gui_State.gui_Name;
vin{2} = [get(varargin{1}.Peer, 'Tag'), '_', varargin{end}];
vin{3} = varargin{1};
vin{4} = varargin{end-1};
vin{5} = guidata(varargin{1}.Peer);
feval(vin{:});
return;
elseif local_isInvokeHGCallbak(gui_State, varargin{:})
% M2TEX('CALLBACK',hObject,eventData,handles,...)
gui_Create = false;
else
% M2TEX(...)
% create the GUI and hand varargin to the openingfcn
gui_Create = true;
end
if ~gui_Create
% In design time, we need to mark all components possibly created in
% the coming callback evaluation as non-serializable. This way, they
% will not be brought into GUIDE and not be saved in the figure file
% when running/saving the GUI from GUIDE.
designEval = false;
if (numargin>1 && ishghandle(varargin{2}))
fig = varargin{2};
while ~isempty(fig) && ~isa(handle(fig),'figure')
fig = get(fig,'parent');
end
designEval = isappdata(0,'CreatingGUIDEFigure') || isprop(fig,'__GUIDEFigure');
end
if designEval
beforeChildren = findall(fig);
end
% evaluate the callback now
varargin{1} = gui_State.gui_Callback;
if nargout
[varargout{1:nargout}] = feval(varargin{:});
else
feval(varargin{:});
end
% Set serializable of objects created in the above callback to off in
% design time. Need to check whether figure handle is still valid in
% case the figure is deleted during the callback dispatching.
if designEval && ishandle(fig)
set(setdiff(findall(fig),beforeChildren), 'Serializable','off');
end
else
if gui_State.gui_Singleton
gui_SingletonOpt = 'reuse';
else
gui_SingletonOpt = 'new';
end
% Check user passing 'visible' P/V pair first so that its value can be
% used by oepnfig to prevent flickering
gui_Visible = 'auto';
gui_VisibleInput = '';
for index=1:2:length(varargin)
if length(varargin) == index || ~ischar(varargin{index})
break;
end
% Recognize 'visible' P/V pair
len1 = min(length('visible'),length(varargin{index}));
len2 = min(length('off'),length(varargin{index+1}));
if ischar(varargin{index+1}) && strncmpi(varargin{index},'visible',len1) && len2 > 1
if strncmpi(varargin{index+1},'off',len2)
gui_Visible = 'invisible';
gui_VisibleInput = 'off';
elseif strncmpi(varargin{index+1},'on',len2)
gui_Visible = 'visible';
gui_VisibleInput = 'on';
end
end
end
% Open fig file with stored settings. Note: This executes all component
% specific CreateFunctions with an empty HANDLES structure.
% Do feval on layout code in m-file if it exists
gui_Exported = ~isempty(gui_State.gui_LayoutFcn);
% this application data is used to indicate the running mode of a GUIDE
% GUI to distinguish it from the design mode of the GUI in GUIDE. it is
% only used by actxproxy at this time.
setappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]),1);
if gui_Exported
gui_hFigure = feval(gui_State.gui_LayoutFcn, gui_SingletonOpt);
% make figure invisible here so that the visibility of figure is
% consistent in OpeningFcn in the exported GUI case
if isempty(gui_VisibleInput)
gui_VisibleInput = get(gui_hFigure,'Visible');
end
set(gui_hFigure,'Visible','off')
% openfig (called by local_openfig below) does this for guis without
% the LayoutFcn. Be sure to do it here so guis show up on screen.
movegui(gui_hFigure,'onscreen');
else
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
% If the figure has InGUIInitialization it was not completely created
% on the last pass. Delete this handle and try again.
if isappdata(gui_hFigure, 'InGUIInitialization')
delete(gui_hFigure);
gui_hFigure = local_openfig(gui_State.gui_Name, gui_SingletonOpt, gui_Visible);
end
end
if isappdata(0, genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]))
rmappdata(0,genvarname(['OpenGuiWhenRunning_', gui_State.gui_Name]));
end
% Set flag to indicate starting GUI initialization
setappdata(gui_hFigure,'InGUIInitialization',1);
% Fetch GUIDE Application options
gui_Options = getappdata(gui_hFigure,'GUIDEOptions');
% Singleton setting in the GUI M-file takes priority if different
gui_Options.singleton = gui_State.gui_Singleton;
if ~isappdata(gui_hFigure,'GUIOnScreen')
% Adjust background color
if gui_Options.syscolorfig
set(gui_hFigure,'Color', get(0,'DefaultUicontrolBackgroundColor'));
end
% Generate HANDLES structure and store with GUIDATA. If there is
% user set GUI data already, keep that also.
data = guidata(gui_hFigure);
handles = guihandles(gui_hFigure);
if ~isempty(handles)
if isempty(data)
data = handles;
else
names = fieldnames(handles);
for k=1:length(names)
data.(char(names(k)))=handles.(char(names(k)));
end
end
end
guidata(gui_hFigure, data);
end
% Apply input P/V pairs other than 'visible'
for index=1:2:length(varargin)
if length(varargin) == index || ~ischar(varargin{index})
break;
end
len1 = min(length('visible'),length(varargin{index}));
if ~strncmpi(varargin{index},'visible',len1)
try set(gui_hFigure, varargin{index}, varargin{index+1}), catch break, end
end
end
% If handle visibility is set to 'callback', turn it on until finished
% with OpeningFcn
gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
if strcmp(gui_HandleVisibility, 'callback')
set(gui_hFigure,'HandleVisibility', 'on');
end
feval(gui_State.gui_OpeningFcn, gui_hFigure, [], guidata(gui_hFigure), varargin{:});
if isscalar(gui_hFigure) && ishandle(gui_hFigure)
% Handle the default callbacks of predefined toolbar tools in this
% GUI, if any
guidemfile('restoreToolbarToolPredefinedCallback',gui_hFigure);
% Update handle visibility
set(gui_hFigure,'HandleVisibility', gui_HandleVisibility);
% Call openfig again to pick up the saved visibility or apply the
% one passed in from the P/V pairs
if ~gui_Exported
gui_hFigure = local_openfig(gui_State.gui_Name, 'reuse',gui_Visible);
elseif ~isempty(gui_VisibleInput)
set(gui_hFigure,'Visible',gui_VisibleInput);
end
if strcmpi(get(gui_hFigure, 'Visible'), 'on')
figure(gui_hFigure);
if gui_Options.singleton
setappdata(gui_hFigure,'GUIOnScreen', 1);
end
end
% Done with GUI initialization
if isappdata(gui_hFigure,'InGUIInitialization')
rmappdata(gui_hFigure,'InGUIInitialization');
end
% If handle visibility is set to 'callback', turn it on until
% finished with OutputFcn
gui_HandleVisibility = get(gui_hFigure,'HandleVisibility');
if strcmp(gui_HandleVisibility, 'callback')
set(gui_hFigure,'HandleVisibility', 'on');
end
gui_Handles = guidata(gui_hFigure);
else
gui_Handles = [];
end