|
@@ -27,6 +27,7 @@ String.prototype.lpad = function(len, chr) {
|
27
|
27
|
};
|
28
|
28
|
String.prototype.prePad = function(len, chr) { return len ? this.lpad(len, chr) : this; };
|
29
|
29
|
String.prototype.zeroPad = function(len) { return this.prePad(len, '0'); };
|
|
30
|
+String.prototype.toHTML = function() { return jQuery('<div>').text(this).html(); };
|
30
|
31
|
String.prototype.regEsc = function() { return this.replace(/[.?*+^$[\]\\(){}|-]/g, "\\$&"); }
|
31
|
32
|
String.prototype.lineCount = function() { var len = this.split(/\r?\n|\r/).length; return len > 0 ? len - 1 : len; };
|
32
|
33
|
|
|
@@ -367,7 +368,7 @@ var configuratorApp = (function(){
|
367
|
368
|
$tipme.hover(
|
368
|
369
|
function() {
|
369
|
370
|
var pos = $tipme.position();
|
370
|
|
- $tooltip.text(inf.comment)
|
|
371
|
+ $tooltip.html(inf.comment)
|
371
|
372
|
.append('<span>')
|
372
|
373
|
.css({bottom:($tooltip.parent().outerHeight()-pos.top)+'px',left:(pos.left+70)+'px'})
|
373
|
374
|
.show();
|
|
@@ -484,6 +485,7 @@ var configuratorApp = (function(){
|
484
|
485
|
* then update, highlight, and scroll to the line
|
485
|
486
|
*/
|
486
|
487
|
setDefineLine: function(name, newline) {
|
|
488
|
+ this.log('setDefineLine:'+name+'\n'+newline,4);
|
487
|
489
|
var $elm = $('#'+name), elm = $elm[0], inf = elm.defineInfo;
|
488
|
490
|
var $c = $(inf.field), txt = $c.text();
|
489
|
491
|
|
|
@@ -492,10 +494,8 @@ var configuratorApp = (function(){
|
492
|
494
|
txt = txt.replace(inf.line, hilite_token + newline);
|
493
|
495
|
inf.line = newline;
|
494
|
496
|
|
495
|
|
- this.log(newline, 2);
|
496
|
|
-
|
497
|
497
|
// Convert txt into HTML before storing
|
498
|
|
- var html = $('<div/>').text(txt).html().replace(hilite_token, '<span></span>');
|
|
498
|
+ var html = txt.toHTML().replace(hilite_token, '<span></span>');
|
499
|
499
|
|
500
|
500
|
// Set the final text including the highlighter
|
501
|
501
|
$c.html(html);
|
|
@@ -634,26 +634,26 @@ var configuratorApp = (function(){
|
634
|
634
|
// Get the end-of-line comment, if there is one
|
635
|
635
|
var comment = '';
|
636
|
636
|
findDef = new RegExp('.*#define[ \\t].*/[/*]+[ \\t]*(.*)');
|
637
|
|
- if (info.line.search(findDef) >= 0) {
|
|
637
|
+ if (info.line.search(findDef) >= 0)
|
638
|
638
|
comment = info.line.replace(findDef, '$1');
|
639
|
|
- }
|
640
|
|
- else {
|
641
|
|
- // Get all the comments immediately before the item
|
642
|
|
- var r, s;
|
643
|
|
- findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n){0,1}' + info.line, 'g');
|
644
|
|
- if (r = findDef.exec(txt)) {
|
645
|
|
- findDef = new RegExp('^[ \\t]*//+[ \\t]*(.*)[ \\t]*$', 'gm');
|
646
|
|
- while((s = findDef.exec(r[1])) !== null) {
|
647
|
|
- if (s[1].match(/^#define[ \\t]/) != null) {
|
648
|
|
- comment = '';
|
649
|
|
- break;
|
650
|
|
- }
|
651
|
|
- comment += s[1] + "\n";
|
|
639
|
+
|
|
640
|
+ // Get all the comments immediately before the item
|
|
641
|
+ var r, s;
|
|
642
|
+ findDef = new RegExp('(([ \\t]*(//|#)[^\n]+\n){1,4})([ \\t]*\n){0,1}' + info.line.regEsc(), 'g');
|
|
643
|
+ if (r = findDef.exec(txt)) {
|
|
644
|
+ findDef = new RegExp('^[ \\t]*//+[ \\t]*(.*)[ \\t]*$', 'gm');
|
|
645
|
+ while((s = findDef.exec(r[1])) !== null) {
|
|
646
|
+ if (s[1].match(/^#define[ \\t]/) != null) {
|
|
647
|
+ comment = '';
|
|
648
|
+ break;
|
652
|
649
|
}
|
|
650
|
+ comment += ' ' + s[1] + "\n";
|
653
|
651
|
}
|
654
|
652
|
}
|
|
653
|
+
|
|
654
|
+ findDef = new RegExp('^[ \\t]*'+name+'[ \\t]*', 'm');
|
655
|
655
|
$.extend(info, {
|
656
|
|
- comment: comment.trim(),
|
|
656
|
+ comment: '<strong>'+name+'</strong> '+comment.replace(findDef,'').trim().toHTML(),
|
657
|
657
|
lineNum: this.getLineNumberOfText(info.line, txt)
|
658
|
658
|
});
|
659
|
659
|
}
|