| OLD | NEW |
| 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others | 1 // CodeMirror, copyright (c) by Marijn Haverbeke and others |
| 2 // Distributed under an MIT license: http://codemirror.net/LICENSE | 2 // Distributed under an MIT license: http://codemirror.net/LICENSE |
| 3 | 3 |
| 4 (function(mod) { | 4 (function(mod) { |
| 5 if (typeof exports == "object" && typeof module == "object") // CommonJS | 5 if (typeof exports == "object" && typeof module == "object") // CommonJS |
| 6 mod(require("../../lib/codemirror")); | 6 mod(require("../../lib/codemirror")); |
| 7 else if (typeof define == "function" && define.amd) // AMD | 7 else if (typeof define == "function" && define.amd) // AMD |
| 8 define(["../../lib/codemirror"], mod); | 8 define(["../../lib/codemirror"], mod); |
| 9 else // Plain browser env | 9 else // Plain browser env |
| 10 mod(CodeMirror); | 10 mod(CodeMirror); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 var currentlyHighlighted = null; | 96 var currentlyHighlighted = null; |
| 97 function doMatchBrackets(cm) { | 97 function doMatchBrackets(cm) { |
| 98 cm.operation(function() { | 98 cm.operation(function() { |
| 99 if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted =
null;} | 99 if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted =
null;} |
| 100 currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); | 100 currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets); |
| 101 }); | 101 }); |
| 102 } | 102 } |
| 103 | 103 |
| 104 CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { | 104 CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) { |
| 105 if (old && old != CodeMirror.Init) | 105 if (old && old != CodeMirror.Init) { |
| 106 cm.off("cursorActivity", doMatchBrackets); | 106 cm.off("cursorActivity", doMatchBrackets); |
| 107 if (currentlyHighlighted) {currentlyHighlighted(); currentlyHighlighted =
null;} |
| 108 } |
| 107 if (val) { | 109 if (val) { |
| 108 cm.state.matchBrackets = typeof val == "object" ? val : {}; | 110 cm.state.matchBrackets = typeof val == "object" ? val : {}; |
| 109 cm.on("cursorActivity", doMatchBrackets); | 111 cm.on("cursorActivity", doMatchBrackets); |
| 110 } | 112 } |
| 111 }); | 113 }); |
| 112 | 114 |
| 113 CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, tr
ue);}); | 115 CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, tr
ue);}); |
| 114 CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config
){ | 116 CodeMirror.defineExtension("findMatchingBracket", function(pos, strict, config
){ |
| 115 return findMatchingBracket(this, pos, strict, config); | 117 return findMatchingBracket(this, pos, strict, config); |
| 116 }); | 118 }); |
| 117 CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config)
{ | 119 CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config)
{ |
| 118 return scanForBracket(this, pos, dir, style, config); | 120 return scanForBracket(this, pos, dir, style, config); |
| 119 }); | 121 }); |
| 120 }); | 122 }); |
| OLD | NEW |