Debian Codegraph @

extensions/CodeEditor/modules/lib/ace/ext-split.js

raw symbols SCIP
1 ace.define("ace/split",["require","exports","module","ace/lib/oop","ace/lib/lang","ace/lib/event_emitter","ace/editor","ace/virtual_renderer","ace/edit_session"], function(require, exports, module){"use strict";
2 var oop = require("./lib/oop");
3 var lang = require("./lib/lang");
4 var EventEmitter = require("./lib/event_emitter").EventEmitter;
5 var Editor = require("./editor").Editor;
6 var Renderer = require("./virtual_renderer").VirtualRenderer;
7 var EditSession = require("./edit_session").EditSession;
8 var Split;
9 Split = function (container, theme, splits) {
10 this.BELOW = 1;
11 this.BESIDE = 0;
12 this.$container = container;
13 this.$theme = theme;
14 this.$splits = 0;
15 this.$editorCSS = "";
16 this.$editors = [];
17 this.$orientation = this.BESIDE;
18 this.setSplits(splits || 1);
19 this.$cEditor = this.$editors[0];
20 this.on("focus", function (editor) {
21 this.$cEditor = editor;
22 }.bind(this));
23 };
24 (function () {
25 oop.implement(this, EventEmitter);
26 this.$createEditor = function () {
27 var el = document.createElement("div");
28 el.className = this.$editorCSS;
29 el.style.cssText = "position: absolute; top:0px; bottom:0px";
30 this.$container.appendChild(el);
31 var editor = new Editor(new Renderer(el, this.$theme));
32 editor.on("focus", function () {
33 this._emit("focus", editor);
34 }.bind(this));
35 this.$editors.push(editor);
36 editor.setFontSize(this.$fontSize);
37 return editor;
38 };
39 this.setSplits = function (splits) {
40 var editor;
41 if (splits < 1) {
42 throw "The number of splits have to be > 0!";
43 }
44 if (splits == this.$splits) {
45 return;
46 }
47 else if (splits > this.$splits) {
48 while (this.$splits < this.$editors.length && this.$splits < splits) {
49 editor = this.$editors[this.$splits];
50 this.$container.appendChild(editor.container);
51 editor.setFontSize(this.$fontSize);
52 this.$splits++;
53 }
54 while (this.$splits < splits) {
55 this.$createEditor();
56 this.$splits++;
57 }
58 }
59 else {
60 while (this.$splits > splits) {
61 editor = this.$editors[this.$splits - 1];
62 this.$container.removeChild(editor.container);
63 this.$splits--;
64 }
65 }
66 this.resize();
67 };
68 this.getSplits = function () {
69 return this.$splits;
70 };
71 this.getEditor = function (idx) {
72 return this.$editors[idx];
73 };
74 this.getCurrentEditor = function () {
75 return this.$cEditor;
76 };
77 this.focus = function () {
78 this.$cEditor.focus();
79 };
80 this.blur = function () {
81 this.$cEditor.blur();
82 };
83 this.setTheme = function (theme) {
84 this.$editors.forEach(function (editor) {
85 editor.setTheme(theme);
86 });
87 };
88 this.setKeyboardHandler = function (keybinding) {
89 this.$editors.forEach(function (editor) {
90 editor.setKeyboardHandler(keybinding);
91 });
92 };
93 this.forEach = function (callback, scope) {
94 this.$editors.forEach(callback, scope);
95 };
96 this.$fontSize = "";
97 this.setFontSize = function (size) {
98 this.$fontSize = size;
99 this.forEach(function (editor) {
100 editor.setFontSize(size);
101 });
102 };
103 this.$cloneSession = function (session) {
104 var s = new EditSession(session.getDocument(), session.getMode());
105 var undoManager = session.getUndoManager();
106 s.setUndoManager(undoManager);
107 s.setTabSize(session.getTabSize());
108 s.setUseSoftTabs(session.getUseSoftTabs());
109 s.setOverwrite(session.getOverwrite());
110 s.setBreakpoints(session.getBreakpoints());
111 s.setUseWrapMode(session.getUseWrapMode());
112 s.setUseWorker(session.getUseWorker());
113 s.setWrapLimitRange(session.$wrapLimitRange.min, session.$wrapLimitRange.max);
114 s.$foldData = session.$cloneFoldData();
115 return s;
116 };
117 this.setSession = function (session, idx) {
118 var editor;
119 if (idx == null) {
120 editor = this.$cEditor;
121 }
122 else {
123 editor = this.$editors[idx];
124 }
125 var isUsed = this.$editors.some(function (editor) {
126 return editor.session === session;
127 });
128 if (isUsed) {
129 session = this.$cloneSession(session);
130 }
131 editor.setSession(session);
132 return session;
133 };
134 this.getOrientation = function () {
135 return this.$orientation;
136 };
137 this.setOrientation = function (orientation) {
138 if (this.$orientation == orientation) {
139 return;
140 }
141 this.$orientation = orientation;
142 this.resize();
143 };
144 this.resize = function () {
145 var width = this.$container.clientWidth;
146 var height = this.$container.clientHeight;
147 var editor;
148 if (this.$orientation == this.BESIDE) {
149 var editorWidth = width / this.$splits;
150 for (var i = 0; i < this.$splits; i++) {
151 editor = this.$editors[i];
152 editor.container.style.width = editorWidth + "px";
153 editor.container.style.top = "0px";
154 editor.container.style.left = i * editorWidth + "px";
155 editor.container.style.height = height + "px";
156 editor.resize();
157 }
158 }
159 else {
160 var editorHeight = height / this.$splits;
161 for (var i = 0; i < this.$splits; i++) {
162 editor = this.$editors[i];
163 editor.container.style.width = width + "px";
164 editor.container.style.top = i * editorHeight + "px";
165 editor.container.style.left = "0px";
166 editor.container.style.height = editorHeight + "px";
167 editor.resize();
168 }
169 }
170 };
171 }).call(Split.prototype);
172 exports.Split = Split;
173
174 });
175
176 ace.define("ace/ext/split",["require","exports","module","ace/split"], function(require, exports, module){"use strict";
177 module.exports = require("../split");
178
179 }); (function() {
180 ace.require(["ace/ext/split"], function(m) {
181 if (typeof module == "object" && typeof exports == "object" && module) {
182 module.exports = m;
183 }
184 });
185 })();
186