Mercurial Hosting > luan
changeset 1897:8ed184a0cde2
regex and swing
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 14 Apr 2025 12:46:45 -0600 |
parents | 1cd29d57c9c1 |
children | 49e2103ebf6a |
files | src/luan/modules/RegexLuan.java src/luan/modules/swing/Abstract_button.luan |
diffstat | 2 files changed, 15 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/RegexLuan.java Sun Apr 13 20:59:22 2025 -0600 +++ b/src/luan/modules/RegexLuan.java Mon Apr 14 12:46:45 2025 -0600 @@ -2,6 +2,7 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; +import java.util.regex.PatternSyntaxException; import luan.Luan; import luan.LuanMutable; import luan.LuanTable; @@ -13,8 +14,12 @@ public Pattern pattern; private boolean immutable = false; - public RegexLuan(String s) { - this.pattern = Pattern.compile(s); + public RegexLuan(String s) throws LuanException { + try { + this.pattern = Pattern.compile(s); + } catch(java.util.regex.PatternSyntaxException e) { + throw new LuanException(e.getMessage(),e); + } } @Override public boolean isImmutable() { @@ -41,7 +46,7 @@ int n = m.groupCount(); Object[] rtn = new Object[2+n]; rtn[0] = m.start() + 1; - rtn[1] = m.end(); + rtn[1] = m.end() + 1; for( int i=0; i<n; i++ ) { rtn[2+i] = m.group(i+1); }
--- a/src/luan/modules/swing/Abstract_button.luan Sun Apr 13 20:59:22 2025 -0600 +++ b/src/luan/modules/swing/Abstract_button.luan Mon Apr 14 12:46:45 2025 -0600 @@ -26,6 +26,9 @@ if key == "text" then return abstract_button.java.getText() end + if key == "is_selected" then + return abstract_button.java.isSelected() + end return fail end @@ -36,6 +39,10 @@ abstract_button.java.setText(value) return end + if key == "is_selected" then + abstract_button.java.setSelected(value) + return + end return fail end