[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/actions PyMethodNavigation.java, 1.6, 1.7
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/actions Modified Files: PyMethodNavigation.java PyFormatStd.java FirstCharAction.java PyOpenAction.java PyShowBrowser.java PyShowOutline.java PyAction.java PySelectWord.java PyGoToDefinition.java OfflineActionTarget.java PyOrganizeImports.java PyConvertTabToSpace.java PyBackspace.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: PySelectWord.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PySelectWord.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PySelectWord.java 1 Jun 2006 17:45:01 -0000 1.1 --- PySelectWord.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 9,27 **** public class PySelectWord extends PyAction{ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! try { ! Tuple<String,Integer> currToken = ps.getCurrToken(); ! if(currToken.o1 != null){ ! int len = currToken.o1.length(); ! if(len > 0){ ! pyEdit.selectAndReveal(currToken.o2, len); ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } } --- 9,27 ---- public class PySelectWord extends PyAction{ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! try { ! Tuple<String,Integer> currToken = ps.getCurrToken(); ! if(currToken.o1 != null){ ! int len = currToken.o1.length(); ! if(len > 0){ ! pyEdit.selectAndReveal(currToken.o2, len); ! } ! } ! } catch (Exception e) { ! PydevPlugin.log(e); ! } ! } } Index: PyConvertTabToSpace.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyConvertTabToSpace.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyConvertTabToSpace.java 14 Jun 2008 22:14:55 -0000 1.6 --- PyConvertTabToSpace.java 28 Sep 2008 12:45:41 -0000 1.7 *************** *** 77,81 **** } ! // If all goes well, replace the text with the modified information doc.replace(ps.getStartLine().getOffset(), ps.getSelLength(), strbuf.toString()); return true; --- 77,81 ---- } ! // If all goes well, replace the text with the modified information doc.replace(ps.getStartLine().getOffset(), ps.getSelLength(), strbuf.toString()); return true; Index: PyShowBrowser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyShowBrowser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyShowBrowser.java 21 Feb 2006 19:27:37 -0000 1.1 --- PyShowBrowser.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 8,14 **** public class PyShowBrowser extends PyShowOutline{ ! @Override ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_GLOBALS_BROWSER; ! } } --- 8,14 ---- public class PyShowBrowser extends PyShowOutline{ ! @Override ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_GLOBALS_BROWSER; ! } } Index: PyMethodNavigation.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyMethodNavigation.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyMethodNavigation.java 23 Feb 2008 18:58:09 -0000 1.6 --- PyMethodNavigation.java 28 Sep 2008 12:45:41 -0000 1.7 *************** *** 24,38 **** public abstract class PyMethodNavigation extends PyAction { ! /** ! * This method will search for the next/previous function (depending on the abstract methods) ! * and will go to the position in the document that corresponds to the name of the class/function definiton. ! */ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ! ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); ! boolean searchForward = getSearchForward(); ! int startLine = selection.getStartLine(); --- 24,38 ---- public abstract class PyMethodNavigation extends PyAction { ! /** ! * This method will search for the next/previous function (depending on the abstract methods) ! * and will go to the position in the document that corresponds to the name of the class/function definiton. ! */ ! public void run(IAction action) { ! PyEdit pyEdit = getPyEdit(); ! IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ! ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); ! boolean searchForward = getSearchForward(); ! int startLine = selection.getStartLine(); *************** *** 44,48 **** } stmtType goHere = FastParser.firstClassOrFunction(doc, startLine, searchForward); ! NameTok node = getNameNode(goHere); if(node != null){ --- 44,48 ---- } stmtType goHere = FastParser.firstClassOrFunction(doc, startLine, searchForward); ! NameTok node = getNameNode(goHere); if(node != null){ *************** *** 59,75 **** } } ! } ! /** ! * @return true if the search should be forward (next method) and false if it should be backward (previous method) ! */ ! protected abstract boolean getSearchForward(); ! /** ! * @param defNode the ClassDef or FunctionDef from where we want to get the name ! * @return the name of the given statement ! */ protected NameTok getNameNode(stmtType defNode) { ! NameTok node = null; if(defNode != null){ if(defNode instanceof ClassDef){ --- 59,75 ---- } } ! } ! /** ! * @return true if the search should be forward (next method) and false if it should be backward (previous method) ! */ ! protected abstract boolean getSearchForward(); ! /** ! * @param defNode the ClassDef or FunctionDef from where we want to get the name ! * @return the name of the given statement ! */ protected NameTok getNameNode(stmtType defNode) { ! NameTok node = null; if(defNode != null){ if(defNode instanceof ClassDef){ *************** *** 82,87 **** } } ! return node; ! } --- 82,87 ---- } } ! return node; ! } Index: PyOpenAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOpenAction.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** PyOpenAction.java 6 Aug 2008 16:23:19 -0000 1.20 --- PyOpenAction.java 28 Sep 2008 12:45:41 -0000 1.21 *************** *** 45,55 **** textEdit.getSelectionProvider().setSelection(sel); } catch (BadLocationException e1) { ! if(textEdit instanceof PyEdit){ ! PyEdit p = (PyEdit) textEdit; ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end+" - "+p.getEditorFile(), e1); ! ! }else{ ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end, e1); ! } } } --- 45,55 ---- textEdit.getSelectionProvider().setSelection(sel); } catch (BadLocationException e1) { ! if(textEdit instanceof PyEdit){ ! PyEdit p = (PyEdit) textEdit; ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end+" - "+p.getEditorFile(), e1); ! ! }else{ ! PydevPlugin.log(IStatus.ERROR, "Error setting selection:"+start+" - "+end, e1); ! } } } *************** *** 65,69 **** } else if (file instanceof IFile) { ! IFile f = (IFile) file; editor = PyOpenEditor.doOpenEditor(f); --- 65,69 ---- } else if (file instanceof IFile) { ! IFile f = (IFile) file; editor = PyOpenEditor.doOpenEditor(f); *************** *** 74,78 **** } else if (file instanceof File) { String absPath = REF.getFileAbsolutePath((File) file); ! IPath path = Path.fromOSString(absPath); editor = PyOpenEditor.doOpenEditor(path); } --- 74,78 ---- } else if (file instanceof File) { String absPath = REF.getFileAbsolutePath((File) file); ! IPath path = Path.fromOSString(absPath); editor = PyOpenEditor.doOpenEditor(path); } Index: PyShowOutline.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyShowOutline.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyShowOutline.java 21 Feb 2006 19:27:37 -0000 1.4 --- PyShowOutline.java 28 Sep 2008 12:45:41 -0000 1.5 *************** *** 17,60 **** public class PyShowOutline extends PyAction{ ! protected IEditorActionDelegate registered; ! /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.run(action); ! } } public void setActiveEditor(IAction action, IEditorPart targetEditor){ ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.setActiveEditor(action, targetEditor); ! } } @Override public void selectionChanged(IAction action, ISelection selection) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.selectionChanged(action, selection); ! } } ! protected IEditorActionDelegate getParticipant() { ! if(registered != null){ ! return registered; ! } ! ! registered = (IEditorActionDelegate) ExtensionHelper.getParticipant(getExtensionName()); ! return registered; ! } ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_QUICK_OUTLINE; ! } } --- 17,60 ---- public class PyShowOutline extends PyAction{ ! protected IEditorActionDelegate registered; ! /* (non-Javadoc) * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ public void run(IAction action) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.run(action); ! } } public void setActiveEditor(IAction action, IEditorPart targetEditor){ ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.setActiveEditor(action, targetEditor); ! } } @Override public void selectionChanged(IAction action, ISelection selection) { ! IEditorActionDelegate participant = getParticipant(); ! if(participant != null){ ! participant.selectionChanged(action, selection); ! } } ! protected IEditorActionDelegate getParticipant() { ! if(registered != null){ ! return registered; ! } ! ! registered = (IEditorActionDelegate) ExtensionHelper.getParticipant(getExtensionName()); ! return registered; ! } ! protected String getExtensionName() { ! return ExtensionHelper.PYDEV_QUICK_OUTLINE; ! } } Index: PyOrganizeImports.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOrganizeImports.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyOrganizeImports.java 16 Jun 2008 00:55:34 -0000 1.19 --- PyOrganizeImports.java 28 Sep 2008 12:45:41 -0000 1.20 *************** *** 44,90 **** */ @SuppressWarnings("unchecked") ! public void run(IAction action) { ! try ! { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! String endLineDelim = ps.getEndLineDelim(); ! final IDocument doc = ps.getDoc(); ! DocumentRewriteSession session = null; ! ! try { ! if (ps.getStartLineIndex() == ps.getEndLineIndex()) { ! //let's see if someone wants to make a better implementation in another plugin... ! List<IOrganizeImports> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_ORGANIZE_IMPORTS); ! ! for (IOrganizeImports organizeImports : participants) { if(!organizeImports.beforePerformArrangeImports(ps, pyEdit)){ return; } } ! ! session = startWrite(doc); ! ! performArrangeImports(doc, endLineDelim, pyEdit.getIndentPrefs().getIndentationString()); ! ! for (IOrganizeImports organizeImports : participants) { ! organizeImports.afterPerformArrangeImports(ps, pyEdit); ! } ! } else { ! session = startWrite(doc); ! performSimpleSort(doc, endLineDelim, ps.getStartLineIndex(), ps.getEndLineIndex()); ! } ! } finally { ! if(session != null){ ! endWrite(doc, session); ! } ! } ! } ! catch ( Exception e ) ! { PydevPlugin.log(e); ! beep ( e ); ! } } --- 44,90 ---- */ @SuppressWarnings("unchecked") ! public void run(IAction action) { ! try ! { ! PyEdit pyEdit = getPyEdit(); ! PySelection ps = new PySelection(pyEdit); ! String endLineDelim = ps.getEndLineDelim(); ! final IDocument doc = ps.getDoc(); ! DocumentRewriteSession session = null; ! ! try { ! if (ps.getStartLineIndex() == ps.getEndLineIndex()) { ! //let's see if someone wants to make a better implementation in another plugin... ! List<IOrganizeImports> participants = ExtensionHelper.getParticipants(ExtensionHelper.PYDEV_ORGANIZE_IMPORTS); ! ! for (IOrganizeImports organizeImports : participants) { if(!organizeImports.beforePerformArrangeImports(ps, pyEdit)){ return; } } ! ! session = startWrite(doc); ! ! performArrangeImports(doc, endLineDelim, pyEdit.getIndentPrefs().getIndentationString()); ! ! for (IOrganizeImports organizeImports : participants) { ! organizeImports.afterPerformArrangeImports(ps, pyEdit); ! } ! } else { ! session = startWrite(doc); ! performSimpleSort(doc, endLineDelim, ps.getStartLineIndex(), ps.getEndLineIndex()); ! } ! } finally { ! if(session != null){ ! endWrite(doc, session); ! } ! } ! } ! catch ( Exception e ) ! { PydevPlugin.log(e); ! beep ( e ); ! } } *************** *** 92,112 **** * Stop a rewrite session */ ! private void endWrite(IDocument doc, DocumentRewriteSession session) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! d.stopRewriteSession(session); ! } ! } ! /** ! * Starts a rewrite session (keep things in a single undo/redo) ! */ ! private DocumentRewriteSession startWrite(IDocument doc) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! return d.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED); ! } ! return null; ! } /** --- 92,112 ---- * Stop a rewrite session */ ! private void endWrite(IDocument doc, DocumentRewriteSession session) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! d.stopRewriteSession(session); ! } ! } ! /** ! * Starts a rewrite session (keep things in a single undo/redo) ! */ ! private DocumentRewriteSession startWrite(IDocument doc) { ! if(doc instanceof IDocumentExtension4){ ! IDocumentExtension4 d = (IDocumentExtension4) doc; ! return d.startRewriteSession(DocumentRewriteSessionType.UNRESTRICTED); ! } ! return null; ! } /** *************** *** 117,126 **** */ @SuppressWarnings("unchecked") ! public static void performArrangeImports(IDocument doc, String endLineDelim, String indentStr){ ! List<Tuple3<Integer, String, ImportHandle>> list = new ArrayList<Tuple3<Integer, String, ImportHandle>>(); ! //Gather imports in a structure we can work on. ! PyImportsHandling pyImportsHandling = new PyImportsHandling(doc); ! int firstImport = -1; ! for(ImportHandle imp:pyImportsHandling){ list.add( new Tuple3<Integer, String, ImportHandle>(imp.startFoundLine, imp.importFound, imp) ); --- 117,126 ---- */ @SuppressWarnings("unchecked") ! public static void performArrangeImports(IDocument doc, String endLineDelim, String indentStr){ ! List<Tuple3<Integer, String, ImportHandle>> list = new ArrayList<Tuple3<Integer, String, ImportHandle>>(); ! //Gather imports in a structure we can work on. ! PyImportsHandling pyImportsHandling = new PyImportsHandling(doc); ! int firstImport = -1; ! for(ImportHandle imp:pyImportsHandling){ list.add( new Tuple3<Integer, String, ImportHandle>(imp.startFoundLine, imp.importFound, imp) ); *************** *** 128,139 **** firstImport = imp.startFoundLine; } ! } ! ! //check if we had any import ! if(firstImport == -1){ ! return; ! } ! //sort in inverse order (for removal of the string of the document). Collections.sort(list, new Comparator<Tuple3<Integer, String, ImportHandle>>() { --- 128,139 ---- firstImport = imp.startFoundLine; } ! } ! ! //check if we had any import ! if(firstImport == -1){ ! return; ! } ! //sort in inverse order (for removal of the string of the document). Collections.sort(list, new Comparator<Tuple3<Integer, String, ImportHandle>>() { *************** *** 405,419 **** */ @SuppressWarnings("unchecked") ! public static void performSimpleSort(IDocument doc, String endLineDelim, int startLine, int endLine) { try { ! ArrayList<String> list = new ArrayList<String>(); ! ! StringBuffer lastLine = null; ! for (int i = startLine; i <= endLine; i++) { ! ! String line = PySelection.getLine(doc, i); ! if(lastLine != null){ ! int len = lastLine.length(); if(len > 0 && lastLine.charAt(len-1) == '\\'){ lastLine.append(endLineDelim); --- 405,419 ---- */ @SuppressWarnings("unchecked") ! public static void performSimpleSort(IDocument doc, String endLineDelim, int startLine, int endLine) { try { ! ArrayList<String> list = new ArrayList<String>(); ! ! StringBuffer lastLine = null; ! for (int i = startLine; i <= endLine; i++) { ! String line = PySelection.getLine(doc, i); ! ! if(lastLine != null){ ! int len = lastLine.length(); if(len > 0 && lastLine.charAt(len-1) == '\\'){ lastLine.append(endLineDelim); *************** *** 423,444 **** lastLine = new StringBuffer(line); } ! }else{ ! lastLine = new StringBuffer(line); ! } ! } ! ! if(lastLine != null){ ! list.add(lastLine.toString()); ! } ! ! Collections.sort(list); ! StringBuffer all = new StringBuffer(); ! for (Iterator iter = list.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! all.append(element); ! if(iter.hasNext()) ! all.append(endLineDelim); ! } ! int length = doc.getLineInformation(endLine).getLength(); int endOffset = doc.getLineInformation(endLine).getOffset()+length; --- 423,444 ---- lastLine = new StringBuffer(line); } ! }else{ ! lastLine = new StringBuffer(line); ! } ! } ! ! if(lastLine != null){ ! list.add(lastLine.toString()); ! } ! ! Collections.sort(list); ! StringBuffer all = new StringBuffer(); ! for (Iterator iter = list.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); ! all.append(element); ! if(iter.hasNext()) ! all.append(endLineDelim); ! } ! int length = doc.getLineInformation(endLine).getLength(); int endOffset = doc.getLineInformation(endLine).getOffset()+length; Index: PyFormatStd.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyFormatStd.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** PyFormatStd.java 17 Aug 2008 00:26:46 -0000 1.21 --- PyFormatStd.java 28 Sep 2008 12:45:41 -0000 1.22 *************** *** 231,266 **** case '+': case '-': ! ! if(c == '-' || c == '+'){ // could also be * ! ! //handle exponentials correctly: e.g.: 1e-6 cannot have a space ! FastStringBuffer localBufToCheckNumber = new FastStringBuffer(); ! for(int j=buf.length()-1;j>=0;j--){ ! char localC = buf.charAt(j); ! if(Character.isJavaIdentifierPart(localC)){ ! localBufToCheckNumber.append(localC); ! }else{ ! break; ! } ! } ! boolean isExponential = true;; ! String partialNumber = localBufToCheckNumber.reverse().toString(); ! int partialLen = partialNumber.length(); ! if(partialLen < 2 || !Character.isDigit(partialNumber.charAt(0))){ ! //at least 2 chars: the number and the 'e' ! isExponential = false; ! }else{ ! //first char checked... now, if the last is an 'e', we must leave it together no matter what ! if(partialNumber.charAt(partialLen-1) != 'e'){ ! isExponential = false; ! break; ! } ! } ! if(isExponential){ ! buf.append(c); ! break; ! } ! //Otherwise, FALLTHROUGH ! } case '/': --- 231,266 ---- case '+': case '-': ! ! if(c == '-' || c == '+'){ // could also be * ! ! //handle exponentials correctly: e.g.: 1e-6 cannot have a space ! FastStringBuffer localBufToCheckNumber = new FastStringBuffer(); ! for(int j=buf.length()-1;j>=0;j--){ ! char localC = buf.charAt(j); ! if(Character.isJavaIdentifierPart(localC)){ ! localBufToCheckNumber.append(localC); ! }else{ ! break; ! } ! } ! boolean isExponential = true;; ! String partialNumber = localBufToCheckNumber.reverse().toString(); ! int partialLen = partialNumber.length(); ! if(partialLen < 2 || !Character.isDigit(partialNumber.charAt(0))){ ! //at least 2 chars: the number and the 'e' ! isExponential = false; ! }else{ ! //first char checked... now, if the last is an 'e', we must leave it together no matter what ! if(partialNumber.charAt(partialLen-1) != 'e'){ ! isExponential = false; ! break; ! } ! } ! if(isExponential){ ! buf.append(c); ! break; ! } ! //Otherwise, FALLTHROUGH ! } case '/': Index: OfflineActionTarget.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/OfflineActionTarget.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** OfflineActionTarget.java 14 Jun 2008 22:14:55 -0000 1.7 --- OfflineActionTarget.java 28 Sep 2008 12:45:41 -0000 1.8 *************** *** 60,64 **** */ private boolean fIsStatusFieldExtension; ! private PyEdit fEdit; --- 60,64 ---- */ private boolean fIsStatusFieldExtension; ! private PyEdit fEdit; *************** *** 192,209 **** } else { ! switch (event.character) { // ESC = quit case 0x1B: ! leave(); ! event.doit= false; ! break; ! //CR = exec and quit case 0x0D: ! boolean executed = doExec(); event.doit= false; if(!executed){ ! return; //we don't want to update the status } break; --- 192,209 ---- } else { ! switch (event.character) { // ESC = quit case 0x1B: ! leave(); ! event.doit= false; ! break; ! //CR = exec and quit case 0x0D: ! boolean executed = doExec(); event.doit= false; if(!executed){ ! return; //we don't want to update the status } break; *************** *** 212,216 **** case 0x08: case 0x7F: ! removeLastCharSearch(); event.doit= false; break; --- 212,216 ---- case 0x08: case 0x7F: ! removeLastCharSearch(); event.doit= false; break; *************** *** 240,244 **** final boolean executed = fEdit.onOfflineAction(fFindString.toString(), this); if(executed){ ! leave(); } return executed; --- 240,244 ---- final boolean executed = fEdit.onOfflineAction(fFindString.toString(), this); if(executed){ ! leave(); } return executed; *************** *** 251,266 **** */ public void removeLastCharSearchAndUpdateStatus() { ! removeLastCharSearch(); ! updateStatus(); } private void removeLastCharSearch() { ! final int len = fFindString.length(); ! if(len > 0){ ! fFindString.deleteCharAt(len-1); ! } ! } ! /** * Adds the given character to the search string and repeats the search with the last parameters. * --- 251,266 ---- */ public void removeLastCharSearchAndUpdateStatus() { ! removeLastCharSearch(); ! updateStatus(); } private void removeLastCharSearch() { ! final int len = fFindString.length(); ! if(len > 0){ ! fFindString.deleteCharAt(len-1); ! } ! } ! /** * Adds the given character to the search string and repeats the search with the last parameters. * *************** *** 426,431 **** ! public boolean isInstalled() { ! return fInstalled; ! } } --- 426,431 ---- ! public boolean isInstalled() { ! return fInstalled; ! } } Index: PyBackspace.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyBackspace.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyBackspace.java 19 Mar 2008 02:22:30 -0000 1.19 --- PyBackspace.java 28 Sep 2008 12:45:41 -0000 1.20 *************** *** 122,132 **** */ public void run(IAction action) { ! OfflineActionTarget adapter = (OfflineActionTarget) getPyEdit().getAdapter(OfflineActionTarget.class); ! if(adapter != null){ ! if(adapter.isInstalled()){ ! adapter.removeLastCharSearchAndUpdateStatus(); ! return; ! } ! } PySelection ps = new PySelection(getTextEditor()); perform(ps); --- 122,132 ---- */ public void run(IAction action) { ! OfflineActionTarget adapter = (OfflineActionTarget) getPyEdit().getAdapter(OfflineActionTarget.class); ! if(adapter != null){ ! if(adapter.isInstalled()){ ! adapter.removeLastCharSearchAndUpdateStatus(); ! return; ! } ! } PySelection ps = new PySelection(getTextEditor()); perform(ps); *************** *** 150,157 **** // |a (delete to previous indentation - considers cursor position) // ! //or ! // // as | as (delete single char) ! // //so, we have to treat it carefully //TODO: use the conditions above and not just erase a single --- 150,157 ---- // |a (delete to previous indentation - considers cursor position) // ! //or ! // // as | as (delete single char) ! // //so, we have to treat it carefully //TODO: use the conditions above and not just erase a single *************** *** 159,167 **** if(PySelection.containsOnlyWhitespaces(lineContentsToCursor)){ ! eraseToIndentation(ps, lineContentsToCursor); ! ! }else{ ! eraseSingleChar(ps); ! } } } --- 159,167 ---- if(PySelection.containsOnlyWhitespaces(lineContentsToCursor)){ ! eraseToIndentation(ps, lineContentsToCursor); ! ! }else{ ! eraseSingleChar(ps); ! } } } Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** PyAction.java 15 Jun 2008 16:45:26 -0000 1.37 --- PyAction.java 28 Sep 2008 12:45:41 -0000 1.38 *************** *** 47,215 **** ! // Always points to the current editor ! protected volatile IEditorPart targetEditor; ! public void setEditor(IEditorPart targetEditor) { ! this.targetEditor = targetEditor; ! } ! ! /** ! * This is an IEditorActionDelegate override ! */ ! public void setActiveEditor(IAction action, IEditorPart targetEditor) { ! setEditor(targetEditor); ! } ! /** ! * Activate action (if we are getting text) ! */ ! public void selectionChanged(IAction action, ISelection selection) { ! action.setEnabled(true); ! } ! public static String getDelimiter(IDocument doc){ ! return PySelection.getDelimiter(doc); ! } ! ! /** ! * This function returns the text editor. ! */ ! protected ITextEditor getTextEditor() { ! if (targetEditor instanceof ITextEditor) { ! return (ITextEditor) targetEditor; ! } else { ! throw new RuntimeException("Expecting text editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! /** ! * @return python editor. ! */ ! protected PyEdit getPyEdit() { ! if (targetEditor instanceof PyEdit) { ! return (PyEdit) targetEditor; ! } else { ! throw new RuntimeException("Expecting PyEdit editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! ! /** ! * Helper for setting caret ! * @param pos ! * @throws BadLocationException ! */ ! protected void setCaretPosition(int pos) throws BadLocationException { ! getTextEditor().selectAndReveal(pos, 0); ! } ! /** ! * Are we in the first char of the line with the offset passed? ! * @param doc ! * @param cursorOffset ! */ ! protected void isInFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! if ("".equals(src)) ! return; ! int i = 0; ! while (i < src.length()) { ! if (!Character.isWhitespace(src.charAt(i))) { ! break; ! } ! i++; ! } ! setCaretPosition(offset + i - 1); ! } catch (BadLocationException e) { ! beep(e); ! return; ! } ! } ! /** ! * 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); ! } ! /** ! * Goes to first char of the line. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! setCaretPosition(offset); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! setCaretPosition(PySelection.getFirstCharPosition(doc, cursorOffset)); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected boolean isAtFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! return PySelection.getFirstCharPosition(doc, cursorOffset) == cursorOffset; ! } catch (BadLocationException e) { ! return false; ! } ! } ! //================================================================ ! // HELPER FOR DEBBUGING... ! //================================================================ ! /* ! * Beep...humm... yeah....beep....ehehheheh ! */ ! protected static void beep(Exception e) { try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); --- 47,215 ---- ! // Always points to the current editor ! protected volatile IEditorPart targetEditor; ! public void setEditor(IEditorPart targetEditor) { ! this.targetEditor = targetEditor; ! } ! ! /** ! * This is an IEditorActionDelegate override ! */ ! public void setActiveEditor(IAction action, IEditorPart targetEditor) { ! setEditor(targetEditor); ! } ! /** ! * Activate action (if we are getting text) ! */ ! public void selectionChanged(IAction action, ISelection selection) { ! action.setEnabled(true); ! } ! public static String getDelimiter(IDocument doc){ ! return PySelection.getDelimiter(doc); ! } ! ! /** ! * This function returns the text editor. ! */ ! protected ITextEditor getTextEditor() { ! if (targetEditor instanceof ITextEditor) { ! return (ITextEditor) targetEditor; ! } else { ! throw new RuntimeException("Expecting text editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! /** ! * @return python editor. ! */ ! protected PyEdit getPyEdit() { ! if (targetEditor instanceof PyEdit) { ! return (PyEdit) targetEditor; ! } else { ! throw new RuntimeException("Expecting PyEdit editor. Found:"+targetEditor.getClass().getName()); ! } ! } ! ! /** ! * Helper for setting caret ! * @param pos ! * @throws BadLocationException ! */ ! protected void setCaretPosition(int pos) throws BadLocationException { ! getTextEditor().selectAndReveal(pos, 0); ! } ! /** ! * Are we in the first char of the line with the offset passed? ! * @param doc ! * @param cursorOffset ! */ ! protected void isInFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! String src = doc.get(offset, region.getLength()); ! if ("".equals(src)) ! return; ! int i = 0; ! while (i < src.length()) { ! if (!Character.isWhitespace(src.charAt(i))) { ! break; ! } ! i++; ! } ! setCaretPosition(offset + i - 1); ! } catch (BadLocationException e) { ! beep(e); ! return; ! } ! } ! /** ! * 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); ! } ! /** ! * Goes to first char of the line. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstChar(IDocument doc, int cursorOffset) { ! try { ! IRegion region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); ! setCaretPosition(offset); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected void gotoFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! setCaretPosition(PySelection.getFirstCharPosition(doc, cursorOffset)); ! } catch (BadLocationException e) { ! beep(e); ! } ! } ! /** ! * Goes to the first visible char. ! * @param doc ! * @param cursorOffset ! */ ! protected boolean isAtFirstVisibleChar(IDocument doc, int cursorOffset) { ! try { ! return PySelection.getFirstCharPosition(doc, cursorOffset) == cursorOffset; ! } catch (BadLocationException e) { ! return false; ! } ! } ! //================================================================ ! // HELPER FOR DEBBUGING... ! //================================================================ ! /* ! * Beep...humm... yeah....beep....ehehheheh ! */ ! protected static void beep(Exception e) { try{ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getDisplay().beep(); *************** *** 217,222 **** //ignore, workbench has still not been created } ! e.printStackTrace(); ! } --- 217,222 ---- //ignore, workbench has still not been created } ! e.printStackTrace(); ! } *************** *** 244,255 **** */ public static int countChars(char c, String line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } --- 244,255 ---- */ public static int countChars(char c, String line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } *************** *** 262,273 **** */ public static int countChars(char c, StringBuffer line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } --- 262,273 ---- */ public static int countChars(char c, StringBuffer line) { ! int ret = 0; ! int len = line.length(); ! for (int i = 0; i < len; i++) { ! if(line.charAt(i) == c){ ! ret += 1; ! } ! } ! return ret; } Index: FirstCharAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/FirstCharAction.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** FirstCharAction.java 28 Feb 2004 05:13:16 -0000 1.1 --- FirstCharAction.java 28 Sep 2008 12:45:41 -0000 1.2 *************** *** 15,33 **** */ public void run(IAction action) { ! ! try{ ! ITextEditor textEditor = getTextEditor(); ! IDocument doc = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); ! ITextSelection selection = (ITextSelection)textEditor.getSelectionProvider().getSelection(); ! ! boolean isAtFirstChar = isAtFirstVisibleChar(doc, selection.getOffset()); ! if (! isAtFirstChar){ ! gotoFirstVisibleChar(doc, selection.getOffset()); ! }else{ ! gotoFirstChar(doc, selection.getOffset()); ! } ! }catch(Exception e){ ! beep(e); ! } } } \ No newline at end of file --- 15,33 ---- */ public void run(IAction action) { ! ! try{ ! ITextEditor textEditor = getTextEditor(); ! IDocument doc = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()); ! ITextSelection selection = (ITextSelection)textEditor.getSelectionProvider().getSelection(); ! ! boolean isAtFirstChar = isAtFirstVisibleChar(doc, selection.getOffset()); ! if (! isAtFirstChar){ ! gotoFirstVisibleChar(doc, selection.getOffset()); ! }else{ ! gotoFirstChar(doc, selection.getOffset()); ! } ! }catch(Exception e){ ! beep(e); ! } } } \ No newline at end of file Index: PyGoToDefinition.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyGoToDefinition.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** PyGoToDefinition.java 11 Jan 2008 01:01:18 -0000 1.28 --- PyGoToDefinition.java 28 Sep 2008 12:45:41 -0000 1.29 *************** *** 66,70 **** pyRefactoring.checkAvailableForRefactoring(request); } catch (Exception e) { ! e.printStackTrace(); ErrorDialog.openError(null, "Error", "Unable to do requested action", new Status(Status.ERROR, PydevPlugin.getPluginID(), 0, e.getMessage(), null)); --- 66,70 ---- pyRefactoring.checkAvailableForRefactoring(request); } catch (Exception e) { ! e.printStackTrace(); ErrorDialog.openError(null, "Error", "Unable to do requested action", new Status(Status.ERROR, PydevPlugin.getPluginID(), 0, e.getMessage(), null)); *************** *** 73,77 **** if (request.pyEdit.isDirty()) ! request.pyEdit.doSave(null); return true; --- 73,77 ---- if (request.pyEdit.isDirty()) ! request.pyEdit.doSave(null); return true; *************** *** 88,92 **** public ItemPointer[] findDefinitionsAndOpen(boolean doOpenDefinition) { ! request = null; final Shell shell = getShell(); try { --- 88,92 ---- public ItemPointer[] findDefinitionsAndOpen(boolean doOpenDefinition) { ! request = null; final Shell shell = getShell(); try { *************** *** 103,107 **** } catch (Exception e) { e.printStackTrace(); ! PydevPlugin.log(e); String msg = e.getMessage(); if(msg == null){ --- 103,107 ---- } catch (Exception e) { e.printStackTrace(); ! PydevPlugin.log(e); String msg = e.getMessage(); if(msg == null){ |