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

Show MorePanel on every MorePanel.setText() instead of showing it explicitly after Ex commands

This commit is contained in:
Andrey Vlasovskikh 2014-04-03 22:49:54 +04:00
parent 3cafe72f8f
commit b703a7eabb
11 changed files with 16 additions and 31 deletions

View File

@ -59,10 +59,7 @@ public abstract class CommandHandler {
* Indicates that the command takes a count, not a range - effects default
*/
public static final int RANGE_IS_COUNT = 64;
/**
* Indicates that the editor should not get focus back after the command
*/
public static final int KEEP_FOCUS = 128;
public static final int DONT_REOPEN = 256;
/**

View File

@ -40,7 +40,6 @@ public class CommandParser {
public static final int RES_EMPTY = 1;
public static final int RES_ERROR = 1;
public static final int RES_READONLY = 1;
public static final int RES_MORE_PANEL = 2;
public static final int RES_DONT_REOPEN = 4;
/**
@ -181,10 +180,6 @@ public class CommandParser {
SelectionType.CHARACTER_WISE, ':', false);
}
if (ok && (handler.getArgFlags() & CommandHandler.KEEP_FOCUS) != 0) {
result |= RES_MORE_PANEL;
}
if ((handler.getArgFlags() & CommandHandler.DONT_REOPEN) != 0) {
result |= RES_DONT_REOPEN;
}

View File

@ -32,7 +32,7 @@ import org.jetbrains.annotations.NotNull;
*/
public class DigraphHandler extends CommandHandler {
public DigraphHandler() {
super("dig", "raphs", ARGUMENT_OPTIONAL | KEEP_FOCUS);
super("dig", "raphs", ARGUMENT_OPTIONAL);
}
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {

View File

@ -36,7 +36,7 @@ import java.util.List;
*/
public class HistoryHandler extends CommandHandler {
public HistoryHandler() {
super("his", "tory", RANGE_FORBIDDEN | ARGUMENT_OPTIONAL | KEEP_FOCUS);
super("his", "tory", RANGE_FORBIDDEN | ARGUMENT_OPTIONAL);
}
public boolean execute(@NotNull Editor editor, @NotNull final DataContext context, @NotNull ExCommand cmd) throws ExException {

View File

@ -42,7 +42,7 @@ public class JumpsHandler extends CommandHandler {
public JumpsHandler() {
super(new CommandName[]{
new CommandName("ju", "mps")
}, ARGUMENT_FORBIDDEN | KEEP_FOCUS);
}, ARGUMENT_FORBIDDEN);
}
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {

View File

@ -52,7 +52,7 @@ public class MapHandler extends CommandHandler implements VimrcCommandHandler {
new CommandName("map!", ""),
new CommandName("im", "ap"),
new CommandName("cm", "ap")
}, RANGE_FORBIDDEN | ARGUMENT_OPTIONAL | KEEP_FOCUS);
}, RANGE_FORBIDDEN | ARGUMENT_OPTIONAL);
}
@Override

View File

@ -42,7 +42,7 @@ public class MarksHandler extends CommandHandler {
public MarksHandler() {
super(new CommandName[]{
new CommandName("marks", "")
}, ARGUMENT_OPTIONAL | KEEP_FOCUS);
}, ARGUMENT_OPTIONAL);
}
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {

View File

@ -40,7 +40,7 @@ public class RegistersHandler extends CommandHandler {
super(new CommandName[]{
new CommandName("di", "splay"),
new CommandName("reg", "isters")
}, ARGUMENT_OPTIONAL | KEEP_FOCUS);
}, ARGUMENT_OPTIONAL);
}
public boolean execute(@NotNull final Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {

View File

@ -33,7 +33,7 @@ import org.jetbrains.annotations.Nullable;
*/
public class SetHandler extends CommandHandler implements VimrcCommandHandler {
public SetHandler() {
super("se", "t", ARGUMENT_OPTIONAL | KEEP_FOCUS);
super("se", "t", ARGUMENT_OPTIONAL);
}
public boolean execute(@NotNull Editor editor, @NotNull DataContext context, @NotNull ExCommand cmd) throws ExException {

View File

@ -35,9 +35,7 @@ import com.maddyhome.idea.vim.common.TextRange;
import com.maddyhome.idea.vim.ex.CommandParser;
import com.maddyhome.idea.vim.ex.ExException;
import com.maddyhome.idea.vim.helper.EditorData;
import com.maddyhome.idea.vim.helper.RunnableHelper;
import com.maddyhome.idea.vim.ui.ExEntryPanel;
import com.maddyhome.idea.vim.ui.MorePanel;
import org.jetbrains.annotations.NotNull;
import javax.swing.*;
@ -182,15 +180,6 @@ public class ProcessGroup {
FileEditorManager.getInstance(project).openFile(EditorData.getVirtualFile(editor), true);
}
}
// If the result of the ex command is to display the "more" panel, show it here.
if ((flg & CommandParser.RES_MORE_PANEL) != 0 && MorePanel.getInstance(editor).hasText()) {
RunnableHelper.runReadCommand(project, new Runnable() {
public void run() {
MorePanel.getInstance(editor).activate();
}
}, "ShowMorePanel", "ExCommand");
}
}
});
}

View File

@ -105,10 +105,6 @@ public class MorePanel extends JPanel {
return panel;
}
public boolean hasText() {
return myText.getText().length() > 0;
}
public void setText(@NotNull String data) {
if (data.length() > 0 && data.charAt(data.length() - 1) == '\n') {
data = data.substring(0, data.length() - 1);
@ -116,6 +112,14 @@ public class MorePanel extends JPanel {
myText.setText(data);
myText.setCaretPosition(0);
if (data.length() > 0) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
activate();
}
});
}
}
/**