Skip to content

Commit

Permalink
update plugins to work with new dom based renderer in ace
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing committed Apr 6, 2018
1 parent c8ca347 commit 6c8a723
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 77 deletions.
2 changes: 0 additions & 2 deletions plugins/c9.ide.language.core/complete.css
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,7 @@

.code_complete_text .ace_line{
background : transparent;

overflow: hidden;
position: relative;
white-space: nowrap;
/*padding : 0 0 1px 0; */ /*todo requires special handling in ace*/
pointer-events: auto;
Expand Down
60 changes: 22 additions & 38 deletions plugins/c9.ide.language.core/completedp.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
define(function(require, exports, module) {
var escapeHTML = require("ace/lib/lang").escapeHTML;

var guidToShortString = exports.guidToShortString = function(guid) {
var result = guid && guid.replace(/^[^:]+:(([^\/]+)\/)*?([^\/]*?)(\[\d+[^\]]*\])?(\/prototype)?$|.*/, "$3");
Expand Down Expand Up @@ -41,71 +40,56 @@ define(function(require, exports, module) {
function tokenizeRow() {
return [];
}
function renderLineInner(builder, row) {
var match = this.data[row];
function renderLine(lineEl, row, foldLine) {
var match = this.popup.data[row];

var html = "<span class='completer-img " + (match.icon
? iconClass[match.icon] || this.$defineIcon(match.icon)
: "") + "'></span>";
var icon = this.dom.createElement("span");
icon.className = "completer-img " + (match.icon
? iconClass[match.icon] || this.popup.$defineIcon(match.icon)
: "");
lineEl.appendChild(icon);

if (match.type) {
var shortType = guidToShortString(match.type);
if (shortType)
match.meta = shortType;
}

var name = escapeHTML(match.name);
var name = match.name;
var prefix = match.identifierRegex
? this.calcPrefix(match.identifierRegex)
: name.substr(0, this.prefix.length);
? this.popup.calcPrefix(match.identifierRegex)
: name.substr(0, this.popup.prefix.length);

var trim = match.meta ? " maintrim" : "";
if (!this.ignoreGenericMatches || !match.isGeneric) {
var simpleName = match.replaceText.replace("^^", "").replace(/\(\)$/, "");
if (name.indexOf(simpleName) === 0) {
simpleName = escapeHTML(simpleName);
html += '<span class="main' + trim + '"><u>'
+ prefix + "</u>" + simpleName.substring(prefix.length)
+ '</span>'
+ '<span class="deferred">'
+ name.substring(Math.max(simpleName.length, prefix.length))
+ '</span>';
this.dom.buildDom(["span", { class: "main" + trim },
["u", prefix], simpleName.substring(prefix.length),
["span", { class: "deferred" }, name.substring(Math.max(simpleName.length, prefix.length))]
], lineEl);
}
else {
html += '<span class="main' + trim + '"><u>'
+ prefix + "</u>" + name.substring(prefix.length)
+ '</span>';
this.dom.buildDom(["span", { class: "main" + trim },
["u", prefix], name.substring(prefix.length)
], lineEl);
}
}
else {
html += '<span class="main' + trim
+ '"><span class="deferred"><u>' + prefix + "</u>"
+ name.substring(prefix.length) + '</span></span>';
this.dom.buildDom(["span", { class: "main" + trim },
["span", { class: "deferred" }, ["u", prefix], name.substring(prefix.length)]
], lineEl);
}

if (match.meta)
html += '<span class="meta"> - ' + match.meta + '</span>';

builder.push(html);
}

function renderLine(stringBuilder, row, onlyContents, foldLine) {
if (!onlyContents) {
stringBuilder.push(
"<div class='ace_line' style='height:", this.config.lineHeight, "px'>"
);
if (match.meta) {
this.dom.buildDom(["span", { class: "meta"}, match.meta], lineEl);
}
this.popup.$renderLineInner(stringBuilder, row);

if (!onlyContents)
stringBuilder.push("</div>");
}

exports.initPopup = function(popup, staticUrl) {
popup.session.bgTokenizer.popup = popup;
popup.session.bgTokenizer.$tokenizeRow = tokenizeRow;
popup.renderer.$textLayer.popup = popup;
popup.$renderLineInner = renderLineInner;
popup.$defineIcon = defineIcon;
popup.renderer.$textLayer.$renderLine = renderLine;
popup.staticUrl = staticUrl;
Expand Down
65 changes: 28 additions & 37 deletions plugins/c9.ide.terminal/aceterm/aceterm.js
Original file line number Diff line number Diff line change
Expand Up @@ -456,26 +456,12 @@ define(function(require, exports, module) {
ace.renderer.$textLayer.element.style.overflow = "visible";

ace.renderer.$textLayer.$renderLine = Aceterm.renderLine;

ace.renderer.$textLayer.$renderLineInner = Aceterm.renderLineInner;

ace.setOption("showPrintMargin", false);
ace.setOption("highlightActiveLine", false);
}

Aceterm.renderLine = function(stringBuilder, row, onlyContents, foldLine) {
if (!onlyContents) {
stringBuilder.push(
"<div class='ace_line' style='height:", this.config.lineHeight, "px'>"
);
}
this.$renderLineInner(stringBuilder, row);

if (!onlyContents)
stringBuilder.push("</div>");
};

Aceterm.renderLineInner = function(stringBuilder, row) {
Aceterm.renderLine = function(lineEl, row, foldLine) {
var term = this.session.term;
if (!term)
return;
Expand All @@ -498,7 +484,8 @@ define(function(require, exports, module) {
: -1;

var defAttr = term.defAttr;
var attr = defAttr;
var attr;
var span, text;
for (var i = 0; i < width; i++) {
var token = line[i] || term.ch;
var data = token[0];
Expand All @@ -507,63 +494,67 @@ define(function(require, exports, module) {
if (i === x) data = -1;

if (data !== attr) {
if (attr !== defAttr)
out += '</span>';
if (span) {
text.data = out;
lineEl.appendChild(span);
out = "";
span = null;
}
text = this.dom.createTextNode();
if (data === defAttr) {
// do nothing
span = text;
} else if (data === -1) {
out += '<span class="reverse-video">';
span = this.dom.createElement("span");
span.appendChild(text);
span.className = "reverse-video";
this.$cur = null;
} else {
out += '<span style="';
span = this.dom.createElement("span");
span.appendChild(text);

bgColor = data & 0x1ff;
fgColor = (data >> 9) & 0x1ff;
flags = data >> 18;

if (flags & 1) {
if (this.$fontMetrics.allowBoldFonts)
out += 'font-weight:bold;';
span.style.fontWeight = "bold";
// see: XTerm*boldColors
if (fgColor < 8)
fgColor += 8;
}

if (flags & 2)
out += 'text-decoration:underline;';
span.style.textDecoration = "underline";

if (bgColor === 256) {
if (fgColor !== 257)
out += 'color:' + (
span.style.color = (
Terminal.overridenColors[fgColor] ||
Terminal.colors[fgColor]
) + ';';
);
} else {
out += 'background-color:' + Terminal.colors[bgColor] + ';';
span.style.backgroundColor = Terminal.colors[bgColor];
if (fgColor !== 257)
out += 'color:' + Terminal.colors[fgColor] + ';';
out += 'display:inline-block" class="aceterm-line-bg" l="' + i;
span.style.color = Terminal.colors[fgColor];
span.style.display = "inline-block"
span.className = "aceterm-line-bg";
}
out += '">';
}
}


if (ch <= ' ')
out += ch == "\x00" ? "" : "\xa0";
else if (ch == '&')
out += '&#38;';
else if (ch == '<')
out += '&#60;';
else
out += ch;

attr = data;
}

if (attr !== defAttr)
out += '</span>';
stringBuilder.push(out);
if (span) {
text.data = out;
lineEl.appendChild(span);
}
};

});

0 comments on commit 6c8a723

Please sign in to comment.