Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2016-09-27 14:51:34 +02:00
5 changed files with 57 additions and 23 deletions
@@ -61,7 +61,7 @@ public class ParameterHintsPresentationManager implements Disposable {
public String getHintText(@NotNull Inlay inlay) {
EditorCustomElementRenderer renderer = inlay.getRenderer();
return renderer instanceof MyRenderer ? ((MyRenderer)renderer).myText : null;
return renderer instanceof MyRenderer ? ((MyRenderer)renderer).getText() : null;
}
public void addHint(@NotNull Editor editor, int offset, @NotNull String hintText, boolean useAnimation) {
@@ -141,7 +141,7 @@ public class ParameterHintsPresentationManager implements Disposable {
}
private static class MyRenderer implements EditorCustomElementRenderer {
private String myText;
private String myText; // text with colon as a suffix
private int startWidth;
private int steps;
private int step;
@@ -151,6 +151,10 @@ public class ParameterHintsPresentationManager implements Disposable {
if (!animated) step = steps + 1;
}
private String getText() {
return myText == null ? null : myText.substring(0, myText.length() - 1);
}
public void update(Editor editor, String newText) {
updateState(editor, newText);
}
@@ -158,7 +162,7 @@ public class ParameterHintsPresentationManager implements Disposable {
private void updateState(Editor editor, String text) {
FontMetrics metrics = getFontMetrics(editor).metrics;
startWidth = doCalcWidth(myText, metrics);
myText = text;
myText = text == null ? null : (text + ":");
int endWidth = doCalcWidth(myText, metrics);
step = 1;
steps = Math.max(1, Math.abs(endWidth - startWidth) / metrics.charWidth('a') / ANIMATION_CHARS_PER_STEP);
@@ -580,6 +580,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
public void setEnabled(boolean enabled) {
if (isEnabled() != enabled) {
super.setEnabled(enabled);
setFocusTraversalPolicyProvider(enabled);
setViewerEnabled(enabled);
EditorEx editor = myEditor;
if (editor != null) {
@@ -175,24 +175,33 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
@Override
public void valueChanged(ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
clearHighlighter();
Object value = ((JList)e.getSource()).getSelectedValue();
if (value instanceof XLineBreakpointType.XLineBreakpointVariant) {
TextRange range = ((XLineBreakpointType.XLineBreakpointVariant)value).getHighlightRange();
TextRange lineRange = DocumentUtil.getLineTextRange(editor.getDocument(), line);
if (range != null) {
range = range.intersection(lineRange);
}
else {
range = lineRange;
}
if (range != null && !range.isEmpty()) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
TextAttributes attributes = scheme.getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
myHighlighter = editor.getMarkupModel().addRangeHighlighter(
range.getStartOffset(), range.getEndOffset(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, attributes,
HighlighterTargetArea.EXACT_RANGE);
}
updateHighlighter(((JList)e.getSource()).getSelectedValue());
}
}
public void initialSet(Object value) {
if (myHighlighter == null) {
updateHighlighter(value);
}
}
void updateHighlighter(Object value) {
clearHighlighter();
if (value instanceof XLineBreakpointType.XLineBreakpointVariant) {
TextRange range = ((XLineBreakpointType.XLineBreakpointVariant)value).getHighlightRange();
TextRange lineRange = DocumentUtil.getLineTextRange(editor.getDocument(), line);
if (range != null) {
range = range.intersection(lineRange);
}
else {
range = lineRange;
}
if (range != null && !range.isEmpty()) {
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
TextAttributes attributes = scheme.getAttributes(DebuggerColors.BREAKPOINT_ATTRIBUTES);
myHighlighter = editor.getMarkupModel().addRangeHighlighter(
range.getStartOffset(), range.getEndOffset(), DebuggerColors.BREAKPOINT_HIGHLIGHTER_LAYER, attributes,
HighlighterTargetArea.EXACT_RANGE);
}
}
}
@@ -251,7 +260,13 @@ public class XDebuggerUtilImpl extends XDebuggerUtil {
public int getDefaultOptionIndex() {
return defaultIndex;
}
});
}) {
@Override
protected void afterShow() {
super.afterShow();
selectionListener.initialSet(getList().getSelectedValue());
}
};
DebuggerUIUtil.registerExtraHandleShortcuts(popup, IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT);
popup.setAdText(DebuggerUIUtil.getSelectionShortcutsAdText(IdeActions.ACTION_TOGGLE_LINE_BREAKPOINT));
@@ -10,6 +10,14 @@ from _pydevd_bundle.pydevd_constants import IS_JYTHON
from _pydevd_bundle.pydevd_utils import to_string
USE_IPYTHON = False
def set_result_ipython_value(ipython):
global USE_IPYTHON
USE_IPYTHON = ipython
# =======================================================================================================================
# Null
# =======================================================================================================================
@@ -76,6 +84,10 @@ class BaseStdIn:
def write(self, *args, **kwargs):
pass # not available StdIn (but it can be expected to be in the stream interface)
def isatty(self):
# return True for IPython console only
return USE_IPYTHON
def flush(self, *args, **kwargs):
pass # not available StdIn (but it can be expected to be in the stream interface)
+3 -1
View File
@@ -39,7 +39,7 @@ except NameError: # version < 2.3 -- didn't have the True/False builtins
setattr(__builtin__, 'True', 1) #Python 3.0 does not accept __builtin__.True = 1 in its syntax
setattr(__builtin__, 'False', 0)
from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface, BaseStdIn
from _pydev_bundle.pydev_console_utils import BaseInterpreterInterface, BaseStdIn, set_result_ipython_value
from _pydev_bundle.pydev_console_utils import CodeFragment
IS_PYTHON_3K = False
@@ -246,6 +246,8 @@ except:
IPYTHON = False
pass
set_result_ipython_value(IPYTHON)
#=======================================================================================================================
# _DoExit
#=======================================================================================================================