public void click(double x, double y) { Line now = text.start.line; for (; ; ) { y -= now.start.next.format.Height; if (y < 0) break; now = now.next; if (now.start.kind == Kind_word.Start) { now = now.before; break; } } for (word = now.start.next; ; word = word.next) { if (word.kind == Kind_word.Break || word.kind == Kind_word.End) { pos = 0; break; } if (x < word.format.WidthIncludingTrailingWhitespace) { pos = word.get_pos(x); break; } x -= word.format.WidthIncludingTrailingWhitespace; } }