Mercurial Hosting > editor
diff src/luan_editor/SpellCheckerLuan.java @ 37:b7ff52d45b9a default tip
copy from luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 21 Apr 2025 13:07:29 -0600 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/luan_editor/SpellCheckerLuan.java Mon Apr 21 13:07:29 2025 -0600 @@ -0,0 +1,36 @@ +package luan_editor; + +import java.net.URL; +import java.net.MalformedURLException; +import javax.swing.text.JTextComponent; +import com.inet.jortho.SpellChecker; +import com.inet.jortho.DefaultMessageHandler; +import luan.LuanException; +import luan.LuanRuntimeException; + + +public class SpellCheckerLuan { + + public static void registerDictionaries( String baseURL, String activeLocale) throws MalformedURLException, LuanException { + SpellChecker.setMessageHandler(new DefaultMessageHandler(null) { + @Override public void handleException(java.lang.Throwable throwable) { + throw new LuanRuntimeException(new LuanException(throwable)); + } + } ); + URL url = new URL(baseURL); + try { + SpellChecker.registerDictionaries( url, activeLocale ); + } catch(LuanRuntimeException e) { + LuanException luanException = (LuanException)e.getCause(); + throw luanException; + } + } + + public static void register(JTextComponent text) { + SpellChecker.register(text); + } + + public static void unregister(JTextComponent text) { + SpellChecker.unregister(text); + } +}