diff --git a/build.gradle b/build.gradle index af4050b..41818cb 100644 --- a/build.gradle +++ b/build.gradle @@ -25,8 +25,8 @@ android { applicationId "org.billthefarmer.editor" minSdkVersion 14 targetSdkVersion 28 - versionName "1.72" - versionCode 172 + versionName "1.73" + versionCode 173 buildConfigField "long", "BUILT", System.currentTimeMillis() + "L" } diff --git a/fastlane/metadata/android/en-GB/changelogs/173.txt b/fastlane/metadata/android/en-GB/changelogs/173.txt new file mode 100644 index 0000000..68f18b1 --- /dev/null +++ b/fastlane/metadata/android/en-GB/changelogs/173.txt @@ -0,0 +1,2 @@ + * Add Emacs Org syntax highlighting + * Update shell script syntax highlighting diff --git a/src/main/java/org/billthefarmer/editor/Editor.java b/src/main/java/org/billthefarmer/editor/Editor.java index d4a2735..dcd52c7 100644 --- a/src/main/java/org/billthefarmer/editor/Editor.java +++ b/src/main/java/org/billthefarmer/editor/Editor.java @@ -348,6 +348,9 @@ public class Editor extends Activity public final static Pattern MD_CODE = Pattern.compile ("(^ {4,}.+$)|(`.+?`)", Pattern.MULTILINE); + public final static Pattern SH_VAR = Pattern.compile + ("(\\$\\b\\w+\\b)|(\\$\\{.+?\\})|(\\$\\(.+?\\))", Pattern.MULTILINE); + public final static Pattern SH_COMMENT = Pattern.compile ("#.*$", Pattern.MULTILINE); @@ -2671,6 +2674,39 @@ private void highlightText() Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } + matcher.region(start, end).usePattern(SH_VAR); + while (matcher.find()) + { + ForegroundColorSpan span = new + ForegroundColorSpan(Color.MAGENTA); + + // Highlight it + editable.setSpan(span, matcher.start(), matcher.end(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + + matcher.region(start, end).usePattern(OPERATOR); + while (matcher.find()) + { + ForegroundColorSpan span = new + ForegroundColorSpan(Color.CYAN); + + // Highlight it + editable.setSpan(span, matcher.start(), matcher.end(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + + matcher.region(start, end).usePattern(QUOTED); + while (matcher.find()) + { + ForegroundColorSpan span = new + ForegroundColorSpan(Color.RED); + + // Highlight it + editable.setSpan(span, matcher.start(), matcher.end(), + Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + matcher.region(start, end).usePattern(SH_COMMENT); while (matcher.find()) {