Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4287/src/org/python/pydev/editor/actions
Modified Files:
PyAction.java
Log Message:
Added some auxiliary functions.
Index: PyAction.java
===================================================================
RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** PyAction.java 21 Jun 2004 21:36:29 -0000 1.5
--- PyAction.java 16 Jul 2004 15:34:39 -0000 1.6
***************
*** 115,121 ****
int i = 0;
while (i < src.length()) {
! if (!Character.isWhitespace(src.charAt(i++))) {
break;
}
}
setCaretPosition(offset + i - 1);
--- 115,122 ----
int i = 0;
while (i < src.length()) {
! if (!Character.isWhitespace(src.charAt(i))) {
break;
}
+ i++;
}
setCaretPosition(offset + i - 1);
***************
*** 128,140 ****
/**
! * Returns the position of the first char.
* @param doc
* @param cursorOffset
! * @return position of the first character of the line
* @throws BadLocationException
*/
protected int getFirstCharPosition(IDocument doc, int cursorOffset)
throws BadLocationException {
! IRegion region;
region = doc.getLineInformationOfOffset(cursorOffset);
int offset = region.getOffset();
--- 129,157 ----
/**
! * Returns the position of the first non whitespace char in the current line.
* @param doc
* @param cursorOffset
! * @return position of the first character of the line (returned as an absolute
! * offset)
* @throws BadLocationException
*/
protected int getFirstCharPosition(IDocument doc, int cursorOffset)
throws BadLocationException {
! IRegion region;
! region = doc.getLineInformationOfOffset(cursorOffset);
! int offset = region.getOffset();
! return offset + getFirstCharRelativePosition(doc, cursorOffset);
! }
!
!
!
! /**
! * @param doc
! * @param cursorOffset
! * @return
! * @throws BadLocationException
! */
! protected int getFirstCharRelativePosition(IDocument doc, int cursorOffset) throws BadLocationException {
! IRegion region;
region = doc.getLineInformationOfOffset(cursorOffset);
int offset = region.getOffset();
***************
*** 142,151 ****
int i = 0;
while (i < src.length()) {
! if (!Character.isWhitespace(src.charAt(i++))) {
break;
}
}
! return (offset + i - 1);
}
--- 159,207 ----
int i = 0;
+ boolean breaked = false;
while (i < src.length()) {
! if ( Character.isWhitespace(src.charAt(i)) == false && src.charAt(i) != '\t' ) {
! i++;
! breaked = true;
break;
}
+ i++;
}
! if (!breaked){
! i++;
! }
! return (i - 1);
! }
!
! /**
! * Returns the position of the last non whitespace char in the current line.
! * @param doc
! * @param cursorOffset
! * @return position of the last character of the line (returned as an absolute
! * offset)
! *
! * @throws BadLocationException
! */
! protected int getLastCharPosition(IDocument doc, int cursorOffset)
! throws BadLocationException {
! IRegion region;
! region = doc.getLineInformationOfOffset(cursorOffset);
! int offset = region.getOffset();
! String src = doc.get(offset, region.getLength());
!
! int i = src.length();
! boolean breaked = false;
! while (i > 0 ) {
! i--;
! //we have to break if we find a character that is not a whitespace or a tab.
! if ( Character.isWhitespace(src.charAt(i)) == false && src.charAt(i) != '\t' ) {
! breaked = true;
! break;
! }
! }
! if (!breaked){
! i--;
! }
! return (offset + i);
}
|