soft wrap at right margin in distraction free mode, to keep text centered (related to IDEA-150440)

This commit is contained in:
Dmitry Batrak
2016-01-21 17:34:00 +03:00
parent 1ab2ebfbc9
commit 3968f161f5
3 changed files with 13 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -568,6 +568,10 @@ public final class EditorUtil {
return width > 0 ? width : 1;
}
public static int getPlainSpaceWidth(@NotNull Editor editor) {
return getSpaceWidth(Font.PLAIN, editor);
}
public static int getTabSize(@NotNull Editor editor) {
return editor.getSettings().getTabSize(editor.getProject());
}
@@ -7045,7 +7045,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
return column;
}
boolean isInDistractionFreeMode() {
public boolean isInDistractionFreeMode() {
return EditorUtil.isRealFileEditor(this)
&& (Registry.is("editor.distraction.free.mode") || isInPresentationMode());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1107,14 +1107,18 @@ public class SoftWrapApplianceManager implements Dumpable {
private static class DefaultVisibleAreaWidthProvider implements VisibleAreaWidthProvider {
private final Editor myEditor;
private final EditorImpl myEditor;
DefaultVisibleAreaWidthProvider(Editor editor) {
DefaultVisibleAreaWidthProvider(EditorImpl editor) {
myEditor = editor;
}
@Override
public int getVisibleAreaWidth() {
if (myEditor.isInDistractionFreeMode()) {
int rightMargin = myEditor.getSettings().getRightMargin(myEditor.getProject());
if (rightMargin > 0) return rightMargin * EditorUtil.getPlainSpaceWidth(myEditor);
}
return myEditor.getScrollingModel().getVisibleArea().width;
}
}