110 // with the input method. It is used to save the composition mode when
111 // focus is traversed across different client components sharing the
112 // same java input context. Also if set/isCompositionEnabled are not
113 // supported, it remains false.
114 protected boolean savedCompositionState = false;
115
116 // variables to keep track of preedit context.
117 // these variables need to be accessed within AWT_LOCK/UNLOCK
118 protected String committedText = null;
119 protected StringBuffer composedText = null;
120 protected IntBuffer rawFeedbacks;
121
122 // private data (X11InputMethodData structure defined in
123 // awt_InputMethod.c) for native methods
124 // this structure needs to be accessed within AWT_LOCK/UNLOCK
125 protected transient long pData = 0; // accessed by native
126
127 // Initialize highlight mapping table
128 static {
129 @SuppressWarnings({"unchecked", "rawtypes"})
130 Map<TextAttribute, ?> styles[] = new Map[4];
131 HashMap<TextAttribute, Object> map;
132
133 // UNSELECTED_RAW_TEXT_HIGHLIGHT
134 map = new HashMap<>(1);
135 map.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
136 styles[0] = Collections.unmodifiableMap(map);
137
138 // SELECTED_RAW_TEXT_HIGHLIGHT
139 map = new HashMap<>(1);
140 map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
141 styles[1] = Collections.unmodifiableMap(map);
142
143 // UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
144 map = new HashMap<>(1);
145 map.put(TextAttribute.INPUT_METHOD_UNDERLINE,
146 TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
147 styles[2] = Collections.unmodifiableMap(map);
148
149 // SELECTED_CONVERTED_TEXT_HIGHLIGHT
150 map = new HashMap<>(1);
473 }
474
475 private void dispatchCommittedText(String str) {
476 dispatchCommittedText(str, EventQueue.getMostRecentEventTime());
477 }
478
479 /**
480 * Updates composed text with XIM preedit information and
481 * posts composed text to the awt event queue. The args of
482 * this method correspond to the XIM preedit callback
483 * information. The XIM highlight attributes are translated via
484 * fixed mapping (i.e., independent from any underlying input
485 * method engine). This method is invoked in the AWT Toolkit
486 * (X event loop) thread context and thus inside the AWT Lock.
487 */
488 // NOTE: This method may be called by privileged threads.
489 // This functionality is implemented in a package-private method
490 // to insure that it cannot be overridden by client subclasses.
491 // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
492 abstract void dispatchComposedText(String chgText,
493 int chgStyles[],
494 int chgOffset,
495 int chgLength,
496 int caretPosition,
497 long when);
498
499 /**
500 * Flushes composed and committed text held in this context.
501 * This method is invoked in the AWT Toolkit (X event loop) thread context
502 * and thus inside the AWT Lock.
503 */
504 // NOTE: This method may be called by privileged threads.
505 // This functionality is implemented in a package-private method
506 // to insure that it cannot be overridden by client subclasses.
507 // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
508 void flushText() {
509 String flush = (committedText != null ? committedText : "");
510 if (composedText != null) {
511 flush += composedText.toString();
512 }
513
|
110 // with the input method. It is used to save the composition mode when
111 // focus is traversed across different client components sharing the
112 // same java input context. Also if set/isCompositionEnabled are not
113 // supported, it remains false.
114 protected boolean savedCompositionState = false;
115
116 // variables to keep track of preedit context.
117 // these variables need to be accessed within AWT_LOCK/UNLOCK
118 protected String committedText = null;
119 protected StringBuffer composedText = null;
120 protected IntBuffer rawFeedbacks;
121
122 // private data (X11InputMethodData structure defined in
123 // awt_InputMethod.c) for native methods
124 // this structure needs to be accessed within AWT_LOCK/UNLOCK
125 protected transient long pData = 0; // accessed by native
126
127 // Initialize highlight mapping table
128 static {
129 @SuppressWarnings({"unchecked", "rawtypes"})
130 Map<TextAttribute, ?>[] styles = new Map[4];
131 HashMap<TextAttribute, Object> map;
132
133 // UNSELECTED_RAW_TEXT_HIGHLIGHT
134 map = new HashMap<>(1);
135 map.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD);
136 styles[0] = Collections.unmodifiableMap(map);
137
138 // SELECTED_RAW_TEXT_HIGHLIGHT
139 map = new HashMap<>(1);
140 map.put(TextAttribute.SWAP_COLORS, TextAttribute.SWAP_COLORS_ON);
141 styles[1] = Collections.unmodifiableMap(map);
142
143 // UNSELECTED_CONVERTED_TEXT_HIGHLIGHT
144 map = new HashMap<>(1);
145 map.put(TextAttribute.INPUT_METHOD_UNDERLINE,
146 TextAttribute.UNDERLINE_LOW_ONE_PIXEL);
147 styles[2] = Collections.unmodifiableMap(map);
148
149 // SELECTED_CONVERTED_TEXT_HIGHLIGHT
150 map = new HashMap<>(1);
473 }
474
475 private void dispatchCommittedText(String str) {
476 dispatchCommittedText(str, EventQueue.getMostRecentEventTime());
477 }
478
479 /**
480 * Updates composed text with XIM preedit information and
481 * posts composed text to the awt event queue. The args of
482 * this method correspond to the XIM preedit callback
483 * information. The XIM highlight attributes are translated via
484 * fixed mapping (i.e., independent from any underlying input
485 * method engine). This method is invoked in the AWT Toolkit
486 * (X event loop) thread context and thus inside the AWT Lock.
487 */
488 // NOTE: This method may be called by privileged threads.
489 // This functionality is implemented in a package-private method
490 // to insure that it cannot be overridden by client subclasses.
491 // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
492 abstract void dispatchComposedText(String chgText,
493 int[] chgStyles,
494 int chgOffset,
495 int chgLength,
496 int caretPosition,
497 long when);
498
499 /**
500 * Flushes composed and committed text held in this context.
501 * This method is invoked in the AWT Toolkit (X event loop) thread context
502 * and thus inside the AWT Lock.
503 */
504 // NOTE: This method may be called by privileged threads.
505 // This functionality is implemented in a package-private method
506 // to insure that it cannot be overridden by client subclasses.
507 // DO NOT INVOKE CLIENT CODE ON THIS THREAD!
508 void flushText() {
509 String flush = (committedText != null ? committedText : "");
510 if (composedText != null) {
511 flush += composedText.toString();
512 }
513
|