|
@@ -281,16 +281,16 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
fun longPress(
|
|
fun longPress(
|
|
|
x: Float,
|
|
x: Float,
|
|
|
y: Float,
|
|
y: Float,
|
|
|
- select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit,
|
|
|
|
|
|
|
+ select: (textPos: TextPos) -> Unit,
|
|
|
) {
|
|
) {
|
|
|
- touch(x, y) { _, relativePos, _, lineIndex, _, charIndex, textChar ->
|
|
|
|
|
|
|
+ touch(x, y) { _, textPos, _, _, textChar ->
|
|
|
if (textChar.isImage) {
|
|
if (textChar.isImage) {
|
|
|
callBack.onImageLongPress(x, y, textChar.charData)
|
|
callBack.onImageLongPress(x, y, textChar.charData)
|
|
|
} else {
|
|
} else {
|
|
|
if (!selectAble) return@touch
|
|
if (!selectAble) return@touch
|
|
|
textChar.selected = true
|
|
textChar.selected = true
|
|
|
invalidate()
|
|
invalidate()
|
|
|
- select(relativePos, lineIndex, charIndex)
|
|
|
|
|
|
|
+ select(textPos)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -300,7 +300,7 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
* @return true:已处理, false:未处理
|
|
* @return true:已处理, false:未处理
|
|
|
*/
|
|
*/
|
|
|
fun click(x: Float, y: Float): Boolean {
|
|
fun click(x: Float, y: Float): Boolean {
|
|
|
- touch(x, y) { _, relativePos, textPage, lineIndex, textLine, charIndex, textChar ->
|
|
|
|
|
|
|
+ touch(x, y) { _, textPos, textPage, textLine, textChar ->
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
return false
|
|
return false
|
|
@@ -312,12 +312,12 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
fun selectText(
|
|
fun selectText(
|
|
|
x: Float,
|
|
x: Float,
|
|
|
y: Float,
|
|
y: Float,
|
|
|
- select: (relativePage: Int, lineIndex: Int, charIndex: Int) -> Unit,
|
|
|
|
|
|
|
+ select: (textPos: TextPos) -> Unit,
|
|
|
) {
|
|
) {
|
|
|
- touch(x, y) { _, relativePos, _, lineIndex, _, charIndex, textChar ->
|
|
|
|
|
|
|
+ touch(x, y) { _, textPos, _, _, textChar ->
|
|
|
textChar.selected = true
|
|
textChar.selected = true
|
|
|
invalidate()
|
|
invalidate()
|
|
|
- select(relativePos, lineIndex, charIndex)
|
|
|
|
|
|
|
+ select(textPos)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -325,11 +325,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
* 开始选择符移动
|
|
* 开始选择符移动
|
|
|
*/
|
|
*/
|
|
|
fun selectStartMove(x: Float, y: Float) {
|
|
fun selectStartMove(x: Float, y: Float) {
|
|
|
- touch(x, y) { relativeOffset, relativePos, _, lineIndex, textLine, charIndex, textChar ->
|
|
|
|
|
- val pos = TextPos(relativePos, lineIndex, charIndex)
|
|
|
|
|
- if (selectStart.compare(pos) != 0) {
|
|
|
|
|
- if (pos.compare(selectEnd) <= 0) {
|
|
|
|
|
- selectStart.upData(pos = pos)
|
|
|
|
|
|
|
+ touch(x, y) { relativeOffset, textPos, _, textLine, textChar ->
|
|
|
|
|
+ if (selectStart.compare(textPos) != 0) {
|
|
|
|
|
+ if (textPos.compare(selectEnd) <= 0) {
|
|
|
|
|
+ selectStart.upData(pos = textPos)
|
|
|
upSelectedStart(
|
|
upSelectedStart(
|
|
|
textChar.start,
|
|
textChar.start,
|
|
|
textLine.lineBottom + relativeOffset,
|
|
textLine.lineBottom + relativeOffset,
|
|
@@ -345,11 +344,10 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
* 结束选择符移动
|
|
* 结束选择符移动
|
|
|
*/
|
|
*/
|
|
|
fun selectEndMove(x: Float, y: Float) {
|
|
fun selectEndMove(x: Float, y: Float) {
|
|
|
- touch(x, y) { relativeOffset, relativePos, _, lineIndex, textLine, charIndex, textChar ->
|
|
|
|
|
- val pos = TextPos(relativePos, lineIndex, charIndex)
|
|
|
|
|
- if (pos.compare(selectEnd) != 0) {
|
|
|
|
|
- if (pos.compare(selectStart) >= 0) {
|
|
|
|
|
- selectEnd.upData(pos)
|
|
|
|
|
|
|
+ touch(x, y) { relativeOffset, textPos, _, textLine, textChar ->
|
|
|
|
|
+ if (textPos.compare(selectEnd) != 0) {
|
|
|
|
|
+ if (textPos.compare(selectStart) >= 0) {
|
|
|
|
|
+ selectEnd.upData(textPos)
|
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset)
|
|
upSelectedEnd(textChar.end, textLine.lineBottom + relativeOffset)
|
|
|
upSelectChars()
|
|
upSelectChars()
|
|
|
}
|
|
}
|
|
@@ -366,11 +364,9 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
y: Float,
|
|
y: Float,
|
|
|
touched: (
|
|
touched: (
|
|
|
relativeOffset: Float,
|
|
relativeOffset: Float,
|
|
|
- relativePos: Int,
|
|
|
|
|
|
|
+ textPos: TextPos,
|
|
|
textPage: TextPage,
|
|
textPage: TextPage,
|
|
|
- lineIndex: Int,
|
|
|
|
|
textLine: TextLine,
|
|
textLine: TextLine,
|
|
|
- charIndex: Int,
|
|
|
|
|
textChar: TextChar
|
|
textChar: TextChar
|
|
|
) -> Unit
|
|
) -> Unit
|
|
|
) {
|
|
) {
|
|
@@ -390,9 +386,8 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
|
|
|
if (textChar.isTouch(x)) {
|
|
if (textChar.isTouch(x)) {
|
|
|
touched.invoke(
|
|
touched.invoke(
|
|
|
relativeOffset,
|
|
relativeOffset,
|
|
|
- relativePos, textPage,
|
|
|
|
|
- lineIndex, textLine,
|
|
|
|
|
- charIndex, textChar
|
|
|
|
|
|
|
+ TextPos(relativePos, lineIndex, charIndex),
|
|
|
|
|
+ textPage, textLine, textChar
|
|
|
)
|
|
)
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|