Skip to content

Commit

Permalink
Revert "Revert "Update ace""
Browse files Browse the repository at this point in the history
  • Loading branch information
nightwing authored Apr 17, 2018
1 parent a4f0cca commit 4835f14
Show file tree
Hide file tree
Showing 53 changed files with 2,608 additions and 893 deletions.
50 changes: 2 additions & 48 deletions plugins/c9.ide.ace/ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -1605,41 +1605,6 @@
return s;
}

/***** Gutter Renderers *****/

var relativeNumbers = {
getText: function(session, row) {
return (Math.abs(session.selection.lead.row - row) || (row + 1 + (row < 9 ? "\xb7" : ""))) + "";
},
getWidth: function(session, lastLineNumber, config) {
return session.getLength().toString().length * config.characterWidth;
},
update: function(e, editor) {
editor.renderer.$loop.schedule(editor.renderer.CHANGE_GUTTER);
},
attach: function(editor) {
editor.renderer.$gutterLayer.$renderer = this;
editor.on("changeSelection", this.update);
},
detach: function(editor) {
editor.renderer.$gutterLayer.$renderer = null;
editor.off("changeSelection", this.update);
}
};

var noNumbers = {
getText: function(session, row) {
return "";
},
getWidth: function(session, lastLineNumber, config) {
return "";
},
attach: function(editor) {
},
detach: function(editor) {
},
};

/**
* The ace handle, responsible for events that involve all ace
* instances. This is the object you get when you request the ace
Expand Down Expand Up @@ -2259,20 +2224,9 @@
break;
case "showLineNumbers":
var renderer = ace.renderer;
var gutterRenderer = renderer.$gutterLayer.$renderer;
if (gutterRenderer && gutterRenderer.detach)
gutterRenderer.detach(ace);
if (value == "relative")
gutterRenderer = relativeNumbers;
else if (value)
gutterRenderer = null;
else
gutterRenderer = noNumbers;
ace.setOption("relativeLineNumbers", value == "relative");
ace.setOption("showLineNumbers", !!value);
dom.setCssClass(renderer.$gutter, "ace_gutter-compact", !value);
renderer.$gutterLayer.$renderer = gutterRenderer;
if (gutterRenderer && gutterRenderer.attach)
gutterRenderer.attach(ace);
renderer.$loop.schedule(renderer.CHANGE_GUTTER);
return;
}

Expand Down
4 changes: 2 additions & 2 deletions plugins/c9.ide.ace/ace_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
it('should allow setting highlightGutterLine', function(done) {
editor.setOption("highlightGutterLine", false);
render();
expect(document.querySelector(".ace_gutter-active-line").offsetHeight).to.not.ok;
expect(document.querySelector(".ace_gutter-active-line")).to.not.ok;

editor.setOption("highlightGutterLine", true);
render();
Expand Down Expand Up @@ -491,7 +491,7 @@ require(["lib/architect/architect", "lib/chai/chai"], function (architect, chai)
doc.value = "function(){\n\t\n}";
editor.setOption("showFoldWidgets", false);
render();
expect.html(document.querySelector(".ace_fold-widget")).not.ok;
expect.html(document.querySelector(".ace_fold-widget").offsetHeight).not.ok;
editor.setOption("showFoldWidgets", true);
render();
expect.html(document.querySelector(".ace_fold-widget")).ok;
Expand Down
8 changes: 1 addition & 7 deletions plugins/c9.ide.language.core/complete.css
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,12 @@
}

.code_complete_text .ace_text-layer{
left : 1px;
right : 1px;
width : auto;
top : 1px;
bottom : 1px;
margin: 1px!important;
}

.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);
}
};

});
2 changes: 1 addition & 1 deletion plugins/node_modules/ace/lib/ace/ace.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4835f14

Please sign in to comment.