• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10/WebInspectorUI-7600.1.17/UserInterface/External/CodeMirror/

Lines Matching refs:pos

15   function SearchCursor(doc, query, pos, caseFold) {
19 pos = pos ? doc.clipPos(pos) : Pos(0, 0);
20 this.pos = {from: pos, to: pos};
28 this.matches = function(reverse, pos) {
31 var line = doc.getLine(pos.line).slice(0, pos.ch), cutOff = 0, match, start;
44 else if (start != doc.getLine(pos.line).length) {
49 query.lastIndex = pos.ch;
50 var line = doc.getLine(pos.line), match = query.exec(line);
56 return {from: Pos(pos.line, start),
57 to: Pos(pos.line, start + matchLen),
72 this.matches = function(reverse, pos) {
74 var orig = doc.getLine(pos.line).slice(0, pos.ch), line = fold(orig);
78 return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
81 var orig = doc.getLine(pos.line).slice(pos.ch), line = fold(orig);
84 match = adjustPos(orig, line, match) + pos.ch;
85 return {from: Pos(pos.line, match), to: Pos(pos.line, match + origQuery.length)};
92 this.matches = function(reverse, pos) {
95 if (pos.line - (target.length - 1) < doc.firstLine()) return;
96 if (fold(doc.getLine(pos.line).slice(0, origTarget[last].length)) != target[target.length - 1]) return;
97 var to = Pos(pos.line, origTarget[last].length);
98 for (var ln = pos.line - 1, i = last - 1; i >= 1; --i, --ln)
104 if (pos.line + (target.length - 1) > doc.lastLine()) return;
105 var line = doc.getLine(pos.line), cut = line.length - origTarget[0].length;
107 var from = Pos(pos.line, cut);
108 for (var ln = pos.line + 1, i = 1; i < last; ++i, ++ln)
123 var self = this, pos = this.doc.clipPos(reverse ? this.pos.from : this.pos.to);
125 var pos = Pos(line, 0);
126 self.pos = {from: pos, to: pos};
132 if (this.pos = this.matches(reverse, pos)) {
134 return this.pos.match || true;
137 if (!pos.line) return savePosAndFail(0);
138 pos = Pos(pos.line-1, this.doc.getLine(pos.line-1).length);
142 if (pos.line == maxLine - 1) return savePosAndFail(maxLine);
143 pos = Pos(pos.line + 1, 0);
148 from: function() {if (this.atOccurrence) return this.pos.from;},
149 to: function() {if (this.atOccurrence) return this.pos.to;},
154 this.doc.replaceRange(lines, this.pos.from, this.pos.to);
155 this.pos.to = Pos(this.pos.from.line + lines.length - 1,
156 lines[lines.length - 1].length + (lines.length == 1 ? this.pos.from.ch : 0));
162 function adjustPos(orig, folded, pos) {
163 if (orig.length == folded.length) return pos;
164 for (var pos1 = Math.min(pos, orig.length);;) {
166 if (len1 < pos) ++pos1;
167 else if (len1 > pos) --pos1;
172 CodeMirror.defineExtension("getSearchCursor", function(query, pos, caseFold) {
173 return new SearchCursor(this.doc, query, pos, caseFold);
175 CodeMirror.defineDocExtension("getSearchCursor", function(query, pos, caseFold) {
176 return new SearchCursor(this, query, pos, caseFold);