@@ -2,13 +2,13 @@ package me.testica.codeeditor
22
33import android.content.Context
44import android.graphics.Color
5+ import android.support.v7.widget.AppCompatEditText
56import android.text.InputType
67import android.text.Spanned
78import android.text.method.ScrollingMovementMethod
89import android.text.style.ForegroundColorSpan
910import android.util.AttributeSet
1011import android.view.Gravity
11- import android.widget.EditText
1212import java.util.regex.Pattern
1313
1414
@@ -18,7 +18,7 @@ import java.util.regex.Pattern
1818 * -> Listener when line count changes
1919 * -> Listener when vertical scroll changes
2020 */
21- class EditorText (context : Context , attrs : AttributeSet ): EditText (context, attrs) {
21+ class EditorText (context : Context , attrs : AttributeSet ): AppCompatEditText (context, attrs) {
2222
2323 private var mNumberLines = 0
2424
@@ -100,7 +100,7 @@ class EditorText(context: Context, attrs: AttributeSet): EditText(context, attrs
100100 if (syntaxHighlightRules.isNullOrEmpty()) return
101101
102102 // first remove all spans
103- text.removeAllSpans()
103+ text? .removeAllSpans()
104104
105105 // set span for proper matching according to a rule
106106 for (syntaxHighlightRule in syntaxHighlightRules!! ) {
@@ -109,7 +109,7 @@ class EditorText(context: Context, attrs: AttributeSet): EditText(context, attrs
109109 // TODO: catch exception
110110 val matcher = Pattern .compile(syntaxHighlightRule.regex).matcher(text)
111111
112- while (matcher.find()) text.setSpan(
112+ while (matcher.find()) text? .setSpan(
113113 ForegroundColorSpan (color),
114114 matcher.start(),
115115 matcher.end(),
0 commit comments