1
0
mirror of https://github.com/chylex/IntelliJ-IdeaVim.git synced 2025-03-02 07:22:33 +01:00

Set default editor font for Ex and More panels on every activation

This commit is contained in:
Andrey Vlasovskikh 2014-04-02 13:17:17 +04:00
parent 6c9608a9ee
commit f511e6ea34
3 changed files with 41 additions and 10 deletions
src/com/maddyhome/idea/vim

View File

@ -0,0 +1,22 @@
package com.maddyhome.idea.vim.helper;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import org.jetbrains.annotations.NotNull;
import java.awt.*;
/**
* @author vlan
*/
public class UiHelper {
private UiHelper() {
}
@NotNull
public static Font getEditorFont() {
final EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
return new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
}
}

View File

@ -22,8 +22,7 @@ import com.intellij.openapi.actionSystem.DataContext;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.colors.EditorColorsManager;
import com.intellij.openapi.editor.colors.EditorColorsScheme;
import com.maddyhome.idea.vim.helper.UiHelper;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -47,15 +46,12 @@ public class ExEntryPanel extends JPanel {
private ExEntryPanel() {
setBorder(BorderFactory.createEtchedBorder());
EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
Font font = new Font(scheme.getEditorFontName(), Font.PLAIN, scheme.getEditorFontSize());
label = new JLabel(" ");
label.setFont(font);
entry = new ExTextField();
entry.setFont(font);
entry.setBorder(null);
setFontForElements();
setForeground(entry.getForeground());
setBackground(entry.getBackground());
@ -83,6 +79,12 @@ public class ExEntryPanel extends JPanel {
};
}
private void setFontForElements() {
final Font font = UiHelper.getEditorFont();
label.setFont(font);
entry.setFont(font);
}
/**
* Turns on the ex entry field for the given editor
*
@ -96,6 +98,7 @@ public class ExEntryPanel extends JPanel {
entry.setEditor(editor, context);
this.label.setText(label);
this.count = count;
setFontForElements();
entry.setDocument(entry.createDefaultModel());
entry.setText(initText);
entry.setType(label);

View File

@ -27,6 +27,7 @@ import com.intellij.ui.components.JBScrollPane;
import com.maddyhome.idea.vim.VimPlugin;
import com.maddyhome.idea.vim.helper.EditorData;
import com.maddyhome.idea.vim.helper.EditorDataContext;
import com.maddyhome.idea.vim.helper.UiHelper;
import com.maddyhome.idea.vim.option.Options;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -76,9 +77,7 @@ public class MorePanel extends JPanel {
add(scrollPane, BorderLayout.CENTER);
add(label, BorderLayout.SOUTH);
Font font = new Font("Monospaced", Font.PLAIN, 12);
text.setFont(font);
label.setFont(font);
setFontForElements();
text.setBorder(null);
scrollPane.setBorder(null);
@ -104,6 +103,12 @@ public class MorePanel extends JPanel {
text.addKeyListener(moreKeyListener);
}
private void setFontForElements() {
final Font font = UiHelper.getEditorFont();
text.setFont(font);
label.setFont(font);
}
/**
* Gets the number of characters that will fit across the 'more' window. This is useful if the text to be
* presented in the 'more' window needs to be formatted based on the display width.
@ -150,6 +155,7 @@ public class MorePanel extends JPanel {
oldGlass.add(this);
oldGlass.addComponentListener(adapter);
setFontForElements();
positionPanel();
oldGlass.setVisible(true);