Forráskód Böngészése

IDE: update CodeMirror and Smalltalk mode to v2.34

mkroehnert 12 éve
szülő
commit
43dceb32e6
3 módosított fájl, 893 hozzáadás és 410 törlés
  1. 119 13
      js/lib/CodeMirror/codemirror.css
  2. 640 268
      js/lib/CodeMirror/codemirror.js
  3. 134 129
      js/lib/CodeMirror/smalltalk.js

+ 119 - 13
js/lib/CodeMirror/codemirror.css

@@ -1,6 +1,11 @@
 .CodeMirror {
   line-height: 1em;
   font-family: monospace;
+
+  /* Necessary so the scrollbar can be absolutely positioned within the wrapper on Lion. */
+  position: relative;
+  /* This prevents unwanted scrollbars from showing up on the body and wrapper in IE. */
+  overflow: hidden;
 }
 
 .CodeMirror-scroll {
@@ -9,10 +14,41 @@
   /* This is needed to prevent an IE[67] bug where the scrolled content
      is visible outside of the scrolling box. */
   position: relative;
+  outline: none;
+}
+
+/* Vertical scrollbar */
+.CodeMirror-scrollbar {
+  position: absolute;
+  right: 0; top: 0;
+  overflow-x: hidden;
+  overflow-y: scroll;
+  z-index: 5;
+}
+.CodeMirror-scrollbar-inner {
+  /* This needs to have a nonzero width in order for the scrollbar to appear
+     in Firefox and IE9. */
+  width: 1px;
+}
+.CodeMirror-scrollbar.cm-sb-overlap {
+  /* Ensure that the scrollbar appears in Lion, and that it overlaps the content
+     rather than sitting to the right of it. */
+  position: absolute;
+  z-index: 1;
+  float: none;
+  right: 0;
+  min-width: 12px;
+}
+.CodeMirror-scrollbar.cm-sb-nonoverlap {
+  min-width: 12px;
+}
+.CodeMirror-scrollbar.cm-sb-ie7 {
+  min-width: 18px;
 }
 
 .CodeMirror-gutter {
   position: absolute; left: 0; top: 0;
+  z-index: 10;
   background-color: #f7f7f7;
   border-right: 1px solid #eee;
   min-width: 2em;
@@ -22,9 +58,13 @@
   color: #aaa;
   text-align: right;
   padding: .4em .2em .4em .4em;
+  white-space: pre !important;
+  cursor: default;
 }
 .CodeMirror-lines {
   padding: .4em;
+  white-space: pre;
+  cursor: text;
 }
 
 .CodeMirror pre {
@@ -38,30 +78,96 @@
   padding: 0; margin: 0;
   white-space: pre;
   word-wrap: normal;
+  line-height: inherit;
+  color: inherit;
+}
+
+.CodeMirror-wrap pre {
+  word-wrap: break-word;
+  white-space: pre-wrap;
+  word-break: normal;
+}
+.CodeMirror-wrap .CodeMirror-scroll {
+  overflow-x: hidden;
 }
 
 .CodeMirror textarea {
-  font-family: inherit !important;
-  font-size: inherit !important;
+  outline: none !important;
 }
 
