mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Fixed short-cup processing (VIM-552).
This commit is contained in:
Binary file not shown.
@@ -10,6 +10,7 @@ import com.jediterm.terminal.ui.TerminalAction;
|
||||
import com.jediterm.terminal.ui.TerminalWidget;
|
||||
import com.jediterm.terminal.ui.settings.SettingsProvider;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
@@ -26,12 +27,24 @@ public class JBTabbedTerminalWidget extends TabbedTerminalWidget {
|
||||
convertActions(this, getActions());
|
||||
}
|
||||
|
||||
public static void convertActions(JComponent component, List<TerminalAction> actions) {
|
||||
public static void convertActions(@NotNull JComponent component,
|
||||
@NotNull List<TerminalAction> actions) {
|
||||
convertActions(component, actions, null);
|
||||
}
|
||||
|
||||
public static void convertActions(@NotNull JComponent component,
|
||||
@NotNull List<TerminalAction> actions,
|
||||
@Nullable final Predicate<KeyEvent> elseAction) {
|
||||
for (final TerminalAction action : actions) {
|
||||
AnAction a = new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
action.perform(e.getInputEvent() instanceof KeyEvent? (KeyEvent)e.getInputEvent() : null);
|
||||
KeyEvent event = e.getInputEvent() instanceof KeyEvent ? (KeyEvent)e.getInputEvent() : null;
|
||||
if (!action.perform(event)) {
|
||||
if (elseAction != null) {
|
||||
elseAction.apply(event);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
a.registerCustomShortcutSet(action.getKeyCode(), action.getModifiers(), component);
|
||||
|
||||
@@ -22,7 +22,12 @@
|
||||
|
||||
package org.jetbrains.plugins.terminal;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.keymap.Keymap;
|
||||
import com.intellij.openapi.keymap.KeymapManager;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.util.JBHiDPIScaledImage;
|
||||
import com.intellij.util.ui.GraphicsUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
@@ -37,6 +42,7 @@ import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.StringSelection;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
import java.awt.datatransfer.UnsupportedFlavorException;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.io.IOException;
|
||||
@@ -47,7 +53,49 @@ public class JBTerminalPanel extends TerminalPanel {
|
||||
@NotNull StyleState styleState) {
|
||||
super(settingsProvider, backBuffer, styleState);
|
||||
|
||||
JBTabbedTerminalWidget.convertActions(this, getActions());
|
||||
JBTabbedTerminalWidget.convertActions(this, getActions(), new Predicate<KeyEvent>() {
|
||||
@Override
|
||||
public boolean apply(KeyEvent input) {
|
||||
JBTerminalPanel.this.handleKeyEvent(input);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
registerKeymapActions(this);
|
||||
}
|
||||
|
||||
private static void registerKeymapActions(final TerminalPanel terminalPanel) {
|
||||
Keymap keymap = KeymapManager.getInstance().getActiveKeymap();
|
||||
String[] actionIds = keymap.getActionIds();
|
||||
|
||||
ActionManager actionManager = ActionManager.getInstance();
|
||||
for (String actionId : actionIds) {
|
||||
final AnAction action = actionManager.getAction(actionId);
|
||||
if (action != null) {
|
||||
AnAction a = new DumbAwareAction() {
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
if (e.getInputEvent() instanceof KeyEvent) {
|
||||
action.update(e);
|
||||
if (e.getPresentation().isEnabled()) {
|
||||
action.actionPerformed(e);
|
||||
}
|
||||
else {
|
||||
terminalPanel.handleKeyEvent((KeyEvent)e.getInputEvent());
|
||||
}
|
||||
|
||||
e.getInputEvent().consume();
|
||||
}
|
||||
}
|
||||
};
|
||||
for (Shortcut sc : action.getShortcutSet().getShortcuts()) {
|
||||
if (sc.isKeyboard() && sc instanceof KeyboardShortcut) {
|
||||
KeyboardShortcut ksc = (KeyboardShortcut)sc;
|
||||
a.registerCustomShortcutSet(ksc.getFirstKeyStroke().getKeyCode(), ksc.getFirstKeyStroke().getModifiers(), terminalPanel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void setupAntialiasing(Graphics graphics, boolean antialiasing) {
|
||||
@@ -69,7 +117,17 @@ public class JBTerminalPanel extends TerminalPanel {
|
||||
drawImage(g, image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, null);
|
||||
}
|
||||
|
||||
public static void drawImage(Graphics g, Image image, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {
|
||||
public static void drawImage(Graphics g,
|
||||
Image image,
|
||||
int dx1,
|
||||
int dy1,
|
||||
int dx2,
|
||||
int dy2,
|
||||
int sx1,
|
||||
int sy1,
|
||||
int sx2,
|
||||
int sy2,
|
||||
ImageObserver observer) {
|
||||
if (image instanceof JBHiDPIScaledImage) {
|
||||
final Graphics2D newG = (Graphics2D)g.create(0, 0, image.getWidth(observer), image.getHeight(observer));
|
||||
newG.scale(0.5, 0.5);
|
||||
@@ -77,10 +135,11 @@ public class JBTerminalPanel extends TerminalPanel {
|
||||
if (img == null) {
|
||||
img = image;
|
||||
}
|
||||
newG.drawImage(img, 2*dx1, 2*dy1, 2*dx2, 2*dy2, sx1, sy1, sx2, sy2, observer);
|
||||
newG.drawImage(img, 2 * dx1, 2 * dy1, 2 * dx2, 2 * dy2, sx1, sy1, sx2, sy2, observer);
|
||||
newG.scale(1, 1);
|
||||
newG.dispose();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
g.drawImage(image, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user