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
this.running = setTimeout(this.$worker, 700);
};
this.scheduleStart = function() {
this.running = setTimeout(this.$worker, 700);
}
this.$updateOnChange = function(delta) {
var range = delta.range;
@ -191,8 +195,6 @@ var BackgroundTokenizer = function(tokenizer, editor) {
this.currentLine = Math.min(startRow, this.currentLine, this.doc.getLength());
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 {
position: absolute;
overflow: hidden;
overflow-x: hidden;
overflow-y: auto;
right: 0;
top: 0;
bottom: 0;
z-index: 6;
}
.ace_scrollbar-inner {
position: absolute;
width: 1px;
cursor: text;
left: 0;
top: 0;
}
.ace_scrollbar-h {
@ -91,15 +93,9 @@
right: 0;
left: 0;
bottom: 0;
z-index: 6;
}
.ace_scrollbar-inner {
position: absolute;
height: 1px;
left: 0;
}
.ace_print-margin {
position: absolute;
height: 100%;

View file

@ -272,7 +272,8 @@ function Folding() {
var endColumn = fold.end.column;
// --- 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";
var startFold = this.getFoldAt(startRow, startColumn, 1);
@ -627,19 +628,25 @@ function Folding() {
depth = 100000; // JSON.stringify doesn't hanle Infinity
var foldWidgets = this.foldWidgets;
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)
foldWidgets[row] = this.getFoldWidget(row);
if (foldWidgets[row] != "start")
continue;
var range = this.getFoldWidgetRange(row);
var rangeEndRow = range.end.row;
// sometimes range can be incompatible with existing fold
// 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);
fold.collapseChildren = depth;
row = range.end.row;
// addFold can change the range
row = rangeEndRow;
} catch(e) {}
}
};

View file

@ -90,6 +90,15 @@ var Editor = function(renderer, session) {
this.commands.on("exec", this.$historyTracker);
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(""));
config.resetOptions(this);

View file

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

View file

@ -89,6 +89,9 @@ function HashHandler(config, platform) {
this.addCommands = function(commands) {
commands && Object.keys(commands).forEach(function(name) {
var command = commands[name];
if (!command)
return;
if (typeof command === "string")
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);
}
// 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);
}
if (success)
break;
}

View file

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

View file

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

View file

@ -78,7 +78,8 @@ var BatchFileHighlightRules = function() {
{ token: 'keyword.operator.redirect.shell',
regex: '&>|\\d*>&\\d*|\\d*(?:>>|>|<)|\\d*<&|\\d*<>' } ],
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'],
regex: '(%)(\\w+)(%?)' }]}

View file

@ -53,7 +53,7 @@ var LogiQLHighlightRules = function() {
//A single line comment.
},
{ token: 'constant.numeric',
regex: '\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?',
regex: '\\d+(?:\\.\\d+)?(?:[eE][+-]?\\d+)?[fd]?',
//An integer constant.
//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, "mousemove", this.onMouseMove.bind(this, "mousemove"));
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"));
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
renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument);
renderer.$scrollbarWidth =
this.width = dom.scrollbarWidth(parent.ownerDocument);
this.fullWidth = this.width;
this.inner.style.width =
this.element.style.width = (this.width || 15) + 5 + "px";
this.setVisible(false);
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
this.height = renderer.$scrollbarWidth;
this.fullHeight = this.height;
this.inner.style.height =
this.element.style.height = (this.height || 15) + 5 + "px";
this.setVisible(false);
this.element.style.overflowX = "scroll";

View file

@ -48,6 +48,10 @@
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 {
border: 1px solid #424242
}

View file

@ -44,6 +44,10 @@
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 {
background: #393939
}

View file

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