(code, id, x, y, ticks, mode)
| 345 | this.onTouchBeganMode(code, id, x, y, ticks, CHAR_MODE); |
| 346 | } |
| 347 | onTouchBeganMode(code, id, x, y, ticks, mode) { |
| 348 | code.focus(); |
| 349 | if ((ticks - this.touchTicks < 1000) && (this.touchX == x) && (this.touchY == y)) { |
| 350 | this.touchCount++; |
| 351 | if (this.touchCount == 4) |
| 352 | this.touchCount = 1; |
| 353 | } |
| 354 | else { |
| 355 | this.touchCount = 1; |
| 356 | this.touchX = x; |
| 357 | this.touchY = y; |
| 358 | } |
| 359 | this.touchTicks = ticks; |
| 360 | if (mode == CHAR_MODE) { |
| 361 | if (this.touchCount == 2) |
| 362 | mode = WORD_MODE; |
| 363 | else if (this.touchCount == 3) |
| 364 | mode = LINE_MODE; |
| 365 | } |
| 366 | this.mode = mode; |
| 367 | var anchor = this.anchor; |
| 368 | var bounds = code.bounds; |
| 369 | var offset = code.hitOffset(x - bounds.x, y - bounds.y); |
| 370 | var from, to; |
| 371 | if (this.mode == LINE_MODE) { |
| 372 | if (shiftKey) { |
| 373 | if (offset < anchor.to) { |
| 374 | from = code.findLineBreak(offset, false); |
| 375 | to = code.selectionOffset + code.selectionLength; |
| 376 | } |
| 377 | else { |
| 378 | from = code.selectionOffset; |
| 379 | to = code.findLineBreak(offset, true); |
| 380 | } |
| 381 | } |
| 382 | else { |
| 383 | from = anchor.from = code.findLineBreak(offset, false); |
| 384 | to = anchor.to = code.findLineBreak(offset, true); |
| 385 | } |
| 386 | } |
| 387 | else if (this.mode == WORD_MODE) { |
| 388 | if (shiftKey) { |
| 389 | if (offset < anchor.to) { |
| 390 | from = code.findWordBreak(offset, false); |
| 391 | to = code.selectionOffset + code.selectionLength; |
| 392 | } |
| 393 | else { |
| 394 | from = code.selectionOffset; |
| 395 | to = code.findWordBreak(offset, true); |
| 396 | } |
| 397 | } |
| 398 | else { |
| 399 | var range = code.findBlock(offset); |
| 400 | if (range) { |
| 401 | from = range.from; |
| 402 | to = range.to; |
| 403 | anchor.from = anchor.to = offset; |
| 404 | } |
no test coverage detected