| 94 | |
| 95 | var word = [/\w/, /[^\w\s]/], bigWord = [/\S/]; |
| 96 | function findWord(line, pos, dir, regexps) { |
| 97 | var stop = 0, next = -1; |
| 98 | if (dir > 0) { stop = line.length; next = 0; } |
| 99 | var start = stop, end = stop; |
| 100 | // Find bounds of next one. |
| 101 | outer: for (; pos != stop; pos += dir) { |
| 102 | for (var i = 0; i < regexps.length; ++i) { |
| 103 | if (regexps[i].test(line.charAt(pos + next))) { |
| 104 | start = pos; |
| 105 | for (; pos != stop; pos += dir) { |
| 106 | if (!regexps[i].test(line.charAt(pos + next))) break; |
| 107 | } |
| 108 | end = pos; |
| 109 | break outer; |
| 110 | } |
| 111 | } |
| 112 | } |
| 113 | return {from: Math.min(start, end), to: Math.max(start, end)}; |
| 114 | } |
| 115 | function moveToWord(cm, regexps, dir, where) { |
| 116 | var cur = cm.getCursor(), ch = cur.ch, line = cm.getLine(cur.line), word; |
| 117 | while (true) { |