allow multiline annotations

This commit is contained in:
nightwing 2012-10-15 14:20:51 +04:00
commit 7fc1944c8b
3 changed files with 13 additions and 3 deletions

View file

@ -242,6 +242,8 @@
-webkit-box-sizing: border-box;
box-sizing: border-box;
cursor: default;
white-space: pre-line;
word-wrap: break-word;
}
.ace_folding-enabled > .ace_gutter-cell {

View file

@ -33,6 +33,7 @@ define(function(require, exports, module) {
var dom = require("../lib/dom");
var oop = require("../lib/oop");
var lang = require("../lib/lang");
var EventEmitter = require("../lib/event_emitter").EventEmitter;
var Gutter = function(parentEl) {
@ -78,12 +79,15 @@ var Gutter = function(parentEl) {
var annotation = annotations[i];
var row = annotation.row;
var rowInfo = this.$annotations[row];
if (!rowInfo) {
if (!rowInfo)
rowInfo = this.$annotations[row] = {text: []};
}
var annoText = annotation.text.replace(/"/g, "&quot;").replace(/'/g, "&#8217;").replace(/</g, "&lt;");
var annoText = annotation.text;
annoText = annoText ? lang.escapeHTML(annoText) : annotation.html || "";
if (rowInfo.text.indexOf(annoText) === -1)
rowInfo.text.push(annoText);
var type = annotation.type;
if (type == "error")
rowInfo.className = " ace_error";

View file

@ -117,6 +117,10 @@ exports.escapeRegExp = function(str) {
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
};
exports.escapeHTML = function(str) {
return str.replace(/&/g, "&#38;").replace(/"/g, "&#34;").replace(/'/g, "&#39;").replace(/</g, "&#60;");
};
exports.getMatchOffsets = function(string, regExp) {
var matches = [];