-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.js
More file actions
77 lines (65 loc) · 2.01 KB
/
Copy patheditor.js
File metadata and controls
77 lines (65 loc) · 2.01 KB
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
var Editor = (function() {
var Editor = function(textarea) {
this.editor = CodeMirror.fromTextArea(textarea, {
lineWrapping : true,
electricChars : false,
gutter : true,
matchBrackets : true,
autofocus : true,
onGutterClick : function(editor, lineNumber) {
var info = editor.lineInfo(lineNumber);
if (info.markerText) {
editor.clearMarker(lineNumber);
} else {
editor.setMarker(lineNumber, "<span class=\"breakpoint\"></span> %N%");
}
}
});
$(window).resize(updateHeight.bind(this));
};
Editor.prototype.getBreakPoints = function() {
var breakPoints = [];
for(var i=0, l=this.editor.lineCount(); i<l; i++) {
var info = this.editor.lineInfo(i);
if (info.markerText) {
breakPoints.push(i);
}
}
return breakPoints;
};
Editor.prototype.clearBreakPoints = function() {
var breakPoints = this.getBreakPoints();
for(var i=0, l=breakPoints.length; i<l; i++) {
this.editor.clearMarker(breakPoints[i]);
}
};
Editor.prototype.clearCurrentLine = function() {
if (Object.isNumber(this.currentLine)) {
this.editor.setLineClass(this.currentLine, null);
this.currentLine = null;
}
};
Editor.prototype.setCurrentLine = function(lineNumber) {
this.currentLine = lineNumber;
this.editor.setLineClass(lineNumber, "activeline");
};
Editor.prototype.setValue = function(value) {
return this.editor.setValue(value);
};
Editor.prototype.getValue = function() {
return this.editor.getValue();
};
var updateHeight = function() {
if (!this.heightUsedByOtherPageElements) { return; }
this.editor.setSize(null, $(window).height() - this.heightUsedByOtherPageElements);
this.editor.refresh();
};
Editor.prototype.useAvailableHeight = function(heightUsedByOtherPageElements) {
this.heightUsedByOtherPageElements = heightUsedByOtherPageElements;
updateHeight.call(this);
};
Editor.prototype.refresh = function() {
this.editor.refresh();
};
return Editor;
})();