int cursorAtCharacter(final Location atLocation, final int lineOffset) { final String text = getText(lineOffset); if (text == null) { for (int i = lineOffset; i >= 0; i--) { final String text2 = getText(i); if (text2 != null) { final int at = text2.length(); LOG.debug("character at " + at + " line " + lineOffset); return at; } } } /* * slightly offsetting mouse helps the user position the cursor between * characters near the pointer rather than always after the pointer */ final int x = atLocation.getX() - 3; int at = 0; final int endAt = text.length(); int width = 0; while (at < endAt && x > width) { width += target.getText().charWidth(text.charAt(at)); at++; } LOG.debug("character at " + at + " line " + lineOffset); return at; }
@Override public void showDebugFrame(final DebuggableWithTitle[] info, final Location at) { final InfoDebugFrame f = new InfoDebugFrame(); f.setInfo(info); f.show(at.getX(), at.getY()); }