/
views-editor.p.xml
2497 lines (2331 loc) · 106 KB
/
views-editor.p.xml
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"?>
<!-- ***** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in
compliance with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS"
basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
License for the specific language governing rights and limitations
under the License.
The Original Code is Komodo code.
The Initial Developer of the Original Code is ActiveState Software Inc.
Portions created by ActiveState Software Inc are Copyright (C) 2000-2007
ActiveState Software Inc. All Rights Reserved.
Contributor(s):
ActiveState Software Inc
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK ***** -->
<!DOCTYPE bindings PUBLIC "-//MOZILLA//DTD XBL V1.0//EN" "http://www.mozilla.org/xbl" [
<!ENTITY % komodoDTD SYSTEM "chrome://komodo/locale/komodo.dtd">
%komodoDTD;
]>
<bindings
xmlns="http://www.mozilla.org/xbl"
xmlns:xbl="http://www.mozilla.org/xbl"
xmlns:html="http://www.w3.org/1999/xhtml"
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="view-editor"
extends="chrome://komodo/content/bindings/views-buffer.xml#view-buffer-base">
<content orient="vertical" flex="6">
<!--<xul:vbox anonid="scintilla-vbox" flex="6">-->
<xul:statusbar orient="horizontal">
<xul:statusbarpanel anonid="statusbar-message-panel" flex="1">
<xul:deck anonid="statusbar-message-deck" class="for-vi-mode" selectedIndex="0" flex="1">
<xul:hbox anonid="statusbar-message-deck-default">
<xul:sectionlist anonid="statusbar-sectionlist" flex="1" />
</xul:hbox>
</xul:deck>
</xul:statusbarpanel>
<xul:statusbarpanel anonid="statusbar-pos-info"
tooltiptext="&filePosition.tooltiptext;"
align="center"
pack="end">
<xul:label anonid="statusbar-selection"/>
<xul:label anonid="statusbar-line-col"/>
</xul:statusbarpanel>
<xul:statusbarpanel anonid="statusbar-encoding"
style="min-width: 5rem"
tooltiptext="&fileEncoding.tooltiptext;"
>
<xul:toolbarbutton class="statusbar-label"
anonid="statusbar-encoding-label"
flex="1"
orient="horizontal"
type="menu"
persist="buttonstyle"
label="--"
buttonstyle="text">
<xul:menupopup anonid="statusbar-encoding-menupopup"
onpopupshowing="ko.statusBar.setupEncodingMenu(this);" />
</xul:toolbarbutton>
</xul:statusbarpanel>
<xul:statusbarpanel anonid="statusbar-language"
style="min-width: 5rem"
pack="end"
>
<xul:toolbarbutton class="statusbar-label languageicon"
anonid="statusbar-language-menu"
tooltiptext="&fileType.tooltiptext;"
flex="1"
orient="horizontal"
type="menu"
persist="buttonstyle"
label="--"
buttonstyle="text">
<xul:menupopup anonid="statusbar-filetype-menu"
position="before_end"
onpopupshowing="ko.uilayout.updateViewAsLanguageMenu(this);" />
</xul:toolbarbutton>
</xul:statusbarpanel>
</xul:statusbar>
<xul:scintilla xbl:inherits="flex,focused,context,mozcontext" flex="1"
anonid="scintilla"
allowIME="true"
mozcontext="editorContextMenu"/>
<xul:ko-findbar class="hud" anonid="findbar"/>
<!--</xul:vbox>-->
<!--
<content orient="vertical" style="border: green solid 1px;" flex="6">
<xul:vbox anonid="scintilla-vbox" flex="1">
<xul:scintilla xbl:inherits="flex,focused,context,mozcontext" flex="1"
anonid="scintilla"
allowIME="true"
mozcontext="editorContextMenu"/>
<xul:ko-findbar anonid="findbar"/>
</xul:vbox>
-->
</content>
<implementation name="vieweditor" implements="koIScintillaView, koIBookmarkableView, ISciMozEvents, nsIObserver">
<!-- We want Komodo editor views to send DOM events. -->
<field name="_dispatch_events">true</field>
<property name="cwd">
<getter><![CDATA[
if (this.koDoc && ! this.koDoc.isUntitled) {
return this.koDoc.file.dirName;
}
return null;
]]></getter>
</property>
<property name="prefs">
<getter><![CDATA[
if (this.koDoc && this.koDoc.prefs) {
return this.koDoc.prefs;
}
return null;
]]></getter>
</property>
<property name="_sectionlist"/>
<property name="sectionlist">
<setter></setter>
<getter><![CDATA[
if ( ! this._sectionlist)
this._sectionlist = require('ko/dom')(this).findAnonymous('anonid', 'statusbar-sectionlist').element();
return this._sectionlist
]]></getter>
</property>
<field name="lintingEnabled">false</field>
<field name="_everLinted">false</field>
<field name="_lintBuffer">null</field>
<field name="_noteLocTimer">null</field>
<property name="lintBuffer">
<setter><![CDATA[
if (this._lintBuffer)
this._lintBuffer.destructor();
this._lintBuffer = val;
]]></setter>
<getter><![CDATA[
try {
if (!this._lintBuffer && this.lintingEnabled)
this._lintBuffer = new ko.lint.lintBuffer(this);
} catch (e) {
// If we have not loaded lint.js into chrome, then we
// do not care about linting and we ignore this error.
}
return this._lintBuffer;
]]></getter>
</property>
<method name="_requestLinting">
<parameter name="reason"/>
<body>
<![CDATA[
if (this.lintBuffer) {
this.lintBuffer.request(reason);
this._everLinted = true;
}
]]>
</body>
</method>
<field name="_view_pref_observer_topics">
[
'codeintel_enabled',
'colorizing_enabled',
]
</field>
<field name="_koDoc_observer_topics">
[
'buffer_dirty',
'language_changed',
'encoding_changed',
'editUseLinting'
]
</field>
<field name="_koDoc">null</field>
<property name="koDoc"
onget="return this._koDoc;">
<setter>
<![CDATA[
this.log.info("view-editor:document setter");
var hadKoDoc = false;
var viewPrefObserverService, obsSvc;
var minimap = this.minimap;
if (this._koDoc) {
hadKoDoc = true;
try {
// We are detaching a document from the view
xtk.domutils.fireEvent(this, 'view_document_detaching');
viewPrefObserverService = this.prefs.prefObserverService;
viewPrefObserverService.removeObserverForTopics(this,
this._view_pref_observer_topics.length,
this._view_pref_observer_topics);
this._koDoc.observerService.removeObserverForTopics(this,
this._koDoc_observer_topics.length,
this._koDoc_observer_topics);
this._koDoc.releaseView(this);
if (minimap) {
minimap.releaseKoDoc();
}
this._koDoc.releaseReference();
obsSvc = Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);
obsSvc.removeObserver(this, 'scheme-changed');
obsSvc.removeObserver(this, 'primary_languages_changed');
} catch(e) {
this.log.exception(e);
}
}
// reset those items that are buffer dependent
// new objects will be recreated on request
this.item = null;
this.lintBuffer = null;
this.lintingEnabled = false;
this.isCICitadelStuffEnabled = undefined;
this.isCIXMLStuffEnabled = undefined;
this._koDoc = val;
if (val) {
// Remove the file from the MRU when it is opened... this may
// seem strange, it's because once you open the file you don't
// need it in the MRU - it will be re-added when the file is
// closed - bug 75381.
// Note: isSpecial typicaly denotes sockets and such, is also
// used by us to identify things like dbgp files
// we don't want special files in our mru
if (!val.isUntitled && val.file && !val.file.isSpecial) {
ko.mru.removeURL("mruFileList", val.file.URI);
}
// We are attaching a document to this view
val.addReference();
val.addView(this);
// Bind a minimap view to the koDoc?
if (minimap) {
//val.addView(minimap);
minimap.attachKoDoc(val);
}
// we want to listen for any changes in the document
val.observerService.addObserverForTopics(this,
this._koDoc_observer_topics.length,
this._koDoc_observer_topics,
0);
viewPrefObserverService = this.prefs.prefObserverService;
viewPrefObserverService.addObserverForTopics(this,
this._view_pref_observer_topics.length,
this._view_pref_observer_topics,
false);
obsSvc = Components.classes["@mozilla.org/observer-service;1"].
getService(Components.interfaces.nsIObserverService);
obsSvc.addObserver(this, 'scheme-changed', false);
obsSvc.addObserver(this, 'primary_languages_changed', false);
this.parentView.updateLeafName(this);
this.parentView.updateFileStatus(this);
this.parentView.updateDirtyStatus(this);
if (hadKoDoc) {
// Have to update the title bar for the new document
// path - bug 87615.
ko.uilayout.updateTitlebar(this);
}
this.lintingEnabled = this.prefs.getBooleanPref("editUseLinting");
if (!ko.views.manager.batchMode) {
this._requestLinting("reset the view's document");
}
let language = val.language;
this._setLanguage(language);
xtk.domutils.fireEvent(this, 'view_document_attached');
}
]]>
</setter>
</property>
<property name="_isCICplnEnabled">
<!-- override views-buffer -->
<getter>
<![CDATA[
var val = ko.codeintel.isActive &&
ko.codeintel.is_cpln_lang(this.language);
if (val && !this.ciCompletionUIHandler) {
this.ciCompletionUIHandler =
new ko.codeintel.CompletionUIHandler(this);
}
return val;
]]>
</getter>
</property>
<field name="_languageObj">null</field>
<property name="languageObj"
onset="throw Components.results.NS_ERROR_NOT_IMPLEMENTED;"
onget="return this.koDoc.languageObj"/>
<field name="_global_pref_observer_topics">
[
'debuggerMaxTooltipSize',
'editor-scheme',
'editSmartWrapSelection',
'editSmartWrapSelectionKeep',
'wrapSelectionOnlyPlainText',
'wrapSelectionDelimiters',
'enableAutoAbbreviations',
'autoAbbreviationTriggerCharacters'
]
</field>
<field name="_doc_pref_observer_topics">
[
'ySlop',
'foldSeparateBlockParts',
'select_most_recent_buffer_on_buffer_close',
'editShowMinimap'
]
</field>
<field name="initializedGlobalPrefs">false</field>
<field name="initializedOwnDocPrefs">false</field>
<field name="initializedGlobalDocPrefs">false</field>
<field name="foldSeparateBlockParts"></field>
<field name="firstDocLine">-1</field>
<field name="lastDocLine">-1</field>
<method name="init">
<body>
<![CDATA[
this.parentView.setContext(this, "tabContextMenu");
this.initPrefs();
this._currentFamily = "";
this._highlightColors = null;
// Duplicate of koUDLLanguageBase.familyAtPosition to avoid
// making the xpcom call on every call. We know we're in
// a UDL file.
this._familyAtPosition = [];
var parts = [
["M", Components.interfaces.ISciMoz.SCE_UDL_CSS_DEFAULT],
["CSS", Components.interfaces.ISciMoz.SCE_UDL_CSL_DEFAULT],
["CSL", Components.interfaces.ISciMoz.SCE_UDL_SSL_DEFAULT],
["SSL", Components.interfaces.ISciMoz.SCE_UDL_TPL_DEFAULT],
["TPL", Components.interfaces.ISciMoz.SCE_UDL_UPPER_BOUND + 1]
];
for (var part, style = 0, i = 0; part = parts[i]; ++i) {
for (; style < part[1]; style++) {
this._familyAtPosition[style] = part[0];
}
}
this.handle_current_view_linecol_changed = (function(event) {
// TODO: We shouldn't need to use this updateCurrentLineColor
// hack, we should be using Scintilla caretLineBackAlpha
// setting instead, removing the need for this function.
var view = event.originalTarget;
if (view != this) {
return;
}
if (this._doHighlightColors && !view.updateCurrentLineColor()) {
// It failed, so don't highlight anymore.
this._doHighlightColors = false;
}
var transientMarkRingArray = this._transientMarkRing;
if (transientMarkRingArray && transientMarkRingArray.length) {
this.displayTransientSelection();
}
}).bind(this);
this.addModifiedHandler(this.onTextInserted,
this,
1000, // high numbers indicate low priority
Components.interfaces.ISciMoz.SC_MOD_INSERTTEXT);
]]>
</body>
</method>
<method name="initWithDocument">
<parameter name="doc"/>
<body>
<![CDATA[
try {
const SME = Components.interfaces.ISciMozEvents;
this.log.info("view-editor:initWithDocument");
this.scintilla.language = doc.language;
this.scintilla.symbolMargin = true;
this.scintilla.encoding = doc.encoding.python_encoding_name;
this.scintilla.init();
this.koDoc = doc;
this._genericController = Components.classes['@activestate.com/koGenericCommandHandler;1'].createInstance();
this._genericController.view = this;
this.scintilla.controllers.appendController(this._genericController);
// I'd like to do the latter instead of what is done above, but that doesn't
// work, for reasons which escape me but probably have to do with the
// special hack in commands.js to deal with focus on embed elements.
// this.controllers.appendController(this._genericController);
this.initPrefs();
this._setupHighlightColors(this.scintilla);
xtk.domutils.fireEvent(this, 'current_view_changed');
this.addEventListener('current_view_linecol_changed',
this.handle_current_view_linecol_changed, false);
this._hookSciMozEvents(SME.SME_UPDATEUI | SME.SME_MARGINCLICK);
this._inInitPhase = false;
// This field is used by views-buffer.isCICplnEnabled
this._isCICplnEnabledViewPref = this.prefs.getBooleanPref('codeintel_enabled');
if (!this.prefs.getBooleanPref('colorizing_enabled')) {
this._turnColourizingOff();
}
ko.lint.initializeGenericPrefs(this.prefs);
var editShowMinimap = this.prefs.getBooleanPref("editShowMinimap");
if (editShowMinimap) {
this.createMinimap();
}
// bug 98866: Let scintilla finish initializing this buffer
// before making sure it can scroll to the caret.
// Then call the post-file-open macros after, in case they
// change the caret position.
this.registerUpdateUICallback(function() {
this.scintilla.scimoz.scrollCaret();
ko.macros.eventHandler.hookPostFileOpen(this);
}.bind(this));
} catch (e) {
this.log.exception(e);
}
this.log.debug('scimoz code page after initWithDoc is '+this.scimoz.codePage);
this.log.debug('document code page after initWithDoc is '+this.koDoc.codePage);
this._setWrapSelectionDelimiters(); // initialize
this.enableAutoAbbreviations = ko.prefs.getBooleanPref("enableAutoAbbreviations");
var evt = new CustomEvent("editor_view_opened", { detail: { view: this } });
window.dispatchEvent(evt);
]]>
</body>
</method>
<method name="createMinimap">
<body><![CDATA[
var minimap = document.createElementNS(this.namespaceURI, 'minimap');
minimap.setAttribute('flex','1');
minimap.setAttribute('type', 'minimap'); // needed for view-list-base.log
this.parentNode.appendChild(minimap); // this.parentNode is the tabbox container
this.minimap = minimap;
window.setTimeout(window.updateCommands, 1, 'minimap_changed');
minimap.initWithView(this);
minimap.attachKoDoc(this.koDoc);
this.updateMinimapDisplay(true);
this.addModifiedHandler(this.updateMinimapOnBufferModified,
this,
1000, // high numbers indicate low priority
(Components.interfaces.ISciMoz.SC_MOD_INSERTTEXT
|Components.interfaces.ISciMoz.SC_MOD_DELETETEXT));
]]>
</body>
</method>
<method name="destroyMinimap">
<body><![CDATA[
this.removeModifiedHandler(this.updateMinimapOnBufferModified);
this.minimap.releaseKoDoc();
this.parentNode.removeChild(this.minimap);
this.minimap = null;
window.setTimeout(window.updateCommands, 1, 'minimap_changed');
]]>
</body>
</method>
<field name="_lastTimeoutId">0</field>
<method name="updateMinimapOnBufferModified">
<body><![CDATA[
clearTimeout(this._lastTimeoutId);
this._lastTimeoutId = setTimeout(function(minimap) {
minimap.syncMinimapFromBuffer();
}, 250, this.minimap);
]]>
</body>
</method>
<method name="initPrefs">
<body><![CDATA[
var prefObserverService = this.__globalPrefs.prefObserverService;
if (!this.initializedGlobalPrefs) {
this.initializedGlobalPrefs = true;
prefObserverService.addObserverForTopics(this,
this._global_pref_observer_topics.length,
this._global_pref_observer_topics,
false);
}
if (!this.initializedGlobalDocPrefs) {
this.initializedGlobalDocPrefs = true;
prefObserverService.addObserverForTopics(this,
this._doc_pref_observer_topics.length,
this._doc_pref_observer_topics,
false);
}
var docPrefsThisTime = this.__globalPrefs;
if (this.prefs) {
if (!this.initializedOwnDocPrefs) {
this.initializedOwnDocPrefs = true;
this.prefs.prefObserverService.addObserverForTopics(this,
this._doc_pref_observer_topics.length,
this._doc_pref_observer_topics,
false);
}
docPrefsThisTime = this.prefs;
}
this.foldSeparateBlockParts = docPrefsThisTime.getBooleanPref('foldSeparateBlockParts');
this.scimoz.setProperty('fold.at.else', this.foldSeparateBlockParts ? 1 : 0);
this.scimoz.setYCaretPolicy(this.scimoz.CARET_SLOP |
this.scimoz.CARET_STRICT |
this.scimoz.CARET_EVEN,
docPrefsThisTime.getLongPref('ySlop'));
this.selectMostRecentBufferOnBufferClose =
docPrefsThisTime.getBooleanPref('select_most_recent_buffer_on_buffer_close');
this._setAutoAbbreviations();
]]></body>
</method>
<method name="_setWrapSelectionDelimiters">
<body>//<![CDATA[
this.editSmartWrapSelection = ko.prefs.getBooleanPref("editSmartWrapSelection");
this.editSmartWrapSelectionKeep = ko.prefs.getBooleanPref("editSmartWrapSelectionKeep");
this.wrapSelectionOnlyPlainText = ko.prefs.getBooleanPref("wrapSelectionOnlyPlainText");
this.wrapSelectionDelimiters = ko.prefs.getStringPref("wrapSelectionDelimiters");
//]]>
</body>
</method>
<method name="_setAutoAbbreviations">
<body>//<![CDATA[
this.enableAutoAbbreviations = ko.prefs.getBooleanPref("enableAutoAbbreviations");
var autoAbbreviationTriggerCharacters = ko.prefs.getStringPref("autoAbbreviationTriggerCharacters");
this.autoAbbreviationTriggerCharacters_Processed = ko.stringutils.backslashUnescape(autoAbbreviationTriggerCharacters);
//]]>
</body>
</method>
<method name="_turnColourizingOff">
<body><![CDATA[
var languageRegistryService = Components.classes['@activestate.com/koLanguageRegistryService;1'].getService(Components.interfaces.koILanguageRegistryService);
var textLanguageService = languageRegistryService.getLanguage("Text");
var lexer = textLanguageService.getLanguageService(Components.interfaces.koILexerLanguageService);
this.koDoc.lexer = lexer;
// Going to text, we need to explicitly clear the styles.
var scimoz = this.scimoz;
scimoz.startStyling(0, 0x3f);
scimoz.setStyling(scimoz.length, 0);
this.koDoc.docSettingsMgr.applyDocumentSettingsToView(this);
scimoz.tabWidth = scimoz.tabWidth;
]]>
</body>
</method>
<method name="getTooltipText">
<parameter name="x"/>
<parameter name="y"/>
<body><![CDATA[
var text = null;
try {
var sm = this.scintilla.scimoz;
var pos = sm.positionFromPoint(x, y);
var lineNo = sm.lineFromPosition(pos);
var margin = this.getMarginForCoord(x, y);
if (margin >= 0) {
// Margin tooltip.
var data = { x: x, y: y, view: this, margin: margin, pos: pos, line: lineNo, text: '' };
var event = new CustomEvent('editor_margin_get_tooltiptext', { detail: data, bubbles: true, cancelable: true });
if (!this.dispatchEvent(event)) {
// Set by an event handler.
return data.text;
}
return null;
}
// Editor tooltip.
var data = { x: x, y: y, view: this, pos: pos, line: lineNo, text: '' };
var event = new CustomEvent('editor_get_tooltiptext', { detail: data, bubbles: true, cancelable: true });
if (!this.dispatchEvent(event)) {
// Set by an event handler.
return data.text;
}
if (pos > 0 && pos < sm.length) {
if (this.lintBuffer && this.lintBuffer.lintResults) {
var charOffset = pos - sm.positionFromLine(lineNo) + 1;
var results = {};
var numResults = {};
this.lintBuffer.lintResults.
getResultsInLineRange(lineNo + 1,
lineNo + 1,
results,
numResults);
for (var i = 0; i < numResults.value; i++) {
var r = results.value[i];
//XXX lintResult.column* are actually
// misnomers. They give character
// offsets from the begining of the
// line, not column numbers
if (r.columnStart <= charOffset &&
charOffset <= r.columnEnd) {
if (text)
text += "\n" + r.description;
else
text = r.description;
}
}
}
}
} catch(e) {
this.log.exception(e);
}
return text;
]]></body>
</method>
<method name="doFocus">
<parameter name="event"/>
<body>
<![CDATA[
try {
if (!ko.views.manager.batchMode && !this._everLinted) {
this._requestLinting("focussing view and have not yet linted");
}
this.updateCurrentLineColor();
if (typeof(gVimController) != 'undefined' &&
gVimController.enabled) {
gVimController.onBufferFocus();
}
} catch (e) {
this.log.exception(e);
}
]]>
</body>
</method>
<method name="_clearFoldLevels">
<parameter name="scimoz"/>
<body>
<![CDATA[
var lastLine = scimoz.lineCount;
for (var i = 0; i < lastLine; i++) {
scimoz.setFoldLevel(i, 0);
}
]]>
</body>
</method>
<method name="_setLanguage">
<parameter name="language"/>
<body>
<![CDATA[
this.language = language;
// Update codeintel variables.
this.isCICitadelStuffEnabled = undefined;
this.isCIXMLStuffEnabled = undefined;
]]>
</body>
</method>
<property name="isCICitadelStuffEnabled">
<getter>
<![CDATA[
if (this._isCICitadelStuffEnabled === undefined) {
if (!this._isCICplnEnabledViewPref) {
this._isCICitadelStuffEnabled = false;
} else if (!ko.codeintel.isActive) {
// Still waiting to initialize
return false;
} else {
this._isCICitadelStuffEnabled =
ko.codeintel.is_citadel_lang(this.language);
}
}
return this._isCICitadelStuffEnabled;
]]>
</getter>
<setter>
return this._isCICitadelStuffEnabled = val;
</setter>
</property>
<field name="_isCICitadelStuffEnabled">undefined</field>
<field name="viewsPropertiesBundle">
Components.classes["@mozilla.org/intl/stringbundle;1"].
getService(Components.interfaces.nsIStringBundleService).
createBundle("chrome://komodo/locale/views.properties")
</field>
<property name="isCIXMLStuffEnabled">
<getter>
<![CDATA[
if (this._isCIXMLStuffEnabled === undefined) {
if (!this._isCICplnEnabledViewPref) {
this._isCIXMLStuffEnabled = false;
} else if (!ko.codeintel.isActive) {
// Still waiting to initialize
return false;
} else {
this._isCIXMLStuffEnabled =
ko.codeintel.is_xml_lang(this.language);
}
}
return this._isCIXMLStuffEnabled;
]]>
</getter>
<setter>
return this._isCICitadelStuffEnabled = val;
</setter>
</property>
<field name="_isCIXMLStuffEnabled">undefined</field>
<!--nsIObserver implementation-->
<method name="observe">
<!-- Generally the subject of the notification is the view's
document (notifications sent directly on the private
nsIObserverService instance for that document instance).
However this is not *always* the case: this view does
register to observe some other notifications. -->
<parameter name="doc"/>
<parameter name="topic"/>
<parameter name="data"/>
<body>
<![CDATA[
// XXX we need to also observe changes in the file
// status so we can appropriately update our tab icons
this.log.debug("editor view for document '"+
this.koDoc.baseName+"' observed '"+topic+"'\n");
switch (topic) {
case 'language_changed':
// Multi-window story: do this on the current view only.
if (!this.isCurrent) {
return;
}
let language = doc.language;
this.log.info("Changed language to:" + language);
this._setLanguage(language);
// bug 34689, bug 81587: force syntax highlighting to re-lex,
// otherwise the syntax colouring is not correctly updated.
this._clearFoldLevels(this.scimoz);
this.scimoz.setProperty('fold',
doc.languageObj.foldable ? 1 : 0);
if (doc.languageObj.foldable) {
this.scimoz.setProperty('fold.at.else', this.foldSeparateBlockParts);
}
this.scimoz.colourise(0,-1);
this.commandCompletionSvc = null;
this._languageObj = null;
if (this == ko.views.manager.currentView) {
if (this.lintBuffer) {
//XXX What if the language of a view other than the
// current is changed (not possible in Komodo
// right now?). This will not re-lint in that case.
this.lintBuffer.request("language changed");
this._everLinted = true;
}
xtk.domutils.fireEvent(this, 'current_view_language_changed');
this.koDoc.docSettingsMgr.applyDocumentSettingsToView(this);
// The change in language may affect controllers
window.setTimeout("window.updateCommands('language_changed');", 1);
window.setTimeout("window.updateCommands('foldability_changed');", 1);
}
if (this.isCICitadelStuffEnabled) {
// Request a scan on language change
ko.codeintel.scan_document(this.koDoc, 0, false);
}
this._setupHighlightColors(this.scintilla);
break;
case 'title_changed':
// XXX need a way to observer file/title changes
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
//this.parentView.updateLeafName(this);
//break;
case 'buffer_dirty':
// Multi-window story: the check on this.isCurrent is sufficient
// If the same file is current in more than one window, including
// the topmost, we'll update its title bar and status in each window.
// Weirdness:
// this.koDoc always points to the doc argument.
if (this.parentView && typeof(this.parentView.updateDirtyStatus) != 'undefined') {
this.parentView.updateDirtyStatus(this);
if (this.isCurrent) {
ko.uilayout.updateTitlebar(this);
}
xtk.domutils.fireEvent(this, 'view_dirty_status_changed');
}
break;
case 'encoding_changed':
// got notification from document, update the statusbar
if (this.isCurrent) {
xtk.domutils.fireEvent(window, 'current_view_encoding_changed');
}
break;
case 'editUseLinting':
this.lintBuffer = null;
this.lintingEnabled = this.prefs.getBooleanPref("editUseLinting");
this._requestLinting("linting preference enabled");
break;
case 'ySlop':
//multi-window: this applies to all windows, as it's a pref
this.scimoz.setYCaretPolicy(this.scimoz.CARET_SLOP |
this.scimoz.CARET_STRICT |
this.scimoz.CARET_EVEN,
(this.prefs || this.__globalPrefs).getLongPref('ySlop'));
break;
case 'editShowMinimap':
var editShowMinimap = this.prefs.getBooleanPref("editShowMinimap");
if (editShowMinimap) {
if (!this.minimap) {
this.createMinimap();
} else if (this.showMinimap) {
// Nothing to do, we're already showing the minimap
} else {
// It's created, but not being displayed (unexpected)
this.updateMinimapDisplay(true);
}
} else if (this.minimap) {
this.updateMinimapDisplay(false);
this.destroyMinimap();
}
// else:
// There is no minimap, and the pref is to not show it, so
// there's nothing to do (unexpected)
break;
case 'foldSeparateBlockParts':
//multi-window: this applies to all windows, as it's a pref
this.foldSeparateBlockParts = (this.prefs || this.__globalPrefs).getBooleanPref('foldSeparateBlockParts');
this.scimoz.setProperty('fold.at.else', this.foldSeparateBlockParts ? 1 : 0);
this.scimoz.colourise(0, -1);
break;
case 'select_most_recent_buffer_on_buffer_close':
this.selectMostRecentBufferOnBufferClose =
(this.prefs || this.__globalPrefs).getBooleanPref('select_most_recent_buffer_on_buffer_close');
break;
case 'editSmartWrapSelection': // pref notification
case 'editSmartWrapSelectionKeep': // pref notification
case 'wrapSelectionOnlyPlainText': // pref notification
case 'wrapSelectionDelimiters': // pref notification
this._setWrapSelectionDelimiters();
break;
case 'enableAutoAbbreviations': // pref notification
case 'autoAbbreviationTriggerCharacters': // pref notification
this._setAutoAbbreviations();
break;
case 'codeintel_enabled':
this._isCICplnEnabledViewPref = this.prefs.getBooleanPref('codeintel_enabled');
xtk.domutils.fireEvent(this, "document_codeintel_pref_changed");
break;
case 'colorizing_enabled':
var locationInfo = {};
this.saveLocation(locationInfo);
var scimoz = this.scimoz;
var colorizing_enabled = this.prefs.getBooleanPref('colorizing_enabled');
if (!colorizing_enabled) {
this._turnColourizingOff();
} else {
this.koDoc.lexer = null;
this.koDoc.docSettingsMgr.applyDocumentSettingsToView(this);
var stylingPos = this.scimoz.endStyled;
scimoz.colourise(0, -1);
}
// This forces a repaint.
scimoz.tabWidth = scimoz.tabWidth;
this.scintilla.focus();
this.restoreLocation(locationInfo);
break;
case 'editor-scheme': // Chose a different scheme
case 'scheme-changed': // Modified the current scheme
setTimeout(function(this_) {
// view.scintilla is still using the old scheme.
this_._setupHighlightColors(this_.scintilla);
}, 1, this);
break;
case 'primary_languages_changed':
// Menu gets rebuild if there is no "komodo_language_menu_already_built" attribute.
var languageMenupopup = document.getAnonymousElementByAttribute(this, "anonid", "language-menupopup");
languageMenupopup.removeAttribute("komodo_language_menu_already_built");
break;
}
]]>
</body>
</method>
<method name="updateMinimapDisplay">
<parameter name="editShowMinimap"/>
<body>
<![CDATA[
var minimap = this.minimap;
this.showMinimap = editShowMinimap;
var scimoz = this.scimoz;
if (editShowMinimap) {
this.scintilla.vScrollBar = false;
minimap.classList.remove("hideMinimap");
var obj = {};
this.updateEditorViewBoundaries();
minimap.syncMinimapFromBuffer();
} else {
minimap.classList.add("hideMinimap");
this.scintilla.vScrollBar = true;
<!-- #if PLATFORM != "linux" -->
// Bug 97483: Make sure the scroll bar's position is correct.
if (scimoz.firstVisibleLine > 0) {
scimoz.lineScrollUp();
scimoz.lineScrollDown();
}
<!-- #endif -->
}
]]>
</body>
</method>
<method name="_setupHighlightColors">
<parameter name="scintilla"/>
<body>
<![CDATA[
var colorInfo = {};
var scheme = scintilla.scheme;
this._highlightColors = {};
if (scheme) {
scheme.getHighlightColorInfo(this.languageObj,
colorInfo, {});
colorInfo = colorInfo.value;
this._doHighlightColors = colorInfo.length > 0;
if (this._doHighlightColors) {
for (var i = 0; i < colorInfo.length; i++) {
var familyName, color;
[familyName, color] = colorInfo[i].split(":");
this._highlightColors[familyName] = parseInt(color, 10);
}
// Force an update so the sub-highlighting gets redone.
// Fixes bug 84707
this._currentFamily = "";
this.updateCurrentLineColor();
}
} else {
this._doHighlightColors = false;
this.log.info("Couldn't get the scheme off the view");
}
]]>
</body>
</method>
<method name="updateCurrentLineColor">
<body>
<![CDATA[
if (!this._highlightColors) {
return false;
}
var family = this._familyAtPosition[this.scimoz.getStyleAt(this.scimoz.currentPos)];
if (family == this._currentFamily) {
return true;
}
this._currentFamily = family;
if (family in this._highlightColors) {