/* ------------------------------ main: - name : FixAutoIndent desc : modify the default behavior of jEdit autoindent date : Thursday, September 16, 2004 details: - caption: overview of this script body : | This macro tests to see if the caret is inside the leading whitespace of the current line. If so, it changes the behavior of jedit autoindent. To use this script, put it somewhere in the jedit macros directory and assign the ENTER key as a shortcut. ------------------------------ */ /// begin_: init vars iLine = textArea.getCaretLine(); iLen = textArea.getLineLength(iLine) + 1; iCtPos = textArea.getCaretPosition(); iLSOffset = textArea.getLineStartOffset(iLine); iWidth = iCtPos - iLSOffset; sLText = textArea.getLineText(iLine).toString(); gnu.regexp.RE.oRegExFind = new gnu.regexp.RE("^(\\s*)(.*)", 0, RESearchMatcher.RE_SYNTAX_JEDIT); iLeadingSpace = oRegExFind.getMatch(sLText).toString(1).length(); bInLeadingSpace = false; /// begin_: modified autoindent if(iLeadingSpace >= iWidth){ bInLeadingSpace = true;} if(bInLeadingSpace){ textArea.setCaretPosition(iLSOffset); textArea.userInput('\n'); textArea.setCaretPosition(iLSOffset + iWidth + 1); }else{ textArea.insertEnterAndIndent(); }