[Pydev-cvs] org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal ScriptCons
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-28 12:46:36
|
Update of /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src_dltk_console/org/python/pydev/dltk/console/ui/internal Modified Files: ScriptConsoleDocumentListener.java ScriptConsoleViewer.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: ScriptConsoleDocumentListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal/ScriptConsoleDocumentListener.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ScriptConsoleDocumentListener.java 9 Jul 2008 19:11:34 -0000 1.12 --- ScriptConsoleDocumentListener.java 28 Sep 2008 12:45:37 -0000 1.13 *************** *** 426,442 **** } }else if (addedCloseParen){ ! String cmdLine = getCommandLine(); String existingDoc = cmdLine+text.substring(1); int cmdLineOffset = cmdLine.length(); if(existingDoc.length() > cmdLineOffset){ ! Document parenDoc = new Document(existingDoc); ! DocCmd docCmd = new DocCmd(cmdLineOffset, 0, ")"); ! docCmd.shiftsCaret = true; ! boolean canSkipOpenParenthesis = strategy.canSkipOpenParenthesis(parenDoc, docCmd); ! if(canSkipOpenParenthesis){ ! shiftsCaret = false; ! setCaretOffset(offset + 1); ! newText = newText.substring(1); ! } } } --- 426,442 ---- } }else if (addedCloseParen){ ! String cmdLine = getCommandLine(); String existingDoc = cmdLine+text.substring(1); int cmdLineOffset = cmdLine.length(); if(existingDoc.length() > cmdLineOffset){ ! Document parenDoc = new Document(existingDoc); ! DocCmd docCmd = new DocCmd(cmdLineOffset, 0, ")"); ! docCmd.shiftsCaret = true; ! boolean canSkipOpenParenthesis = strategy.canSkipOpenParenthesis(parenDoc, docCmd); ! if(canSkipOpenParenthesis){ ! shiftsCaret = false; ! setCaretOffset(offset + 1); ! newText = newText.substring(1); ! } } } *************** *** 552,556 **** private void setCaretOffset(int offset) { ! setCaretOffset(offset, false); } --- 552,556 ---- private void setCaretOffset(int offset) { ! setCaretOffset(offset, false); } Index: ScriptConsoleViewer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src_dltk_console/org/python/pydev/dltk/console/ui/internal/ScriptConsoleViewer.java,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** ScriptConsoleViewer.java 28 Jun 2008 12:35:38 -0000 1.21 --- ScriptConsoleViewer.java 28 Sep 2008 12:45:37 -0000 1.22 *************** *** 117,121 **** //if we had an enter with the shift pressed and we're in a completion, we must stop it if(inCompletion && (event.stateMask & SWT.SHIFT) != 0){ ! ((PyContentAssistant)ScriptConsoleViewer.this.fContentAssistant).hide(); } --- 117,121 ---- //if we had an enter with the shift pressed and we're in a completion, we must stop it if(inCompletion && (event.stateMask & SWT.SHIFT) != 0){ ! ((PyContentAssistant)ScriptConsoleViewer.this.fContentAssistant).hide(); } *************** *** 130,155 **** if (event.character == SWT.ESC) { ! if(!inCompletion){ ! //while in a completion, esc won't clear the line (just stop the completion) ! listener.setCommandLine(""); ! } ! return; } }else{ //not printable char if (isCaretInEditableRange()) { ! if(!inCompletion && event.keyCode == SWT.PAGE_UP){ ! event.doit = false; ! List<String> commands = history.getAsList(); ! List<String> commandsToExecute = ScriptConsoleHistorySelector.select(commands); ! if(commandsToExecute != null){ ! //remove the current command (substituted by the one gotten from page up) ! listener.setCommandLine(""); ! for(String s:commandsToExecute){ ! IDocument d = getDocument(); ! d.replace(d.getLength(), 0, s+"\n"); ! } ! } ! return; ! } } } --- 130,155 ---- if (event.character == SWT.ESC) { ! if(!inCompletion){ ! //while in a completion, esc won't clear the line (just stop the completion) ! listener.setCommandLine(""); ! } ! return; } }else{ //not printable char if (isCaretInEditableRange()) { ! if(!inCompletion && event.keyCode == SWT.PAGE_UP){ ! event.doit = false; ! List<String> commands = history.getAsList(); ! List<String> commandsToExecute = ScriptConsoleHistorySelector.select(commands); ! if(commandsToExecute != null){ ! //remove the current command (substituted by the one gotten from page up) ! listener.setCommandLine(""); ! for(String s:commandsToExecute){ ! IDocument d = getDocument(); ! d.replace(d.getLength(), 0, s+"\n"); ! } ! } ! return; ! } } } *************** *** 203,207 **** * @param style style to be used */ ! public ScriptConsoleStyledText(Composite parent, int style) { super(parent, style); --- 203,207 ---- * @param style style to be used */ ! public ScriptConsoleStyledText(Composite parent, int style) { super(parent, style); *************** *** 215,221 **** addVerifyListener(new VerifyListener(){ ! public void verifyText(VerifyEvent e) { ! internalCaretSet = -1; ! }} ); --- 215,221 ---- addVerifyListener(new VerifyListener(){ ! public void verifyText(VerifyEvent e) { ! internalCaretSet = -1; ! }} ); *************** *** 225,237 **** addExtendedModifyListener(new ExtendedModifyListener(){ ! public void modifyText(ExtendedModifyEvent event) { ! if(internalCaretSet != -1){ ! if(internalCaretSet != getCaretOffset()){ ! setCaretOffset(internalCaretSet); ! } ! internalCaretSet = -1; ! } ! }} ); --- 225,237 ---- addExtendedModifyListener(new ExtendedModifyListener(){ ! public void modifyText(ExtendedModifyEvent event) { ! if(internalCaretSet != -1){ ! if(internalCaretSet != getCaretOffset()){ ! setCaretOffset(internalCaretSet); ! } ! internalCaretSet = -1; ! } ! }} ); *************** *** 241,258 **** } ! /** ! * Overridden to keep track of changes in the caret. ! */ ! @Override ! public void setCaretOffset(int offset) { ! internalCaretSet = offset; ! super.setCaretOffset(offset); ! } ! ! /** ! * Execute some action. ! */ ! public void invokeAction(int action) { ! //some actions have a different scope (not in selected range / out of selected range) switch (action) { case ST.LINE_START: --- 241,258 ---- } ! /** ! * Overridden to keep track of changes in the caret. ! */ ! @Override ! public void setCaretOffset(int offset) { ! internalCaretSet = offset; ! super.setCaretOffset(offset); ! } ! ! /** ! * Execute some action. ! */ ! public void invokeAction(int action) { ! //some actions have a different scope (not in selected range / out of selected range) switch (action) { case ST.LINE_START: *************** *** 270,274 **** try { int historyChange = 0; ! switch (action) { case ST.LINE_UP: historyChange = 1; --- 270,274 ---- try { int historyChange = 0; ! switch (action) { case ST.LINE_UP: historyChange = 1; *************** *** 284,305 **** case ST.DELETE_WORD_PREVIOUS: ! handleDeletePreviousWord.execute(getDocument(), getCaretOffset(), getCommandLineOffset()); return; } ! ! if(historyChange != 0){ ! if(changedAfterLastHistoryRequest){ ! //only set a new match if it didn't change since the last time we did an UP/DOWN ! history.setMatchStart(getCommandLine()); ! } ! boolean didChange; ! if(historyChange == 1){ ! didChange = history.prev(); ! }else{ ! didChange = history.next(); ! } ! ! if(didChange){ ! inHistoryRequests += 1; try { listener.setCommandLine(history.get()); --- 284,305 ---- case ST.DELETE_WORD_PREVIOUS: ! handleDeletePreviousWord.execute(getDocument(), getCaretOffset(), getCommandLineOffset()); return; } ! ! if(historyChange != 0){ ! if(changedAfterLastHistoryRequest){ ! //only set a new match if it didn't change since the last time we did an UP/DOWN ! history.setMatchStart(getCommandLine()); ! } ! boolean didChange; ! if(historyChange == 1){ ! didChange = history.prev(); ! }else{ ! didChange = history.next(); ! } ! ! if(didChange){ ! inHistoryRequests += 1; try { listener.setCommandLine(history.get()); *************** *** 308,315 **** inHistoryRequests -= 1; } ! } changedAfterLastHistoryRequest = false; return; ! } --- 308,315 ---- inHistoryRequests -= 1; } ! } changedAfterLastHistoryRequest = false; return; ! } *************** *** 420,435 **** final StyledText textWidget = getTextWidget(); if(textWidget != null){ ! if(async){ ! Display display = textWidget.getDisplay(); ! if(display != null){ ! display.asyncExec(new Runnable() { ! public void run() { ! textWidget.setCaretOffset(offset); ! } ! }); ! } ! }else{ ! textWidget.setCaretOffset(offset); ! } } } --- 420,435 ---- final StyledText textWidget = getTextWidget(); if(textWidget != null){ ! if(async){ ! Display display = textWidget.getDisplay(); ! if(display != null){ ! display.asyncExec(new Runnable() { ! public void run() { ! textWidget.setCaretOffset(offset); ! } ! }); ! } ! }else{ ! textWidget.setCaretOffset(offset); ! } } } *************** *** 542,548 **** styledText.addFocusListener(new FocusListener() { ! /** ! * When the initial focus is gained, set the caret position to the last position (just after the prompt) ! */ public void focusGained(FocusEvent e) { setCaretOffset(getDocument().getLength(), true); --- 542,548 ---- styledText.addFocusListener(new FocusListener() { ! /** ! * When the initial focus is gained, set the caret position to the last position (just after the prompt) ! */ public void focusGained(FocusEvent e) { setCaretOffset(getDocument().getLength(), true); *************** *** 576,587 **** styledText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { ! if (getCaretOffset() >= getCommandLineOffset()){ ! if (KeyBindingHelper.matchesContentAssistKeybinding(e)) { ! contentHandler.contentAssistRequired(); ! ! }else if (KeyBindingHelper.matchesQuickAssistKeybinding(e)) { ! contentHandler.quickAssistRequired(); } ! } } --- 576,587 ---- styledText.addKeyListener(new KeyListener() { public void keyPressed(KeyEvent e) { ! if (getCaretOffset() >= getCommandLineOffset()){ ! if (KeyBindingHelper.matchesContentAssistKeybinding(e)) { ! contentHandler.contentAssistRequired(); ! ! }else if (KeyBindingHelper.matchesQuickAssistKeybinding(e)) { ! contentHandler.quickAssistRequired(); } ! } } *************** *** 598,627 **** @Override public void configure(SourceViewerConfiguration configuration) { ! super.configure(configuration); ! ICompletionListener completionListener = new ICompletionListener(){ ! ! public void assistSessionStarted(ContentAssistEvent event) { ! inCompletion = true; ! } ! ! public void assistSessionEnded(ContentAssistEvent event) { ! inCompletion = false; ! } ! ! public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) { ! } ! }; ! ! if(fContentAssistant != null){ ((IContentAssistantExtension2)fContentAssistant).addCompletionListener(completionListener); ! } ! ! if(fQuickAssistAssistant != null){ ! fQuickAssistAssistant.addCompletionListener(completionListener); ! } ! ! if(isMainViewer){ ! clear(true); ! } } --- 598,627 ---- @Override public void configure(SourceViewerConfiguration configuration) { ! super.configure(configuration); ! ICompletionListener completionListener = new ICompletionListener(){ ! ! public void assistSessionStarted(ContentAssistEvent event) { ! inCompletion = true; ! } ! ! public void assistSessionEnded(ContentAssistEvent event) { ! inCompletion = false; ! } ! ! public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) { ! } ! }; ! ! if(fContentAssistant != null){ ((IContentAssistantExtension2)fContentAssistant).addCompletionListener(completionListener); ! } ! ! if(fQuickAssistAssistant != null){ ! fQuickAssistAssistant.addCompletionListener(completionListener); ! } ! ! if(isMainViewer){ ! clear(true); ! } } |