1
/* ***** BEGIN LICENSE BLOCK *****
2
* Distributed under the BSD license:
4
* Copyright (c) 2010, Ajax.org B.V.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the name of Ajax.org B.V. nor the
15
* names of its contributors may be used to endorse or promote products
16
* derived from this software without specific prior written permission.
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
22
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
* ***** END LICENSE BLOCK ***** */
31
define('ace/ext/static_highlight', ['require', 'exports', 'module' , 'ace/edit_session', 'ace/layer/text'], function(require, exports, module) {
34
var EditSession = require("../edit_session").EditSession;
35
var TextLayer = require("../layer/text").Text;
36
var baseStyles = ".ace_editor {\
37
font-family: 'Monaco', 'Menlo', 'Droid Sans Mono', 'Courier New', monospace;\
40
.ace_editor .ace_gutter { \
41
width: 25px !important;\
48
.ace_line { clear: both; }\
50
-moz-user-select: -moz-none;\
51
-khtml-user-select: none;\
52
-webkit-user-select: none;\
56
exports.render = function(input, mode, theme, lineStart, disableGutter) {
57
lineStart = parseInt(lineStart || 1, 10);
59
var session = new EditSession("");
60
session.setMode(mode);
61
session.setUseWorker(false);
63
var textLayer = new TextLayer(document.createElement("div"));
64
textLayer.setSession(session);
70
session.setValue(input);
72
var stringBuilder = [];
73
var length = session.getLength();
75
for(var ix = 0; ix < length; ix++) {
76
stringBuilder.push("<div class='ace_line'>");
78
stringBuilder.push("<span class='ace_gutter ace_gutter-cell' unselectable='on'>" + (ix + lineStart) + "</span>");
79
textLayer.$renderLine(stringBuilder, ix, true, false);
80
stringBuilder.push("</div>");
82
var html = "<div class=':cssClass'>\
83
<div class='ace_editor ace_scroller ace_text-layer'>\
86
</div>".replace(/:cssClass/, theme.cssClass).replace(/:code/, stringBuilder.join(""));
91
css: baseStyles + theme.cssText,