src/java.desktop/macosx/classes/sun/lwawt/macosx/CInputMethod.java
Print this page
*** 420,430 ****
/**
* Tell the component to commit all of the characters in the string to the current
* text view. This effectively wipes out any text in progress.
*/
! synchronized private void insertText(String aString) {
AttributedString attribString = new AttributedString(aString);
// Set locale information on the new string.
attribString.addAttribute(Attribute.LANGUAGE, getLocale(), 0, aString.length());
--- 420,430 ----
/**
* Tell the component to commit all of the characters in the string to the current
* text view. This effectively wipes out any text in progress.
*/
! private synchronized void insertText(String aString) {
AttributedString attribString = new AttributedString(aString);
// Set locale information on the new string.
attribString.addAttribute(Attribute.LANGUAGE, getLocale(), 0, aString.length());
*** 445,459 ****
fCurrentTextAsString = new String(rawText);
fCurrentText = new AttributedString(fCurrentTextAsString);
fCurrentTextLength = rawText.length();
}
! static private final int kCaretPosition = 0;
! static private final int kRawText = 1;
! static private final int kSelectedRawText = 2;
! static private final int kConvertedText = 3;
! static private final int kSelectedConvertedText = 4;
/**
* Convert Cocoa text highlight attributes into Java input method highlighting.
*/
private void addAttribute (boolean isThickUnderline, boolean isGray, int start, int length) {
--- 445,459 ----
fCurrentTextAsString = new String(rawText);
fCurrentText = new AttributedString(fCurrentTextAsString);
fCurrentTextLength = rawText.length();
}
! private static final int kCaretPosition = 0;
! private static final int kRawText = 1;
! private static final int kSelectedRawText = 2;
! private static final int kConvertedText = 3;
! private static final int kSelectedConvertedText = 4;
/**
* Convert Cocoa text highlight attributes into Java input method highlighting.
*/
private void addAttribute (boolean isThickUnderline, boolean isGray, int start, int length) {
*** 554,564 ****
}
/**
* Frequent callbacks from NSTextInput. I think we're supposed to commit it here?
*/
! synchronized private void unmarkText() {
if (fCurrentText == null)
return;
TextHitInfo theCaret = TextHitInfo.afterOffset(fCurrentTextLength);
TextHitInfo visiblePosition = theCaret;
--- 554,564 ----
}
/**
* Frequent callbacks from NSTextInput. I think we're supposed to commit it here?
*/
! private synchronized void unmarkText() {
if (fCurrentText == null)
return;
TextHitInfo theCaret = TextHitInfo.afterOffset(fCurrentTextLength);
TextHitInfo visiblePosition = theCaret;
*** 572,591 ****
fCurrentText = null;
fCurrentTextAsString = null;
fCurrentTextLength = 0;
}
! synchronized private boolean hasMarkedText() {
return fCurrentText != null;
}
/**
* Cocoa assumes the marked text and committed text is all stored in the same storage, but
* Java does not. So, we have to see where the request is and based on that return the right
* substring.
*/
! synchronized private String attributedSubstringFromRange(final int locationIn, final int lengthIn) {
final String[] retString = new String[1];
try {
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(retString) {
--- 572,591 ----
fCurrentText = null;
fCurrentTextAsString = null;
fCurrentTextLength = 0;
}
! private synchronized boolean hasMarkedText() {
return fCurrentText != null;
}
/**
* Cocoa assumes the marked text and committed text is all stored in the same storage, but
* Java does not. So, we have to see where the request is and based on that return the right
* substring.
*/
! private synchronized String attributedSubstringFromRange(final int locationIn, final int lengthIn) {
final String[] retString = new String[1];
try {
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(retString) {
*** 633,643 ****
* Cocoa wants the range of characters that are currently selected. We have to synthesize this
* by getting the insert location and the length of the selected text. NB: This does NOT allow
* for the fact that the insert point in Swing can come AFTER the selected text, making this
* potentially incorrect.
*/
! synchronized private int[] selectedRange() {
final int[] returnValue = new int[2];
try {
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(returnValue) {
--- 633,643 ----
* Cocoa wants the range of characters that are currently selected. We have to synthesize this
* by getting the insert location and the length of the selected text. NB: This does NOT allow
* for the fact that the insert point in Swing can come AFTER the selected text, making this
* potentially incorrect.
*/
! private synchronized int[] selectedRange() {
final int[] returnValue = new int[2];
try {
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(returnValue) {
*** 681,691 ****
* Cocoa wants the range of characters that are currently marked. Since Java doesn't store committed and
* text in progress (composed text) together, we have to synthesize it. We know where the text will be
* inserted, so we can return that position, and the length of the text in progress. If there is no marked text
* return null.
*/
! synchronized private int[] markedRange() {
if (fCurrentText == null)
return null;
final int[] returnValue = new int[2];
--- 681,691 ----
* Cocoa wants the range of characters that are currently marked. Since Java doesn't store committed and
* text in progress (composed text) together, we have to synthesize it. We know where the text will be
* inserted, so we can return that position, and the length of the text in progress. If there is no marked text
* return null.
*/
! private synchronized int[] markedRange() {
if (fCurrentText == null)
return null;
final int[] returnValue = new int[2];
*** 708,718 ****
* location of that rectangle. We are given the index of the character for which we want the location on
* screen, which will be a character in the in-progress text. By subtracting the current insert position,
* which is always in front of the in-progress text, we get the offset into the composed text, and we get
* that location from the input method context.
*/
! synchronized private int[] firstRectForCharacterRange(final int absoluteTextOffset) {
final int[] rect = new int[4];
try {
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(rect) {
--- 708,718 ----
* location of that rectangle. We are given the index of the character for which we want the location on
* screen, which will be a character in the in-progress text. By subtracting the current insert position,
* which is always in front of the in-progress text, we get the offset into the composed text, and we get
* that location from the input method context.
*/
! private synchronized int[] firstRectForCharacterRange(final int absoluteTextOffset) {
final int[] rect = new int[4];
try {
LWCToolkit.invokeAndWait(new Runnable() {
public void run() { synchronized(rect) {
*** 751,761 ****
/* This method returns the index for the character that is nearest to the point described by screenX and screenY.
* The coordinates are in Java screen coordinates. If no character in the composed text was hit, we return -1, indicating
* not found.
*/
! synchronized private int characterIndexForPoint(final int screenX, final int screenY) {
final TextHitInfo[] offsetInfo = new TextHitInfo[1];
final int[] insertPositionOffset = new int[1];
try {
LWCToolkit.invokeAndWait(new Runnable() {
--- 751,761 ----
/* This method returns the index for the character that is nearest to the point described by screenX and screenY.
* The coordinates are in Java screen coordinates. If no character in the composed text was hit, we return -1, indicating
* not found.
*/
! private synchronized int characterIndexForPoint(final int screenX, final int screenY) {
final TextHitInfo[] offsetInfo = new TextHitInfo[1];
final int[] insertPositionOffset = new int[1];
try {
LWCToolkit.invokeAndWait(new Runnable() {