jdk/src/share/demo/jfc/CodePointIM/CodePointInputMethod.java
author tbell
Fri, 27 Feb 2009 10:54:11 -0800
changeset 2091 7faffd237305
parent 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2002-2004 Sun Microsystems, Inc.  All Rights Reserved.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 * Redistribution and use in source and binary forms, with or without
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * modification, are permitted provided that the following conditions
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * are met:
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *   - Redistributions of source code must retain the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 *     notice, this list of conditions and the following disclaimer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 *   - Redistributions in binary form must reproduce the above copyright
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 *     notice, this list of conditions and the following disclaimer in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 *     documentation and/or other materials provided with the distribution.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 *   - Neither the name of Sun Microsystems nor the names of its
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *     contributors may be used to endorse or promote products derived
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 *     from this software without specific prior written permission.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
package com.sun.inputmethods.internal.codepointim;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.text.AttributedCharacterIterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.AWTEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.Toolkit;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.awt.event.InputMethodEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.awt.event.KeyEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import java.awt.font.TextAttribute;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import java.awt.font.TextHitInfo;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import java.awt.im.InputMethodHighlight;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
import java.awt.im.spi.InputMethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import java.awt.im.spi.InputMethodContext;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
import java.text.AttributedString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import java.util.Locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 * The Code Point Input Method is a simple input method that allows Unicode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
 * characters to be entered using their code point or code unit values. See the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 * accompanying file README.txt for more information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
 * @author Brian Beck
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
public class CodePointInputMethod implements InputMethod {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    private static final int UNSET           = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private static final int ESCAPE          = 1; // \u0000       - \uFFFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    private static final int SPECIAL_ESCAPE  = 2; // \U000000     - \U10FFFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    private static final int SURROGATE_PAIR  = 3; // \uD800\uDC00 - \uDBFF\uDFFF
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    private InputMethodContext context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    private Locale locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private StringBuffer buffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    private int insertionPoint;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private int format = UNSET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    public CodePointInputMethod() throws IOException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
     * This is the input method's main routine.  The composed text is stored
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
     * in buffer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    public void dispatchEvent(AWTEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        // This input method handles KeyEvent only.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        if (!(event instanceof KeyEvent)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        KeyEvent e = (KeyEvent) event;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        int eventID = event.getID();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        boolean notInCompositionMode = buffer.length() == 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        if (eventID == KeyEvent.KEY_PRESSED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            // If we are not in composition mode, pass through
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            if (notInCompositionMode)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            switch (e.getKeyCode()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
                case KeyEvent.VK_LEFT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                    moveCaretLeft();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                case KeyEvent.VK_RIGHT:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
                    moveCaretRight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        } else if (eventID == KeyEvent.KEY_TYPED) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
            char c = e.getKeyChar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
            // If we are not in composition mode, wait a back slash
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            if (notInCompositionMode)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
                // If the type character is not a back slash, pass through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
                if (c != '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
                    return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
                startComposition();     // Enter to composition mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
                switch (c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                case ' ':       // Exit from composition mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                    finishComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
                case '\u007f':  // Delete
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
                    deleteCharacter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                case '\b':      // BackSpace
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    deletePreviousCharacter();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
                case '\u001b':  // Escape
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                    cancelComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                case '\n':      // Return
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                case '\t':      // Tab
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    composeUnicodeEscape(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                    break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        } else {  // KeyEvent.KEY_RELEASED
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
            // If we are not in composition mode, pass through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            if (notInCompositionMode)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        e.consume();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    private void composeUnicodeEscape(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
        switch (buffer.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
            case  1:  // \\
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                waitEscapeCharacter(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            case 2:  // \\u or \\U
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
            case 3:  // \\ux or \\Ux
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
            case 4:  // \\uxx or \\Uxx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                waitDigit(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            case 5:  // \\uxxx or \\Uxxx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                if (format == SPECIAL_ESCAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                    waitDigit(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                    waitDigit2(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            case 6:  // \\uxxxx or \\Uxxxx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                if (format == SPECIAL_ESCAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    waitDigit(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                } else if (format == SURROGATE_PAIR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                    waitBackSlashOrLowSurrogate(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
                    beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            case 7:  // \\Uxxxxx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
                // Only SPECIAL_ESCAPE format uses this state.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
                // Since the second "\\u" of SURROGATE_PAIR format is inserted
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                // automatically, users don't have to type these keys.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                waitDigit(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            case 8:  // \\uxxxx\\u
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            case 9:  // \\uxxxx\\ux
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            case 10: // \\uxxxx\\uxx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
            case 11: // \\uxxxx\\uxxx
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                if (format == SURROGATE_PAIR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    waitDigit(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                    beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            default:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                break;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    private void waitEscapeCharacter(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        if (c == 'u' || c == 'U') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
            buffer.append(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
            insertionPoint++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
            sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            format = (c == 'u') ? ESCAPE : SPECIAL_ESCAPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
            if (c != '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                buffer.append(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                insertionPoint++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
    private void waitDigit(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
        if (Character.digit(c, 16) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
            buffer.insert(insertionPoint++, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    private void waitDigit2(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
        if (Character.digit(c, 16) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            buffer.insert(insertionPoint++, c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
            char codePoint = (char)getCodePoint(buffer, 2, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            if (Character.isHighSurrogate(codePoint)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                format = SURROGATE_PAIR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                buffer.append("\\u");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                insertionPoint = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                format = ESCAPE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    private void waitBackSlashOrLowSurrogate(char c) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        if (insertionPoint == 6) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            if (c == '\\') {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                buffer.append(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
                buffer.append('u');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                insertionPoint = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
            } else if (Character.digit(c, 16) != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                buffer.append("\\u");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
                buffer.append(c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
                insertionPoint = 9;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
                sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * Send the composed text to the client.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    private void sendComposedText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        AttributedString as = new AttributedString(buffer.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        as.addAttribute(TextAttribute.INPUT_METHOD_HIGHLIGHT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                        InputMethodHighlight.SELECTED_RAW_TEXT_HIGHLIGHT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
        context.dispatchInputMethodEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                                  InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                                  as.getIterator(), 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                                  TextHitInfo.leading(insertionPoint), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
     * Send the committed text to the client.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    private void sendCommittedText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
        AttributedString as = new AttributedString(buffer.toString());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
        context.dispatchInputMethodEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
                                  InputMethodEvent.INPUT_METHOD_TEXT_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
                                  as.getIterator(), buffer.length(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
                                  TextHitInfo.leading(insertionPoint), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        buffer.setLength(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        insertionPoint = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        format = UNSET;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * Move the insertion point one position to the left in the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * Do not let the caret move to the left of the "\\u" or "\\U".
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    private void moveCaretLeft() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        int len = buffer.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
        if (--insertionPoint < 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
            insertionPoint++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
        } else if (format == SURROGATE_PAIR && insertionPoint == 7) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
            insertionPoint = 8;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
        context.dispatchInputMethodEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
                                  InputMethodEvent.CARET_POSITION_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
                                  null, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                                  TextHitInfo.leading(insertionPoint), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * Move the insertion point one position to the right in the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
    private void moveCaretRight() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
        int len = buffer.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        if (++insertionPoint > len) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            insertionPoint = len;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        context.dispatchInputMethodEvent(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                                  InputMethodEvent.CARET_POSITION_CHANGED,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
                                  null, 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
                                  TextHitInfo.leading(insertionPoint), null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
     * Delete the character preceding the insertion point in the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
     * If the insertion point is not at the end of the composed text and the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     * preceding text is "\\u" or "\\U", ring the bell.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    private void deletePreviousCharacter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        if (insertionPoint == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            if (buffer.length() == 2) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
                cancelComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
                // Do not allow deletion of the leading "\\u" or "\\U" if there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                // are other digits in the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
        } else if (insertionPoint == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            if (buffer.length() == 8) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                if (format == SURROGATE_PAIR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
                    buffer.deleteCharAt(--insertionPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
                buffer.deleteCharAt(--insertionPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
                sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
                // Do not allow deletion of the second "\\u" if there are other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
                // digits in the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
                beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
            buffer.deleteCharAt(--insertionPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
            if (buffer.length() == 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
            } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * Delete the character following the insertion point in the composed text.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     * If the insertion point is at the end of the composed text, ring the bell.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    private void deleteCharacter() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        if (insertionPoint < buffer.length()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
            buffer.deleteCharAt(insertionPoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
            beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    private void startComposition() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        buffer.append('\\');
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        insertionPoint = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        sendComposedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    private void cancelComposition() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        buffer.setLength(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        insertionPoint = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    private void finishComposition() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        int len = buffer.length();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
        if (len == 6 && format != SPECIAL_ESCAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
            char codePoint = (char)getCodePoint(buffer, 2, 5);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            if (Character.isValidCodePoint(codePoint) && codePoint != 0xFFFF) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
                buffer.setLength(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
                buffer.append(codePoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
                sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
        } else if (len == 8 && format == SPECIAL_ESCAPE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
            int codePoint = getCodePoint(buffer, 2, 7);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            if (Character.isValidCodePoint(codePoint) && codePoint != 0xFFFF) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
                buffer.setLength(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
                buffer.appendCodePoint(codePoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
                sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
        } else if (len == 12 && format == SURROGATE_PAIR) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
            char[] codePoint = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                (char)getCodePoint(buffer, 2, 5),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                (char)getCodePoint(buffer, 8, 11)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
            if (Character.isHighSurrogate(codePoint[0]) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                Character.isLowSurrogate(codePoint[1])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
                buffer.setLength(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
                buffer.append(codePoint);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
                sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
                return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
        beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    private int getCodePoint(StringBuffer sb, int from, int to) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        int value = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        for (int i = from; i <= to; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
            value = (value<<4) + Character.digit(sb.charAt(i), 16);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        return value;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    private static void beep() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
        Toolkit.getDefaultToolkit().beep();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    public void activate() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        if (buffer == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            buffer = new StringBuffer(12);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            insertionPoint = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    public void deactivate(boolean isTemporary) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        if (!isTemporary) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            buffer = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    public void dispose() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    public Object getControlObject() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public void endComposition() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        sendCommittedText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    public Locale getLocale() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        return locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    public void hideWindows() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    public boolean isCompositionEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        // always enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    public void notifyClientWindowChange(Rectangle location) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    public void reconvert() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
        // not supported yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
    public void removeNotify() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    public void setCharacterSubsets(Character.Subset[] subsets) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    public void setCompositionEnabled(boolean enable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
        // not supported yet
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
        throw new UnsupportedOperationException();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    public void setInputMethodContext(InputMethodContext context) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        this.context = context;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
     * The Code Point Input Method supports all locales.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    public boolean setLocale(Locale locale) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
        this.locale = locale;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
}