-.CodeMirror-cursor {
+.CodeMirror pre.CodeMirror-cursor {
   z-index: 10;
   position: absolute;
   visibility: hidden;
-  border-left: 1px solid black !important;
+  border-left: 1px solid black;
+  border-right: none;
+  width: 0;
+}
+.cm-keymap-fat-cursor pre.CodeMirror-cursor {
+  width: auto;
+  border: 0;
+  background: transparent;
+  background: rgba(0, 200, 0, .4);
+  filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
 }
-.CodeMirror-focused .CodeMirror-cursor {
+/* Kludge to turn off filter in ie9+, which also accepts rgba */
+.cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
+  filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
+}
+.CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
+.CodeMirror-focused pre.CodeMirror-cursor {
   visibility: visible;
 }
 
-span.CodeMirror-selected {
-  background: #ccc !important;
-  color: HighlightText !important;
-}
-.CodeMirror-focused span.CodeMirror-selected {
-  background: Highlight !important;
+div.CodeMirror-selected { background: #d9d9d9; }
+.CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
+
+.CodeMirror-searching {
+  background: #ffa;
+  background: rgba(255, 255, 0, .4);
 }
 
-.CodeMirror-matchingbracket {color: #0f0 !important;}
-.CodeMirror-nonmatchingbracket {color: #f22 !important;}
+/* Default theme */
+
+.cm-s-default span.cm-keyword {color: #708;}
+.cm-s-default span.cm-atom {color: #219;}
+.cm-s-default span.cm-number {color: #164;}
+.cm-s-default span.cm-def {color: #00f;}
+.cm-s-default span.cm-variable {color: black;}
+.cm-s-default span.cm-variable-2 {color: #05a;}
+.cm-s-default span.cm-variable-3 {color: #085;}
+.cm-s-default span.cm-property {color: black;}
+.cm-s-default span.cm-operator {color: black;}
+.cm-s-default span.cm-comment {color: #a50;}
+.cm-s-default span.cm-string {color: #a11;}
+.cm-s-default span.cm-string-2 {color: #f50;}
+.cm-s-default span.cm-meta {color: #555;}
+.cm-s-default span.cm-error {color: #f00;}
+.cm-s-default span.cm-qualifier {color: #555;}
+.cm-s-default span.cm-builtin {color: #30a;}
+.cm-s-default span.cm-bracket {color: #997;}
+.cm-s-default span.cm-tag {color: #170;}
+.cm-s-default span.cm-attribute {color: #00c;}
+.cm-s-default span.cm-header {color: blue;}
+.cm-s-default span.cm-quote {color: #090;}
+.cm-s-default span.cm-hr {color: #999;}
+.cm-s-default span.cm-link {color: #00c;}
+
+span.cm-header, span.cm-strong {font-weight: bold;}
+span.cm-em {font-style: italic;}
+span.cm-emstrong {font-style: italic; font-weight: bold;}
+span.cm-link {text-decoration: underline;}
+
+span.cm-invalidchar {color: #f00;}
+
+div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
+div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
+
+@media print {
+
+  /* Hide the cursor when printing */
+  .CodeMirror pre.CodeMirror-cursor {
+    visibility: hidden;
+  }
+
+}

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 640 - 268
js/lib/CodeMirror/codemirror.js


+ 134 - 129
js/lib/CodeMirror/smalltalk.js

@@ -1,134 +1,139 @@
-CodeMirror.defineMode("smalltalk", function(config, parserConfig) {
-    var keywords = {"true": 1, "false": 1, nil: 1, self: 1, "super": 1, thisContext: 1};
-    var indentUnit = config.indentUnit;
-
-    function chain(stream, state, f) {
-	state.tokenize = f;
-	return f(stream, state);
-    }
-
-    var type;
-    function ret(tp, style) {
-	type = tp;
-	return style;
-    }
-
-    function tokenBase(stream, state) {
-	var ch = stream.next();
-	if (ch == '"')
-	    return chain(stream, state, tokenComment(ch));
-	else if (ch == "'")
-	    return chain(stream, state, tokenString(ch));
-	else if (ch == "#") {
-	    stream.eatWhile(/[\w\$_]/);
-	    return ret("string", "string");
-	}
-	else if(ch == "^") {
-	    return ret("return", "return");
-	}
-	else if(/[A-Z]/.test(ch)) {
-	    stream.eatWhile(/[^\s]/);
-	    return ret("className", "className");
-	}
-	else if (/\d/.test(ch)) {
-	    stream.eatWhile(/[\w\.]/);
-	    return ret("number", "number");
-	}
-	else if (/[\[\]()]/.test(ch)) {
-	    return ret(ch, null);
-	}
-	else {
-	    if(ch == ":") {
-		if(stream.eat("=")) {
-		    return ret("assignment", "assignment");
+CodeMirror.defineMode('smalltalk', function(config, modeConfig) {
+
+	var specialChars = /[+\-/\\*~<>=@%|&?!.:;^]/;
+	var keywords = /true|false|nil|self|super|thisContext/;
+
+	var Context = function(tokenizer, parent) {
+		this.next = tokenizer;
+		this.parent = parent;
+	};
+
+	var Token = function(name, context, eos) {
+		this.name = name;
+		this.context = context;
+		this.eos = eos;
+	};
+
+	var State = function() {
+		this.context = new Context(next, null);
+		this.expectVariable = true;
+		this.indentation = 0;
+		this.userIndentationDelta = 0;
+	};
+
+	State.prototype.userIndent = function(indentation) {
+		this.userIndentationDelta = indentation > 0 ? (indentation / config.indentUnit - this.indentation) : 0;
+	};
+
+	var next = function(stream, context, state) {
+		var token = new Token(null, context, false);
+		var aChar = stream.next();
+
+		if (aChar === '"') {
+			token = nextComment(stream, new Context(nextComment, context));
+
+		} else if (aChar === '\'') {
+			token = nextString(stream, new Context(nextString, context));
+
+		} else if (aChar === '#') {
+			stream.eatWhile(/[^ .]/);
+			token.name = 'string-2';
+
+		} else if (aChar === '$') {
+			stream.eatWhile(/[^ ]/);
+			token.name = 'string-2';
+
+		} else if (aChar === '|' && state.expectVariable) {
+			token.context = new Context(nextTemporaries, context);
+
+		} else if (/[\[\]{}()]/.test(aChar)) {
+			token.name = 'bracket';
+			token.eos = /[\[{(]/.test(aChar);
+
+			if (aChar === '[') {
+				state.indentation++;
+			} else if (aChar === ']') {
+				state.indentation = Math.max(0, state.indentation - 1);
+			}
+
+		} else if (specialChars.test(aChar)) {
+			stream.eatWhile(specialChars);
+			token.name = 'operator';
+			token.eos = aChar !== ';'; // ; cascaded message expression
+
+		} else if (/\d/.test(aChar)) {
+			stream.eatWhile(/[\w\d]/);
+			token.name = 'number';
+
+		} else if (/[\w_]/.test(aChar)) {
+			stream.eatWhile(/[\w\d_]/);
+			token.name = state.expectVariable ? (keywords.test(stream.current()) ? 'keyword' : 'variable') : null;
+
+		} else {
+			token.eos = state.expectVariable;
 		}
-	    }
-	    stream.eatWhile(/[\w\$_]/);
-	    if (keywords && keywords.propertyIsEnumerable(stream.current())) return ret("keyword", "keyword");
-	    return ret("operator", "operator");
-	}
-    }
-
-    function tokenString(quote) {
-	return function(stream, state) {
-	    var escaped = false, next, end = false;
-	    while ((next = stream.next()) != null) {
-		if (next == quote && !escaped) {end = true; break;}
-		escaped = !escaped && next == "\\";
-	    }
-	    if (end || !(escaped))
-		state.tokenize = tokenBase;
-	    return ret("string", "string");
+
+		return token;
+	};
+
+	var nextComment = function(stream, context) {
+		stream.eatWhile(/[^"]/);
+		return new Token('comment', stream.eat('"') ? context.parent : context, true);
+	};
+
+	var nextString = function(stream, context) {
+		stream.eatWhile(/[^']/);
+		return new Token('string', stream.eat('\'') ? context.parent : context, false);
+	};
+
+	var nextTemporaries = function(stream, context, state) {
+		var token = new Token(null, context, false);
+		var aChar = stream.next();
+
+		if (aChar === '|') {
+			token.context = context.parent;
+			token.eos = true;
+
+		} else {
+			stream.eatWhile(/[^|]/);
+			token.name = 'variable';
+		}
+
+		return token;
 	};
-    }
-
-    function tokenComment(quote) {
-	return function(stream, state) {
-	    var next, end = false;
-	    while ((next = stream.next()) != null) {
-		if (next == quote) {end = true; break;}
-	    }
-	    if (end)
-		state.tokenize = tokenBase;
-	    return ret("comment", "comment");
+
+	return {
+		startState: function() {
+			return new State;
+		},
+
+		token: function(stream, state) {
+			state.userIndent(stream.indentation());
+
+			if (stream.eatSpace()) {
+				return null;
+			}
+
+			var token = state.context.next(stream, state.context, state);
+			state.context = token.context;
+			state.expectVariable = token.eos;
+
+			state.lastToken = token;
+			return token.name;
+		},
+
+		blankLine: function(state) {
+			state.userIndent(0);
+		},
+
+		indent: function(state, textAfter) {
+			var i = state.context.next === next && textAfter && textAfter.charAt(0) === ']' ? -1 : state.userIndentationDelta;
+			return (state.indentation + i) * config.indentUnit;
+		},
+
+		electricChars: ']'
 	};
-    }
-
-    function Context(indented, column, type, align, prev) {
-	this.indented = indented;
-	this.column = column;
-	this.type = type;
-	this.align = align;
-	this.prev = prev;
-    }
-
-    function pushContext(state, col, type) {
-	return state.context = new Context(state.indented, col, type, null, state.context);
-    }
-    function popContext(state) {
-	return state.context = state.context.prev;
-    }
-
-    // Interface
-
-    return {
-	startState: function(basecolumn) {
-	    return {
-		tokenize: tokenBase,
-		context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
-		indented: 0,
-		startOfLine: true
-	    };
-	},
-
-	token: function(stream, state) {
-	    var ctx = state.context;
-	    if (stream.sol()) {
-		if (ctx.align == null) ctx.align = false;
-		state.indented = stream.indentation();
-		state.startOfLine = true;
-	    }
-	    if (stream.eatSpace()) return null;
-	    var style = state.tokenize(stream, state);
-	    if (type == "comment") return style;
-	    if (ctx.align == null) ctx.align = true;
-
-	    if (type == "[") pushContext(state, stream.column(), "]");
-	    else if (type == "(") pushContext(state, stream.column(), ")");
-	    else if (type == ctx.type) popContext(state);
-	    state.startOfLine = false;
-	    return style;
-	},
-
-	indent: function(state, textAfter) {
-	    if (state.tokenize != tokenBase) return 0;
-	    var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
-	    if (ctx.align) return ctx.column + (closing ? 0 : 1);
-	    else return ctx.indented + (closing ? 0 : indentUnit);
-	},
-
-	electricChars: "]"
-    };
+
 });
 
-CodeMirror.defineMIME("text/x-stsrc", {name: "smalltalk"});
+CodeMirror.defineMIME('text/x-stsrc', {name: 'smalltalk'});

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott