mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-2248 Support text wrapping in a <pre> tag in JEditorPane
port from JBR 11 to JBR 15 (cherry picked from commitff2e915371) cherry picked from commit6a30c56138
This commit is contained in:
committed by
alexey.ushakov@jetbrains.com
parent
60d8918c3d
commit
897aef83b2
@@ -42,6 +42,7 @@ import javax.swing.text.*;
|
||||
class LineView extends ParagraphView {
|
||||
/** Last place painted at. */
|
||||
int tabBase;
|
||||
private boolean wrap;
|
||||
|
||||
/**
|
||||
* Creates a LineView object.
|
||||
@@ -71,7 +72,7 @@ class LineView extends ParagraphView {
|
||||
* @see View#getPreferredSpan
|
||||
*/
|
||||
public float getMinimumSpan(int axis) {
|
||||
return getPreferredSpan(axis);
|
||||
return wrap ? super.getMinimumSpan(axis) : getPreferredSpan(axis);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,7 +121,7 @@ class LineView extends ParagraphView {
|
||||
* is the height inside of the inset area.
|
||||
*/
|
||||
protected void layout(int width, int height) {
|
||||
super.layout(Integer.MAX_VALUE - 1, height);
|
||||
super.layout(wrap ? width : Integer.MAX_VALUE - 1, height);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,4 +185,10 @@ class LineView extends ParagraphView {
|
||||
protected int getCharactersPerTab() {
|
||||
return 8;
|
||||
}
|
||||
|
||||
protected void setPropertiesFromAttributes() {
|
||||
super.setPropertiesFromAttributes();
|
||||
View parent = getParent();
|
||||
wrap = parent != null && parent.getAttributes().containsAttribute(CSS.Attribute.WHITE_SPACE, "pre-wrap");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user