Merge pull request #1571 from ajaxorg/newclient

sync with newclient
This commit is contained in:
Lennart Kats 2013-09-06 00:21:34 -07:00
commit e746383ec0
16 changed files with 80 additions and 44 deletions

View file

@ -170,6 +170,10 @@ var BackgroundTokenizer = function(tokenizer, editor) {
// pretty long delay to prevent the tokenizer from interfering with the user // pretty long delay to prevent the tokenizer from interfering with the user
this.running = setTimeout(this.$worker, 700); this.running = setTimeout(this.$worker, 700);
}; };
this.scheduleStart = function() {
this.running = setTimeout(this.$worker, 700);
}
this.$updateOnChange = function(delta) { this.$updateOnChange = function(delta) {
var range = delta.range; var range = delta.range;
@ -191,8 +195,6 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength()); this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
this.stop(); this.stop();
// pretty long delay to prevent the tokenizer from interfering with the user
this.running = setTimeout(this.$worker, 700);
}; };
/** /**

View file

@ -71,17 +71,19 @@
.ace_scrollbar { .ace_scrollbar {
position: absolute; position: absolute;
overflow: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
right: 0; right: 0;
top: 0; top: 0;
bottom: 0; bottom: 0;
z-index: 6;
} }
.ace_scrollbar-inner { .ace_scrollbar-inner {
position: absolute; position: absolute;
width: 1px; cursor: text;
left: 0; left: 0;
top: 0;
} }
.ace_scrollbar-h { .ace_scrollbar-h {
@ -91,15 +93,9 @@
right: 0; right: 0;
left: 0; left: 0;
bottom: 0; bottom: 0;
z-index: 6;
} }
.ace_scrollbar-inner {
position: absolute;
height: 1px;
left: 0;
}
.ace_print-margin { .ace_print-margin {
position: absolute; position: absolute;
height: 100%; height: 100%;

View file

@ -272,7 +272,8 @@ function Folding() {
var endColumn = fold.end.column; var endColumn = fold.end.column;
// --- Some checking --- // --- Some checking ---
if (startRow == endRow && endColumn - startColumn < 2) if (!(startRow < endRow ||
startRow == endRow && startColumn <= endColumn - 2))
throw "The range has to be at least 2 characters width"; throw "The range has to be at least 2 characters width";
var startFold = this.getFoldAt(startRow, startColumn, 1); var startFold = this.getFoldAt(startRow, startColumn, 1);
@ -627,19 +628,25 @@ function Folding() {
depth = 100000; // JSON.stringify doesn't hanle Infinity depth = 100000; // JSON.stringify doesn't hanle Infinity
var foldWidgets = this.foldWidgets; var foldWidgets = this.foldWidgets;
endRow = endRow || this.getLength(); endRow = endRow || this.getLength();
for (var row = startRow || 0; row < endRow; row++) { startRow = startRow || 0;
for (var row = startRow; row < endRow; row++) {
if (foldWidgets[row] == null) if (foldWidgets[row] == null)
foldWidgets[row] = this.getFoldWidget(row); foldWidgets[row] = this.getFoldWidget(row);
if (foldWidgets[row] != "start") if (foldWidgets[row] != "start")
continue; continue;
var range = this.getFoldWidgetRange(row); var range = this.getFoldWidgetRange(row);
var rangeEndRow = range.end.row;
// sometimes range can be incompatible with existing fold // sometimes range can be incompatible with existing fold
// TODO change addFold to return null istead of throwing // TODO change addFold to return null istead of throwing
if (range && range.end.row <= endRow) try { if (range && range.isMultiLine()
&& rangeEndRow <= endRow
&& range.start.row >= startRow
) try {
var fold = this.addFold("...", range); var fold = this.addFold("...", range);
fold.collapseChildren = depth; fold.collapseChildren = depth;
row = range.end.row; // addFold can change the range
row = rangeEndRow;
} catch(e) {} } catch(e) {}
} }
}; };

View file

@ -90,6 +90,15 @@ var Editor = function(renderer, session) {
this.commands.on("exec", this.$historyTracker); this.commands.on("exec", this.$historyTracker);
this.$initOperationListeners(); this.$initOperationListeners();
this._$emitInputEvent = lang.delayedCall(function() {
this._signal("input", {});
this.session.bgTokenizer && this.session.bgTokenizer.scheduleStart();
}.bind(this));
this.on("change", function(_, _self) {
_self._$emitInputEvent.schedule(31);
});
this.setSession(session || new EditSession("")); this.setSession(session || new EditSession(""));
config.resetOptions(this); config.resetOptions(this);

View file

@ -63,7 +63,7 @@ exports.$detectIndentation = function(lines, fallback) {
// ignore lines ending with backslash // ignore lines ending with backslash
while (line[line.length - 1] == "\\") while (line[line.length - 1] == "\\")
line = lines[i++]; line = lines[i++];
}; }
function getScore(indent) { function getScore(indent) {
var score = 0; var score = 0;
@ -113,15 +113,17 @@ exports.detectIndentation = function(session) {
return indent; return indent;
}; };
exports.trimTrailingSpace = function(session) { exports.trimTrailingSpace = function(session, trimEmpty) {
var doc = session.getDocument(); var doc = session.getDocument();
var lines = doc.getAllLines(); var lines = doc.getAllLines();
var min = trimEmpty ? -1 : 0;
for (var i = 0, l=lines.length; i < l; i++) { for (var i = 0, l=lines.length; i < l; i++) {
var line = lines[i]; var line = lines[i];
var index = line.search(/\s+$/); var index = line.search(/\s+$/);
if (index !== -1) if (index > min)
doc.removeInLine(i, index, line.length); doc.removeInLine(i, index, line.length);
} }
}; };
@ -160,14 +162,14 @@ exports.convertIndentation = function(session, ch, len) {
}; };
exports.$parseStringArg = function(text) { exports.$parseStringArg = function(text) {
var indent = {} var indent = {};
if (/t/.test(text)) if (/t/.test(text))
indent.ch = "\t"; indent.ch = "\t";
else if (/s/.test(text)) else if (/s/.test(text))
indent.ch = " "; indent.ch = " ";
var m = text.match(/\d+/); var m = text.match(/\d+/);
if (m) if (m)
indent.length = parseInt(m[0]); indent.length = parseInt(m[0], 10);
return indent; return indent;
}; };
@ -179,7 +181,7 @@ exports.$parseArg = function(arg) {
if (typeof arg.text == "string") if (typeof arg.text == "string")
return exports.$parseStringArg(arg.text); return exports.$parseStringArg(arg.text);
return arg; return arg;
} };
exports.commands = [{ exports.commands = [{
name: "detectIndentation", name: "detectIndentation",
@ -196,7 +198,7 @@ exports.commands = [{
name: "convertIndentation", name: "convertIndentation",
exec: function(editor, arg) { exec: function(editor, arg) {
var indent = exports.$parseArg(arg); var indent = exports.$parseArg(arg);
exports.convertIndentation(editor.session, arg.ch, arg.length); exports.convertIndentation(editor.session, indent.ch, indent.length);
} }
}, { }, {
name: "setIndentation", name: "setIndentation",
@ -205,6 +207,6 @@ exports.commands = [{
indent.length && editor.session.setTabSize(indent.length); indent.length && editor.session.setTabSize(indent.length);
indent.ch && editor.session.setUseSoftTabs(indent.ch == " "); indent.ch && editor.session.setUseSoftTabs(indent.ch == " ");
} }
}] }];
}); });

View file

@ -89,6 +89,9 @@ function HashHandler(config, platform) {
this.addCommands = function(commands) { this.addCommands = function(commands) {
commands && Object.keys(commands).forEach(function(name) { commands && Object.keys(commands).forEach(function(name) {
var command = commands[name]; var command = commands[name];
if (!command)
return;
if (typeof command === "string") if (typeof command === "string")
return this.bindKey(command, name); return this.bindKey(command, name);

View file

@ -108,8 +108,11 @@ var KeyBinding = function(editor) {
success = commands.exec(toExecute.command, this.$editor, toExecute.args, e); success = commands.exec(toExecute.command, this.$editor, toExecute.args, e);
} }
// do not stop input events to not break repeating // do not stop input events to not break repeating
if (success && e && hashId != -1 && toExecute.passEvent != true) if (success && e && hashId != -1 &&
toExecute.passEvent != true && toExecute.command.passEvent != true
) {
event.stopEvent(e); event.stopEvent(e);
}
if (success) if (success)
break; break;
} }

View file

@ -55,6 +55,7 @@ EventEmitter._dispatchEvent = function(eventName, e) {
if (!e.preventDefault) if (!e.preventDefault)
e.preventDefault = preventDefault; e.preventDefault = preventDefault;
listeners = listeners.slice();
for (var i=0; i<listeners.length; i++) { for (var i=0; i<listeners.length; i++) {
listeners[i](e, this); listeners[i](e, this);
if (e.propagationStopped) if (e.propagationStopped)
@ -70,7 +71,7 @@ EventEmitter._signal = function(eventName, e) {
var listeners = (this._eventRegistry || {})[eventName]; var listeners = (this._eventRegistry || {})[eventName];
if (!listeners) if (!listeners)
return; return;
listeners = listeners.slice();
for (var i=0; i<listeners.length; i++) for (var i=0; i<listeners.length; i++)
listeners[i](e, this); listeners[i](e, this);
}; };

View file

@ -14,16 +14,12 @@
["text"," "], ["text"," "],
["keyword.command.dosbatch","set"], ["keyword.command.dosbatch","set"],
["text"," var1="], ["text"," var1="],
["markup.list","%"], ["constant.numeric","%cd%"]
["constant.other","cd"],
["markup.list","%"]
],[ ],[
"start", "start",
["keyword.command.dosbatch","echo"], ["keyword.command.dosbatch","echo"],
["text"," unhide everything in "], ["text"," unhide everything in "],
["markup.list","%"], ["constant.numeric","%var1%"],
["constant.other","var1"],
["markup.list","%"],
["text","!"] ["text","!"]
],[ ],[
"start" "start"
@ -46,19 +42,13 @@
"start", "start",
["keyword.command.dosbatch","echo"], ["keyword.command.dosbatch","echo"],
["text"," "], ["text"," "],
["markup.list","%"], ["constant.numeric","%var1%%%G"]
["constant.other","var1"],
["markup.list","%"],
["constant.numeric","%%G"]
],[ ],[
"start", "start",
["keyword.command.dosbatch","attrib"], ["keyword.command.dosbatch","attrib"],
["text"," -r -a -h -s "], ["text"," -r -a -h -s "],
["punctuation.definition.string.begin.shell","\""], ["punctuation.definition.string.begin.shell","\""],
["markup.list","%"], ["constant.numeric","%var1%%%G"],
["constant.other","var1"],
["markup.list","%"],
["constant.numeric","%%G"],
["punctuation.definition.string.end.shell","\""], ["punctuation.definition.string.end.shell","\""],
["text"," /D /S"] ["text"," /D /S"]
],[ ],[

View file

@ -78,7 +78,8 @@ var BatchFileHighlightRules = function() {
{ token: 'keyword.operator.redirect.shell', { token: 'keyword.operator.redirect.shell',
regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ], regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ],
variable: [ variable: [
{ token: 'constant.numeric', regex: '%%\\w+'}, { token: 'constant.numeric', regex: '%%\\w+|%[*\\d]|%\\w+%'},
{ token: 'constant.numeric', regex: '%~\\d+'},
{ token: ['markup.list', 'constant.other', 'markup.list'], { token: ['markup.list', 'constant.other', 'markup.list'],
regex: '(%)(\\w+)(%?)' }]} regex: '(%)(\\w+)(%?)' }]}

View file

@ -53,7 +53,7 @@ var LogiQLHighlightRules = function() {
//A single line comment. //A single line comment.
}, },
{ token: 'constant.numeric', { token: 'constant.numeric',
regex: '\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?', regex: '\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?[fd]?',
//An integer constant. //An integer constant.
//Or a Real number. //Or a Real number.
}, },

View file

@ -50,6 +50,10 @@ var MouseHandler = function(editor) {
event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click")); event.addListener(mouseTarget, "click", this.onMouseEvent.bind(this, "click"));
event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove")); event.addListener(mouseTarget, "mousemove", this.onMouseMove.bind(this, "mousemove"));
event.addMultiMouseDownListener(mouseTarget, [300, 300, 250], this, "onMouseEvent"); event.addMultiMouseDownListener(mouseTarget, [300, 300, 250], this, "onMouseEvent");
if (editor.renderer.scrollBarV) {
event.addMultiMouseDownListener(editor.renderer.scrollBarV.inner, [300, 300, 250], this, "onMouseEvent");
event.addMultiMouseDownListener(editor.renderer.scrollBarH.inner, [300, 300, 250], this, "onMouseEvent");
}
event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel")); event.addMouseWheelListener(editor.container, this.onMouseWheel.bind(this, "mousewheel"));
var gutterEl = editor.renderer.$gutter; var gutterEl = editor.renderer.$gutter;

View file

@ -64,7 +64,10 @@ var ScrollBarV = function(parent, renderer) {
// make element a little bit wider to retain scrollbar when page is zoomed // make element a little bit wider to retain scrollbar when page is zoomed
renderer.$scrollbarWidth = renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument); this.width = dom.scrollbarWidth(parent.ownerDocument);
renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument);
this.fullWidth = this.width; this.fullWidth = this.width;
this.inner.style.width =
this.element.style.width = (this.width || 15) + 5 + "px"; this.element.style.width = (this.width || 15) + 5 + "px";
this.setVisible(false); this.setVisible(false);
this.element.style.overflowY = "scroll"; this.element.style.overflowY = "scroll";
@ -89,6 +92,7 @@ var ScrollBarH = function(parent, renderer) {
// make element a little bit wider to retain scrollbar when page is zoomed // make element a little bit wider to retain scrollbar when page is zoomed
this.height = renderer.$scrollbarWidth; this.height = renderer.$scrollbarWidth;
this.fullHeight = this.height; this.fullHeight = this.height;
this.inner.style.height =
this.element.style.height = (this.height || 15) + 5 + "px"; this.element.style.height = (this.height || 15) + 5 + "px";
this.setVisible(false); this.setVisible(false);
this.element.style.overflowX = "scroll"; this.element.style.overflowX = "scroll";

View file

@ -48,6 +48,10 @@
background-color: #2A2A2A background-color: #2A2A2A
} }
.ace-tomorrow-night-bright .ace_stack {
background-color: rgb(66, 90, 44);
}
.ace-tomorrow-night-bright .ace_marker-layer .ace_selected-word { .ace-tomorrow-night-bright .ace_marker-layer .ace_selected-word {
border: 1px solid #424242 border: 1px solid #424242
} }

View file

@ -44,6 +44,10 @@
border: 1px solid #6A6A6A border: 1px solid #6A6A6A
} }
.ace-tomorrow-night-bright .ace_stack {
background: rgb(66, 90, 44)
}
.ace-tomorrow-night-eighties .ace_marker-layer .ace_active-line { .ace-tomorrow-night-eighties .ace_marker-layer .ace_active-line {
background: #393939 background: #393939
} }

View file

@ -344,7 +344,7 @@ var VirtualRenderer = function(container, theme) {
if (force) if (force)
this.$renderChanges(changes, true); this.$renderChanges(changes, true);
else else
this.$loop.schedule(changes || this.$changes); this.$loop.schedule(changes | this.$changes);
if (this.resizing) if (this.resizing)
this.resizing = 0; this.resizing = 0;
@ -353,6 +353,12 @@ var VirtualRenderer = function(container, theme) {
this.$updateCachedSize = function(force, gutterWidth, width, height) { this.$updateCachedSize = function(force, gutterWidth, width, height) {
var changes = 0; var changes = 0;
var size = this.$size; var size = this.$size;
var oldSize = {
width: size.width,
height: size.height,
scrollerHeight: size.scrollerHeight,
scrollerWidth: size.scrollerWidth
};
if (height && (force || size.height != height)) { if (height && (force || size.height != height)) {
size.height = height; size.height = height;
changes = this.CHANGE_SIZE; changes = this.CHANGE_SIZE;
@ -394,7 +400,7 @@ var VirtualRenderer = function(container, theme) {
} }
if (changes) if (changes)
this._signal("resize"); this._signal("resize", oldSize);
return changes; return changes;
}; };
@ -402,7 +408,7 @@ var VirtualRenderer = function(container, theme) {
this.onGutterResize = function() { this.onGutterResize = function() {
var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0; var gutterWidth = this.$showGutter ? this.$gutter.offsetWidth : 0;
if (gutterWidth != this.gutterWidth) if (gutterWidth != this.gutterWidth)
this.$changes != this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height); this.$changes |= this.$updateCachedSize(true, gutterWidth, this.$size.width, this.$size.height);
if (this.session.getUseWrapMode() && this.adjustWrapLimit()) if (this.session.getUseWrapMode() && this.adjustWrapLimit())
this.$loop.schedule(this.CHANGE_FULL); this.$loop.schedule(this.CHANGE_FULL);