(code, id, x, y, ticks, mode)
| 326 | this.onTouchBeganMode(code, id, x, y, ticks, CHAR_MODE); |
| 327 | } |
| 328 | onTouchBeganMode(code, id, x, y, ticks, mode) { |
| 329 | code.focus(); |
| 330 | if ((ticks - this.touchTicks < 1000) && (this.touchX == x) && (this.touchY == y)) { |
| 331 | this.touchCount++; |
| 332 | if (this.touchCount == 4) |
| 333 | this.touchCount = 1; |
| 334 | } |
| 335 | else { |
| 336 | this.touchCount = 1; |
| 337 | this.touchX = x; |
| 338 | this.touchY = y; |
| 339 | } |
| 340 | this.touchTicks = ticks; |
| 341 | if (mode == CHAR_MODE) { |
| 342 | if (this.touchCount == 2) |
| 343 | mode = WORD_MODE; |
| 344 | else if (this.touchCount == 3) |
| 345 | mode = LINE_MODE; |
| 346 | } |
| 347 | this.mode = mode; |
| 348 | var anchor = this.anchor; |
| 349 | var bounds = code.bounds; |
| 350 | var offset = code.hitOffset(x - bounds.x, y - bounds.y); |
| 351 | var from, to; |
| 352 | if (this.mode == LINE_MODE) { |
| 353 | if (shiftKey) { |
| 354 | if (offset < anchor.to) { |
| 355 | from = code.findLineBreak(offset, false); |
| 356 | to = code.selectionOffset + code.selectionLength; |
| 357 | } |
| 358 | else { |
| 359 | from = code.selectionOffset; |
| 360 | to = code.findLineBreak(offset, true); |
| 361 | } |
| 362 | } |
| 363 | else { |
| 364 | from = anchor.from = code.findLineBreak(offset, false); |
| 365 | to = anchor.to = code.findLineBreak(offset, true); |
| 366 | } |
| 367 | } |
| 368 | else if (this.mode == WORD_MODE) { |
| 369 | if (shiftKey) { |
| 370 | if (offset < anchor.to) { |
| 371 | from = code.findWordBreak(offset, false); |
| 372 | to = code.selectionOffset + code.selectionLength; |
| 373 | } |
| 374 | else { |
| 375 | from = code.selectionOffset; |
| 376 | to = code.findWordBreak(offset, true); |
| 377 | } |
| 378 | } |
| 379 | else { |
| 380 | var range = code.findBlock(offset); |
| 381 | if (range) { |
| 382 | from = range.from; |
| 383 | to = range.to; |
| 384 | anchor.from = anchor.to = offset; |
| 385 | } |
no test coverage detected