mirror of
https://github.com/chylex/IntelliJ-IdeaVim.git
synced 2025-03-02 07:22:33 +01:00
Made MorePanel per-editor based
This commit is contained in:
parent
b0760222f0
commit
f8781353a2
src/com/maddyhome/idea/vim
@ -142,8 +142,8 @@ public class MotionGroup {
|
||||
ExEntryPanel.getInstance().deactivate();
|
||||
}
|
||||
|
||||
if (MorePanel.getInstance().isActive()) {
|
||||
MorePanel.getInstance().deactivate();
|
||||
if (MorePanel.getInstance(editor).isActive()) {
|
||||
MorePanel.getInstance(editor).deactivate();
|
||||
}
|
||||
|
||||
CommandState.SubMode visualMode = CommandState.SubMode.NONE;
|
||||
@ -220,8 +220,8 @@ public class MotionGroup {
|
||||
ExEntryPanel.getInstance().deactivate();
|
||||
}
|
||||
|
||||
if (MorePanel.getInstance().isActive()) {
|
||||
MorePanel.getInstance().deactivate();
|
||||
if (MorePanel.getInstance(editor).isActive()) {
|
||||
MorePanel.getInstance(editor).deactivate();
|
||||
}
|
||||
|
||||
if (update) {
|
||||
@ -257,8 +257,8 @@ public class MotionGroup {
|
||||
ExEntryPanel.getInstance().deactivate();
|
||||
}
|
||||
|
||||
if (MorePanel.getInstance().isActive()) {
|
||||
MorePanel.getInstance().deactivate();
|
||||
if (MorePanel.getInstance(editor).isActive()) {
|
||||
MorePanel.getInstance(editor).deactivate();
|
||||
}
|
||||
|
||||
logger.debug("mouse released");
|
||||
@ -1771,14 +1771,12 @@ public class MotionGroup {
|
||||
if (ExEntryPanel.getInstance().isActive()) {
|
||||
ExEntryPanel.getInstance().deactivate();
|
||||
}
|
||||
|
||||
if (MorePanel.getInstance().isActive()) {
|
||||
MorePanel.getInstance().deactivate();
|
||||
}
|
||||
|
||||
FileEditor fe = event.getOldEditor();
|
||||
if (fe instanceof TextEditor) {
|
||||
Editor editor = ((TextEditor)fe).getEditor();
|
||||
final FileEditor fileEditor = event.getOldEditor();
|
||||
if (fileEditor instanceof TextEditor) {
|
||||
final Editor editor = ((TextEditor)fileEditor).getEditor();
|
||||
if (MorePanel.getInstance(editor).isActive()) {
|
||||
MorePanel.getInstance(editor).deactivate();
|
||||
}
|
||||
if (CommandState.getInstance(editor).getMode() == CommandState.Mode.VISUAL) {
|
||||
VimPlugin.getMotion().exitVisual(EditorHelper.getEditor(event.getManager(), event.getOldFile()), true);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.maddyhome.idea.vim.command.CommandState;
|
||||
import com.maddyhome.idea.vim.command.VisualChange;
|
||||
import com.maddyhome.idea.vim.command.VisualRange;
|
||||
import com.maddyhome.idea.vim.ui.MorePanel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -59,6 +60,7 @@ public class EditorData {
|
||||
editor.putUserData(LAST_HIGHLIGHTS, null);
|
||||
editor.putUserData(VISUAL, null);
|
||||
editor.putUserData(VISUAL_OP, null);
|
||||
editor.putUserData(MORE_PANEL, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,6 +188,14 @@ public class EditorData {
|
||||
return res != null;
|
||||
}
|
||||
|
||||
public static MorePanel getMorePanel(Editor editor) {
|
||||
return editor.getUserData(MORE_PANEL);
|
||||
}
|
||||
|
||||
public static void setMorePanel(@NotNull Editor editor, @NotNull MorePanel panel) {
|
||||
editor.putUserData(MORE_PANEL, panel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the virtual file associated with this editor
|
||||
*
|
||||
@ -211,6 +221,8 @@ public class EditorData {
|
||||
private static final Key<CommandState> COMMAND_STATE = new Key<CommandState>("commandState");
|
||||
private static final Key<Boolean> CHANGE_GROUP = new Key<Boolean>("changeGroup");
|
||||
private static final Key<Boolean> MOTION_GROUP = new Key<Boolean>("motionGroup");
|
||||
private static final Key<MorePanel> MORE_PANEL = new Key<MorePanel>("IdeaVim.morePanel");
|
||||
|
||||
private static Key CONSOLE_VIEW_IN_EDITOR_VIEW = Key.create("CONSOLE_VIEW_IN_EDITOR_VIEW");
|
||||
|
||||
private static Logger logger = Logger.getInstance(EditorData.class.getName());
|
||||
|
@ -45,16 +45,16 @@ import java.util.List;
|
||||
* This panel displays text in a <code>more</code> like window.
|
||||
*/
|
||||
public class MorePanel extends JPanel {
|
||||
private static MorePanel ourInstance;
|
||||
private static Logger ourLogger = Logger.getInstance(MorePanel.class.getName());
|
||||
|
||||
@NotNull private final Editor myEditor;
|
||||
@NotNull private final JComponent myParent;
|
||||
|
||||
@NotNull private JLabel myLabel = new JLabel("more");
|
||||
@NotNull private JTextArea myText = new JTextArea();
|
||||
@NotNull private JScrollPane myScrollPane =
|
||||
new JBScrollPane(myText, JScrollPane.VERTICAL_SCROLLBAR_NEVER, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
private ComponentAdapter myAdapter;
|
||||
@Nullable private Editor myEditor = null;
|
||||
@Nullable private JComponent myParent = null;
|
||||
private boolean myAtEnd = false;
|
||||
private int myLineHeight = 0;
|
||||
|
||||
@ -64,7 +64,10 @@ public class MorePanel extends JPanel {
|
||||
|
||||
private boolean myActive = false;
|
||||
|
||||
private MorePanel() {
|
||||
private MorePanel(@NotNull Editor editor) {
|
||||
myEditor = editor;
|
||||
myParent = editor.getContentComponent();
|
||||
|
||||
// Create a text editor for the text and a label for the prompt
|
||||
BorderLayout layout = new BorderLayout(0, 0);
|
||||
setLayout(layout);
|
||||
@ -97,29 +100,14 @@ public class MorePanel extends JPanel {
|
||||
myText.addKeyListener(moreKeyListener);
|
||||
}
|
||||
|
||||
public static MorePanel getInstance() {
|
||||
if (ourInstance == null) {
|
||||
ourInstance = new MorePanel();
|
||||
}
|
||||
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static MorePanel getInstance(@NotNull Editor editor) {
|
||||
if (ourInstance == null) {
|
||||
ourInstance = new MorePanel();
|
||||
MorePanel panel = EditorData.getMorePanel(editor);
|
||||
if (panel == null) {
|
||||
panel = new MorePanel(editor);
|
||||
EditorData.setMorePanel(editor, panel);
|
||||
}
|
||||
|
||||
ourInstance.setEditor(editor);
|
||||
return ourInstance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param editor The editor that this more panel will be displayed over
|
||||
*/
|
||||
public void setEditor(@NotNull Editor editor) {
|
||||
this.myEditor = editor;
|
||||
this.myParent = editor.getContentComponent();
|
||||
return panel;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -204,10 +192,7 @@ public class MorePanel extends JPanel {
|
||||
myOldGlass.setOpaque(myWasOpaque);
|
||||
myOldGlass.setLayout(myOldLayout);
|
||||
}
|
||||
if (myParent != null) {
|
||||
myParent.requestFocus();
|
||||
}
|
||||
myParent = null;
|
||||
myParent.requestFocus();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -294,8 +279,6 @@ public class MorePanel extends JPanel {
|
||||
}
|
||||
|
||||
private void positionPanel() {
|
||||
if (myParent == null) return;
|
||||
|
||||
Container scroll = SwingUtilities.getAncestorOfClass(JScrollPane.class, myParent);
|
||||
setSize(scroll.getSize());
|
||||
|
||||
@ -341,9 +324,6 @@ public class MorePanel extends JPanel {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
deactivate();
|
||||
if (myEditor == null) {
|
||||
return;
|
||||
}
|
||||
final VirtualFile vf = EditorData.getVirtualFile(myEditor);
|
||||
if (vf != null) {
|
||||
FileEditorManager.getInstance(myEditor.getProject()).openFile(vf, true);
|
||||
|
Loading…
Reference in New Issue
Block a user