657 * IM server or language service and we want to try our best to return as much
658 * information as possible.
659 *
660 * Note: This method could return null on Linux if XMODIFIERS is not set properly or
661 * if any IOException is thrown.
662 * See man page of XSetLocaleModifiers(3X11) for the usgae of XMODIFIERS,
663 * atok12setup(1) and wnn6setup(1) for the information written to
664 * $HOME/.dtprofile when you run these two commands.
665 *
666 */
667 public String getNativeInputMethodInfo() {
668 String xmodifiers = System.getenv("XMODIFIERS");
669 String imInfo = null;
670
671 // If XMODIFIERS is set, return the value
672 if (xmodifiers != null) {
673 int imIndex = xmodifiers.indexOf("@im=");
674 if (imIndex != -1) {
675 imInfo = xmodifiers.substring(imIndex + 4);
676 }
677 } else if (System.getProperty("os.name").startsWith("SunOS")) {
678 File dtprofile = new File(System.getProperty("user.home") +
679 "/.dtprofile");
680 String languageEngineInfo = null;
681 try {
682 BufferedReader br = new BufferedReader(new FileReader(dtprofile));
683 String line = null;
684
685 while ( languageEngineInfo == null && (line = br.readLine()) != null) {
686 if (line.contains("atok") || line.contains("wnn")) {
687 StringTokenizer tokens = new StringTokenizer(line);
688 while (tokens.hasMoreTokens()) {
689 String token = tokens.nextToken();
690 if (Pattern.matches("atok.*setup", token) ||
691 Pattern.matches("wnn.*setup", token)){
692 languageEngineInfo = token.substring(0, token.indexOf("setup"));
693 break;
694 }
695 }
696 }
697 }
698
699 br.close();
700 } catch(IOException ioex) {
701 // Since this method is provided for internal testing only,
702 // we dump the stack trace for the ease of debugging.
703 ioex.printStackTrace();
704 }
705
706 imInfo = "htt " + languageEngineInfo;
707 }
708
709 return imInfo;
710 }
711
712
713 /**
714 * Performs mapping from an XIM visible feedback value to Java IM highlight.
715 * @return Java input method highlight
716 */
717 protected InputMethodHighlight convertVisualFeedbackToHighlight(int feedback) {
718 InputMethodHighlight highlight;
719
720 switch (feedback) {
721 case XIMUnderline:
722 highlight = InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT;
723 break;
724 case XIMReverse:
725 highlight = InputMethodHighlight.SELECTED_CONVERTED_TEXT_HIGHLIGHT;
726 break;
|
657 * IM server or language service and we want to try our best to return as much
658 * information as possible.
659 *
660 * Note: This method could return null on Linux if XMODIFIERS is not set properly or
661 * if any IOException is thrown.
662 * See man page of XSetLocaleModifiers(3X11) for the usgae of XMODIFIERS,
663 * atok12setup(1) and wnn6setup(1) for the information written to
664 * $HOME/.dtprofile when you run these two commands.
665 *
666 */
667 public String getNativeInputMethodInfo() {
668 String xmodifiers = System.getenv("XMODIFIERS");
669 String imInfo = null;
670
671 // If XMODIFIERS is set, return the value
672 if (xmodifiers != null) {
673 int imIndex = xmodifiers.indexOf("@im=");
674 if (imIndex != -1) {
675 imInfo = xmodifiers.substring(imIndex + 4);
676 }
677 }
678
679 return imInfo;
680 }
681
682
683 /**
684 * Performs mapping from an XIM visible feedback value to Java IM highlight.
685 * @return Java input method highlight
686 */
687 protected InputMethodHighlight convertVisualFeedbackToHighlight(int feedback) {
688 InputMethodHighlight highlight;
689
690 switch (feedback) {
691 case XIMUnderline:
692 highlight = InputMethodHighlight.UNSELECTED_CONVERTED_TEXT_HIGHLIGHT;
693 break;
694 case XIMReverse:
695 highlight = InputMethodHighlight.SELECTED_CONVERTED_TEXT_HIGHLIGHT;
696 break;
|