Merge remote-tracking branch 'origin/master'

This commit is contained in:
Roman Shevchenko
2014-10-13 15:53:15 +02:00
27 changed files with 277 additions and 223 deletions
+1 -1
View File
@@ -191,7 +191,7 @@ libraryLicense(name: "Jaxen", version: "", license: "modified Apache", url: "htt
libraryLicense(name: "JavaHelp", version: "2.0_02", license: "included as license/javahelp_license.html in IntelliJ IDEA distribution", url: "http://java.sun.com/products/javahelp/")
libraryLicense(name: "Java-WebSocket", libraryName: "java_websocket.jar", version: "1.4.0 Trunk", license: "MIT", url: "https://github.com/TooTallNate/Java-WebSocket", licenseUrl:"https://github.com/TooTallNate/Java-WebSocket/blob/master/LICENSE")
libraryLicense(name: "Apache XML Graphics Commons", libraryName: "xmlgraphics-commons-1.3.1.jar", version: "1.3.1", license: "Apache 2.0", url: "http://xmlgraphics.apache.org/commons/", licenseUrl:"http://www.apache.org/licenses/LICENSE-2.0")
libraryLicense(name: "SnuggleTeX", libraryName: "snuggletex-core-1.3-SNAPSHOT.jar", version: "1.3 (with patches by JetBrains)", license: "BSD", url: "http://snuggletex.sourceforge.net/", licenseUrl:"http://snuggletex.sourceforge.net/maven/license.html")
libraryLicense(name: "SnuggleTeX", version: "1.3 (with patches by JetBrains)", license: "BSD", url: "http://snuggletex.sourceforge.net/", licenseUrl:"http://snuggletex.sourceforge.net/maven/license.html")
libraryLicense(name: "JEuclid", libraryName: "jeuclid-core-3.1.9.jar", version: "3.1.9", license: "Apache 2.0", url: "http://jeuclid.sourceforge.net", licenseUrl:"http://sourceforge.net/p/jeuclid/code/ci/default/tree/LICENSE.txt")
libraryLicense(name: "JCIP Annotations", libraryName: "jcip", license: "Creative Commons Attribution License", url: "http://www.jcip.net", licenseUrl: "http://creativecommons.org/licenses/by/2.5")
libraryLicense(name: "JDOM", version: "1.1 (with patches by JetBrains)", license: "modified Apache", url: "http://www.jdom.org/", licenseUrl: "http://www.jdom.org/docs/faq.html#a0030")
@@ -187,23 +187,11 @@ public class ReformatCodeAction extends AnAction implements DumbAware {
}
if (rearrangeEntries && file != null && editor != null) {
final ArrangementEngine engine = ServiceManager.getService(project, ArrangementEngine.class);
try {
final PsiFile finalFile = file;
SelectionModel selectionModel = editor.getSelectionModel();
final TextRange rangeToUse = selectionModel.hasSelection()
? TextRange.create(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd())
: TextRange.create(0, editor.getDocument().getTextLength());
CommandProcessor.getInstance().executeCommand(project, new Runnable() {
@Override
public void run() {
engine.arrange(editor, finalFile, Collections.singleton(rangeToUse));
}
}, getTemplatePresentation().getText(), null);
}
finally {
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
}
SelectionModel selectionModel = editor.getSelectionModel();
final TextRange rangeToUse = selectionModel.hasSelection()
? TextRange.create(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd())
: TextRange.create(0, editor.getDocument().getTextLength());
new RearrangeCodeProcessor(project, file, Collections.singleton(rangeToUse)).run();
}
}
@@ -24,7 +24,6 @@ import com.intellij.ui.ColorUtil;
import com.intellij.ui.Gray;
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.tabs.TabInfo;
import com.intellij.ui.tabs.TabsUtil;
import com.intellij.ui.tabs.UiDecorator;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.ui.tabs.impl.TabLabel;
@@ -75,7 +74,7 @@ public class
int _y = effectiveBounds.y + insets.top + 3;
int _width = effectiveBounds.width - insets.left - insets.right;
int _height = effectiveBounds.height - insets.top - insets.bottom - 3;
_height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
_height -= getActiveTabUnderlineHeight();
if (dark) {
g2d.setPaint(UIUtil.getGradientPaint(_x, _y, ColorUtil.shift(UIUtil.getListBackground(), 1.3), _x, _y + effectiveBounds.height, UIUtil.getPanelBackground()));
g2d.fillRect(_x, _y, _width, _height);
@@ -122,7 +121,7 @@ public class
Rectangle rectangle;
int y = r2.y + insets.top;
int height = maxLength - insets.top - insets.bottom;
height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
height -= getActiveTabUnderlineHeight();
rectangle = new Rectangle(maxOffset, y, r2.width - maxOffset - insets.left - insets.right, height);
@@ -194,7 +193,7 @@ public class
shape.insets = shape.path.transformInsets(getLayoutInsets());
shape.labelPath = shape.path.createTransform(r);
shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1);
shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1);
shape.labelTopY = shape.labelPath.getY() + shape.labelPath.deltaY(1);
shape.labelLeftX = shape.labelPath.getX();
shape.labelRightX = shape.labelPath.getMaxX() - shape.labelPath.deltaX(1);
@@ -210,8 +209,8 @@ public class
int lastX = shape.path.getWidth() - shape.path.deltaX(shape.insets.right);
shape.path.lineTo(lastX, shape.labelBottomY);
shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1));
shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1));
shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1));
shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1));
shape.path.closePath();
shape.fillPath = shape.path.copy();
@@ -298,7 +297,7 @@ public class
@Override
public Dimension getPreferredSize() {
Dimension result = super.getPreferredSize();
result.height += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
result.height += myTabs.getActiveTabUnderlineHeight();
return result;
}
}
@@ -47,6 +47,7 @@ import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiFile;
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
import com.intellij.util.containers.WeakList;
import com.intellij.util.ui.ButtonlessScrollBarUI;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -825,7 +826,7 @@ public class EditorWindowImpl extends UserDataHolderBase implements EditorWindow
}
@Override
public void registerScrollBarRepaintCallback(@Nullable RepaintCallback callback) {
public void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) {
myDelegate.registerScrollBarRepaintCallback(callback);
}
@@ -26,7 +26,6 @@ import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.tabs.JBTabsPosition;
import com.intellij.ui.tabs.TabInfo;
import com.intellij.ui.tabs.TabsUtil;
import com.intellij.ui.tabs.impl.singleRow.ScrollableSingleRowLayout;
import com.intellij.ui.tabs.impl.singleRow.SingleRowLayout;
import com.intellij.ui.tabs.impl.table.TableLayout;
@@ -98,9 +97,11 @@ public class JBEditorTabs extends JBTabsImpl {
@Override
public boolean hasUnderline() {
return true;
return isSingleRow();
}
protected void doPaintInactive(Graphics2D g2d,
boolean leftGhostExists,
TabLabel label,
@@ -116,14 +117,14 @@ public class JBEditorTabs extends JBTabsImpl {
if ((!isSingleRow() /* for multiline */) || (isSingleRow() && isHorizontalTabs())) {
if (isSingleRow() && getPosition() == JBTabsPosition.bottom) {
_y += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
_y += getActiveTabUnderlineHeight();
} else {
if (isSingleRow()) {
_height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
_height -= getActiveTabUnderlineHeight();
} else {
TabInfo info = label.getInfo();
if (((TableLayout)getEffectiveLayout()).isLastRow(info)) {
_height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
_height -= getActiveTabUnderlineHeight();
}
}
}
@@ -131,7 +132,19 @@ public class JBEditorTabs extends JBTabsImpl {
final boolean vertical = getTabsPosition() == JBTabsPosition.left || getTabsPosition() == JBTabsPosition.right;
final Color tabColor = label.getInfo().getTabColor();
final Composite oldComposite = g2d.getComposite();
//if (label != getSelectedLabel()) {
// g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.9f));
//}
getPainter().doPaintInactive(g2d, effectiveBounds, _x, _y, _width, _height, tabColor, row, column, vertical);
//g2d.setComposite(oldComposite);
}
@Override
public int getActiveTabUnderlineHeight() {
return hasUnderline() ? super.getActiveTabUnderlineHeight() : 1;
}
JBEditorTabsPainter getPainter() {
@@ -186,9 +199,9 @@ public class JBEditorTabs extends JBTabsImpl {
int y = r2.y + insets.top;
int height = maxLength - insets.top - insets.bottom;
if (getTabsPosition() == JBTabsPosition.bottom) {
y = r2.height - height - insets.top + TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
y = r2.height - height - insets.top + getActiveTabUnderlineHeight();
} else {
height -= TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
height -= getActiveTabUnderlineHeight();
}
rectangle = new Rectangle(maxOffset, y, r2.width - maxOffset - insets.left - insets.right, height);
@@ -229,7 +242,7 @@ public class JBEditorTabs extends JBTabsImpl {
shape.insets = shape.path.transformInsets(getLayoutInsets());
shape.labelPath = shape.path.createTransform(getSelectedLabel().getBounds());
shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1);
shape.labelBottomY = shape.labelPath.getMaxY() - shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1);
shape.labelTopY =
shape.labelPath.getY() + (getPosition() == JBTabsPosition.top || getPosition() == JBTabsPosition.bottom ? shape.labelPath.deltaY(1) : 0) ;
shape.labelLeftX = shape.labelPath.getX() + (getPosition() == JBTabsPosition.top || getPosition() == JBTabsPosition.bottom ? 0 : shape.labelPath.deltaX(
@@ -247,8 +260,8 @@ public class JBEditorTabs extends JBTabsImpl {
int lastX = shape.path.getWidth() - shape.path.deltaX(shape.insets.right);
shape.path.lineTo(lastX, shape.labelBottomY);
shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1));
shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1));
shape.path.lineTo(lastX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1));
shape.path.lineTo(leftX, shape.labelBottomY + shape.labelPath.deltaY(getActiveTabUnderlineHeight() - 1));
shape.path.closePath();
shape.fillPath = shape.path.copy();
@@ -345,6 +345,10 @@ public class JBTabsImpl extends JComponent
return this;
}
public int getActiveTabUnderlineHeight() {
return TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT;
}
public boolean isEditorTabs() {
return false;
}
@@ -53,7 +53,7 @@ public class TabLabel extends JPanel {
private boolean myCentered;
private final Wrapper myLabelPlaceholder = new Wrapper(false);
private final JBTabsImpl myTabs;
protected final JBTabsImpl myTabs;
private BufferedImage myInactiveStateImage;
private Rectangle myLastPaintedInactiveImageBounds;
@@ -241,7 +241,12 @@ public class TabLabel extends JPanel {
}
});
final Composite oldComposite = ((Graphics2D)g).getComposite();
if (myTabs instanceof JBEditorTabs && !myTabs.isSingleRow() && myTabs.getSelectedInfo() != myInfo) {
((Graphics2D)g).setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.6f));
}
super.paint(g);
((Graphics2D)g).setComposite(oldComposite);
doTranslate(new PairConsumer<Integer, Integer>() {
@Override
@@ -253,7 +258,7 @@ public class TabLabel extends JPanel {
protected int getNonSelectedOffset() {
if (myTabs.isEditorTabs() && (myTabs.isSingleRow() || ((TableLayout)myTabs.getEffectiveLayout()).isLastRow(getInfo()))) {
return -TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT / 2 + 1;
return -myTabs.getActiveTabUnderlineHeight() / 2 + 1;
}
return 1;
}
@@ -275,7 +280,7 @@ public class TabLabel extends JPanel {
switch (pos) {
case top:
case bottom:
if (myTabs.hasUnderline()) size.height += TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT - 1;
if (myTabs.hasUnderline()) size.height += myTabs.getActiveTabUnderlineHeight() - 1;
break;
case left:
case right:
@@ -18,7 +18,6 @@ package com.intellij.ui.tabs.impl.singleRow;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.tabs.JBTabsPosition;
import com.intellij.ui.tabs.TabInfo;
import com.intellij.ui.tabs.TabsUtil;
import com.intellij.ui.tabs.impl.*;
import org.jetbrains.annotations.Nullable;
@@ -50,8 +49,8 @@ public class SingleRowLayout extends TabLayout {
protected int getIconY(Rectangle iconRec) {
final int shift;
switch (myTabs.getTabsPosition()) {
case bottom: shift = TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT; break;
case top: shift = -(TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT / 2); break;
case bottom: shift = myTabs.getActiveTabUnderlineHeight(); break;
case top: shift = -(myTabs.getActiveTabUnderlineHeight() / 2); break;
default: shift = 0;
}
return super.getIconY(iconRec) + shift;
@@ -16,7 +16,6 @@
package com.intellij.ui.tabs.impl.table;
import com.intellij.ui.tabs.TabInfo;
import com.intellij.ui.tabs.TabsUtil;
import com.intellij.ui.tabs.impl.JBTabsImpl;
import com.intellij.ui.tabs.impl.LayoutPassInfo;
import com.intellij.ui.tabs.impl.TabLabel;
@@ -103,10 +102,10 @@ public class TableLayout extends TabLayout {
toMove.add(data.table.get(i));
}
for (TableRow eachMove : toMove) {
data.table.remove(eachMove);
data.table.add(0, eachMove);
}
//for (TableRow eachMove : toMove) {
// data.table.remove(eachMove);
// data.table.add(0, eachMove);
//}
return data;
@@ -131,7 +130,7 @@ public class TableLayout extends TabLayout {
int eachY = insets.top;
int eachX;
int row = 0;
final int tabUnderlineFix = myTabs.isEditorTabs() ? TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT : 0;
final int tabUnderlineFix = myTabs.isEditorTabs() ? myTabs.getActiveTabUnderlineHeight() : 0;
for (TableRow eachRow : data.table) {
eachX = insets.left;
@@ -91,7 +91,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
private Animator myMacScrollbarFadeAnimator;
private double myMacScrollbarFadeLevel = 0;
private boolean myMacScrollbarHidden;
private ScrollbarRepaintCallback myRepaintCallback;
protected ButtonlessScrollBarUI() {
myAdjustmentListener = new AdjustmentListener() {
@@ -264,6 +265,43 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
}
}
/**
* This is overridden only to increase the invalid area.
* This ensures that whole track will be repainted in case of installed callback
*/
@Override
protected void setThumbBounds(int x, int y, int width, int height) {
if (myRepaintCallback == null) {
super.setThumbBounds(x, y, width, height);
}
else {
/* If the thumbs bounds haven't changed, we're done.
*/
if ((thumbRect.x == x) &&
(thumbRect.y == y) &&
(thumbRect.width == width) &&
(thumbRect.height == height)) {
return;
}
/* Update thumbRect, and repaint the union of x,y,w,h and
* the old thumbRect.
*/
int minX = Math.min(x, trackRect.x);
int minY = Math.min(y, trackRect.y);
int maxX = Math.max(x + width, trackRect.x + trackRect.width);
int maxY = Math.max(y + height, trackRect.y + trackRect.height);
thumbRect.setBounds(x, y, width, height);
scrollbar.repaint(minX, minY, maxX - minX, maxY - minY);
// Once there is API to determine the mouse location this will need
// to be changed.
setThumbRollover(false);
}
}
@Override
protected ModelListener createModelListener() {
return new ModelListener() {
@@ -615,6 +653,10 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
else {
g.drawLine(bounds.x, bounds.y, bounds.x + bounds.width, bounds.y);
}
if (myRepaintCallback != null) {
myRepaintCallback.call(g);
}
}
@Override
@@ -774,6 +816,10 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
return myMacScrollbarHidden && Registry.is("editor.distraction.free.mode");
}
public void registerRepaintCallback(ScrollbarRepaintCallback callback) {
myRepaintCallback = callback;
}
private static class EmptyButton extends JButton {
private EmptyButton() {
setFocusable(false);
@@ -795,4 +841,8 @@ public class ButtonlessScrollBarUI extends BasicScrollBarUI {
return getMaximumSize();
}
}
public interface ScrollbarRepaintCallback {
void call(Graphics g);
}
}
@@ -41,6 +41,7 @@ public class FormBuilder {
private int myVerticalGap;
private int myHorizontalGap;
private int myFormLeftIndent;
public FormBuilder() {
myPanel = new JPanel(new GridBagLayout());
@@ -49,6 +50,7 @@ public class FormBuilder {
myAlignLabelOnRight = false;
myVerticalGap = DEFAULT_VGAP;
myHorizontalGap = DEFAULT_HGAP;
myFormLeftIndent = 0;
}
public static FormBuilder createFormBuilder() {
@@ -143,7 +145,7 @@ public class FormBuilder {
c.weighty = 0;
c.fill = NONE;
c.anchor = getLabelAnchor(component, false);
c.insets = new Insets(topInset, myIndent, DEFAULT_VGAP, 0);
c.insets = new Insets(topInset, myIndent + myFormLeftIndent, DEFAULT_VGAP, 0);
if (label != null) myPanel.add(label, c);
@@ -153,7 +155,7 @@ public class FormBuilder {
c.weighty = getWeightY(component);
c.fill = getFill(component);
c.anchor = WEST;
c.insets = new Insets(label == null ? topInset : 0, myIndent, 0, 0);
c.insets = new Insets(label == null ? topInset : 0, myIndent + myFormLeftIndent, 0, 0);
myPanel.add(component, c);
@@ -167,7 +169,7 @@ public class FormBuilder {
c.weighty = 0;
c.fill = NONE;
c.anchor = getLabelAnchor(component, true);
c.insets = new Insets(topInset, myIndent, 0, myHorizontalGap);
c.insets = new Insets(topInset, myIndent + myFormLeftIndent, 0, myHorizontalGap);
myPanel.add(label, c);
@@ -176,7 +178,7 @@ public class FormBuilder {
c.weighty = getWeightY(component);
c.fill = getFill(component);
c.anchor = WEST;
c.insets = new Insets(topInset, 0, 0, 0);
c.insets = new Insets(topInset, myIndent, 0, 0);
myPanel.add(component, c);
@@ -237,8 +239,17 @@ public class FormBuilder {
return this;
}
/**
* @deprecated use {@code setHorizontalGap} or {@code setFormLeftIndent}, to be removed in IDEA 16
*/
@Deprecated
public FormBuilder setIndent(int indent) {
myIndent = indent;
return this;
}
public FormBuilder setFormLeftIndent(int formLeftIndent) {
myFormLeftIndent = formLeftIndent;
return this;
}
}
@@ -32,15 +32,14 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.plaf.ScrollBarUI;
import java.awt.*;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
/**
* The container for an {@link Editor}, which is added then to {@link com.intellij.openapi.diff.impl.util.ThreePanels}.
*/
public class EditorPlace extends JComponent implements Disposable, EditorEx.RepaintCallback {
public class EditorPlace extends JComponent implements Disposable, ButtonlessScrollBarUI.ScrollbarRepaintCallback {
private static final Logger LOG = Logger.getInstance(EditorPlace.class);
@NotNull private final MergePanel2.DiffEditorState myState;
@@ -58,121 +57,57 @@ public class EditorPlace extends JComponent implements Disposable, EditorEx.Repa
}
@Override
public void paint(Graphics g) {
super.paint(g);
public void call(Graphics g) {
paintThis(g);
}
public void call(Graphics g) {
repaintScrollbar();
}
private void repaintScrollbar() {
if (myEditor == null || myColumn != MergePanelColumn.BASE) {
return; // we draw above the scrollbar only in the central column
}
Component editorComponent = myEditor.getComponent();
JScrollBar scrollBar = myEditor.getScrollPane().getVerticalScrollBar();
repaint(editorComponent.getWidth() - scrollBar.getWidth(), 0, scrollBar.getWidth(), scrollBar.getHeight());
}
private void paintThis(Graphics g) {
if (myEditor != null) {
ArrayList<DividerPolygon> polygons = DividerPolygon.createVisiblePolygons(myMergePanel.getSecondEditingSide(), FragmentSide.SIDE1,
DiffDivider.MERGE_DIVIDER_POLYGONS_OFFSET);
for (DividerPolygon polygon : polygons) {
int startY = polygon.getTopLeftY();
int endY = polygon.getBottomLeftY();
int height = endY - startY;
if (myEditor == null) return;
// painting only above the central scrollbar, because painting on edge scrollbars is not needed, and there are error stripes
if (myColumn != MergePanelColumn.BASE) return;
if (height == 0) { // draw at least a one-pixel line (e.g. for insertion or deletion), as it is done in highlighters
height = 1;
}
int offset = DiffDivider.MERGE_SCROLL_DIVIDER_POLYGONS_OFFSET;
ArrayList<DividerPolygon> polygons =
DividerPolygon.createVisiblePolygons(myMergePanel.getSecondEditingSide(true), FragmentSide.SIDE1, offset);
for (DividerPolygon polygon : polygons) {
int startY = polygon.getTopLeftY();
int endY = polygon.getBottomLeftY();
int height = endY - startY;
drawPolygonAboveScrollBar((Graphics2D)g, startY, height, polygon.getColor(), polygon.isApplied());
if (height == 0) { // draw at least a one-pixel line (e.g. for insertion or deletion), as it is done in highlighters
height = 1;
}
drawPolygon((Graphics2D)g, startY, height, polygon.getColor(), polygon.isApplied());
}
}
private void drawPolygonAboveScrollBar(@NotNull Graphics2D g, int startY, int height, @NotNull Color color, boolean applied) {
// painting only above the central scrollbar, because painting on edge scrollbars is not needed, and there are error stripes
if (myColumn != MergePanelColumn.BASE) {
return;
}
g.setColor(color);
JScrollBar scrollBar = myEditor.getScrollPane().getVerticalScrollBar();
int startX = scrollBar.getX();
int endX = startX + scrollBar.getWidth() - 1;
Rectangle thumb = calcThumbBounds(scrollBar);
private void drawPolygon(@NotNull Graphics2D g, int startY, int height, @NotNull Color color, boolean applied) {
int scrollbarWidth = myEditor.getScrollPane().getVerticalScrollBar().getWidth();
int startX = 0;
int endX = startX + scrollbarWidth - 1;
int endY = startY + height;
g.setColor(color);
if (!applied) {
if (height > 2) {
fillRectAboveScrollBar(g, startX, startY, scrollBar.getWidth(), height, thumb);
g.fillRect(startX, startY, scrollbarWidth, height);
Color framingColor = DiffUtil.getFramingColor(color);
if (outsideBounds(startY, thumb)) {
UIUtil.drawLine(g, startX, startY, endX, startY, null, framingColor);
}
if (outsideBounds(endY, thumb)) {
UIUtil.drawLine(g, startX, endY, endX, endY, null, framingColor);
}
UIUtil.drawLine(g, startX, startY, endX, startY, null, framingColor);
UIUtil.drawLine(g, startX, endY, endX, endY, null, framingColor);
}
else {
if (outsideBounds(startY, thumb)) {
DiffUtil.drawDoubleShadowedLine(g, startX, endX, startY, color);
}
DiffUtil.drawDoubleShadowedLine(g, startX, endX, startY, color);
}
}
else {
if (outsideBounds(startY, thumb)) {
UIUtil.drawBoldDottedLine(g, startX, endX, startY, null, color, false);
}
if (outsideBounds(endY, thumb)) {
UIUtil.drawBoldDottedLine(g, startX, endX, endY, null, color, false);
}
UIUtil.drawBoldDottedLine(g, startX, endX, startY, null, color, false);
UIUtil.drawBoldDottedLine(g, startX, endX, endY, null, color, false);
}
}
private static void fillRectAboveScrollBar(Graphics2D g, int startX, int startY, int width, int height, Rectangle thumb) {
int endY = startY + height;
int thumbEndY = thumb == null ? 0 : thumb.y + thumb.height; // it's for further readability (could have a 2-level ifs for the variable)
if (thumb == null) {
g.fillRect(startX, startY, width, height);
}
else if (outsideBounds(startY, thumb) && !outsideBounds(endY, thumb)) {
g.fillRect(startX, startY, width, thumb.y - startY);
}
else if (!outsideBounds(startY, thumb) && outsideBounds(endY, thumb)) {
g.fillRect(startX, thumbEndY, width, endY - thumbEndY);
}
else if (startY < thumb.y && endY > thumbEndY) { // surrounding the thumb
g.fillRect(startX, startY, width, thumb.y - startY);
g.fillRect(startX, thumbEndY, width, endY - thumbEndY);
}
else if (outsideBounds(startY, thumb) && outsideBounds(endY, thumb)) { // outside without intersection
g.fillRect(startX, startY, width, height);
}
}
private static boolean outsideBounds(int y, @Nullable Rectangle rectangle) {
if (rectangle == null) {
return true;
}
return y < rectangle.y || y > rectangle.y + rectangle.height;
}
@Nullable
private static Rectangle calcThumbBounds(JScrollBar scrollBar) {
ScrollBarUI scrollBarUI = scrollBar.getUI();
if (scrollBarUI instanceof ButtonlessScrollBarUI) {
return ((ButtonlessScrollBarUI)scrollBarUI).getThumbBounds();
}
return null;
}
public void addNotify() {
if (myEditor != null) {
super.addNotify();
@@ -249,6 +184,7 @@ public class EditorPlace extends JComponent implements Disposable, EditorEx.Repa
public interface EditorListener {
void onEditorCreated(EditorPlace place);
void onEditorReleased(Editor releasedEditor);
}
@@ -29,6 +29,7 @@ import java.awt.*;
public class DiffDivider extends JComponent {
public static final int MERGE_DIVIDER_POLYGONS_OFFSET = 1;
public static final int MERGE_SCROLL_DIVIDER_POLYGONS_OFFSET = 2;
private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.diff.impl.util.DiffDivider");
private final Editor[] myEditors = new Editor[2];
private final FragmentSide myLeftSide;
@@ -32,6 +32,7 @@ import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.util.TextRange;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.ui.ButtonlessScrollBarUI;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
@@ -262,10 +263,5 @@ public interface EditorEx extends Editor {
* @param callback callback which will be called from the {@link javax.swing.JComponent#paint(java.awt.Graphics)} method of
* the editor vertical scrollbar.
*/
void registerScrollBarRepaintCallback(@Nullable RepaintCallback callback);
interface RepaintCallback {
void call(Graphics g);
}
void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback);
}
@@ -597,7 +597,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
}
@Override
public void registerScrollBarRepaintCallback(@Nullable RepaintCallback callback) {
public void registerScrollBarRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) {
myVerticalScrollBar.registerRepaintCallback(callback);
}
@@ -4779,7 +4779,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
class MyScrollBar extends JBScrollBar implements IdeGlassPane.TopComponent {
@NonNls private static final String APPLE_LAF_AQUA_SCROLL_BAR_UI_CLASS = "apple.laf.AquaScrollBarUI";
private ScrollBarUI myPersistentUI;
@Nullable private RepaintCallback myRepaintCallback;
private MyScrollBar(@JdkConstants.AdjustableOrientation int orientation) {
super(orientation);
@@ -4804,9 +4803,6 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
@Override
public void paint(@NotNull Graphics g) {
super.paint(g);
if (myRepaintCallback != null) {
myRepaintCallback.call(g);
}
}
/**
@@ -4877,8 +4873,10 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return myEditorComponent.getScrollableBlockIncrement(vr, SwingConstants.VERTICAL, direction);
}
public void registerRepaintCallback(@Nullable RepaintCallback callback) {
myRepaintCallback = callback;
public void registerRepaintCallback(@Nullable ButtonlessScrollBarUI.ScrollbarRepaintCallback callback) {
if (myPersistentUI instanceof ButtonlessScrollBarUI) {
((ButtonlessScrollBarUI)myPersistentUI).registerRepaintCallback(callback);
}
}
}
@@ -117,7 +117,7 @@ public class ModifierKeyDoubleClickHandler {
resetState();
return false;
}
if (ourOtherKeyWasPressed.get() && Clock.getTime() - ourLastTimePressed.get() < 500) {
if (myActionKeyCode == -1 && ourOtherKeyWasPressed.get() && Clock.getTime() - ourLastTimePressed.get() < 500) {
resetState();
return false;
}
@@ -65,11 +65,11 @@ public class JBTabsPaneImpl implements TabbedPane, SwingConstants {
maxOffset++;
g2d.setPaint(UIUtil.getPanelBackground());
if (getFirstTabOffset() > 0) {
g2d.fillRect(clip.x, clip.y, clip.x + getFirstTabOffset() - 1, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
g2d.fillRect(clip.x, clip.y, clip.x + getFirstTabOffset() - 1, clip.y + maxLength - getActiveTabUnderlineHeight());
}
g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
g2d.fillRect(clip.x + maxOffset, clip.y, clip.width - maxOffset, clip.y + maxLength - getActiveTabUnderlineHeight());
g2d.setPaint(new JBColor(Gray._181, UIUtil.getPanelBackground()));
g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT, clip.x + clip.width, clip.y + maxLength - TabsUtil.ACTIVE_TAB_UNDERLINE_HEIGHT);
g2d.drawLine(clip.x + maxOffset, clip.y + maxLength - getActiveTabUnderlineHeight(), clip.x + clip.width, clip.y + maxLength - getActiveTabUnderlineHeight());
g2d.setPaint(UIUtil.getPanelBackground());
g2d.drawLine(clip.x, clip.y + maxLength, clip.width, clip.y + maxLength);
}
@@ -42,6 +42,7 @@ import com.intellij.openapi.editor.markup.GutterIconRenderer;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.MessageType;
import com.intellij.openapi.util.Comparing;
import com.intellij.openapi.util.Computable;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.ToolWindowId;
@@ -381,13 +382,21 @@ public class XDebugSessionImpl implements XDebugSession {
private <B extends XBreakpoint<?>> void handleBreakpoint(final XBreakpointHandler<B> handler, final B b, final boolean register,
final boolean temporary) {
if (register && isBreakpointActive(b)) {
synchronized (myRegisteredBreakpoints) {
myRegisteredBreakpoints.put(b, new CustomizedBreakpointPresentation());
if (register) {
boolean active = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
return isBreakpointActive(b);
}
});
if (active) {
synchronized (myRegisteredBreakpoints) {
myRegisteredBreakpoints.put(b, new CustomizedBreakpointPresentation());
}
handler.registerBreakpoint(b);
}
handler.registerBreakpoint(b);
}
if (!register) {
else {
boolean removed;
synchronized (myRegisteredBreakpoints) {
removed = myRegisteredBreakpoints.remove(b) != null;
+4 -28
View File
@@ -26,41 +26,17 @@
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<library name="SnuggleTeX">
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/batik.jar!/" />
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
<root url="jar://$MODULE_DIR$/lib/jeuclid-core-3.1.9.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/snuggletex-core-1.3-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/xmlgraphics-commons-1.3.1.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/lib/commons-io-1.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
</module>
Binary file not shown.
@@ -0,0 +1,4 @@
## This is hand-edited. Add all of the non-auto-generated definitions
3A6:varPhi:ALPHA
3C6:varphi:ALPHA
02248:thickapprox:REL
@@ -1,7 +1,10 @@
package org.jetbrains.plugins.ipnb;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.ui.BrowserHyperlinkListener;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.text.MarkdownUtil;
import com.petebevin.markdown.MarkdownProcessor;
import net.sourceforge.jeuclid.MathMLParserSupport;
import net.sourceforge.jeuclid.context.LayoutContextImpl;
@@ -29,6 +32,7 @@ import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Dictionary;
import java.util.Hashtable;
@@ -49,8 +53,22 @@ public class IpnbUtils {
"padding: 8px 35px 8px 14px;" +
"border: 1px solid #fbeed5;}";
public static String markdown2Html(@NotNull final String description) {
return ourMarkdownProcessor.markdown(description);
private static final String ourAlertSuccessRule = ".alert-success{ background-color: #dff0d8;\n" +
"color: #468847;" +
"padding: 8px 35px 8px 14px;" +
"border: 1px solid #d6e9c6;}";
private static final String ourAlertErrorRule = ".alert-error{ background-color: #f2dede;\n" +
"color: #b94a48;" +
"padding: 8px 35px 8px 14px;" +
"border: 1px solid #eed3d7;}";
public static String markdown2Html(@NotNull String description) {
description = StringUtil.replace(description, "class=\"alert alert-success\"", "class=\"alert-success\"");
description = StringUtil.replace(description, "class=\"alert alert-error\"", "class=\"alert-error\"");
ArrayList<String> lines = ContainerUtil.newArrayList(description.split("\n|\r|\r\n"));
MarkdownUtil.replaceHeaders(lines);
return ourMarkdownProcessor.markdown(StringUtil.join(lines, "\n"));
}
public static void addLatexToPanel(@NotNull final String source, @NotNull final JPanel panel) {
@@ -61,6 +79,8 @@ public class IpnbUtils {
sheet.addRule(ourBodyRule);
sheet.addRule(ourCodeRule);
sheet.addRule(ourAlertRule);
sheet.addRule(ourAlertSuccessRule);
sheet.addRule(ourAlertErrorRule);
editorPane.setEditable(false);
@@ -75,6 +95,7 @@ public class IpnbUtils {
}
});
editorPane.addHyperlinkListener(new BrowserHyperlinkListener());
//TODO: jump to the section (see User Interface#Utilities)
panel.add(editorPane);
}
@@ -137,8 +158,8 @@ public class IpnbUtils {
markdown.append(charAt);
}
if (formula.length() != 0) {
addFormula(formula.toString(), editorPane, imageIndex);
result.append("<img src=\"").append(ourImagePrefix).append(imageIndex).append(".jpg\">");
addFormula(formula.toString(), editorPane, imageIndex, result);
imageIndex += 1;
formula = new StringBuilder();
}
@@ -146,12 +167,12 @@ public class IpnbUtils {
if (inEnd && charAt == '}') {
inMultiStringCode -= 1;
inEnd = false;
}
}
if (formula.length() != 0) {
addFormula(formula.toString(), editorPane, imageIndex);
result.append("<img src=\"").append(ourImagePrefix).append(imageIndex).append(".jpg\">");
addFormula(formula.toString(), editorPane, imageIndex, result);
}
if (markdown.length() != 0) {
result.append(markdown.toString());
@@ -159,7 +180,7 @@ public class IpnbUtils {
return markdown2Html(result.toString());
}
private static void addFormula(@NotNull final String formulaText, JEditorPane editorPane, int imageIndex) {
private static void addFormula(@NotNull final String formulaText, JEditorPane editorPane, int imageIndex, StringBuilder result) {
final SnuggleEngine engine = new SnuggleEngine();
engine.getPackages().add(0, IpnbTexPackageDefinitions.getPackage());
@@ -206,5 +227,10 @@ public class IpnbUtils {
catch (ParserConfigurationException e) {
LOG.error(e);
}
if (formulaText.startsWith("$$") || formulaText.startsWith("\\begin")) {
result.append("<p style = \"text-align:center;\"><img src=\"").append(ourImagePrefix).append(imageIndex).append(".jpg\"/></p>");
}
else
result.append("<img src=\"").append(ourImagePrefix).append(imageIndex).append(".jpg\">");
}
}
@@ -44,7 +44,7 @@ public class IpnbEditorUtil {
public enum PromptType { In, Out, None }
public static Dimension PROMPT_SIZE = new Dimension(80, 30);
public static int PANEL_WIDTH = 900;
public static int PANEL_WIDTH = (int)(Toolkit.getDefaultToolkit().getScreenSize().width * 0.5);
public static Editor createPythonCodeEditor(@NotNull final Project project, @NotNull final IpnbCodeSourcePanel codeSourcePanel) {
final EditorFactory editorFactory = EditorFactory.getInstance();
@@ -107,12 +107,28 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
private JPanel createControlPanel() {
final JPanel controlPanel = new JPanel();
controlPanel.setBackground(IpnbEditorUtil.getBackground());
addSaveButton(controlPanel);
addAddButton(controlPanel);
addCutButton(controlPanel);
addCopyButton(controlPanel);
addPasteButton(controlPanel);
addRunButton(controlPanel);
final JPanel savePanel = new JPanel(new GridBagLayout());
savePanel.setBackground(IpnbEditorUtil.getBackground());
addSaveButton(savePanel);
controlPanel.add(savePanel);
final JPanel addPanel = new JPanel(new GridBagLayout());
addPanel.setBackground(IpnbEditorUtil.getBackground());
addAddButton(addPanel);
controlPanel.add(addPanel);
final JPanel editorPanel = new JPanel(new GridBagLayout());
editorPanel.setBackground(IpnbEditorUtil.getBackground());
addCutButton(editorPanel);
addCopyButton(editorPanel);
addPasteButton(editorPanel);
controlPanel.add(editorPanel);
final JPanel runPanel = new JPanel(new GridBagLayout());
runPanel.setBackground(IpnbEditorUtil.getBackground());
addRunButton(runPanel);
controlPanel.add(runPanel);
myCellTypeCombo = new ComboBox(ourCellTypes);
@@ -146,6 +162,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
action.runCell(myIpnbFilePanel, true);
}
});
myRunCellButton.setToolTipText("Run Cell");
controlPanel.add(myRunCellButton);
}
@@ -156,7 +173,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
final IpnbSaveAction action = (IpnbSaveAction)ActionManager.getInstance().getAction("IpnbSaveAction");
action.saveAndCheckpoint(IpnbFileEditor.this);
}
}, AllIcons.Actions.Menu_saveall);
}, AllIcons.Actions.Menu_saveall, "Save and Checkpoint");
}
private void addCutButton(@NotNull final JPanel controlPanel) {
@@ -166,7 +183,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
final IpnbCutCellAction action = (IpnbCutCellAction)ActionManager.getInstance().getAction("IpnbCutCellAction");
action.cutCell(myIpnbFilePanel);
}
}, AllIcons.Actions.Menu_cut);
}, AllIcons.Actions.Menu_cut, "Cut Cell");
}
private void addCopyButton(@NotNull final JPanel controlPanel) {
@@ -176,7 +193,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
final IpnbCopyCellAction action = (IpnbCopyCellAction)ActionManager.getInstance().getAction("IpnbCopyCellAction");
action.copyCell(myIpnbFilePanel);
}
}, AllIcons.Actions.Copy);
}, AllIcons.Actions.Copy, "Copy Cell");
}
private void addPasteButton(@NotNull final JPanel controlPanel) {
@@ -186,15 +203,19 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
final IpnbPasteCellAction action = (IpnbPasteCellAction)ActionManager.getInstance().getAction("IpnbPasteCellAction");
action.pasteCell(myIpnbFilePanel);
}
}, AllIcons.Actions.Menu_paste);
}, AllIcons.Actions.Menu_paste, "Paste Cell Below");
}
private static void addButton(@NotNull final JPanel controlPanel, @NotNull final ActionListener listener, @NotNull final Icon icon) {
private static void addButton(@NotNull final JPanel controlPanel,
@NotNull final ActionListener listener,
@NotNull final Icon icon,
@NotNull final String tooltip) {
final JButton button = new JButton();
button.setBackground(IpnbEditorUtil.getBackground());
button.setPreferredSize(new Dimension(30, 30));
button.setIcon(icon);
button.addActionListener(listener);
button.setToolTipText(tooltip);
controlPanel.add(button);
}
@@ -205,7 +226,7 @@ public class IpnbFileEditor extends UserDataHolderBase implements FileEditor, Te
final IpnbAddCellAction action = (IpnbAddCellAction)ActionManager.getInstance().getAction("IpnbAddCellAction");
action.addCell(myIpnbFilePanel);
}
}, AllIcons.General.Add);
}, AllIcons.General.Add, "Insert Cell Below");
}
public JButton getRunCellButton() {
@@ -282,6 +282,7 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
if (mySelectedCell != null && e.getID() == KeyEvent.KEY_PRESSED) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
mySelectedCell.switchToEditing();
repaint();
}
int index = myIpnbPanels.indexOf(mySelectedCell);
final Rectangle rect = getVisibleRect();
@@ -346,7 +347,14 @@ public class IpnbFilePanel extends JPanel implements Scrollable, DataProvider {
super.paintComponent(g);
if (mySelectedCell != null) {
g.setColor(mySelectedCell.isEditing() ? JBColor.GREEN : JBColor.GRAY);
g.drawRoundRect(100, mySelectedCell.getTop() - 1, getWidth() - 200, mySelectedCell.getHeight() + 2, 5, 5);
if (mySelectedCell instanceof IpnbCodePanel) {
g.drawRoundRect(mySelectedCell.getX() - 50, mySelectedCell.getTop() - 1,
mySelectedCell.getWidth() + 145 - IpnbEditorUtil.PROMPT_SIZE.width, mySelectedCell.getHeight() + 2, 5, 5);
}
else {
g.drawRoundRect(mySelectedCell.getX() - IpnbEditorUtil.PROMPT_SIZE.width - 55, mySelectedCell.getTop() - 1,
mySelectedCell.getWidth() + 150, mySelectedCell.getHeight() + 2, 5, 5);
}
}
}
@@ -3,24 +3,31 @@ package org.jetbrains.plugins.ipnb.editor.panels;
import org.w3c.dom.Element;
import uk.ac.ed.ph.snuggletex.SnugglePackage;
import uk.ac.ed.ph.snuggletex.dombuilding.CommandHandler;
import uk.ac.ed.ph.snuggletex.dombuilding.EqnArrayHandler;
import uk.ac.ed.ph.snuggletex.internal.DOMBuilder;
import uk.ac.ed.ph.snuggletex.internal.SnuggleParseException;
import uk.ac.ed.ph.snuggletex.semantics.Interpretation;
import uk.ac.ed.ph.snuggletex.tokens.CommandToken;
import uk.ac.ed.ph.snuggletex.tokens.FlowToken;
import java.util.List;
import static uk.ac.ed.ph.snuggletex.definitions.Globals.ALL_MODES;
import static uk.ac.ed.ph.snuggletex.definitions.Globals.MATH_MODE_ONLY;
import static uk.ac.ed.ph.snuggletex.definitions.LaTeXMode.MATH;
import static uk.ac.ed.ph.snuggletex.definitions.TextFlowContext.START_NEW_XHTML_BLOCK;
public final class IpnbTexPackageDefinitions {
private static final SnugglePackage ourPackage;
public static SnugglePackage getPackage() {
public static SnugglePackage getPackage() {
return ourPackage;
}
static {
private static String ourMathCharacters = "org/jetbrains/plugins/ipnb/math-characters.txt";
static {
ourPackage = new SnugglePackage("Ipnb");
ourPackage.addComplexCommandSameArgMode("dot", false, 1, MATH_MODE_ONLY, new CommandHandler() {
@@ -38,5 +45,8 @@ public final class IpnbTexPackageDefinitions {
builder.appendMathMLOperatorElement(parentElement, "\u03c0");
}
}, null);
ourPackage.addEnvironment("eqnarray", ALL_MODES, MATH, Interpretation.TABULAR, new EqnArrayHandler(), START_NEW_XHTML_BLOCK);
ourPackage.loadMathCharacterDefinitions(ourMathCharacters);
}
}
@@ -65,7 +65,7 @@ public class IpnbCodeSourcePanel extends IpnbPanel<JComponent, IpnbCodeCell> imp
@Override
protected JComponent createViewPanel() {
final JPanel panel = new JPanel(new VerticalFlowLayout(FlowLayout.LEFT, true, true));
final JPanel panel = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.TOP, true, true));
panel.setBackground(UIUtil.isUnderDarcula() ? IpnbEditorUtil.getBackground() : Gray._247);
if (mySource.startsWith("%")) {