commit
650cf8e5af
7 changed files with 41 additions and 18 deletions
|
|
@ -88,8 +88,6 @@ split.on("focus", function(editor) {
|
||||||
});
|
});
|
||||||
env.split = split;
|
env.split = split;
|
||||||
window.env = env;
|
window.env = env;
|
||||||
window.ace = env.editor;
|
|
||||||
env.editor.setAnimatedScroll(true);
|
|
||||||
|
|
||||||
// add multiple cursor support to editor
|
// add multiple cursor support to editor
|
||||||
require("ace/multi_select").MultiSelect(env.editor);
|
require("ace/multi_select").MultiSelect(env.editor);
|
||||||
|
|
@ -617,3 +615,13 @@ env.editor.setOptions({
|
||||||
})
|
})
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// allow easy access to ace in console, but not in ace code which uses strict
|
||||||
|
function isNonStrict() {
|
||||||
|
try { return !!arguments.callee.caller.caller }
|
||||||
|
catch(e){ return false }
|
||||||
|
}
|
||||||
|
window.__defineGetter__("ace", function(){ return isNonStrict() && env.editor });
|
||||||
|
window.__defineGetter__("editor", function(){ return isNonStrict() && env.editor });
|
||||||
|
window.__defineGetter__("session", function(){ return isNonStrict() && env.editor.session });
|
||||||
|
window.__defineGetter__("split", function(){ return isNonStrict() && env.split });
|
||||||
|
|
|
||||||
|
|
@ -206,9 +206,12 @@ var AcePopup = function(parentNode) {
|
||||||
};
|
};
|
||||||
popup.show = function(pos, lineHeight) {
|
popup.show = function(pos, lineHeight) {
|
||||||
var el = this.container;
|
var el = this.container;
|
||||||
if (pos.top > window.innerHeight / 2 + lineHeight) {
|
var screenHeight = window.innerHeight;
|
||||||
|
var renderer = this.renderer;
|
||||||
|
var maxH = renderer.$maxLines * lineHeight;
|
||||||
|
if (pos.top +maxH > screenHeight - lineHeight) {
|
||||||
el.style.top = "";
|
el.style.top = "";
|
||||||
el.style.bottom = window.innerHeight - pos.top + "px";
|
el.style.bottom = screenHeight - pos.top + "px";
|
||||||
} else {
|
} else {
|
||||||
pos.top += lineHeight;
|
pos.top += lineHeight;
|
||||||
el.style.top = pos.top + "px";
|
el.style.top = pos.top + "px";
|
||||||
|
|
|
||||||
|
|
@ -885,9 +885,11 @@ var EditSession = function(text, mode) {
|
||||||
if (!this.$modes["ace/mode/text"])
|
if (!this.$modes["ace/mode/text"])
|
||||||
this.$modes["ace/mode/text"] = new TextMode();
|
this.$modes["ace/mode/text"] = new TextMode();
|
||||||
|
|
||||||
if (this.$modes[path] && !options)
|
if (this.$modes[path] && !options) {
|
||||||
return this.$onChangeMode(this.$modes[path]);
|
this.$onChangeMode(this.$modes[path]);
|
||||||
|
cb && cb();
|
||||||
|
return;
|
||||||
|
}
|
||||||
// load on demand
|
// load on demand
|
||||||
this.$modeId = path;
|
this.$modeId = path;
|
||||||
config.loadModule(["mode", path], function(m) {
|
config.loadModule(["mode", path], function(m) {
|
||||||
|
|
@ -902,7 +904,7 @@ var EditSession = function(text, mode) {
|
||||||
m.$id = path;
|
m.$id = path;
|
||||||
}
|
}
|
||||||
this.$onChangeMode(m);
|
this.$onChangeMode(m);
|
||||||
cb && cb(this.mode);
|
cb && cb();
|
||||||
}
|
}
|
||||||
}.bind(this));
|
}.bind(this));
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,6 +212,11 @@ var TextHighlightRules = function() {
|
||||||
for (var i = list.length; i--; )
|
for (var i = list.length; i--; )
|
||||||
keywords[list[i]] = className;
|
keywords[list[i]] = className;
|
||||||
});
|
});
|
||||||
|
// in old versions of opera keywords["__proto__"] sets prototype
|
||||||
|
// even on objects with __proto__=null
|
||||||
|
if (Object.getPrototypeOf(keywords)) {
|
||||||
|
keywords.__proto__ = null;
|
||||||
|
}
|
||||||
this.$keywordList = Object.keys(keywords);
|
this.$keywordList = Object.keys(keywords);
|
||||||
map = null;
|
map = null;
|
||||||
return ignoreCase
|
return ignoreCase
|
||||||
|
|
|
||||||
|
|
@ -155,11 +155,13 @@ var SnippetManager = function() {
|
||||||
case "SELECTED_TEXT":
|
case "SELECTED_TEXT":
|
||||||
return s.getTextRange(r);
|
return s.getTextRange(r);
|
||||||
case "CURRENT_LINE":
|
case "CURRENT_LINE":
|
||||||
return s.getLine(e.getCursorPosition().row);
|
return s.getLine(editor.getCursorPosition().row);
|
||||||
|
case "PREV_LINE": // not possible in textmate
|
||||||
|
return s.getLine(editor.getCursorPosition().row - 1);
|
||||||
case "LINE_INDEX":
|
case "LINE_INDEX":
|
||||||
return e.getCursorPosition().column;
|
return editor.getCursorPosition().column;
|
||||||
case "LINE_NUMBER":
|
case "LINE_NUMBER":
|
||||||
return e.getCursorPosition().row + 1;
|
return editor.getCursorPosition().row + 1;
|
||||||
case "SOFT_TABS":
|
case "SOFT_TABS":
|
||||||
return s.getUseSoftTabs() ? "YES" : "NO";
|
return s.getUseSoftTabs() ? "YES" : "NO";
|
||||||
case "TAB_SIZE":
|
case "TAB_SIZE":
|
||||||
|
|
|
||||||
|
|
@ -23,14 +23,15 @@ snippet ![:*
|
||||||
![${1:id}]: ${2:`@*`} "${3:title}"
|
![${1:id}]: ${2:`@*`} "${3:title}"
|
||||||
|
|
||||||
snippet ===
|
snippet ===
|
||||||
`repeat('=', strlen(getline(line(".") - 1)))`
|
regex /^/=+/=*//
|
||||||
|
${PREV_LINE/./=/g}
|
||||||
|
|
||||||
${1}
|
${0}
|
||||||
snippet ---
|
snippet ---
|
||||||
`repeat('-', strlen(getline(line(".") - 1)))`
|
regex /^/-+/-*//
|
||||||
|
${PREV_LINE/./-/g}
|
||||||
|
|
||||||
${1}
|
${0}
|
||||||
|
|
||||||
snippet blockquote
|
snippet blockquote
|
||||||
{% blockquote %}
|
{% blockquote %}
|
||||||
${1:quote}
|
${1:quote}
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@ define(function(require, exports, module) {
|
||||||
// tokenizing lines longer than this makes editor very slow
|
// tokenizing lines longer than this makes editor very slow
|
||||||
var MAX_TOKEN_COUNT = 1000;
|
var MAX_TOKEN_COUNT = 1000;
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
*
|
|
||||||
* This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter).
|
* This class takes a set of highlighting rules, and creates a tokenizer out of them. For more information, see [the wiki on extending highlighters](https://github.com/ajaxorg/ace/wiki/Creating-or-Extending-an-Edit-Mode#wiki-extendingTheHighlighter).
|
||||||
* @class Tokenizer
|
* @class Tokenizer
|
||||||
**/
|
**/
|
||||||
|
|
@ -128,6 +126,10 @@ var Tokenizer = function(rules) {
|
||||||
};
|
};
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
this.$setMaxTokenCount = function(m) {
|
||||||
|
MAX_TOKEN_COUNT = m | 0;
|
||||||
|
};
|
||||||
|
|
||||||
this.$applyToken = function(str) {
|
this.$applyToken = function(str) {
|
||||||
var values = this.splitRegex.exec(str).slice(1);
|
var values = this.splitRegex.exec(str).slice(1);
|
||||||
var types = this.token.apply(this, values);
|
var types = this.token.apply(this, values);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue