Here you can find the source of indentationStringOfCursorLine(String text, int cursor)
public static String indentationStringOfCursorLine(String text, int cursor)
//package com.java2s; //License from project: Apache License public class Main { public static String indentationStringOfCursorLine(String text, int cursor) { int lineStart = startColOfCursorLine(text, cursor); int firstCharAt = lineStart; while (firstCharAt < text.length()) { // TODO: tab indentation? if (text.charAt(firstCharAt) != ' ') { break; }/*from w w w . j a va 2 s . c o m*/ ++firstCharAt; } return text.substring(lineStart, firstCharAt); } public static int startColOfCursorLine(String text, int cursor) { int i = cursor; while (i > 0) { char c = text.charAt(i - 1); if (c == '\n') { break; } --i; } return i; } }