couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ryanram...@apache.org
Subject [05/51] [partial] Restructure to simpler jam/erica style.
Date Sat, 11 May 2013 05:48:18 GMT
http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/commonlisp/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/commonlisp/index.html b/src/fauxton/jam/codemirror/mode/commonlisp/index.html
new file mode 100644
index 0000000..f9766a8
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/commonlisp/index.html
@@ -0,0 +1,165 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>CodeMirror: Common Lisp mode</title>
+    <link rel="stylesheet" href="../../lib/codemirror.css">
+    <script src="../../lib/codemirror.js"></script>
+    <script src="commonlisp.js"></script>
+    <style>.CodeMirror {background: #f8f8f8;}</style>
+    <link rel="stylesheet" href="../../doc/docs.css">
+  </head>
+  <body>
+    <h1>CodeMirror: Common Lisp mode</h1>
+    <form><textarea id="code" name="code">(in-package :cl-postgres)
+
+;; These are used to synthesize reader and writer names for integer
+;; reading/writing functions when the amount of bytes and the
+;; signedness is known. Both the macro that creates the functions and
+;; some macros that use them create names this way.
+(eval-when (:compile-toplevel :load-toplevel :execute)
+  (defun integer-reader-name (bytes signed)
+    (intern (with-standard-io-syntax
+              (format nil "~a~a~a~a" '#:read- (if signed "" '#:u) '#:int bytes))))
+  (defun integer-writer-name (bytes signed)
+    (intern (with-standard-io-syntax
+              (format nil "~a~a~a~a" '#:write- (if signed "" '#:u) '#:int bytes)))))
+
+(defmacro integer-reader (bytes)
+  "Create a function to read integers from a binary stream."
+  (let ((bits (* bytes 8)))
+    (labels ((return-form (signed)
+               (if signed
+                   `(if (logbitp ,(1- bits) result)
+                        (dpb result (byte ,(1- bits) 0) -1)
+                        result)
+                   `result))
+             (generate-reader (signed)
+               `(defun ,(integer-reader-name bytes signed) (socket)
+                  (declare (type stream socket)
+                           #.*optimize*)
+                  ,(if (= bytes 1)
+                       `(let ((result (the (unsigned-byte 8) (read-byte socket))))
+                          (declare (type (unsigned-byte 8) result))
+                          ,(return-form signed))
+                       `(let ((result 0))
+                          (declare (type (unsigned-byte ,bits) result))
+                          ,@(loop :for byte :from (1- bytes) :downto 0
+                                   :collect `(setf (ldb (byte 8 ,(* 8 byte)) result)
+                                                   (the (unsigned-byte 8) (read-byte socket))))
+                          ,(return-form signed))))))
+      `(progn
+;; This causes weird errors on SBCL in some circumstances. Disabled for now.
+;;         (declaim (inline ,(integer-reader-name bytes t)
+;;                          ,(integer-reader-name bytes nil)))
+         (declaim (ftype (function (t) (signed-byte ,bits))
+                         ,(integer-reader-name bytes t)))
+         ,(generate-reader t)
+         (declaim (ftype (function (t) (unsigned-byte ,bits))
+                         ,(integer-reader-name bytes nil)))
+         ,(generate-reader nil)))))
+
+(defmacro integer-writer (bytes)
+  "Create a function to write integers to a binary stream."
+  (let ((bits (* 8 bytes)))
+    `(progn
+      (declaim (inline ,(integer-writer-name bytes t)
+                       ,(integer-writer-name bytes nil)))
+      (defun ,(integer-writer-name bytes nil) (socket value)
+        (declare (type stream socket)
+                 (type (unsigned-byte ,bits) value)
+                 #.*optimize*)
+        ,@(if (= bytes 1)
+              `((write-byte value socket))
+              (loop :for byte :from (1- bytes) :downto 0
+                    :collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
+                               socket)))
+        (values))
+      (defun ,(integer-writer-name bytes t) (socket value)
+        (declare (type stream socket)
+                 (type (signed-byte ,bits) value)
+                 #.*optimize*)
+        ,@(if (= bytes 1)
+              `((write-byte (ldb (byte 8 0) value) socket))
+              (loop :for byte :from (1- bytes) :downto 0
+                    :collect `(write-byte (ldb (byte 8 ,(* byte 8)) value)
+                               socket)))
+        (values)))))
+
+;; All the instances of the above that we need.
+
+(integer-reader 1)
+(integer-reader 2)
+(integer-reader 4)
+(integer-reader 8)
+
+(integer-writer 1)
+(integer-writer 2)
+(integer-writer 4)
+
+(defun write-bytes (socket bytes)
+  "Write a byte-array to a stream."
+  (declare (type stream socket)
+           (type (simple-array (unsigned-byte 8)) bytes)
+           #.*optimize*)
+  (write-sequence bytes socket))
+
+(defun write-str (socket string)
+  "Write a null-terminated string to a stream \(encoding it when UTF-8
+support is enabled.)."
+  (declare (type stream socket)
+           (type string string)
+           #.*optimize*)
+  (enc-write-string string socket)
+  (write-uint1 socket 0))
+
+(declaim (ftype (function (t unsigned-byte)
+                          (simple-array (unsigned-byte 8) (*)))
+                read-bytes))
+(defun read-bytes (socket length)
+  "Read a byte array of the given length from a stream."
+  (declare (type stream socket)
+           (type fixnum length)
+           #.*optimize*)
+  (let ((result (make-array length :element-type '(unsigned-byte 8))))
+    (read-sequence result socket)
+    result))
+
+(declaim (ftype (function (t) string) read-str))
+(defun read-str (socket)
+  "Read a null-terminated string from a stream. Takes care of encoding
+when UTF-8 support is enabled."
+  (declare (type stream socket)
+           #.*optimize*)
+  (enc-read-string socket :null-terminated t))
+
+(defun skip-bytes (socket length)
+  "Skip a given number of bytes in a binary stream."
+  (declare (type stream socket)
+           (type (unsigned-byte 32) length)
+           #.*optimize*)
+  (dotimes (i length)
+    (read-byte socket)))
+
+(defun skip-str (socket)
+  "Skip a null-terminated string."
+  (declare (type stream socket)
+           #.*optimize*)
+  (loop :for char :of-type fixnum = (read-byte socket)
+        :until (zerop char)))
+
+(defun ensure-socket-is-closed (socket &amp;key abort)
+  (when (open-stream-p socket)
+    (handler-case
+        (close socket :abort abort)
+      (error (error)
+        (warn "Ignoring the error which happened while trying to close PostgreSQL socket: ~A" error)))))
+</textarea></form>
+    <script>
+      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {lineNumbers: true});
+    </script>
+
+    <p><strong>MIME types defined:</strong> <code>text/x-common-lisp</code>.</p>
+
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/css/css.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/css/css.js b/src/fauxton/jam/codemirror/mode/css/css.js
new file mode 100644
index 0000000..87d5d74
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/css/css.js
@@ -0,0 +1,448 @@
+CodeMirror.defineMode("css", function(config) {
+  var indentUnit = config.indentUnit, type;
+  
+  var atMediaTypes = keySet([
+    "all", "aural", "braille", "handheld", "print", "projection", "screen",
+    "tty", "tv", "embossed"
+  ]);
+  
+  var atMediaFeatures = keySet([
+    "width", "min-width", "max-width", "height", "min-height", "max-height",
+    "device-width", "min-device-width", "max-device-width", "device-height",
+    "min-device-height", "max-device-height", "aspect-ratio",
+    "min-aspect-ratio", "max-aspect-ratio", "device-aspect-ratio",
+    "min-device-aspect-ratio", "max-device-aspect-ratio", "color", "min-color",
+    "max-color", "color-index", "min-color-index", "max-color-index",
+    "monochrome", "min-monochrome", "max-monochrome", "resolution",
+    "min-resolution", "max-resolution", "scan", "grid"
+  ]);
+
+  var propertyKeywords = keySet([
+    "align-content", "align-items", "align-self", "alignment-adjust",
+    "alignment-baseline", "anchor-point", "animation", "animation-delay",
+    "animation-direction", "animation-duration", "animation-iteration-count",
+    "animation-name", "animation-play-state", "animation-timing-function",
+    "appearance", "azimuth", "backface-visibility", "background",
+    "background-attachment", "background-clip", "background-color",
+    "background-image", "background-origin", "background-position",
+    "background-repeat", "background-size", "baseline-shift", "binding",
+    "bleed", "bookmark-label", "bookmark-level", "bookmark-state",
+    "bookmark-target", "border", "border-bottom", "border-bottom-color",
+    "border-bottom-left-radius", "border-bottom-right-radius",
+    "border-bottom-style", "border-bottom-width", "border-collapse",
+    "border-color", "border-image", "border-image-outset",
+    "border-image-repeat", "border-image-slice", "border-image-source",
+    "border-image-width", "border-left", "border-left-color",
+    "border-left-style", "border-left-width", "border-radius", "border-right",
+    "border-right-color", "border-right-style", "border-right-width",
+    "border-spacing", "border-style", "border-top", "border-top-color",
+    "border-top-left-radius", "border-top-right-radius", "border-top-style",
+    "border-top-width", "border-width", "bottom", "box-decoration-break",
+    "box-shadow", "box-sizing", "break-after", "break-before", "break-inside",
+    "caption-side", "clear", "clip", "color", "color-profile", "column-count",
+    "column-fill", "column-gap", "column-rule", "column-rule-color",
+    "column-rule-style", "column-rule-width", "column-span", "column-width",
+    "columns", "content", "counter-increment", "counter-reset", "crop", "cue",
+    "cue-after", "cue-before", "cursor", "direction", "display",
+    "dominant-baseline", "drop-initial-after-adjust",
+    "drop-initial-after-align", "drop-initial-before-adjust",
+    "drop-initial-before-align", "drop-initial-size", "drop-initial-value",
+    "elevation", "empty-cells", "fit", "fit-position", "flex", "flex-basis",
+    "flex-direction", "flex-flow", "flex-grow", "flex-shrink", "flex-wrap",
+    "float", "float-offset", "font", "font-feature-settings", "font-family",
+    "font-kerning", "font-language-override", "font-size", "font-size-adjust",
+    "font-stretch", "font-style", "font-synthesis", "font-variant",
+    "font-variant-alternates", "font-variant-caps", "font-variant-east-asian",
+    "font-variant-ligatures", "font-variant-numeric", "font-variant-position",
+    "font-weight", "grid-cell", "grid-column", "grid-column-align",
+    "grid-column-sizing", "grid-column-span", "grid-columns", "grid-flow",
+    "grid-row", "grid-row-align", "grid-row-sizing", "grid-row-span",
+    "grid-rows", "grid-template", "hanging-punctuation", "height", "hyphens",
+    "icon", "image-orientation", "image-rendering", "image-resolution",
+    "inline-box-align", "justify-content", "left", "letter-spacing",
+    "line-break", "line-height", "line-stacking", "line-stacking-ruby",
+    "line-stacking-shift", "line-stacking-strategy", "list-style",
+    "list-style-image", "list-style-position", "list-style-type", "margin",
+    "margin-bottom", "margin-left", "margin-right", "margin-top",
+    "marker-offset", "marks", "marquee-direction", "marquee-loop",
+    "marquee-play-count", "marquee-speed", "marquee-style", "max-height",
+    "max-width", "min-height", "min-width", "move-to", "nav-down", "nav-index",
+    "nav-left", "nav-right", "nav-up", "opacity", "order", "orphans", "outline",
+    "outline-color", "outline-offset", "outline-style", "outline-width",
+    "overflow", "overflow-style", "overflow-wrap", "overflow-x", "overflow-y",
+    "padding", "padding-bottom", "padding-left", "padding-right", "padding-top",
+    "page", "page-break-after", "page-break-before", "page-break-inside",
+    "page-policy", "pause", "pause-after", "pause-before", "perspective",
+    "perspective-origin", "pitch", "pitch-range", "play-during", "position",
+    "presentation-level", "punctuation-trim", "quotes", "rendering-intent",
+    "resize", "rest", "rest-after", "rest-before", "richness", "right",
+    "rotation", "rotation-point", "ruby-align", "ruby-overhang",
+    "ruby-position", "ruby-span", "size", "speak", "speak-as", "speak-header",
+    "speak-numeral", "speak-punctuation", "speech-rate", "stress", "string-set",
+    "tab-size", "table-layout", "target", "target-name", "target-new",
+    "target-position", "text-align", "text-align-last", "text-decoration",
+    "text-decoration-color", "text-decoration-line", "text-decoration-skip",
+    "text-decoration-style", "text-emphasis", "text-emphasis-color",
+    "text-emphasis-position", "text-emphasis-style", "text-height",
+    "text-indent", "text-justify", "text-outline", "text-shadow",
+    "text-space-collapse", "text-transform", "text-underline-position",
+    "text-wrap", "top", "transform", "transform-origin", "transform-style",
+    "transition", "transition-delay", "transition-duration",
+    "transition-property", "transition-timing-function", "unicode-bidi",
+    "vertical-align", "visibility", "voice-balance", "voice-duration",
+    "voice-family", "voice-pitch", "voice-range", "voice-rate", "voice-stress",
+    "voice-volume", "volume", "white-space", "widows", "width", "word-break",
+    "word-spacing", "word-wrap", "z-index"
+  ]);
+
+  var colorKeywords = keySet([
+    "black", "silver", "gray", "white", "maroon", "red", "purple", "fuchsia",
+    "green", "lime", "olive", "yellow", "navy", "blue", "teal", "aqua"
+  ]);
+  
+  var valueKeywords = keySet([
+    "above", "absolute", "activeborder", "activecaption", "afar",
+    "after-white-space", "ahead", "alias", "all", "all-scroll", "alternate",
+    "always", "amharic", "amharic-abegede", "antialiased", "appworkspace",
+    "arabic-indic", "armenian", "asterisks", "auto", "avoid", "background",
+    "backwards", "baseline", "below", "bidi-override", "binary", "bengali",
+    "blink", "block", "block-axis", "bold", "bolder", "border", "border-box",
+    "both", "bottom", "break-all", "break-word", "button", "button-bevel",
+    "buttonface", "buttonhighlight", "buttonshadow", "buttontext", "cambodian",
+    "capitalize", "caps-lock-indicator", "caption", "captiontext", "caret",
+    "cell", "center", "checkbox", "circle", "cjk-earthly-branch",
+    "cjk-heavenly-stem", "cjk-ideographic", "clear", "clip", "close-quote",
+    "col-resize", "collapse", "compact", "condensed", "contain", "content",
+    "content-box", "context-menu", "continuous", "copy", "cover", "crop",
+    "cross", "crosshair", "currentcolor", "cursive", "dashed", "decimal",
+    "decimal-leading-zero", "default", "default-button", "destination-atop",
+    "destination-in", "destination-out", "destination-over", "devanagari",
+    "disc", "discard", "document", "dot-dash", "dot-dot-dash", "dotted",
+    "double", "down", "e-resize", "ease", "ease-in", "ease-in-out", "ease-out",
+    "element", "ellipsis", "embed", "end", "ethiopic", "ethiopic-abegede",
+    "ethiopic-abegede-am-et", "ethiopic-abegede-gez", "ethiopic-abegede-ti-er",
+    "ethiopic-abegede-ti-et", "ethiopic-halehame-aa-er",
+    "ethiopic-halehame-aa-et", "ethiopic-halehame-am-et",
+    "ethiopic-halehame-gez", "ethiopic-halehame-om-et",
+    "ethiopic-halehame-sid-et", "ethiopic-halehame-so-et",
+    "ethiopic-halehame-ti-er", "ethiopic-halehame-ti-et",
+    "ethiopic-halehame-tig", "ew-resize", "expanded", "extra-condensed",
+    "extra-expanded", "fantasy", "fast", "fill", "fixed", "flat", "footnotes",
+    "forwards", "from", "geometricPrecision", "georgian", "graytext", "groove",
+    "gujarati", "gurmukhi", "hand", "hangul", "hangul-consonant", "hebrew",
+    "help", "hidden", "hide", "higher", "highlight", "highlighttext",
+    "hiragana", "hiragana-iroha", "horizontal", "hsl", "hsla", "icon", "ignore",
+    "inactiveborder", "inactivecaption", "inactivecaptiontext", "infinite",
+    "infobackground", "infotext", "inherit", "initial", "inline", "inline-axis",
+    "inline-block", "inline-table", "inset", "inside", "intrinsic", "invert",
+    "italic", "justify", "kannada", "katakana", "katakana-iroha", "khmer",
+    "landscape", "lao", "large", "larger", "left", "level", "lighter",
+    "line-through", "linear", "lines", "list-item", "listbox", "listitem",
+    "local", "logical", "loud", "lower", "lower-alpha", "lower-armenian",
+    "lower-greek", "lower-hexadecimal", "lower-latin", "lower-norwegian",
+    "lower-roman", "lowercase", "ltr", "malayalam", "match",
+    "media-controls-background", "media-current-time-display",
+    "media-fullscreen-button", "media-mute-button", "media-play-button",
+    "media-return-to-realtime-button", "media-rewind-button",
+    "media-seek-back-button", "media-seek-forward-button", "media-slider",
+    "media-sliderthumb", "media-time-remaining-display", "media-volume-slider",
+    "media-volume-slider-container", "media-volume-sliderthumb", "medium",
+    "menu", "menulist", "menulist-button", "menulist-text",
+    "menulist-textfield", "menutext", "message-box", "middle", "min-intrinsic",
+    "mix", "mongolian", "monospace", "move", "multiple", "myanmar", "n-resize",
+    "narrower", "navy", "ne-resize", "nesw-resize", "no-close-quote", "no-drop",
+    "no-open-quote", "no-repeat", "none", "normal", "not-allowed", "nowrap",
+    "ns-resize", "nw-resize", "nwse-resize", "oblique", "octal", "open-quote",
+    "optimizeLegibility", "optimizeSpeed", "oriya", "oromo", "outset",
+    "outside", "overlay", "overline", "padding", "padding-box", "painted",
+    "paused", "persian", "plus-darker", "plus-lighter", "pointer", "portrait",
+    "pre", "pre-line", "pre-wrap", "preserve-3d", "progress", "push-button",
+    "radio", "read-only", "read-write", "read-write-plaintext-only", "relative",
+    "repeat", "repeat-x", "repeat-y", "reset", "reverse", "rgb", "rgba",
+    "ridge", "right", "round", "row-resize", "rtl", "run-in", "running",
+    "s-resize", "sans-serif", "scroll", "scrollbar", "se-resize", "searchfield",
+    "searchfield-cancel-button", "searchfield-decoration",
+    "searchfield-results-button", "searchfield-results-decoration",
+    "semi-condensed", "semi-expanded", "separate", "serif", "show", "sidama",
+    "single", "skip-white-space", "slide", "slider-horizontal",
+    "slider-vertical", "sliderthumb-horizontal", "sliderthumb-vertical", "slow",
+    "small", "small-caps", "small-caption", "smaller", "solid", "somali",
+    "source-atop", "source-in", "source-out", "source-over", "space", "square",
+    "square-button", "start", "static", "status-bar", "stretch", "stroke",
+    "sub", "subpixel-antialiased", "super", "sw-resize", "table",
+    "table-caption", "table-cell", "table-column", "table-column-group",
+    "table-footer-group", "table-header-group", "table-row", "table-row-group",
+    "telugu", "text", "text-bottom", "text-top", "textarea", "textfield", "thai",
+    "thick", "thin", "threeddarkshadow", "threedface", "threedhighlight",
+    "threedlightshadow", "threedshadow", "tibetan", "tigre", "tigrinya-er",
+    "tigrinya-er-abegede", "tigrinya-et", "tigrinya-et-abegede", "to", "top",
+    "transparent", "ultra-condensed", "ultra-expanded", "underline", "up",
+    "upper-alpha", "upper-armenian", "upper-greek", "upper-hexadecimal",
+    "upper-latin", "upper-norwegian", "upper-roman", "uppercase", "urdu", "url",
+    "vertical", "vertical-text", "visible", "visibleFill", "visiblePainted",
+    "visibleStroke", "visual", "w-resize", "wait", "wave", "white", "wider",
+    "window", "windowframe", "windowtext", "x-large", "x-small", "xor",
+    "xx-large", "xx-small", "yellow"
+  ]);
+
+  function keySet(array) { var keys = {}; for (var i = 0; i < array.length; ++i) keys[array[i]] = true; return keys; }
+  function ret(style, tp) {type = tp; return style;}
+
+  function tokenBase(stream, state) {
+    var ch = stream.next();
+    if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("def", stream.current());}
+    else if (ch == "/" && stream.eat("*")) {
+      state.tokenize = tokenCComment;
+      return tokenCComment(stream, state);
+    }
+    else if (ch == "<" && stream.eat("!")) {
+      state.tokenize = tokenSGMLComment;
+      return tokenSGMLComment(stream, state);
+    }
+    else if (ch == "=") ret(null, "compare");
+    else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
+    else if (ch == "\"" || ch == "'") {
+      state.tokenize = tokenString(ch);
+      return state.tokenize(stream, state);
+    }
+    else if (ch == "#") {
+      stream.eatWhile(/[\w\\\-]/);
+      return ret("atom", "hash");
+    }
+    else if (ch == "!") {
+      stream.match(/^\s*\w*/);
+      return ret("keyword", "important");
+    }
+    else if (/\d/.test(ch)) {
+      stream.eatWhile(/[\w.%]/);
+      return ret("number", "unit");
+    }
+    else if (ch === "-") {
+      if (/\d/.test(stream.peek())) {
+        stream.eatWhile(/[\w.%]/);
+        return ret("number", "unit");
+      } else if (stream.match(/^[^-]+-/)) {
+        return ret("meta", type);
+      }
+    }
+    else if (/[,+>*\/]/.test(ch)) {
+      return ret(null, "select-op");
+    }
+    else if (ch == "." && stream.match(/^-?[_a-z][_a-z0-9-]*/i)) {
+      return ret("qualifier", type);
+    }
+    else if (ch == ":") {
+      return ret("operator", ch);
+    }
+    else if (/[;{}\[\]\(\)]/.test(ch)) {
+      return ret(null, ch);
+    }
+    else {
+      stream.eatWhile(/[\w\\\-]/);
+      return ret("property", "variable");
+    }
+  }
+
+  function tokenCComment(stream, state) {
+    var maybeEnd = false, ch;
+    while ((ch = stream.next()) != null) {
+      if (maybeEnd && ch == "/") {
+        state.tokenize = tokenBase;
+        break;
+      }
+      maybeEnd = (ch == "*");
+    }
+    return ret("comment", "comment");
+  }
+
+  function tokenSGMLComment(stream, state) {
+    var dashes = 0, ch;
+    while ((ch = stream.next()) != null) {
+      if (dashes >= 2 && ch == ">") {
+        state.tokenize = tokenBase;
+        break;
+      }
+      dashes = (ch == "-") ? dashes + 1 : 0;
+    }
+    return ret("comment", "comment");
+  }
+
+  function tokenString(quote) {
+    return function(stream, state) {
+      var escaped = false, ch;
+      while ((ch = stream.next()) != null) {
+        if (ch == quote && !escaped)
+          break;
+        escaped = !escaped && ch == "\\";
+      }
+      if (!escaped) state.tokenize = tokenBase;
+      return ret("string", "string");
+    };
+  }
+
+  return {
+    startState: function(base) {
+      return {tokenize: tokenBase,
+              baseIndent: base || 0,
+              stack: []};
+    },
+
+    token: function(stream, state) {
+      
+      // Use these terms when applicable (see http://www.xanthir.com/blog/b4E50)
+      // 
+      // rule** or **ruleset:
+      // A selector + braces combo, or an at-rule.
+      // 
+      // declaration block:
+      // A sequence of declarations.
+      // 
+      // declaration:
+      // A property + colon + value combo.
+      // 
+      // property value:
+      // The entire value of a property.
+      // 
+      // component value:
+      // A single piece of a property value. Like the 5px in
+      // text-shadow: 0 0 5px blue;. Can also refer to things that are
+      // multiple terms, like the 1-4 terms that make up the background-size
+      // portion of the background shorthand.
+      // 
+      // term:
+      // The basic unit of author-facing CSS, like a single number (5),
+      // dimension (5px), string ("foo"), or function. Officially defined
+      //  by the CSS 2.1 grammar (look for the 'term' production)
+      // 
+      // 
+      // simple selector:
+      // A single atomic selector, like a type selector, an attr selector, a
+      // class selector, etc.
+      // 
+      // compound selector:
+      // One or more simple selectors without a combinator. div.example is
+      // compound, div > .example is not.
+      // 
+      // complex selector:
+      // One or more compound selectors chained with combinators.
+      // 
+      // combinator:
+      // The parts of selectors that express relationships. There are four
+      // currently - the space (descendant combinator), the greater-than
+      // bracket (child combinator), the plus sign (next sibling combinator),
+      // and the tilda (following sibling combinator).
+      // 
+      // sequence of selectors:
+      // One or more of the named type of selector chained with commas.
+
+      if (stream.eatSpace()) return null;
+      var style = state.tokenize(stream, state);
+
+      // Changing style returned based on context
+      var context = state.stack[state.stack.length-1];
+      if (style == "property") {
+        if (context == "propertyValue"){
+          if (valueKeywords[stream.current()]) {
+            style = "string-2";
+          } else if (colorKeywords[stream.current()]) {
+            style = "keyword";
+          } else {
+            style = "variable-2";
+          }
+        } else if (context == "rule") {
+          if (!propertyKeywords[stream.current()]) {
+            style += " error";
+          }
+        } else if (!context || context == "@media{") {
+          style = "tag";
+        } else if (context == "@media") {
+          if (atMediaTypes[stream.current()]) {
+            style = "attribute"; // Known attribute
+          } else if (/^(only|not)$/i.test(stream.current())) {
+            style = "keyword";
+          } else if (stream.current().toLowerCase() == "and") {
+            style = "error"; // "and" is only allowed in @mediaType
+          } else if (atMediaFeatures[stream.current()]) {
+            style = "error"; // Known property, should be in @mediaType(
+          } else {
+            // Unknown, expecting keyword or attribute, assuming attribute
+            style = "attribute error";
+          }
+        } else if (context == "@mediaType") {
+          if (atMediaTypes[stream.current()]) {
+            style = "attribute";
+          } else if (stream.current().toLowerCase() == "and") {
+            style = "operator";
+          } else if (/^(only|not)$/i.test(stream.current())) {
+            style = "error"; // Only allowed in @media
+          } else if (atMediaFeatures[stream.current()]) {
+            style = "error"; // Known property, should be in parentheses
+          } else {
+            // Unknown attribute or property, but expecting property (preceded
+            // by "and"). Should be in parentheses
+            style = "error";
+          }
+        } else if (context == "@mediaType(") {
+          if (propertyKeywords[stream.current()]) {
+            // do nothing, remains "property"
+          } else if (atMediaTypes[stream.current()]) {
+            style = "error"; // Known property, should be in parentheses
+          } else if (stream.current().toLowerCase() == "and") {
+            style = "operator";
+          } else if (/^(only|not)$/i.test(stream.current())) {
+            style = "error"; // Only allowed in @media
+          } else {
+            style += " error";
+          }
+        } else {
+          style = "error";
+        }
+      } else if (style == "atom") {
+        if(!context || context == "@media{") {
+          style = "builtin";
+        } else if (context == "propertyValue") {
+          if (!/^#([0-9a-fA-f]{3}|[0-9a-fA-f]{6})$/.test(stream.current())) {
+            style += " error";
+          }
+        } else {
+          style = "error";
+        }
+      } else if (context == "@media" && type == "{") {
+        style = "error";
+      }
+
+      // Push/pop context stack
+      if (type == "{") {
+        if (context == "@media" || context == "@mediaType") {
+          state.stack.pop();
+          state.stack[state.stack.length-1] = "@media{";
+        }
+        else state.stack.push("rule");
+      }
+      else if (type == "}") {
+        state.stack.pop();
+        if (context == "propertyValue") state.stack.pop();
+      }
+      else if (type == "@media") state.stack.push("@media");
+      else if (context == "@media" && /\b(keyword|attribute)\b/.test(style))
+        state.stack.push("@mediaType");
+      else if (context == "@mediaType" && stream.current() == ",") state.stack.pop();
+      else if (context == "@mediaType" && type == "(") state.stack.push("@mediaType(");
+      else if (context == "@mediaType(" && type == ")") state.stack.pop();
+      else if (context == "rule" && type == ":") state.stack.push("propertyValue");
+      else if (context == "propertyValue" && type == ";") state.stack.pop();
+      return style;
+    },
+
+    indent: function(state, textAfter) {
+      var n = state.stack.length;
+      if (/^\}/.test(textAfter))
+        n -= state.stack[state.stack.length-1] == "propertyValue" ? 2 : 1;
+      return state.baseIndent + n * indentUnit;
+    },
+
+    electricChars: "}"
+  };
+});
+
+CodeMirror.defineMIME("text/css", "css");

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/css/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/css/index.html b/src/fauxton/jam/codemirror/mode/css/index.html
new file mode 100644
index 0000000..ae2c3bf
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/css/index.html
@@ -0,0 +1,58 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>CodeMirror: CSS mode</title>
+    <link rel="stylesheet" href="../../lib/codemirror.css">
+    <script src="../../lib/codemirror.js"></script>
+    <script src="css.js"></script>
+    <style>.CodeMirror {background: #f8f8f8;}</style>
+    <link rel="stylesheet" href="../../doc/docs.css">
+  </head>
+  <body>
+    <h1>CodeMirror: CSS mode</h1>
+    <form><textarea id="code" name="code">
+/* Some example CSS */
+
+@import url("something.css");
+
+body {
+  margin: 0;
+  padding: 3em 6em;
+  font-family: tahoma, arial, sans-serif;
+  color: #000;
+}
+
+#navigation a {
+  font-weight: bold;
+  text-decoration: none !important;
+}
+
+h1 {
+  font-size: 2.5em;
+}
+
+h2 {
+  font-size: 1.7em;
+}
+
+h1:before, h2:before {
+  content: "::";
+}
+
+code {
+  font-family: courier, monospace;
+  font-size: 80%;
+  color: #418A8A;
+}
+</textarea></form>
+    <script>
+      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
+    </script>
+
+    <p><strong>MIME types defined:</strong> <code>text/css</code>.</p>
+
+    <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#css_*">normal</a>,  <a href="../../test/index.html#verbose,css_*">verbose</a>.</p>
+
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/css/test.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/css/test.js b/src/fauxton/jam/codemirror/mode/css/test.js
new file mode 100644
index 0000000..fd6a4b8
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/css/test.js
@@ -0,0 +1,501 @@
+// Initiate ModeTest and set defaults
+var MT = ModeTest;
+MT.modeName = 'css';
+MT.modeOptions = {};
+
+// Requires at least one media query
+MT.testMode(
+  'atMediaEmpty',
+  '@media { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'error', '{',
+    null, ' }'
+  ]
+);
+
+MT.testMode(
+  'atMediaMultiple',
+  '@media not screen and (color), not print and (color) { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'keyword', 'not',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'operator', 'and',
+    null, ' (',
+    'property', 'color',
+    null, '), ',
+    'keyword', 'not',
+    null, ' ',
+    'attribute', 'print',
+    null, ' ',
+    'operator', 'and',
+    null, ' (',
+    'property', 'color',
+    null, ') { }'
+  ]
+);
+
+MT.testMode(
+  'atMediaCheckStack',
+  '@media screen { } foo { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' { } ',
+    'tag', 'foo',
+    null, ' { }'
+  ]
+);
+
+MT.testMode(
+  'atMediaCheckStack',
+  '@media screen (color) { } foo { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' (',
+    'property', 'color',
+    null, ') { } ',
+    'tag', 'foo',
+    null, ' { }'
+  ]
+);
+
+MT.testMode(
+  'atMediaCheckStackInvalidAttribute',
+  '@media foobarhello { } foo { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute error', 'foobarhello',
+    null, ' { } ',
+    'tag', 'foo',
+    null, ' { }'
+  ]
+);
+
+// Error, because "and" is only allowed immediately preceding a media expression
+MT.testMode(
+  'atMediaInvalidAttribute',
+  '@media foobarhello { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute error', 'foobarhello',
+    null, ' { }'
+  ]
+);
+
+// Error, because "and" is only allowed immediately preceding a media expression
+MT.testMode(
+  'atMediaInvalidAnd',
+  '@media and screen { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'error', 'and',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' { }'
+  ]
+);
+
+// Error, because "not" is only allowed as the first item in each media query
+MT.testMode(
+  'atMediaInvalidNot',
+  '@media screen not (not) { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'error', 'not',
+    null, ' (',
+    'error', 'not',
+    null, ') { }'
+  ]
+);
+
+// Error, because "only" is only allowed as the first item in each media query
+MT.testMode(
+  'atMediaInvalidOnly',
+  '@media screen only (only) { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'error', 'only',
+    null, ' (',
+    'error', 'only',
+    null, ') { }'
+  ]
+);
+
+// Error, because "foobarhello" is neither a known type or property, but
+// property was expected (after "and"), and it should be in parenthese.
+MT.testMode(
+  'atMediaUnknownType',
+  '@media screen and foobarhello { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'operator', 'and',
+    null, ' ',
+    'error', 'foobarhello',
+    null, ' { }'
+  ]
+);
+
+// Error, because "color" is not a known type, but is a known property, and
+// should be in parentheses.
+MT.testMode(
+  'atMediaInvalidType',
+  '@media screen and color { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'operator', 'and',
+    null, ' ',
+    'error', 'color',
+    null, ' { }'
+  ]
+);
+
+// Error, because "print" is not a known property, but is a known type,
+// and should not be in parenthese.
+MT.testMode(
+  'atMediaInvalidProperty',
+  '@media screen and (print) { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'operator', 'and',
+    null, ' (',
+    'error', 'print',
+    null, ') { }'
+  ]
+);
+
+// Soft error, because "foobarhello" is not a known property or type.
+MT.testMode(
+  'atMediaUnknownProperty',
+  '@media screen and (foobarhello) { }',
+  [
+    'def', '@media',
+    null, ' ',
+    'attribute', 'screen',
+    null, ' ',
+    'operator', 'and',
+    null, ' (',
+    'property error', 'foobarhello',
+    null, ') { }'
+  ]
+);
+
+MT.testMode(
+  'tagSelector',
+  'foo { }',
+  [
+    'tag', 'foo',
+    null, ' { }'
+  ]
+);
+
+MT.testMode(
+  'classSelector',
+  '.foo-bar_hello { }',
+  [
+    'qualifier', '.foo-bar_hello',
+    null, ' { }'
+  ]
+);
+
+MT.testMode(
+  'idSelector',
+  '#foo { #foo }',
+  [
+    'builtin', '#foo',
+    null, ' { ',
+    'error', '#foo',
+    null, ' }'
+  ]
+);
+
+MT.testMode(
+  'tagSelectorUnclosed',
+  'foo { margin: 0 } bar { }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'margin',
+    'operator', ':',
+    null, ' ',
+    'number', '0',
+    null, ' } ',
+    'tag', 'bar',
+    null, ' { }'
+  ]
+);
+
+MT.testMode(
+  'tagStringNoQuotes',
+  'foo { font-family: hello world; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'font-family',
+    'operator', ':',
+    null, ' ',
+    'variable-2', 'hello',
+    null, ' ',
+    'variable-2', 'world',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagStringDouble',
+  'foo { font-family: "hello world"; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'font-family',
+    'operator', ':',
+    null, ' ',
+    'string', '"hello world"',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagStringSingle',
+  'foo { font-family: \'hello world\'; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'font-family',
+    'operator', ':',
+    null, ' ',
+    'string', '\'hello world\'',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagColorKeyword',
+  'foo { color: black; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'color',
+    'operator', ':',
+    null, ' ',
+    'keyword', 'black',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagColorHex3',
+  'foo { background: #fff; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'background',
+    'operator', ':',
+    null, ' ',
+    'atom', '#fff',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagColorHex6',
+  'foo { background: #ffffff; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'background',
+    'operator', ':',
+    null, ' ',
+    'atom', '#ffffff',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagColorHex4',
+  'foo { background: #ffff; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'background',
+    'operator', ':',
+    null, ' ',
+    'atom error', '#ffff',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagColorHexInvalid',
+  'foo { background: #ffg; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'background',
+    'operator', ':',
+    null, ' ',
+    'atom error', '#ffg',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagNegativeNumber',
+  'foo { margin: -5px; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'margin',
+    'operator', ':',
+    null, ' ',
+    'number', '-5px',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagPositiveNumber',
+  'foo { padding: 5px; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'padding',
+    'operator', ':',
+    null, ' ',
+    'number', '5px',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagVendor',
+  'foo { -foo-box-sizing: -foo-border-box; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'meta', '-foo-',
+    'property', 'box-sizing',
+    'operator', ':',
+    null, ' ',
+    'meta', '-foo-',
+    'string-2', 'border-box',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagBogusProperty',
+  'foo { barhelloworld: 0; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property error', 'barhelloworld',
+    'operator', ':',
+    null, ' ',
+    'number', '0',
+    null, '; }'
+  ]
+);
+
+MT.testMode(
+  'tagTwoProperties',
+  'foo { margin: 0; padding: 0; }',
+  [
+    'tag', 'foo',
+    null, ' { ',
+    'property', 'margin',
+    'operator', ':',
+    null, ' ',
+    'number', '0',
+    null, '; ',
+    'property', 'padding',
+    'operator', ':',
+    null, ' ',
+    'number', '0',
+    null, '; }'
+  ]
+);
+//
+//MT.testMode(
+//  'tagClass',
+//  '@media only screen and (min-width: 500px), print {foo.bar#hello { color: black !important; background: #f00; margin: -5px; padding: 5px; -foo-box-sizing: border-box; } /* world */}',
+//  [
+//    'def', '@media',
+//    null, ' ',
+//    'keyword', 'only',
+//    null, ' ',
+//    'attribute', 'screen',
+//    null, ' ',
+//    'operator', 'and',
+//    null, ' ',
+//    'bracket', '(',
+//    'property', 'min-width',
+//    'operator', ':',
+//    null, ' ',
+//    'number', '500px',
+//    'bracket', ')',
+//    null, ', ',
+//    'attribute', 'print',
+//    null, ' {',
+//    'tag', 'foo',
+//    'qualifier', '.bar',
+//    'header', '#hello',
+//    null, ' { ',
+//    'property', 'color',
+//    'operator', ':',
+//    null, ' ',
+//    'keyword', 'black',
+//    null, ' ',
+//    'keyword', '!important',
+//    null, '; ',
+//    'property', 'background',
+//    'operator', ':',
+//    null, ' ',
+//    'atom', '#f00',
+//    null, '; ',
+//    'property', 'padding',
+//    'operator', ':',
+//    null, ' ',
+//    'number', '5px',
+//    null, '; ',
+//    'property', 'margin',
+//    'operator', ':',
+//    null, ' ',
+//    'number', '-5px',
+//    null, '; ',
+//    'meta', '-foo-',
+//    'property', 'box-sizing',
+//    'operator', ':',
+//    null, ' ',
+//    'string-2', 'border-box',
+//    null, '; } ',
+//    'comment', '/* world */',
+//    null, '}'
+//  ]
+//);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/diff/diff.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/diff/diff.js b/src/fauxton/jam/codemirror/mode/diff/diff.js
new file mode 100644
index 0000000..3402f3b
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/diff/diff.js
@@ -0,0 +1,32 @@
+CodeMirror.defineMode("diff", function() {
+
+  var TOKEN_NAMES = {
+    '+': 'tag',
+    '-': 'string',
+    '@': 'meta'
+  };
+
+  return {
+    token: function(stream) {
+      var tw_pos = stream.string.search(/[\t ]+?$/);
+
+      if (!stream.sol() || tw_pos === 0) {
+        stream.skipToEnd();
+        return ("error " + (
+          TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
+      }
+
+      var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
+
+      if (tw_pos === -1) {
+        stream.skipToEnd();
+      } else {
+        stream.pos = tw_pos;
+      }
+
+      return token_name;
+    }
+  };
+});
+
+CodeMirror.defineMIME("text/x-diff", "diff");

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/diff/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/diff/index.html b/src/fauxton/jam/codemirror/mode/diff/index.html
new file mode 100644
index 0000000..5560252
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/diff/index.html
@@ -0,0 +1,105 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>CodeMirror: Diff mode</title>
+    <link rel="stylesheet" href="../../lib/codemirror.css">
+    <script src="../../lib/codemirror.js"></script>
+    <script src="diff.js"></script>
+    <style>
+      .CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
+      span.cm-meta {color: #a0b !important;}
+      span.cm-error { background-color: black; opacity: 0.4;}
+      span.cm-error.cm-string { background-color: red; }
+      span.cm-error.cm-tag { background-color: #2b2; }
+    </style>
+    <link rel="stylesheet" href="../../doc/docs.css">
+  </head>
+  <body>
+    <h1>CodeMirror: Diff mode</h1>
+    <form><textarea id="code" name="code">
+diff --git a/index.html b/index.html
+index c1d9156..7764744 100644
+--- a/index.html
++++ b/index.html
+@@ -95,7 +95,8 @@ StringStream.prototype = {
+     <script>
+       var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+         lineNumbers: true,
+-        autoMatchBrackets: true
++        autoMatchBrackets: true,
++      onGutterClick: function(x){console.log(x);}
+       });
+     </script>
+   </body>
+diff --git a/lib/codemirror.js b/lib/codemirror.js
+index 04646a9..9a39cc7 100644
+--- a/lib/codemirror.js
++++ b/lib/codemirror.js
+@@ -399,10 +399,16 @@ var CodeMirror = (function() {
+     }
+ 
+     function onMouseDown(e) {
+-      var start = posFromMouse(e), last = start;    
++      var start = posFromMouse(e), last = start, target = e.target();
+       if (!start) return;
+       setCursor(start.line, start.ch, false);
+       if (e.button() != 1) return;
++      if (target.parentNode == gutter) {    
++        if (options.onGutterClick)
++          options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
++        return;
++      }
++
+       if (!focused) onFocus();
+ 
+       e.stop();
+@@ -808,7 +814,7 @@ var CodeMirror = (function() {
+       for (var i = showingFrom; i < showingTo; ++i) {
+         var marker = lines[i].gutterMarker;
+         if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
+-        else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
++        else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
+       }
+       gutter.style.display = "none"; // TODO test whether this actually helps
+       gutter.innerHTML = html.join("");
+@@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
+         if (option == "parser") setParser(value);
+         else if (option === "lineNumbers") setLineNumbers(value);
+         else if (option === "gutter") setGutter(value);
+-        else if (option === "readOnly") options.readOnly = value;
+-        else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
+-        else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
+-        else throw new Error("Can't set option " + option);
++        else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
++        else options[option] = value;
+       },
+       cursorCoords: cursorCoords,
+       undo: operation(undo),
+@@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
+       replaceRange: operation(replaceRange),
+ 
+       operation: function(f){return operation(f)();},
+-      refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
++      refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
++      getInputField: function(){return input;}
+     };
+     return instance;
+   }
+@@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
+     readOnly: false,
+     onChange: null,
+     onCursorActivity: null,
++    onGutterClick: null,
+     autoMatchBrackets: false,
+     workTime: 200,
+     workDelay: 300,
+</textarea></form>
+    <script>
+      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
+    </script>
+
+    <p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
+
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/ecl/ecl.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/ecl/ecl.js b/src/fauxton/jam/codemirror/mode/ecl/ecl.js
new file mode 100644
index 0000000..c0e4479
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/ecl/ecl.js
@@ -0,0 +1,203 @@
+CodeMirror.defineMode("ecl", function(config) {
+
+  function words(str) {
+    var obj = {}, words = str.split(" ");
+    for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
+    return obj;
+  }
+
+  function metaHook(stream, state) {
+    if (!state.startOfLine) return false;
+    stream.skipToEnd();
+    return "meta";
+  }
+
+  function tokenAtString(stream, state) {
+    var next;
+    while ((next = stream.next()) != null) {
+      if (next == '"' && !stream.eat('"')) {
+        state.tokenize = null;
+        break;
+      }
+    }
+    return "string";
+  }
+
+  var indentUnit = config.indentUnit;
+  var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xm
 lunicode");
+  var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
+  var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
+  var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
+  var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
+  var blockKeywords = words("catch class do else finally for if switch try while");
+  var atoms = words("true false null");
+  var hooks = {"#": metaHook};
+  var multiLineStrings;
+  var isOperatorChar = /[+\-*&%=<>!?|\/]/;
+
+  var curPunc;
+
+  function tokenBase(stream, state) {
+    var ch = stream.next();
+    if (hooks[ch]) {
+      var result = hooks[ch](stream, state);
+      if (result !== false) return result;
+    }
+    if (ch == '"' || ch == "'") {
+      state.tokenize = tokenString(ch);
+      return state.tokenize(stream, state);
+    }
+    if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
+      curPunc = ch;
+      return null;
+    }
+    if (/\d/.test(ch)) {
+      stream.eatWhile(/[\w\.]/);
+      return "number";
+    }
+    if (ch == "/") {
+      if (stream.eat("*")) {
+        state.tokenize = tokenComment;
+        return tokenComment(stream, state);
+      }
+      if (stream.eat("/")) {
+        stream.skipToEnd();
+        return "comment";
+      }
+    }
+    if (isOperatorChar.test(ch)) {
+      stream.eatWhile(isOperatorChar);
+      return "operator";
+    }
+    stream.eatWhile(/[\w\$_]/);
+    var cur = stream.current().toLowerCase();
+    if (keyword.propertyIsEnumerable(cur)) {
+      if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+      return "keyword";
+    } else if (variable.propertyIsEnumerable(cur)) {
+      if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+      return "variable";
+    } else if (variable_2.propertyIsEnumerable(cur)) {
+      if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+      return "variable-2";
+    } else if (variable_3.propertyIsEnumerable(cur)) {
+      if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+      return "variable-3";
+    } else if (builtin.propertyIsEnumerable(cur)) {
+      if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
+      return "builtin";
+    } else { //Data types are of from KEYWORD## 
+		var i = cur.length - 1;
+		while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
+			--i;
+		
+		if (i > 0) {
+			var cur2 = cur.substr(0, i + 1);
+	    	if (variable_3.propertyIsEnumerable(cur2)) {
+	      		if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
+	      		return "variable-3";
+	      	}
+	    }
+    }
+    if (atoms.propertyIsEnumerable(cur)) return "atom";
+    return null;
+  }
+
+  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 || multiLineStrings))
+        state.tokenize = tokenBase;
+      return "string";
+    };
+  }
+
+  function tokenComment(stream, state) {
+    var maybeEnd = false, ch;
+    while (ch = stream.next()) {
+      if (ch == "/" && maybeEnd) {
+        state.tokenize = tokenBase;
+        break;
+      }
+      maybeEnd = (ch == "*");
+    }
+    return "comment";
+  }
+
+  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) {
+    var t = state.context.type;
+    if (t == ")" || t == "]" || t == "}")
+      state.indented = state.context.indented;
+    return state.context = state.context.prev;
+  }
+
+  // Interface
+
+  return {
+    startState: function(basecolumn) {
+      return {
+        tokenize: null,
+        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;
+      curPunc = null;
+      var style = (state.tokenize || tokenBase)(stream, state);
+      if (style == "comment" || style == "meta") return style;
+      if (ctx.align == null) ctx.align = true;
+
+      if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
+      else if (curPunc == "{") pushContext(state, stream.column(), "}");
+      else if (curPunc == "[") pushContext(state, stream.column(), "]");
+      else if (curPunc == "(") pushContext(state, stream.column(), ")");
+      else if (curPunc == "}") {
+        while (ctx.type == "statement") ctx = popContext(state);
+        if (ctx.type == "}") ctx = popContext(state);
+        while (ctx.type == "statement") ctx = popContext(state);
+      }
+      else if (curPunc == ctx.type) popContext(state);
+      else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
+        pushContext(state, stream.column(), "statement");
+      state.startOfLine = false;
+      return style;
+    },
+
+    indent: function(state, textAfter) {
+      if (state.tokenize != tokenBase && state.tokenize != null) return 0;
+      var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
+      if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
+      var closing = firstChar == ctx.type;
+      if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
+      else if (ctx.align) return ctx.column + (closing ? 0 : 1);
+      else return ctx.indented + (closing ? 0 : indentUnit);
+    },
+
+    electricChars: "{}"
+  };
+});
+
+CodeMirror.defineMIME("text/x-ecl", "ecl");

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/ecl/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/ecl/index.html b/src/fauxton/jam/codemirror/mode/ecl/index.html
new file mode 100644
index 0000000..d6b41f4
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/ecl/index.html
@@ -0,0 +1,42 @@
+<!doctype html>
+<html>
+  <head>
+    <title>CodeMirror: ECL mode</title>
+    <link rel="stylesheet" href="../../lib/codemirror.css">
+    <script src="../../lib/codemirror.js"></script>
+    <script src="ecl.js"></script>
+    <link rel="stylesheet" href="../../doc/docs.css">
+    <style>.CodeMirror {border: 1px solid black;}</style>
+  </head>
+  <body>
+    <h1>CodeMirror: ECL mode</h1>
+    <form><textarea id="code" name="code">
+/*
+sample useless code to demonstrate ecl syntax highlighting
+this is a multiline comment!
+*/
+
+//  this is a singleline comment!
+
+import ut;
+r := 
+  record
+   string22 s1 := '123';
+   integer4 i1 := 123;
+  end;
+#option('tmp', true);
+d := dataset('tmp::qb', r, thor);
+output(d);
+</textarea></form>
+    <script>
+      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+        tabMode: "indent",
+        matchBrackets: true,
+      });
+    </script>
+
+    <p>Based on CodeMirror's clike mode.  For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
+    <p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
+
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/erlang/erlang.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/erlang/erlang.js b/src/fauxton/jam/codemirror/mode/erlang/erlang.js
new file mode 100644
index 0000000..e79ab76
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/erlang/erlang.js
@@ -0,0 +1,463 @@
+// block; "begin", "case", "fun", "if", "receive", "try": closed by "end"
+// block internal; "after", "catch", "of"
+// guard; "when", closed by "->"
+// "->" opens a clause, closed by ";" or "."
+// "<<" opens a binary, closed by ">>"
+// "," appears in arglists, lists, tuples and terminates lines of code
+// "." resets indentation to 0
+// obsolete; "cond", "let", "query"
+
+CodeMirror.defineMIME("text/x-erlang", "erlang");
+
+CodeMirror.defineMode("erlang", function(cmCfg, modeCfg) {
+
+  function rval(state,stream,type) {
+    // distinguish between "." as terminator and record field operator
+    if (type == "record") {
+      state.context = "record";
+    }else{
+      state.context = false;
+    }
+
+    // remember last significant bit on last line for indenting
+    if (type != "whitespace" && type != "comment") {
+      state.lastToken = stream.current();
+    }
+    //     erlang             -> CodeMirror tag
+    switch (type) {
+      case "atom":        return "atom";
+      case "attribute":   return "attribute";
+      case "builtin":     return "builtin";
+      case "comment":     return "comment";
+      case "fun":         return "meta";
+      case "function":    return "tag";
+      case "guard":       return "property";
+      case "keyword":     return "keyword";
+      case "macro":       return "variable-2";
+      case "number":      return "number";
+      case "operator":    return "operator";
+      case "record":      return "bracket";
+      case "string":      return "string";
+      case "type":        return "def";
+      case "variable":    return "variable";
+      case "error":       return "error";
+      case "separator":   return null;
+      case "open_paren":  return null;
+      case "close_paren": return null;
+      default:            return null;
+    }
+  }
+
+  var typeWords = [
+    "-type", "-spec", "-export_type", "-opaque"];
+
+  var keywordWords = [
+    "after","begin","catch","case","cond","end","fun","if",
+    "let","of","query","receive","try","when"];
+
+  var separatorWords = [
+    "->",";",":",".",","];
+
+  var operatorWords = [
+    "and","andalso","band","bnot","bor","bsl","bsr","bxor",
+    "div","not","or","orelse","rem","xor"];
+
+  var symbolWords = [
+    "+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-"];
+
+  var openParenWords = [
+    "<<","(","[","{"];
+
+  var closeParenWords = [
+    "}","]",")",">>"];
+
+  var guardWords = [
+    "is_atom","is_binary","is_bitstring","is_boolean","is_float",
+    "is_function","is_integer","is_list","is_number","is_pid",
+    "is_port","is_record","is_reference","is_tuple",
+    "atom","binary","bitstring","boolean","function","integer","list",
+    "number","pid","port","record","reference","tuple"];
+
+  var bifWords = [
+    "abs","adler32","adler32_combine","alive","apply","atom_to_binary",
+    "atom_to_list","binary_to_atom","binary_to_existing_atom",
+    "binary_to_list","binary_to_term","bit_size","bitstring_to_list",
+    "byte_size","check_process_code","contact_binary","crc32",
+    "crc32_combine","date","decode_packet","delete_module",
+    "disconnect_node","element","erase","exit","float","float_to_list",
+    "garbage_collect","get","get_keys","group_leader","halt","hd",
+    "integer_to_list","internal_bif","iolist_size","iolist_to_binary",
+    "is_alive","is_atom","is_binary","is_bitstring","is_boolean",
+    "is_float","is_function","is_integer","is_list","is_number","is_pid",
+    "is_port","is_process_alive","is_record","is_reference","is_tuple",
+    "length","link","list_to_atom","list_to_binary","list_to_bitstring",
+    "list_to_existing_atom","list_to_float","list_to_integer",
+    "list_to_pid","list_to_tuple","load_module","make_ref","module_loaded",
+    "monitor_node","node","node_link","node_unlink","nodes","notalive",
+    "now","open_port","pid_to_list","port_close","port_command",
+    "port_connect","port_control","pre_loaded","process_flag",
+    "process_info","processes","purge_module","put","register",
+    "registered","round","self","setelement","size","spawn","spawn_link",
+    "spawn_monitor","spawn_opt","split_binary","statistics",
+    "term_to_binary","time","throw","tl","trunc","tuple_size",
+    "tuple_to_list","unlink","unregister","whereis"];
+
+  // ignored for indenting purposes
+  var ignoreWords = [
+    ",", ":", "catch", "after", "of", "cond", "let", "query"];
+
+
+  var smallRE      = /[a-z_]/;
+  var largeRE      = /[A-Z_]/;
+  var digitRE      = /[0-9]/;
+  var octitRE      = /[0-7]/;
+  var anumRE       = /[a-z_A-Z0-9]/;
+  var symbolRE     = /[\+\-\*\/<>=\|:]/;
+  var openParenRE  = /[<\(\[\{]/;
+  var closeParenRE = /[>\)\]\}]/;
+  var sepRE        = /[\->\.,:;]/;
+
+  function isMember(element,list) {
+    return (-1 < list.indexOf(element));
+  }
+
+  function isPrev(stream,string) {
+    var start = stream.start;
+    var len = string.length;
+    if (len <= start) {
+      var word = stream.string.slice(start-len,start);
+      return word == string;
+    }else{
+      return false;
+    }
+  }
+
+  function tokenize(stream, state) {
+    if (stream.eatSpace()) {
+      return rval(state,stream,"whitespace");
+    }
+
+    // attributes and type specs
+    if ((peekToken(state).token == "" || peekToken(state).token == ".") &&
+        stream.peek() == '-') {
+      stream.next();
+      if (stream.eat(smallRE) && stream.eatWhile(anumRE)) {
+        if (isMember(stream.current(),typeWords)) {
+          return rval(state,stream,"type");
+        }else{
+          return rval(state,stream,"attribute");
+        }
+      }
+      stream.backUp(1);
+    }
+
+    var ch = stream.next();
+
+    // comment
+    if (ch == '%') {
+      stream.skipToEnd();
+      return rval(state,stream,"comment");
+    }
+
+    // macro
+    if (ch == '?') {
+      stream.eatWhile(anumRE);
+      return rval(state,stream,"macro");
+    }
+
+    // record
+    if ( ch == "#") {
+      stream.eatWhile(anumRE);
+      return rval(state,stream,"record");
+    }
+
+    // char
+    if ( ch == "$") {
+      if (stream.next() == "\\") {
+        if (!stream.eatWhile(octitRE)) {
+          stream.next();
+        }
+      }
+      return rval(state,stream,"string");
+    }
+
+    // quoted atom
+    if (ch == '\'') {
+      if (singleQuote(stream)) {
+        return rval(state,stream,"atom");
+      }else{
+        return rval(state,stream,"error");
+      }
+    }
+
+    // string
+    if (ch == '"') {
+      if (doubleQuote(stream)) {
+        return rval(state,stream,"string");
+      }else{
+        return rval(state,stream,"error");
+      }
+    }
+
+    // variable
+    if (largeRE.test(ch)) {
+      stream.eatWhile(anumRE);
+      return rval(state,stream,"variable");
+    }
+
+    // atom/keyword/BIF/function
+    if (smallRE.test(ch)) {
+      stream.eatWhile(anumRE);
+
+      if (stream.peek() == "/") {
+        stream.next();
+        if (stream.eatWhile(digitRE)) {
+          return rval(state,stream,"fun");      // f/0 style fun
+        }else{
+          stream.backUp(1);
+          return rval(state,stream,"atom");
+        }
+      }
+
+      var w = stream.current();
+
+      if (isMember(w,keywordWords)) {
+        pushToken(state,stream);
+        return rval(state,stream,"keyword");
+      }
+      if (stream.peek() == "(") {
+        // 'put' and 'erlang:put' are bifs, 'foo:put' is not
+        if (isMember(w,bifWords) &&
+            (!isPrev(stream,":") || isPrev(stream,"erlang:"))) {
+          return rval(state,stream,"builtin");
+        }else{
+          return rval(state,stream,"function");
+        }
+      }
+      if (isMember(w,guardWords)) {
+        return rval(state,stream,"guard");
+      }
+      if (isMember(w,operatorWords)) {
+        return rval(state,stream,"operator");
+      }
+      if (stream.peek() == ":") {
+        if (w == "erlang") {
+          return rval(state,stream,"builtin");
+        } else {
+          return rval(state,stream,"function");
+        }
+      }
+      return rval(state,stream,"atom");               
+    }
+
+    // number
+    if (digitRE.test(ch)) {
+      stream.eatWhile(digitRE);
+      if (stream.eat('#')) {
+        stream.eatWhile(digitRE);    // 16#10  style integer
+      } else {
+        if (stream.eat('.')) {       // float
+          stream.eatWhile(digitRE);
+        }
+        if (stream.eat(/[eE]/)) {
+          stream.eat(/[-+]/);        // float with exponent
+          stream.eatWhile(digitRE);
+        }
+      }
+      return rval(state,stream,"number");   // normal integer
+    }
+
+    // open parens
+    if (nongreedy(stream,openParenRE,openParenWords)) {
+      pushToken(state,stream);
+      return rval(state,stream,"open_paren");
+    }
+
+    // close parens
+    if (nongreedy(stream,closeParenRE,closeParenWords)) {
+      pushToken(state,stream);
+      return rval(state,stream,"close_paren");
+    }
+
+    // separators
+    if (greedy(stream,sepRE,separatorWords)) {
+      // distinguish between "." as terminator and record field operator
+      if (state.context == false) {
+        pushToken(state,stream);
+      }
+      return rval(state,stream,"separator");
+    }
+
+    // operators
+    if (greedy(stream,symbolRE,symbolWords)) {
+      return rval(state,stream,"operator");
+    }
+
+    return rval(state,stream,null);
+  }
+
+  function nongreedy(stream,re,words) {
+    if (stream.current().length == 1 && re.test(stream.current())) {
+      stream.backUp(1);
+      while (re.test(stream.peek())) {
+        stream.next();
+        if (isMember(stream.current(),words)) {
+          return true;
+        }
+      }
+      stream.backUp(stream.current().length-1);
+    }
+    return false;
+  }
+
+  function greedy(stream,re,words) {
+    if (stream.current().length == 1 && re.test(stream.current())) {
+      while (re.test(stream.peek())) {
+        stream.next();
+      }
+      while (0 < stream.current().length) {
+        if (isMember(stream.current(),words)) {
+          return true;
+        }else{
+          stream.backUp(1);
+        }
+      }
+      stream.next();
+    }
+    return false;
+  }
+
+  function doubleQuote(stream) {
+    return quote(stream, '"', '\\');
+  }
+
+  function singleQuote(stream) {
+    return quote(stream,'\'','\\');
+  }
+
+  function quote(stream,quoteChar,escapeChar) {
+    while (!stream.eol()) {
+      var ch = stream.next();
+      if (ch == quoteChar) {
+        return true;
+      }else if (ch == escapeChar) {
+        stream.next();
+      }
+    }
+    return false;
+  }
+
+  function Token(stream) {
+    this.token  = stream ? stream.current() : "";
+    this.column = stream ? stream.column() : 0;
+    this.indent = stream ? stream.indentation() : 0;
+  }
+
+  function myIndent(state,textAfter) {
+    var indent = cmCfg.indentUnit;
+    var outdentWords = ["after","catch"];
+    var token = (peekToken(state)).token;
+    var wordAfter = takewhile(textAfter,/[^a-z]/);
+
+    if (isMember(token,openParenWords)) {
+      return (peekToken(state)).column+token.length;
+    }else if (token == "." || token == ""){
+      return 0;
+    }else if (token == "->") {
+      if (wordAfter == "end") {
+        return peekToken(state,2).column;
+      }else if (peekToken(state,2).token == "fun") {
+        return peekToken(state,2).column+indent;
+      }else{
+        return (peekToken(state)).indent+indent;
+      }
+    }else if (isMember(wordAfter,outdentWords)) {
+      return (peekToken(state)).indent;
+    }else{
+      return (peekToken(state)).column+indent;
+    }
+  }
+
+  function takewhile(str,re) {
+    var m = str.match(re);
+    return m ? str.slice(0,m.index) : str;
+  }
+
+  function popToken(state) {
+    return state.tokenStack.pop();
+  }
+
+  function peekToken(state,depth) {
+    var len = state.tokenStack.length;
+    var dep = (depth ? depth : 1);
+    if (len < dep) {
+      return new Token;
+    }else{
+      return state.tokenStack[len-dep];
+    }
+  }
+
+  function pushToken(state,stream) {
+    var token = stream.current();
+    var prev_token = peekToken(state).token;
+    if (isMember(token,ignoreWords)) {
+      return false;
+    }else if (drop_both(prev_token,token)) {
+      popToken(state);
+      return false;
+    }else if (drop_first(prev_token,token)) {
+      popToken(state);
+      return pushToken(state,stream);
+    }else{
+      state.tokenStack.push(new Token(stream));
+      return true;
+    }
+  }
+
+  function drop_first(open, close) {
+    switch (open+" "+close) {
+      case "when ->":       return true;
+      case "-> end":        return true;
+      case "-> .":          return true;
+      case ". .":           return true;
+      default:              return false;
+    }
+  }
+
+  function drop_both(open, close) {
+    switch (open+" "+close) {
+      case "( )":         return true;
+      case "[ ]":         return true;
+      case "{ }":         return true;
+      case "<< >>":       return true;
+      case "begin end":   return true;
+      case "case end":    return true;
+      case "fun end":     return true;
+      case "if end":      return true;
+      case "receive end": return true;
+      case "try end":     return true;
+      case "-> ;":        return true;
+      default:            return false;
+    }
+  }
+
+  return {
+    startState:
+      function() {
+        return {tokenStack: [],
+                context: false,
+                lastToken: null};
+      },
+
+    token:
+      function(stream, state) {
+        return tokenize(stream, state);
+      },
+
+    indent:
+      function(state, textAfter) {
+//        console.log(state.tokenStack);
+        return myIndent(state,textAfter);
+      }
+  };
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/erlang/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/erlang/index.html b/src/fauxton/jam/codemirror/mode/erlang/index.html
new file mode 100644
index 0000000..c28389a
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/erlang/index.html
@@ -0,0 +1,63 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>CodeMirror: Erlang mode</title>
+    <link rel="stylesheet" href="../../lib/codemirror.css">
+    <script src="../../lib/codemirror.js"></script>
+    <script src="erlang.js"></script>
+    <link rel="stylesheet" href="../../theme/erlang-dark.css">
+    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+    <link rel="stylesheet" href="../../doc/docs.css">
+  </head>
+  <body>
+    <h1>CodeMirror: Erlang mode</h1>
+
+<form><textarea id="code" name="code">
+%% -*- mode: erlang; erlang-indent-level: 2 -*-
+%%% Created :  7 May 2012 by mats cronqvist <masse@klarna.com>
+
+%% @doc
+%% Demonstrates how to print a record.
+%% @end
+
+-module('ex').
+-author('mats cronqvist').
+-export([demo/0,
+         rec_info/1]).
+
+-record(demo,{a="One",b="Two",c="Three",d="Four"}).
+
+rec_info(demo) -> record_info(fields,demo).
+
+demo() -> expand_recs(?MODULE,#demo{a="A",b="BB"}).
+  
+expand_recs(M,List) when is_list(List) ->
+  [expand_recs(M,L)||L<-List];
+expand_recs(M,Tup) when is_tuple(Tup) ->
+  case tuple_size(Tup) of
+    L when L < 1 -> Tup;
+    L ->
+      try Fields = M:rec_info(element(1,Tup)),
+          L = length(Fields)+1,
+          lists:zip(Fields,expand_recs(M,tl(tuple_to_list(Tup))))
+      catch _:_ ->
+          list_to_tuple(expand_recs(M,tuple_to_list(Tup)))
+      end
+  end;
+expand_recs(_,Term) ->
+  Term.
+</textarea></form>
+
+    <script>
+      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+        lineNumbers: true,
+        matchBrackets: true,
+        extraKeys: {"Tab":  "indentAuto"},
+        theme: "erlang-dark"
+      });
+    </script>
+
+    <p><strong>MIME types defined:</strong> <code>text/x-erlang</code>.</p>
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/gfm/gfm.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/gfm/gfm.js b/src/fauxton/jam/codemirror/mode/gfm/gfm.js
new file mode 100644
index 0000000..21b8259
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/gfm/gfm.js
@@ -0,0 +1,94 @@
+CodeMirror.defineMode("gfm", function(config, parserConfig) {
+  var codeDepth = 0;
+  function blankLine(state) {
+    state.code = false;
+    return null;
+  }
+  var gfmOverlay = {
+    startState: function() {
+      return {
+        code: false,
+        codeBlock: false,
+        ateSpace: false
+      };
+    },
+    copyState: function(s) {
+      return {
+        code: s.code,
+        codeBlock: s.codeBlock,
+        ateSpace: s.ateSpace
+      };
+    },
+    token: function(stream, state) {
+      // Hack to prevent formatting override inside code blocks (block and inline)
+      if (state.codeBlock) {
+        if (stream.match(/^```/)) {
+          state.codeBlock = false;
+          return null;
+        }
+        stream.skipToEnd();
+        return null;
+      }
+      if (stream.sol()) {
+        state.code = false;
+      }
+      if (stream.sol() && stream.match(/^```/)) {
+        stream.skipToEnd();
+        state.codeBlock = true;
+        return null;
+      }
+      // If this block is changed, it may need to be updated in Markdown mode
+      if (stream.peek() === '`') {
+        stream.next();
+        var before = stream.pos;
+        stream.eatWhile('`');
+        var difference = 1 + stream.pos - before;
+        if (!state.code) {
+          codeDepth = difference;
+          state.code = true;
+        } else {
+          if (difference === codeDepth) { // Must be exact
+            state.code = false;
+          }
+        }
+        return null;
+      } else if (state.code) {
+        stream.next();
+        return null;
+      }
+      // Check if space. If so, links can be formatted later on
+      if (stream.eatSpace()) {
+        state.ateSpace = true;
+        return null;
+      }
+      if (stream.sol() || state.ateSpace) {
+        state.ateSpace = false;
+        if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
+          // User/Project@SHA
+          // User@SHA
+          // SHA
+          return "link";
+        } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
+          // User/Project#Num
+          // User#Num
+          // #Num
+          return "link";
+        }
+      }
+      if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i)) {
+        // URLs
+        // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
+        return "link";
+      }
+      stream.next();
+      return null;
+    },
+    blankLine: blankLine
+  };
+  CodeMirror.defineMIME("gfmBase", {
+    name: "markdown",
+    underscoresBreakWords: false,
+    fencedCodeBlocks: true
+  });
+  return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
+});

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/gfm/index.html
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/gfm/index.html b/src/fauxton/jam/codemirror/mode/gfm/index.html
new file mode 100644
index 0000000..05256f4
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/gfm/index.html
@@ -0,0 +1,71 @@
+<!doctype html>
+<html>
+  <head>
+    <meta charset="utf-8">
+    <title>CodeMirror: GFM mode</title>
+    <link rel="stylesheet" href="../../lib/codemirror.css">
+    <script src="../../lib/codemirror.js"></script>
+    <script src="../../lib/util/overlay.js"></script>
+    <script src="../xml/xml.js"></script>
+    <script src="../markdown/markdown.js"></script>
+    <script src="gfm.js"></script>
+    
+    <!-- Code block highlighting modes -->
+    <script src="../javascript/javascript.js"></script>
+    <script src="../css/css.js"></script>
+    <script src="../htmlmixed/htmlmixed.js"></script>
+    <script src="../clike/clike.js"></script>
+    
+    <link rel="stylesheet" href="../markdown/markdown.css">
+    <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
+    <link rel="stylesheet" href="../../doc/docs.css">
+  </head>
+  <body>
+    <h1>CodeMirror: GFM mode</h1>
+
+<form><textarea id="code" name="code">
+GitHub Flavored Markdown
+========================
+
+Everything from markdown plus GFM features:
+
+## URL autolinking
+
+Underscores_are_allowed_between_words.
+
+## Fenced code blocks (and syntax highlighting... someday)
+
+```javascript
+for (var i = 0; i &lt; items.length; i++) {
+    console.log(items[i], i); // log them
+}
+```
+
+## A bit of GitHub spice
+
+* SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
+* User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
+* User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
+* \#Num: #1
+* User/#Num: mojombo#1
+* User/Project#Num: mojombo/god#1
+
+See http://github.github.com/github-flavored-markdown/.
+
+</textarea></form>
+
+    <script>
+      var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
+        mode: 'gfm',
+        lineNumbers: true,
+        matchBrackets: true,
+        theme: "default"
+      });
+    </script>
+
+    <p>Optionally depends on other modes for properly highlighted code blocks.</p>
+
+    <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gfm_*">normal</a>,  <a href="../../test/index.html#verbose,gfm_*">verbose</a>.</p>
+
+  </body>
+</html>

http://git-wip-us.apache.org/repos/asf/couchdb/blob/4615a788/src/fauxton/jam/codemirror/mode/gfm/test.js
----------------------------------------------------------------------
diff --git a/src/fauxton/jam/codemirror/mode/gfm/test.js b/src/fauxton/jam/codemirror/mode/gfm/test.js
new file mode 100644
index 0000000..3a261f8
--- /dev/null
+++ b/src/fauxton/jam/codemirror/mode/gfm/test.js
@@ -0,0 +1,225 @@
+// Initiate ModeTest and set defaults
+var MT = ModeTest;
+MT.modeName = 'gfm';
+MT.modeOptions = {};
+
+// Emphasis characters within a word
+MT.testMode(
+  'emInWordAsterisk',
+  'foo*bar*hello',
+  [
+    null, 'foo',
+    'em', '*bar*',
+    null, 'hello'
+  ]
+);
+MT.testMode(
+  'emInWordUnderscore',
+  'foo_bar_hello',
+  [
+    null, 'foo_bar_hello'
+  ]
+);
+MT.testMode(
+  'emStrongUnderscore',
+  '___foo___ bar',
+  [
+    'strong', '__',
+    'emstrong', '_foo__',
+    'em', '_',
+    null, ' bar'
+  ]
+);
+
+// Fenced code blocks
+MT.testMode(
+  'fencedCodeBlocks',
+  '```\nfoo\n\n```\nbar',
+  [
+    'comment', '```',
+    'comment', 'foo',
+    'comment', '```',
+    null, 'bar'
+  ]
+);
+// Fenced code block mode switching
+MT.testMode(
+  'fencedCodeBlockModeSwitching',
+  '```javascript\nfoo\n\n```\nbar',
+  [
+    'comment', '```javascript',
+    'variable', 'foo',
+    'comment', '```',
+    null, 'bar'
+  ]
+);
+
+// SHA
+MT.testMode(
+  'SHA',
+  'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 bar',
+  [
+    null, 'foo ',
+    'link', 'be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
+    null, ' bar'
+  ]
+);
+// GitHub highlights hashes 7-40 chars in length
+MT.testMode(
+  'shortSHA',
+  'foo be6a8cc bar',
+  [
+    null, 'foo ',
+    'link', 'be6a8cc',
+    null, ' bar'
+  ]
+);
+// Invalid SHAs
+// 
+// GitHub does not highlight hashes shorter than 7 chars
+MT.testMode(
+  'tooShortSHA',
+  'foo be6a8c bar',
+  [
+    null, 'foo be6a8c bar'
+  ]
+);
+// GitHub does not highlight hashes longer than 40 chars
+MT.testMode(
+  'longSHA',
+  'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar',
+  [
+    null, 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar'
+  ]
+);
+MT.testMode(
+  'badSHA',
+  'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar',
+  [
+    null, 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar'
+  ]
+);
+// User@SHA
+MT.testMode(
+  'userSHA',
+  'foo bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 hello',
+  [
+    null, 'foo ',
+    'link', 'bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
+    null, ' hello'
+  ]
+);
+// User/Project@SHA
+MT.testMode(
+  'userProjectSHA',
+  'foo bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 world',
+  [
+    null, 'foo ',
+    'link', 'bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
+    null, ' world'
+  ]
+);
+
+// #Num
+MT.testMode(
+  'num',
+  'foo #1 bar',
+  [
+    null, 'foo ',
+    'link', '#1',
+    null, ' bar'
+  ]
+);
+// bad #Num
+MT.testMode(
+  'badNum',
+  'foo #1bar hello',
+  [
+    null, 'foo #1bar hello'
+  ]
+);
+// User#Num
+MT.testMode(
+  'userNum',
+  'foo bar#1 hello',
+  [
+    null, 'foo ',
+    'link', 'bar#1',
+    null, ' hello'
+  ]
+);
+// User/Project#Num
+MT.testMode(
+  'userProjectNum',
+  'foo bar/hello#1 world',
+  [
+    null, 'foo ',
+    'link', 'bar/hello#1',
+    null, ' world'
+  ]
+);
+
+// Vanilla links
+MT.testMode(
+  'vanillaLink',
+  'foo http://www.example.com/ bar',
+  [
+    null, 'foo ',
+    'link', 'http://www.example.com/',
+    null, ' bar'
+  ]
+);
+MT.testMode(
+  'vanillaLinkPunctuation',
+  'foo http://www.example.com/. bar',
+  [
+    null, 'foo ',
+    'link', 'http://www.example.com/',
+    null, '. bar'
+  ]
+);
+MT.testMode(
+  'vanillaLinkExtension',
+  'foo http://www.example.com/index.html bar',
+  [
+    null, 'foo ',
+    'link', 'http://www.example.com/index.html',
+    null, ' bar'
+  ]
+);
+// Not a link
+MT.testMode(
+  'notALink',
+  '```css\nfoo {color:black;}\n```http://www.example.com/',
+  [
+    'comment', '```css',
+    'tag', 'foo',
+    null, ' {',
+    'property', 'color',
+    'operator', ':',
+    'keyword', 'black',
+    null, ';}',
+    'comment', '```',
+    'link', 'http://www.example.com/'
+  ]
+);
+// Not a link
+MT.testMode(
+  'notALink',
+  '``foo `bar` http://www.example.com/`` hello',
+  [
+    'comment', '``foo `bar` http://www.example.com/``',
+    null, ' hello'
+  ]
+);
+// Not a link
+MT.testMode(
+  'notALink',
+  '`foo\nhttp://www.example.com/\n`foo\n\nhttp://www.example.com/',
+  [
+    'comment', '`foo',
+    'link', 'http://www.example.com/',
+    'comment', '`foo',
+    'link', 'http://www.example.com/'
+  ]
+);
\ No newline at end of file


Mime
View raw message