Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 1a0d1ea

Browse files
Add protected visibility modifier
1 parent c17c62f commit 1a0d1ea

File tree

2 files changed

+21
-16
lines changed

2 files changed

+21
-16
lines changed

editorkit/src/main/kotlin/com/blacksquircle/ui/editorkit/widget/internal/LineNumbersEditText.kt

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ abstract class LineNumbersEditText @JvmOverloads constructor(
4949
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {
5050
doBeforeTextChanged(s, start, count, after)
5151
}
52+
5253
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {
5354
doOnTextChanged(s, start, before, count)
5455
}
56+
5557
override fun afterTextChanged(s: Editable?) {
5658
doAfterTextChanged(s)
5759
}
@@ -68,12 +70,17 @@ abstract class LineNumbersEditText @JvmOverloads constructor(
6870
InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS
6971
}
7072

71-
open fun doBeforeTextChanged(text: CharSequence?, start: Int, count: Int, after: Int) {
73+
protected open fun doBeforeTextChanged(
74+
text: CharSequence?,
75+
start: Int,
76+
count: Int,
77+
after: Int
78+
) {
7279
textChangeStart = start
7380
textChangeEnd = start + count
7481
}
7582

76-
open fun doOnTextChanged(text: CharSequence?, start: Int, before: Int, count: Int) {
83+
protected open fun doOnTextChanged(text: CharSequence?, start: Int, before: Int, count: Int) {
7784
textChangedNewText = text?.subSequence(start, start + count) ?: ""
7885
replaceText(textChangeStart, textChangeEnd, textChangedNewText)
7986
val startLine = structure.getLineForIndex(textChangeStart)
@@ -87,7 +94,15 @@ abstract class LineNumbersEditText @JvmOverloads constructor(
8794
}
8895
}
8996

90-
open fun doAfterTextChanged(text: Editable?) = Unit
97+
protected open fun doAfterTextChanged(text: Editable?) = Unit
98+
99+
protected open fun processLine(lineNumber: Int, lineStart: Int, lineEnd: Int) = Unit
100+
101+
protected open fun addLine(lineNumber: Int, lineStart: Int) =
102+
structure.add(lineNumber, lineStart)
103+
104+
protected open fun removeLine(lineNumber: Int) =
105+
structure.remove(lineNumber)
91106

92107
open fun setTextContent(text: CharSequence) {
93108
removeTextChangedListener(textWatcher)
@@ -103,7 +118,7 @@ abstract class LineNumbersEditText @JvmOverloads constructor(
103118
addTextChangedListener(textWatcher)
104119
}
105120

106-
open fun replaceText(newStart: Int, newEnd: Int, newText: CharSequence) {
121+
private fun replaceText(newStart: Int, newEnd: Int, newText: CharSequence) {
107122
val start = if (newStart < 0) 0 else newStart
108123
val end = if (newEnd > structure.text.length) structure.text.length else newEnd
109124
val newCharCount = newText.length - (end - start)
@@ -124,14 +139,4 @@ abstract class LineNumbersEditText @JvmOverloads constructor(
124139
editable.replace(start, end, newText)
125140
}
126141
}
127-
128-
open fun processLine(lineNumber: Int, lineStart: Int, lineEnd: Int) = Unit
129-
130-
open fun addLine(lineNumber: Int, lineStart: Int) {
131-
structure.add(lineNumber, lineStart)
132-
}
133-
134-
open fun removeLine(lineNumber: Int) {
135-
structure.remove(lineNumber)
136-
}
137142
}

editorkit/src/main/kotlin/com/blacksquircle/ui/editorkit/widget/internal/SyntaxHighlightEditText.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ abstract class SyntaxHighlightEditText @JvmOverloads constructor(
119119
syntaxHighlight()
120120
}
121121

122-
open fun onLanguageChanged() {
122+
protected open fun onLanguageChanged() {
123123
syntaxHighlight()
124124
}
125125

126-
open fun onColorSchemeChanged() {
126+
protected open fun onColorSchemeChanged() {
127127
findResultStyleSpan = StyleSpan(color = colorScheme.findResultBackgroundColor)
128128
setTextColor(colorScheme.textColor)
129129
setCursorDrawableColor(colorScheme.cursorColor)

0 commit comments

Comments
 (0)