diff --git a/demo/kitchen-sink/docs/matlab.matlab b/demo/kitchen-sink/docs/matlab.matlab index 30404ce4..b2ca44d5 100644 --- a/demo/kitchen-sink/docs/matlab.matlab +++ b/demo/kitchen-sink/docs/matlab.matlab @@ -1 +1,17 @@ -TODO \ No newline at end of file +%{ + %{ + Ace Matlab demo + %} +%} + +classdef hello + methods + function greet(this) + disp('Hello!') % say hi + end + end +end + +% transpose +a = [ 'x''y', "x\n\ + y", 1' ]' + 2' \ No newline at end of file diff --git a/demo/kitchen-sink/styles.css b/demo/kitchen-sink/styles.css index 7db52e45..3f46f701 100644 --- a/demo/kitchen-sink/styles.css +++ b/demo/kitchen-sink/styles.css @@ -46,4 +46,10 @@ body { position: absolute; right: 0; border-left: 1px solid; -} \ No newline at end of file +} + +/* .ace_text-input { + z-index: 10!important; + opacity: 1!important; + background: rgb(84, 0, 255)!important; +}*/ diff --git a/doc/site/js/main.js b/doc/site/js/main.js index 514fad42..92ce6e08 100644 --- a/doc/site/js/main.js +++ b/doc/site/js/main.js @@ -171,7 +171,11 @@ function highlight() { var highlighter = ace.require("ace/ext/static_highlight") var dom = ace.require("ace/lib/dom") function qsa(sel) { - return Array.apply(null, document.querySelectorAll(sel)); + var els = document.querySelectorAll(sel); + var result = []; + for (var i = 0, l = els.length; i < l; i++) + result[i] = els[i]; + return result; } qsa("code[class]").forEach(function(el) { diff --git a/lib/ace/autocomplete.js b/lib/ace/autocomplete.js index d5724441..78015bd4 100644 --- a/lib/ace/autocomplete.js +++ b/lib/ace/autocomplete.js @@ -89,6 +89,8 @@ var Autocomplete = function() { pos.left += renderer.$gutterLayer.gutterWidth; this.popup.show(pos, lineHeight); + } else if (keepPopupPosition && !prefix) { + this.detach(); } }; @@ -206,7 +208,8 @@ var Autocomplete = function() { var prefix = util.retrievePrecedingIdentifier(line, pos.column); this.base = session.doc.createAnchor(pos.row, pos.column - prefix.length); - + this.base.$insertRight = true; + var matches = []; var total = editor.completers.length; editor.completers.forEach(function(completer, i) { @@ -297,7 +300,7 @@ var Autocomplete = function() { return detachIfFinished(); // Autoinsert if one result - if (this.autoInsert && filtered.length == 1) + if (this.autoInsert && filtered.length == 1 && results.finished) return this.insertMatch(filtered[0]); this.openPopup(this.editor, prefix, keepPopupPosition); diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index f563579d..71cda95c 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -969,8 +969,10 @@ var EditSession = function(text, mode) { try { this.$worker = this.$mode.createWorker(this); } catch (e) { - console.log("Could not load worker"); - console.log(e); + if (typeof console == "object") { + console.log("Could not load worker"); + console.log(e); + } this.$worker = null; } }; @@ -1958,6 +1960,8 @@ var EditSession = function(text, mode) { split = lastSplit + wrapLimit; // The split is inside of a CHAR or CHAR_EXT token and no space // around -> force a split. + if (tokens[split] == CHAR_EXT) + split--; addSplit(split); } return splits; diff --git a/lib/ace/keyboard/textinput.js b/lib/ace/keyboard/textinput.js index e4e8f2a9..d2293024 100644 --- a/lib/ace/keyboard/textinput.js +++ b/lib/ace/keyboard/textinput.js @@ -51,6 +51,7 @@ var TextInput = function(parentNode, host) { text.spellcheck = false; text.style.opacity = "0"; + if (useragent.isOldIE) text.style.top = "-100px"; parentNode.insertBefore(text, parentNode.firstChild); var PLACEHOLDER = "\x01\x01"; @@ -436,6 +437,8 @@ var TextInput = function(parentNode, host) { }; this.moveToMouse = function(e, bringToFront) { + if (!bringToFront && useragent.isOldIE) + return; if (!tempStyle) tempStyle = text.style.cssText; text.style.cssText = (bringToFront ? "z-index:100000;" : "") @@ -460,13 +463,15 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = null; // on windows context menu is opened after mouseup - if (useragent.isWin) + if (useragent.isWin && !useragent.isOldIE) event.capture(host.container, move, onContextMenuClose); }; this.onContextMenuClose = onContextMenuClose; + var closeTimeout; function onContextMenuClose() { - setTimeout(function () { + clearTimeout(closeTimeout) + closeTimeout = setTimeout(function () { if (tempStyle) { text.style.cssText = tempStyle; tempStyle = ''; @@ -475,7 +480,7 @@ var TextInput = function(parentNode, host) { host.renderer.$keepTextAreaAtCursor = true; host.renderer.$moveTextAreaToCursor(); } - }, 0); + }, useragent.isOldIE ? 200 : 0); } var onContextMenu = function(e) { diff --git a/lib/ace/layer/text.js b/lib/ace/layer/text.js index 7c3aa053..aeb74f1c 100644 --- a/lib/ace/layer/text.js +++ b/lib/ace/layer/text.js @@ -322,7 +322,7 @@ var Text = function(parentEl) { this.$renderToken = function(stringBuilder, screenColumn, token, value) { var self = this; - var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; + var replaceReg = /\t|&|<|( +)|([\x00-\x1f\x80-\xa0\xad\u1680\u180E\u2000-\u200f\u2028\u2029\u202F\u205F\u3000\uFEFF])|[\u1100-\u115F\u11A3-\u11A7\u11FA-\u11FF\u2329-\u232A\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u2FF0-\u2FFB\u3000-\u303E\u3041-\u3096\u3099-\u30FF\u3105-\u312D\u3131-\u318E\u3190-\u31BA\u31C0-\u31E3\u31F0-\u321E\u3220-\u3247\u3250-\u32FE\u3300-\u4DBF\u4E00-\uA48C\uA490-\uA4C6\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFAFF\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE66\uFE68-\uFE6B\uFF01-\uFF60\uFFE0-\uFFE6]/g; var replaceFunc = function(c, a, b, tabIdx, idx4) { if (a) { return self.showInvisibles ? diff --git a/lib/ace/lib/keys.js b/lib/ace/lib/keys.js index e708a5d4..e75a6e47 100644 --- a/lib/ace/lib/keys.js +++ b/lib/ace/lib/keys.js @@ -34,6 +34,8 @@ For more information about SproutCore, visit http://www.sproutcore.com define(function(require, exports, module) { "use strict"; +require("./fixoldbrowsers"); + var oop = require("./oop"); /* @@ -136,7 +138,7 @@ var Keys = (function() { (function() { var mods = ["cmd", "ctrl", "alt", "shift"]; - for (var i = Math.pow(2, mods.length); i--;) { + for (var i = Math.pow(2, mods.length); i--;) { ret.KEY_MODS[i] = mods.filter(function(x) { return i & ret.KEY_MODS[x]; }).join("-") + "-"; diff --git a/lib/ace/mode/matlab_highlight_rules.js b/lib/ace/mode/matlab_highlight_rules.js index 14474e2c..ee0e1ca8 100644 --- a/lib/ace/mode/matlab_highlight_rules.js +++ b/lib/ace/mode/matlab_highlight_rules.js @@ -164,15 +164,53 @@ var keywords = ( }, "identifier", true); this.$rules = { - "start" : [ { + // allowQstring + start: [{ + token : "string", + regex : "'", + stateName : "qstring", + next : [{ + token : "constant.language.escape", + regex : "''" + }, { + token : "string", + regex : "'|$", + next : "start" + }, { + defaultToken: "string" + }] + }, { + token : "text", + regex : "\\s+" + }, { + regex: "", + next: "noQstring" + }], + noQstring : [{ + regex: "^\\s*%{\\s*$", + token: "comment.start", + push: "blockComment" + }, { token : "comment", regex : "%[^\r\n]*" }, { - token : "string", // " string - regex : '".*?"' - }, { - token : "string", // ' string - regex : "'.*?'" + token : "string", + regex : '"', + stateName : "qqstring", + next : [{ + token : "constant.language.escape", + regex : /\\./ + }, { + token : "string", + regex : "\\\\$", + next : "qqstring" + }, { + token : "string", + regex : '"|$', + next : "start" + }, { + defaultToken: "string" + }] }, { token : "constant.numeric", // float regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b" @@ -181,21 +219,41 @@ var keywords = ( regex : "[a-zA-Z_$][a-zA-Z0-9_$]*\\b" }, { token : "keyword.operator", - regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=" + regex : "\\+|\\-|\\/|\\/\\/|<@>|@>|<@|&|\\^|~|<|>|<=|=>|==|!=|<>|=", + next: "start" }, { - token : "punctuation.operator", - regex : "\\?|\\:|\\,|\\;|\\." + token : "punctuation.operator", + regex : "\\?|\\:|\\,|\\;|\\.", + next: "start" }, { token : "paren.lparen", - regex : "[\\(]" + regex : "[({\\[]", + next: "start" }, { token : "paren.rparen", - regex : "[\\)]" + regex : "[\\]})]" }, { token : "text", regex : "\\s+" - } ] + }, { + token : "text", + regex : "$", + next : "start" + }], + blockComment: [{ + regex: "^\\s*%{\\s*$", + token: "comment.start", + push: "blockComment" + }, { + regex: "^\\s*%}\\s*$", + token: "comment.end", + next: "pop" + }, { + defaultToken: "comment" + }], }; + + this.normalizeRules(); }; oop.inherits(MatlabHighlightRules, TextHighlightRules);