mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
set nearest font size for the documentation toolwindow
This commit is contained in:
+1
-1
@@ -104,7 +104,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
private SmartPsiElementPointer myElement;
|
||||
private long myModificationCount;
|
||||
|
||||
private static final String QUICK_DOC_FONT_SIZE_PROPERTY = "quick.doc.font.size";
|
||||
public static final String QUICK_DOC_FONT_SIZE_PROPERTY = "quick.doc.font.size";
|
||||
|
||||
private final Stack<Context> myBackStack = new Stack<>();
|
||||
private final Stack<Context> myForwardStack = new Stack<>();
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.ToggleAction;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsScheme;
|
||||
import com.intellij.openapi.options.FontSize;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
@@ -36,6 +37,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.awt.*;
|
||||
|
||||
import static com.intellij.codeInsight.documentation.DocumentationComponent.COLOR_KEY;
|
||||
import static com.intellij.codeInsight.documentation.DocumentationComponent.QUICK_DOC_FONT_SIZE_PROPERTY;
|
||||
import static com.jetbrains.python.debugger.containerview.PyDataView.DATA_VIEWER_ID;
|
||||
|
||||
public class PySciViewAction extends ToggleAction implements DumbAware {
|
||||
@@ -103,6 +105,8 @@ public class PySciViewAction extends ToggleAction implements DumbAware {
|
||||
if (element != null) {
|
||||
DocumentationManager.getInstance(project).showJavaDocInfo(element, element);
|
||||
}
|
||||
setDocFontSize();
|
||||
|
||||
final ToolWindow window = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.DOCUMENTATION);
|
||||
if (window != null) {
|
||||
window.setAnchor(ToolWindowAnchor.RIGHT, null);
|
||||
@@ -113,6 +117,21 @@ public class PySciViewAction extends ToggleAction implements DumbAware {
|
||||
}
|
||||
}
|
||||
|
||||
private static void setDocFontSize() {
|
||||
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
final int editorFontSize = scheme.getEditorFontSize();
|
||||
final FontSize[] values = FontSize.values();
|
||||
FontSize fontSize = FontSize.MEDIUM;
|
||||
for (FontSize value : values) {
|
||||
if (value.getSize() > editorFontSize) {
|
||||
break;
|
||||
}
|
||||
fontSize = value;
|
||||
}
|
||||
|
||||
PropertiesComponent.getInstance().setValue(QUICK_DOC_FONT_SIZE_PROPERTY, String.valueOf(fontSize.toString()));
|
||||
}
|
||||
|
||||
private void restoreDocumentationPopup(Project project) {
|
||||
PropertiesComponent.getInstance().setValue(DocumentationManager.getInstance(project).getAutoUpdateEnabledProperty(), false);
|
||||
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
|
||||
|
||||
Reference in New Issue
Block a user