-
Notifications
You must be signed in to change notification settings - Fork 1
/
stand_alone_globals.leo
4698 lines (3912 loc) · 146 KB
/
stand_alone_globals.leo
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
<?xml version="1.0" encoding="utf-8"?>
<!-- Created by Leo (http://webpages.charter.net/edreamleo/front.html) -->
<?xml-stylesheet ekr_test?>
<leo_file xmlns:leo="http://www.leo-editor.org/2011/leo" >
<leo_header file_format="2" tnodes="0" max_tnode_index="0" clone_windows="0"/>
<globals body_outline_ratio="0.5" body_secondary_ratio="0.5">
<global_window_position top="50" left="50" height="500" width="700"/>
<global_log_window_position top="0" left="0" height="0" width="0"/>
</globals>
<preferences/>
<find_panel_settings/>
<vnodes>
<v t="ekr.20120625092120.12815"><vh>Unused from leoGlobals.py</vh>
<v t="ekr.20120625092120.12471"><vh><< imports >></vh></v>
<v t="ekr.20120625092120.12474"><vh>Checking Leo Files</vh>
<v t="ekr.20120625092120.12475"><vh>createTopologyList</vh></v>
</v>
<v t="ekr.20120625092120.12476"><vh>Commands & Directives</vh>
<v t="ekr.20120625092120.12477"><vh>g.Directive utils...</vh>
<v t="ekr.20120625092120.12478"><vh>g.comment_delims_from_extension</vh></v>
<v t="ekr.20120625092120.12479"><vh>g.findAtTabWidthDirectives (must be fast)</vh></v>
<v t="ekr.20120625092120.12480"><vh>g.findLanguageDirectives (must be fast)</vh></v>
<v t="ekr.20120625092120.12481"><vh>g.findReference</vh></v>
<v t="ekr.20120625092120.12482"><vh>g.get_directives_dict (must be fast)</vh>
<v t="ekr.20120625092120.12483"><vh>compute_directives_re</vh></v>
</v>
<v t="ekr.20120625092120.12484"><vh>g.get_directives_dict_list (must be fast)</vh></v>
<v t="ekr.20120625092120.12485"><vh>g.getLanguageFromAncestorAtFileNode (New)</vh></v>
<v t="ekr.20120625092120.12486"><vh>g.getOutputNewline</vh></v>
<v t="ekr.20120625092120.12487"><vh>g.scanAtCommentAndLanguageDirectives</vh></v>
<v t="ekr.20120625092120.12488"><vh>g.scanAtEncodingDirectives</vh></v>
<v t="ekr.20120625092120.12489"><vh>g.scanAtHeaderDirectives</vh></v>
<v t="ekr.20120625092120.12490"><vh>g.scanAtLineendingDirectives</vh></v>
<v t="ekr.20120625092120.12491"><vh>g.scanAtPagewidthDirectives</vh></v>
<v t="ekr.20120625092120.12492"><vh>g.scanAtPathDirectives scanAllAtPathDirectives</vh></v>
<v t="ekr.20120625092120.12493"><vh>g.scanAtRootDirectives</vh></v>
<v t="ekr.20120625092120.12494"><vh>g.scanAtRootOptions</vh>
<v t="ekr.20120625092120.12495"><vh><< scan another @root option >></vh></v>
</v>
<v t="ekr.20120625092120.12496"><vh>g.scanAtTabwidthDirectives & scanAllTabWidthDirectives</vh></v>
<v t="ekr.20120625092120.12497"><vh>g.scanAtWrapDirectives & scanAllAtWrapDirectives</vh></v>
<v t="ekr.20120625092120.12498"><vh>g.scanDirectives (for compatibility only)</vh></v>
<v t="ekr.20120625092120.12499"><vh>g.scanForAtIgnore</vh></v>
<v t="ekr.20120625092120.12500"><vh>g.scanForAtLanguage</vh></v>
<v t="ekr.20120625092120.12501"><vh>g.scanForAtSettings</vh></v>
<v t="ekr.20120625092120.12502"><vh>g.set_delims_from_language</vh></v>
<v t="ekr.20120625092120.12503"><vh>g.set_delims_from_string</vh></v>
<v t="ekr.20120625092120.12504"><vh>g.set_language</vh></v>
<v t="ekr.20120625092120.12505"><vh>g.setDefaultDirectory & helper</vh>
<v t="ekr.20120625092120.12506"><vh>g.checkOpenDirectory</vh></v>
</v>
<v t="ekr.20120625092120.12507"><vh>g.stripPathCruft</vh></v>
</v>
</v>
<v t="ekr.20120625092120.12816"><vh>Debugging</vh>
<v t="ekr.20120625092120.12553"><vh>class Tracer & g.startTracer</vh>
<v t="ekr.20120625092120.12554"><vh> __init__ (Tracer)</vh></v>
<v t="ekr.20120625092120.12555"><vh>computeName</vh></v>
<v t="ekr.20120625092120.12556"><vh>report</vh></v>
<v t="ekr.20120625092120.12557"><vh>stop</vh></v>
<v t="ekr.20120625092120.12558"><vh>tracer</vh></v>
<v t="ekr.20120625092120.12559"><vh>updateStats</vh></v>
</v>
<v t="ekr.20120625092120.12818"><vh>Dumps</vh>
<v t="ekr.20120625092120.12514"><vh>dump</vh></v>
<v t="ekr.20120625092120.12515"><vh>es_dump</vh></v>
<v t="ekr.20120625092120.12522"><vh>printBindings</vh></v>
<v t="ekr.20120625092120.12523"><vh>printGlobals</vh></v>
</v>
<v t="ekr.20120625092120.12509"><vh>g.alert</vh></v>
<v t="ekr.20120625092120.12524"><vh>g.printEntireTree</vh></v>
<v t="ekr.20120625092120.12819"><vh>Getters</vh>
<v t="ekr.20120625092120.12542"><vh>g.get_line & get_line__after</vh></v>
<v t="ekr.20120625092120.12541"><vh>g.getIvarsDict and checkUnchangedIvars</vh></v>
<v t="ekr.20120625092120.12545"><vh>g.print_dict & dictToString</vh></v>
<v t="ekr.20120625092120.12546"><vh>g.print_list & listToString</vh></v>
<v t="ekr.20120625092120.12544"><vh>g.print_obj & toString</vh></v>
<v t="ekr.20120625092120.12547"><vh>g.print_stack (printStack)</vh></v>
</v>
<v t="ekr.20120625092120.12525"><vh>printLeoModules</vh></v>
<v t="ekr.20120625092120.12527"><vh>redirecting stderr and stdout to Leo's log pane</vh>
<v t="ekr.20120625092120.12528"><vh><< redirectClass methods >></vh>
<v t="ekr.20120625092120.12529"><vh>redirectClass.__init__</vh></v>
<v t="ekr.20120625092120.12530"><vh>isRedirected</vh></v>
<v t="ekr.20120625092120.12531"><vh>flush</vh></v>
<v t="ekr.20120625092120.12532"><vh>rawPrint</vh></v>
<v t="ekr.20120625092120.12533"><vh>redirect</vh></v>
<v t="ekr.20120625092120.12534"><vh>undirect</vh></v>
<v t="ekr.20120625092120.12535"><vh>write</vh></v>
</v>
<v t="ekr.20120625092120.12536"><vh><< define convenience methods for redirecting streams >></vh>
<v t="ekr.20120625092120.12537"><vh>redirectStderr & redirectStdout</vh></v>
<v t="ekr.20120625092120.12538"><vh>restoreStderr & restoreStdout</vh></v>
<v t="ekr.20120625092120.12539"><vh>stdErrIsRedirected & stdOutIsRedirected</vh></v>
<v t="ekr.20120625092120.12540"><vh>rawPrint</vh></v>
</v>
</v>
<v t="ekr.20120625092120.12548"><vh>Statistics</vh>
<v t="ekr.20120625092120.12549"><vh>clear_stats</vh></v>
<v t="ekr.20120625092120.12550"><vh>print_stats</vh></v>
<v t="ekr.20120625092120.12551"><vh>stat</vh></v>
</v>
<v t="ekr.20120625092120.12552"><vh>Timing</vh></v>
</v>
<v t="ekr.20120625092120.12820"><vh>Files & Directories</vh>
<v t="ekr.20120625092120.12561"><vh> Redirection to LoadManager methods</vh></v>
<v t="ekr.20120625092120.12562"><vh>g.chdir</vh></v>
<v t="ekr.20120625092120.12563"><vh>g.create_temp_file</vh></v>
<v t="ekr.20120625092120.12564"><vh>g.ensure_extension</vh></v>
<v t="ekr.20120625092120.12526"><vh>g.file/module/plugin_date</vh></v>
<v t="ekr.20120625092120.12565"><vh>g.getBaseDirectory</vh></v>
<v t="ekr.20120625092120.12566"><vh>g.guessExternalEditor</vh></v>
<v t="ekr.20120625092120.12567"><vh>g.is_binary_file</vh></v>
<v t="ekr.20120625092120.12568"><vh>g.is_sentinel</vh>
<v t="ekr.20120625092120.12569"><vh><< is_sentinel doc tests >></vh></v>
</v>
<v t="ekr.20120625092120.12570"><vh>g.makeAllNonExistentDirectories</vh></v>
<v t="ekr.20120625092120.12571"><vh>g.makePathRelativeTo</vh></v>
<v t="ekr.20120625092120.12572"><vh>g.openWithFileName</vh></v>
<v t="ekr.20120625092120.12573"><vh>g.readFileIntoString (Leo 4.7)</vh></v>
<v t="ekr.20120625092120.12574"><vh>g.readlineForceUnixNewline</vh></v>
<v t="ekr.20120625092120.12575"><vh>g.recursiveUNLSearch</vh></v>
<v t="ekr.20120625092120.12576"><vh>g.sanitize_filename</vh></v>
<v t="ekr.20120625092120.12577"><vh>g.setGlobalOpenDir</vh></v>
<v t="ekr.20120625092120.12579"><vh>Used by tangle code & leoFileCommands</vh>
<v t="ekr.20120625092120.12580"><vh>g.update_file_if_changed</vh></v>
<v t="ekr.20120625092120.12581"><vh>g.utils_remove</vh></v>
<v t="ekr.20120625092120.12582"><vh>g.utils_rename</vh></v>
<v t="ekr.20120625092120.12583"><vh>g.utils_chmod</vh></v>
<v t="ekr.20120625092120.12584"><vh>g.utils_stat</vh></v>
</v>
</v>
<v t="ekr.20120625092120.12585"><vh>Garbage Collection</vh>
<v t="ekr.20120625092120.12586"><vh>clearAllIvars</vh></v>
<v t="ekr.20120625092120.12587"><vh>collectGarbage</vh></v>
<v t="ekr.20120625092120.12588"><vh>enable_gc_debug</vh></v>
<v t="ekr.20120625092120.12589"><vh>printGc</vh>
<v t="ekr.20120625092120.12590"><vh>printGcRefs</vh></v>
</v>
<v t="ekr.20120625092120.12591"><vh>printGcAll</vh></v>
<v t="ekr.20120625092120.12592"><vh>printGcObjects (printNewObjects=pno)</vh>
<v t="ekr.20120625092120.12593"><vh><< print number of each type of object >></vh></v>
<v t="ekr.20120625092120.12594"><vh><< print added functions >></vh></v>
</v>
<v t="ekr.20120625092120.12595"><vh>printGcSummary</vh></v>
<v t="ekr.20120625092120.12596"><vh>printGcVerbose</vh></v>
</v>
<v t="ekr.20120625092120.12597"><vh>Hooks & plugins</vh>
<v t="ekr.20120625092120.12598"><vh>idle time functions (leoGlobals)</vh>
<v t="ekr.20120625092120.12599"><vh>enableIdleTimeHook</vh></v>
<v t="ekr.20120625092120.12600"><vh>disableIdleTimeHook</vh></v>
<v t="ekr.20120625092120.12601"><vh>idleTimeHookHandler</vh></v>
</v>
<v t="ekr.20120625092120.12602"><vh>g.act_on_node</vh></v>
<v t="ekr.20120625092120.12603"><vh>g.doHook</vh></v>
<v t="ekr.20120625092120.12604"><vh>g.command (decorator for creating global commands)</vh></v>
<v t="ekr.20120625092120.12605"><vh>g.childrenModifiedSet, g.contentModifiedSet</vh></v>
<v t="ekr.20120625092120.12606"><vh>Wrappers for g.app.pluginController methods</vh>
<v t="ekr.20120625092120.12607"><vh>Loading & registration</vh></v>
<v t="ekr.20120625092120.12608"><vh>Information</vh></v>
</v>
</v>
<v t="ekr.20120625092120.12827"><vh>Most used</vh>
<v t="ekr.20120625092120.12610"><vh>g.choose</vh></v>
<v t="ekr.20120625092120.12612"><vh>g.enl, ecnl & ecnls</vh></v>
<v t="ekr.20120625092120.12614"><vh>g.es</vh></v>
<v t="ekr.20120625092120.12615"><vh>g.es_print</vh></v>
<v t="ekr.20120625092120.12616"><vh>g.es_trace</vh></v>
<v t="ekr.20120625092120.12618"><vh>g.posList</vh>
<v t="ekr.20120625092120.12619"><vh><< docstring for posList >></vh></v>
</v>
</v>
<v t="ekr.20120625092120.12830"><vh>Scanning</vh>
<v t="ekr.20120625092120.12649"><vh>Functions that call scanError</vh>
<v t="ekr.20120625092120.12650"><vh>skip_block_comment</vh></v>
<v t="ekr.20120625092120.12651"><vh>skip_braces</vh></v>
<v t="ekr.20120625092120.12652"><vh>skip_php_braces (no longer used)</vh></v>
<v t="ekr.20120625092120.12653"><vh>skip_parens</vh></v>
<v t="ekr.20120625092120.12654"><vh>skip_pascal_begin_end</vh></v>
<v t="ekr.20120625092120.12655"><vh>skip_pascal_block_comment</vh></v>
<v t="ekr.20120625092120.12656"><vh>skip_pascal_string : called by tangle</vh></v>
<v t="ekr.20120625092120.12657"><vh>skip_heredoc_string : called by php import (Dave Hein)</vh></v>
<v t="ekr.20120625092120.12658"><vh>skip_pp_directive</vh></v>
<v t="ekr.20120625092120.12659"><vh>skip_pp_if</vh></v>
<v t="ekr.20120625092120.12660"><vh>skip_pp_part</vh></v>
<v t="ekr.20120625092120.12661"><vh>skip_python_string</vh></v>
<v t="ekr.20120625092120.12662"><vh>skip_string</vh></v>
<v t="ekr.20120625092120.12663"><vh>skip_to_semicolon</vh></v>
<v t="ekr.20120625092120.12664"><vh>skip_typedef</vh></v>
</v>
<v t="ekr.20120625092120.12647"><vh>scanError</vh></v>
<v t="ekr.20120625092120.12648"><vh>scanf</vh></v>
</v>
<v t="ekr.20120625092120.12691"><vh>Script Tools</vh>
<v t="ekr.20120625092120.12692"><vh>g.executeFile</vh></v>
<v t="ekr.20120625092120.12693"><vh>g.findNode... &,findTopLevelNode</vh></v>
<v t="ekr.20120625092120.12694"><vh>g.getScript</vh></v>
<v t="ekr.20120625092120.12695"><vh>g.handleScriptException</vh>
<v t="ekr.20120625092120.12696"><vh><< dump the lines near the error >></vh></v>
</v>
<v t="ekr.20120625092120.12697"><vh>g.initScriptFind (set up dialog)</vh></v>
</v>
<v t="ekr.20120625092120.12698"><vh>Tokenizing & parsing</vh>
<v t="ekr.20120625092120.12699"><vh>g.python_tokenize</vh></v>
</v>
<v t="ekr.20120625092120.12834"><vh>Unicode</vh>
<v t="ekr.20120625092120.12709"><vh>toEncodedStringWithErrorCode (for unit testing)</vh></v>
<v t="ekr.20120625092120.12710"><vh>toUnicodeWithErrorCode (for unit testing)</vh></v>
</v>
<v t="ekr.20120625092120.12711"><vh>Unit testing</vh>
<v t="ekr.20120625092120.12712"><vh>g.getTestVars</vh></v>
<v t="ekr.20120625092120.12713"><vh>g.findTestScript</vh></v>
</v>
<v t="ekr.20120625092120.12714"><vh>Urls</vh>
<v t="ekr.20120625092120.12715"><vh>g.computeFileUrl</vh></v>
<v t="ekr.20120625092120.12716"><vh>g.getUrlFromNode</vh></v>
<v t="ekr.20120625092120.12717"><vh>g.handleUrl</vh></v>
<v t="ekr.20120625092120.12718"><vh>g.isValidUrl</vh></v>
<v t="ekr.20120625092120.12719"><vh>g.openUrl</vh></v>
<v t="ekr.20120625092120.12720"><vh>g.openUrlOnClick (open-url-under-cursor)</vh></v>
</v>
<v t="ekr.20120625092120.12821"><vh>Utility classes, functions & objects</vh>
<v t="ekr.20120625092120.12722"><vh> Index utilities</vh>
<v t="ekr.20120625092120.12723"><vh>g.convertPythonIndexToRowCol</vh></v>
<v t="ekr.20120625092120.12724"><vh>g.convertRowColToPythonIndex</vh></v>
</v>
<v t="ekr.20120625092120.12725"><vh> List utilities...</vh>
<v t="ekr.20120625092120.12726"><vh>appendToList</vh></v>
<v t="ekr.20120625092120.12727"><vh>flattenList</vh></v>
<v t="ekr.20120625092120.12728"><vh>maxStringListLength</vh></v>
</v>
<v t="ekr.20120625092120.12730"><vh>CheckVersion</vh>
<v t="ekr.20120625092120.12731"><vh>CheckVersion, helper</vh>
<v t="ekr.20120625092120.12732"><vh>CheckVersionToInt</vh></v>
</v>
<v t="ekr.20120625092120.12733"><vh>oldCheckVersion (Dave Hein)</vh></v>
</v>
<v t="ekr.20120625092120.12736"><vh>g.assertui</vh></v>
<v t="ekr.20120625092120.12738"><vh>g.computeWindowTitle</vh></v>
<v t="ekr.20120625092120.12739"><vh>g.ensureLeading/TrailingNewlines</vh></v>
<v t="ekr.20120625092120.12740"><vh>g.executeScript</vh></v>
<v t="ekr.20120625092120.12750"><vh>g.GeneralSetting & isGeneralSetting</vh></v>
<v t="ekr.20120625092120.12751"><vh>g.getDocString</vh></v>
<v t="ekr.20120625092120.12752"><vh>g.getDocStringForFunction</vh></v>
<v t="ekr.20120625092120.12754"><vh>g.isMacOS</vh></v>
<v t="ekr.20120625092120.12784"><vh>g.KeyStroke & isStroke/OrNone</vh>
<v t="ekr.20120625092120.12785"><vh> ks.ctor</vh></v>
<v t="ekr.20120625092120.12786"><vh> Special methods</vh>
<v t="ekr.20120625092120.12787"><vh>ks.__hash__</vh></v>
<v t="ekr.20120625092120.12788"><vh>ks.__repr___ & __str__</vh></v>
<v t="ekr.20120625092120.12789"><vh>ks.rich comparisons</vh></v>
</v>
<v t="ekr.20120625092120.12790"><vh>ks.find, lower & startswith</vh></v>
<v t="ekr.20120625092120.12791"><vh>ks.isFKey</vh></v>
<v t="ekr.20120625092120.12792"><vh>ks.toGuiChar</vh></v>
</v>
<v t="ekr.20120625092120.12755"><vh>g.longestCommonPrefix & g.itemsMatchingPrefixInList</vh></v>
<v t="ekr.20120625092120.12757"><vh>g.prettyPrintType</vh></v>
<v t="ekr.20120625092120.12758"><vh>g.removeLeading/Trailing</vh></v>
<v t="ekr.20120625092120.12759"><vh>g.ShortcutInfo & isShortcutInfo</vh>
<v t="ekr.20120625092120.12760"><vh> ctor (ShortcutInfo)</vh></v>
<v t="ekr.20120625092120.12761"><vh>__hash__ (ShortcutInfo)</vh></v>
<v t="ekr.20120625092120.12762"><vh>__repr__ & ___str_& dump (ShortcutInfo)</vh></v>
<v t="ekr.20120625092120.12763"><vh>isModeBinding</vh></v>
</v>
<v t="ekr.20120625092120.12765"><vh>g.toPythonIndex</vh></v>
<v t="ekr.20120625092120.12766"><vh>g.TypedDict/OfLists & isTypedDict/OfLists</vh>
<v t="ekr.20120625092120.12767"><vh>td.ctor</vh></v>
<v t="ekr.20120625092120.12768"><vh>td.__repr__ & __str__</vh></v>
<v t="ekr.20120625092120.12769"><vh>td._checkKey/ValType</vh></v>
<v t="ekr.20120625092120.12770"><vh>td.add & td.replace</vh></v>
<v t="ekr.20120625092120.12771"><vh>td.copy</vh></v>
<v t="ekr.20120625092120.12772"><vh>td.dump</vh></v>
<v t="ekr.20120625092120.12773"><vh>td getters</vh></v>
<v t="ekr.20120625092120.12774"><vh>td.setName</vh></v>
<v t="ekr.20120625092120.12775"><vh>td.update</vh></v>
</v>
<v t="ekr.20120625092120.12624"><vh>g.windows</vh></v>
<v t="ekr.20120625092120.12776"><vh>import wrappers</vh>
<v t="ekr.20120625092120.12777"><vh>g.cantImport</vh></v>
<v t="ekr.20120625092120.12778"><vh>g.importModule</vh></v>
<v t="ekr.20120625092120.12779"><vh>g.importExtension & helpers</vh></v>
<v t="ekr.20120625092120.12780"><vh>g.importFromPath</vh></v>
</v>
<v t="ekr.20120625092120.12781"><vh>readLines class and generator</vh>
<v t="ekr.20120625092120.12782"><vh>g.readLinesGenerator</vh></v>
<v t="ekr.20120625092120.12783"><vh>class readLinesClass</vh></v>
</v>
</v>
<v t="ekr.20120625092120.12835"><vh>Whitesapce</vh>
<v t="ekr.20120625092120.12799"><vh>wrap_lines</vh>
<v t="ekr.20120625092120.12800"><vh><< place blank and word on the present line >></vh></v>
<v t="ekr.20120625092120.12801"><vh><< place word on a new line >></vh></v>
</v>
</v>
<v t="ekr.20120625092120.12837"><vh>Wrappers for os.path</vh>
<v t="ekr.20120625092120.12630"><vh>os_path_expandExpression</vh></v>
</v>
<v t="ekr.20120625092120.12812"><vh>ZODB support</vh>
<v t="ekr.20120625092120.12813"><vh>g.init_zodb</vh></v>
</v>
</v>
<v t="ekr.20120625092120.12838"><vh>test</vh></v>
<v t="ekr.20120625092120.12469" descendentVnodeUnknownAttributes="7d71005805000000302e362e3071017d71025808000000616e6e6f7461746571037d710473732e"
expanded="ekr.20120625092120.12646,"><vh>@file leoStandAloneGlobals.py</vh></v>
</vnodes>
<tnodes>
<t tx="ekr.20120625092120.12471"># Don't import this here: it messes up Leo's startup code.
# import leo.core.leoTest as leoTest
try:
import gc
except ImportError:
gc = None
try:
import filecmp
except ImportError: # does not exist in jython.
filecmp = None
try:
import gettext
except ImportError: # does not exist in jython.
gettext = None
if isPython3:
from functools import reduce
if isPython3:
import io
StringIO = io.StringIO
else:
import cStringIO
StringIO = cStringIO.StringIO
import imp
import inspect
import operator
import os
# Module 'urllib' has no 'parse' member.
import urllib # pylint: disable=E0611
# Do NOT import pdb here! We shall define pdb as a _function_ below.
# import pdb
import re
import shutil
import string
import subprocess
# import sys
import tempfile
import time
import traceback
import types
if isPython3:
# E0611: No name 'parse' in urllib.
import urllib.parse as urlparse # pylint: disable=E0611
else:
import urlparse
# import zipfile
# These do not exist in IronPython.
# However, it *is* valid for IronPython to use the Python 2.4 libs!
# import os
# import string
# import tempfile
# import traceback
# import types
</t>
<t tx="ekr.20120625092120.12474"></t>
<t tx="ekr.20120625092120.12475">def createTopologyList (c,root=None,useHeadlines=False):
"""Creates a list describing a node and all its descendents"""
if not root: root = c.rootPosition()
v = root
if useHeadlines:
aList = [(v.numberOfChildren(),v.headString()),]
else:
aList = [v.numberOfChildren()]
child = v.firstChild()
while child:
aList.append(g.createTopologyList(c,child,useHeadlines))
child = child.next()
return aList
</t>
<t tx="ekr.20120625092120.12476"></t>
<t tx="ekr.20120625092120.12477"># New in Leo 4.6:
# g.findAtTabWidthDirectives, g.findLanguageDirectives and
# g.get_directives_dict use re module for faster searching.
</t>
<t tx="ekr.20120625092120.12478">def comment_delims_from_extension(filename):
"""
Return the comment delims corresponding to the filename's extension.
>>> import leo.core.leoGlobals as g
>>> g.comment_delims_from_extension(".py")
('#', '', '')
>>> g.comment_delims_from_extension(".c")
('//', '/*', '*/')
>>> g.comment_delims_from_extension(".html")
('', '<!--', '-->')
"""
if filename.startswith('.'):
# Python 2.6 changes how splitext works.
root,ext = None,filename
else:
root, ext = os.path.splitext(filename)
if ext == '.tmp':
root, ext = os.path.splitext(root)
language = g.app.extension_dict.get(ext[1:])
if ext:
return g.set_delims_from_language(language)
else:
g.trace("unknown extension: %s, filename: %s, root: %s" % (
repr(ext),repr(filename),repr(root)))
return '','',''
</t>
<t tx="ekr.20120625092120.12479">g_tabwidth_pat = re.compile(r'(^@tabwidth)',re.MULTILINE)
def findTabWidthDirectives(c,p):
'''Return the language in effect at position p.'''
if c is None:
return # c may be None for testing.
w = None
# 2009/10/02: no need for copy arg to iter
for p in p.self_and_parents():
if w: break
for s in p.h,p.b:
if w: break
anIter = g_tabwidth_pat.finditer(s)
for m in anIter:
word = m.group(0)
i = m.start(0)
j = g.skip_ws(s,i + len(word))
junk,w = g.skip_long(s,j)
if w == 0: w = None
return w
</t>
<t tx="ekr.20120625092120.12480">g_language_pat = re.compile(r'(^@language)',re.MULTILINE)
def findLanguageDirectives(c,p):
'''Return the language in effect at position p.'''
trace = False and not g.unitTesting
if c is None:
return # c may be None for testing.
if c.target_language:
language = c.target_language.lower()
else:
language = 'python'
found = False
# 2009/10/02: no need for copy arg to iter.
for p in p.self_and_parents():
if found: break
for s in p.h,p.b:
if found: break
anIter = g_language_pat.finditer(s)
for m in anIter:
word = m.group(0)
i = m.start(0)
j = i + len(word)
k = g.skip_line(s,j)
language = s[j:k].strip()
found = True
if trace: g.trace(language)
return language
</t>
<t tx="ekr.20120625092120.12481"># Called from the syntax coloring method that colorizes section references.
def findReference(c,name,root):
'''Find the section definition for name.
If a search of the descendants fails,
and an ancestor is an @root node,
search all the descendants of the @root node.
'''
for p in root.subtree():
assert(p!=root)
if p.matchHeadline(name) and not p.isAtIgnoreNode():
return p
# New in Leo 4.7: expand the search for @root trees.
for p in root.self_and_parents():
d = g.get_directives_dict(p)
if 'root' in d:
for p2 in p.subtree():
if p2.matchHeadline(name) and not p2.isAtIgnoreNode():
return p2
# g.trace("not found:",name,root)
return c.nullPosition()
</t>
<t tx="ekr.20120625092120.12482"># The caller passes [root_node] or None as the second arg.
# This allows us to distinguish between None and [None].
g_noweb_root = re.compile('<'+'<'+'*'+'>'+'>'+'=',re.MULTILINE)
def get_directives_dict(p,root=None,scanToCursor=False):
"""Scan p for @directives found in globalDirectiveList.
Returns a dict containing the stripped remainder of the line
following the first occurrence of each recognized directive"""
trace = False and not g.unitTesting
verbose = False
if trace: g.trace('*'*20,p.h)
if root: root_node = root[0]
d = {}
# Do this every time so plugins can add directives.
pat = g.compute_directives_re()
directives_pat = re.compile(pat,re.MULTILINE)
# The headline has higher precedence because it is more visible.
for kind,s in (('head',p.h),('body',p.b)):
anIter = directives_pat.finditer(s)
for m in anIter:
word = m.group(0)[1:] # Omit the @
i = m.start(0)
if (
# 2012/03/9: Special case @language directive in the body.
(kind == 'body' and scanToCursor and word.strip() == 'language')
or word.strip() not in d
):
j = i + 1 + len(word)
k = g.skip_line(s,j)
val = s[j:k].strip()
if j < len(s) and s[j] not in (' ','\t','\n'):
# g.es_print('invalid character after directive',s[max(0,i-1):k-1],color='red')
# if trace:g.trace(word,repr(val),s[i:i+20])
pass # Not a valid directive: just ignore it.
else:
directive_word = word.strip()
if directive_word == 'language':
if kind == 'body' and scanToCursor:
# 2012/03/09:Only add preceding @language directives.
c = p.v.context
w = c.frame.body.bodyCtrl
ins = w.getInsertPoint()
i1,i2 = g.getLine(s,i)
if trace: g.trace(kind,directive_word,val)
if ins >= i2:
d[directive_word] = val
else:
d[directive_word] = val
else:
if directive_word in ('root-doc', 'root-code'):
d['root'] = val # in addition to optioned version
d[directive_word] = val
# g.trace(kind,directive_word,val)
if trace: g.trace(word.strip(),kind,repr(val))
# A special case for @path in the body text of @<file> nodes.
# Don't give an actual warning: just set some flags.
if kind == 'body' and word.strip() == 'path' and p.isAnyAtFileNode():
g.app.atPathInBodyWarning = p.h
d['@path_in_body'] = p.h
if trace: g.trace('@path in body',p.h)
if root:
anIter = g_noweb_root.finditer(p.b)
for m in anIter:
if root_node:
d["root"]=0 # value not immportant
else:
g.es('%s= may only occur in a topmost node (i.e., without a parent)' % (
g.angleBrackets('*')))
break
if trace and verbose: g.trace('%4d' % (len(p.h) + len(p.b)),g.callers(5))
return d
</t>
<t tx="ekr.20120625092120.12483">def compute_directives_re ():
'''Return an re pattern which will match all Leo directives.'''
global globalDirectiveList
aList = ['^@%s' % z for z in globalDirectiveList
if z != 'others']
if 0: # 2010/02/01
# The code never uses this, and this regex is broken
# because it can confuse g.get_directives_dict.
# @others can have leading whitespace.
aList.append(r'^\s@others\s')
return '|'.join(aList)
</t>
<t tx="ekr.20120625092120.12484">def get_directives_dict_list(p,scanToCursor=False):
"""Scans p and all its ancestors for directives.
Returns a list of dicts containing pointers to
the start of each directive"""
trace = False and not g.unitTesting
# if trace: time1 = g.getTime()
result = []
p1 = p.copy()
for p in p1.self_and_parents():
if p.hasParent(): root = None
else: root = [p.copy()]
result.append(g.get_directives_dict(p,
root=root,
scanToCursor=scanToCursor and p == p1))
# if trace:
# n = len(p1.h) + len(p1.b)
# g.trace('%4d %s' % (n,g.timeSince(time1)))
return result
</t>
<t tx="ekr.20120625092120.12485">def getLanguageFromAncestorAtFileNode(p):
'''Return the language in effect as determined
by the file extension of the nearest enclosing @<file> node.
'''
for p in p.self_and_parents():
if p.isAnyAtFileNode():
name = p.anyAtFileNodeName()
junk,ext = g.os_path_splitext(name)
ext = ext[1:] # strip the leading .
language = g.app.extension_dict.get(ext)
# g.trace('found extension',p.h,ext,language)
return language
return None
</t>
<t tx="ekr.20120625092120.12486">def getOutputNewline (c=None,name=None):
'''Convert the name of a line ending to the line ending itself.
Priority:
- Use name if name given
- Use c.config.output_newline if c given,
- Otherwise use g.app.config.output_newline.'''
if name: s = name
elif c: s = c.config.output_newline
else: s = app.config.output_newline
if not s: s = ''
s = s.lower()
if s in ( "nl","lf"): s = '\n'
elif s == "cr": s = '\r'
elif s == "platform": s = os.linesep # 12/2/03: emakital
elif s == "crlf": s = "\r\n"
else: s = '\n' # Default for erroneous values.
# g.trace(c,name,c.config.output_newline,'returns',repr(s))
if g.isPython3:
s = str(s)
return s
</t>
<t tx="ekr.20120625092120.12487">def scanAtCommentAndAtLanguageDirectives(aList):
'''Scan aList for @comment and @language directives.
@comment should follow @language if both appear in the same node.'''
trace = False and not g.unitTesting
lang = None
for d in aList:
comment = d.get('comment')
language = d.get('language')
# Important: assume @comment follows @language.
if language:
# if g.unitTesting: g.trace('language',language)
lang,delim1,delim2,delim3 = g.set_language(language,0)
if comment:
# if g.unitTesting: g.trace('comment',comment)
delim1,delim2,delim3 = g.set_delims_from_string(comment)
if comment or language:
delims = delim1,delim2,delim3
d = {'language':lang,'comment':comment,'delims':delims}
if trace: g.trace(d)
return d
if trace: g.trace(repr(None))
return None
</t>
<t tx="ekr.20120625092120.12488">def scanAtEncodingDirectives(aList):
'''Scan aList for @encoding directives.'''
for d in aList:
encoding = d.get('encoding')
if encoding and g.isValidEncoding(encoding):
# g.trace(encoding)
return encoding
elif encoding and not g.app.unitTesting:
g.es("invalid @encoding:",encoding,color="red")
return None
</t>
<t tx="ekr.20120625092120.12489">def scanAtHeaderDirectives(aList):
'''scan aList for @header and @noheader directives.'''
for d in aList:
if d.get('header') and d.get('noheader'):
g.es_print("conflicting @header and @noheader directives",color='red')
</t>
<t tx="ekr.20120625092120.12490">def scanAtLineendingDirectives(aList):
'''Scan aList for @lineending directives.'''
for d in aList:
e = d.get('lineending')
if e in ("cr","crlf","lf","nl","platform"):
lineending = g.getOutputNewline(name=e)
return lineending
# else:
# g.es("invalid @lineending directive:",e,color="red")
return None
</t>
<t tx="ekr.20120625092120.12491">def scanAtPagewidthDirectives(aList,issue_error_flag=False):
'''Scan aList for @pagewidth directives.'''
for d in aList:
s = d.get('pagewidth')
if s is not None:
i, val = g.skip_long(s,0)
if val != None and val > 0:
# g.trace(val)
return val
else:
if issue_error_flag and not g.app.unitTesting:
g.es("ignoring @pagewidth",s,color="red")
return None
</t>
<t tx="ekr.20120625092120.12492">def scanAtPathDirectives(c,aList):
path = c.scanAtPathDirectives(aList)
return path
def scanAllAtPathDirectives(c,p):
aList = g.get_directives_dict_list(p)
path = c.scanAtPathDirectives(aList)
return path
</t>
<t tx="ekr.20120625092120.12493">def scanAtRootDirectives(aList):
'''Scan aList for @root directives.'''
for d in aList:
s = d.get('root')
if s is not None:
i, mode = g.scanAtRootOptions(s,0)
g.trace(mode)
return mode
return None
</t>
<t tx="ekr.20120625092120.12494">def scanAtRootOptions (s,i,err_flag=False):
# The @root has been eaten when called from tangle.scanAllDirectives.
if g.match(s,i,"@root"):
i += len("@root")
i = g.skip_ws(s,i)
mode = None
while g.match(s,i,'-'):
<< scan another @root option >>
if mode == None:
doc = app.config.at_root_bodies_start_in_doc_mode
mode = g.choose(doc,"doc","code")
# g.trace(mode,g.callers(3))
return i,mode
</t>
<t tx="ekr.20120625092120.12495">i += 1 ; err = -1
if g.match_word(s,i,"code"): # Just match the prefix.
if not mode: mode = "code"
elif err_flag: g.es("modes conflict in:",g.get_line(s,i))
elif g.match(s,i,"doc"): # Just match the prefix.
if not mode: mode = "doc"
elif err_flag: g.es("modes conflict in:",g.get_line(s,i))
else:
err = i-1
# Scan to the next minus sign.
while i < len(s) and s[i] not in (' ','\t','\n','-'):
i += 1
if err > -1 and err_flag:
z_opt = s[err:i]
z_line = g.get_line(s,i)
g.es("unknown option:",z_opt,"in",z_line)
</t>
<t tx="ekr.20120625092120.12496">def scanAtTabwidthDirectives(aList,issue_error_flag=False):
'''Scan aList for @tabwidth directives.'''
for d in aList:
s = d.get('tabwidth')
if s is not None:
junk,val = g.skip_long(s,0)
if val not in (None,0):
return val
else:
if issue_error_flag and not g.app.unitTesting:
g.es("ignoring @tabwidth",s,color="red")
return None
def scanAllAtTabWidthDirectives(c,p):
'''Scan p and all ancestors looking for @tabwidth directives.'''
if c and p:
aList = g.get_directives_dict_list(p)
val = g.scanAtTabwidthDirectives(aList)
ret = g.choose(val is None,c.tab_width,val)
else:
ret = None
# g.trace(ret,p and p.h,ret)
return ret
</t>
<t tx="ekr.20120625092120.12497">def scanAtWrapDirectives(aList,issue_error_flag=False):
'''Scan aList for @wrap and @nowrap directives.'''
for d in aList:
if d.get('wrap') is not None:
return True
elif d.get('nowrap') is not None:
return False
return None
def scanAllAtWrapDirectives(c,p):
'''Scan p and all ancestors looking for @wrap/@nowrap directives.'''
if c and p:
default = c and c.config.getBool("body_pane_wraps")
aList = g.get_directives_dict_list(p)
val = g.scanAtWrapDirectives(aList)
ret = g.choose(val is None,default,val)
else:
ret = None
# g.trace(ret,p.h)
return ret
</t>
<t tx="ekr.20120625092120.12498">def scanDirectives(c,p=None):
return c.scanAllDirectives(p)
</t>
<t tx="ekr.20120625092120.12499">def scanForAtIgnore(c,p):
"""Scan position p and its ancestors looking for @ignore directives."""
if g.app.unitTesting:
return False # For unit tests.
for p in p.self_and_parents():
d = g.get_directives_dict(p)
if 'ignore' in d:
return True
return False
</t>
<t tx="ekr.20120625092120.12500">def scanForAtLanguage(c,p):
"""Scan position p and p's ancestors looking only for @language and @ignore directives.
Returns the language found, or c.target_language."""
# Unlike the code in x.scanAllDirectives, this code ignores @comment directives.
if c and p:
for p in p.self_and_parents():
d = g.get_directives_dict(p)
if 'language' in d:
z = d["language"]
language,delim1,delim2,delim3 = g.set_language(z,0)
return language
return c.target_language
</t>
<t tx="ekr.20120625092120.12501">def scanForAtSettings(p):
"""Scan position p and its ancestors looking for @settings nodes."""
for p in p.self_and_parents():
h = p.h
h = g.app.config.canonicalizeSettingName(h)
if h.startswith("@settings"):
return True
return False
</t>
<t tx="ekr.20120625092120.12502"># Returns a tuple (single,start,end) of comment delims
def set_delims_from_language(language):
trace = False and not g.unitTesting
val = g.app.language_delims_dict.get(language)
# if language.startswith('huh'): g.pdb()
if val:
delim1,delim2,delim3 = g.set_delims_from_string(val)
if trace: g.trace(repr(language),
repr(delim1),repr(delim2),repr(delim3),g.callers(5))
if delim2 and not delim3:
return '',delim1,delim2
else: # 0,1 or 3 params.
return delim1,delim2,delim3
else:
return '','','' # Indicate that no change should be made
</t>
<t tx="ekr.20120625092120.12503">def set_delims_from_string(s):
"""Returns (delim1, delim2, delim2), the delims following the @comment directive.
This code can be called from @language logic, in which case s can point at @comment"""
# Skip an optional @comment
tag = "@comment"
i = 0
if g.match_word(s,i,tag):
i += len(tag)
count = 0 ; delims = ['','','']
while count < 3 and i < len(s):
i = j = g.skip_ws(s,i)
while i < len(s) and not g.is_ws(s[i]) and not g.is_nl(s,i):
i += 1
if j == i: break
delims[count] = s[j:i] or ''
count += 1
# 'rr 09/25/02
if count == 2: # delims[0] is always the single-line delim.
delims[2] = delims[1]
delims[1] = delims[0]
delims[0] = ''
# 7/8/02: The "REM hack": replace underscores by blanks.
# 9/25/02: The "perlpod hack": replace double underscores by newlines.
for i in range(0,3):
if delims[i]:
delims[i] = delims[i].replace("__",'\n').replace('_',' ')
return delims[0], delims[1], delims[2]
</t>
<t tx="ekr.20120625092120.12504">def set_language(s,i,issue_errors_flag=False):
"""Scan the @language directive that appears at s[i:].
The @language may have been stripped away.
Returns (language, delim1, delim2, delim3)
"""
tag = "@language"
# g.trace(g.get_line(s,i))
assert(i != None)