*
* @return true if it was done and false otherwise.
*/
public boolean execute(IDocument doc, int caretOffset, int commandLineOffset, IScriptConsoleViewer viewer) {
try {
TextSelectionUtils ps = new TextSelectionUtils(doc, caretOffset);
int lineOffset = ps.getLineOffset();
int promptEndOffset = lineOffset;
ScriptConsolePartitioner partitioner = (ScriptConsolePartitioner) doc.getDocumentPartitioner();
int docLen = doc.getLength();
for (; promptEndOffset < docLen; promptEndOffset++) {
ScriptStyleRange[] range = partitioner.getStyleRanges(promptEndOffset, 1);
if (range.length >= 1) {
if (range[0].scriptType != ScriptStyleRange.PROMPT) {
break;
}
}
}
int absoluteCursorOffset = ps.getAbsoluteCursorOffset();
IRegion lineInformation = doc.getLineInformationOfOffset(absoluteCursorOffset);
String contentsFromPrompt = doc.get(promptEndOffset,
lineInformation.getOffset() + lineInformation.getLength() - promptEndOffset);
int firstCharPosition = TextSelectionUtils.getFirstCharPosition(contentsFromPrompt);