Skip to content

Commit

Permalink
#79 Add Ctrl-F4 to Close Tab
Browse files Browse the repository at this point in the history
  • Loading branch information
deathmarine committed May 16, 2017
1 parent befd23f commit 7e6be07
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/us/deathmarine/luyten/Model.java
Expand Up @@ -4,6 +4,8 @@
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.InputEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
Expand All @@ -27,16 +29,20 @@
import java.util.TreeSet;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;

import javax.swing.AbstractAction;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JProgressBar;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTree;
import javax.swing.KeyStroke;
import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
Expand All @@ -62,6 +68,8 @@
import com.strobel.decompiler.DecompilerSettings;
import com.strobel.decompiler.PlainTextOutput;

import us.deathmarine.luyten.FindBox.FindExploreAction;

/**
* Jar-level model
*/
Expand Down Expand Up @@ -146,6 +154,20 @@ public void mouseClicked(MouseEvent e) {
}
}
});

KeyStroke sfuncF4 = KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.CTRL_DOWN_MASK, false);
mainWindow.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(sfuncF4, "CloseTab");

mainWindow.getRootPane().getActionMap().put("CloseTab", new AbstractAction() {
private static final long serialVersionUID = -885398399200419492L;

@Override
public void actionPerformed(ActionEvent e) {
closeOpenTab(house.getSelectedIndex());
}

});

JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, 1));
panel.setBorder(BorderFactory.createTitledBorder("Code"));
Expand Down Expand Up @@ -639,7 +661,7 @@ public void loadFile(File file) {
if (open)
closeFile();
this.file = file;

RecentFiles.add(file.getAbsolutePath());
mainWindow.mainMenuBar.updateRecentFiles();
loadTree();
Expand Down Expand Up @@ -925,6 +947,7 @@ public RSyntaxTextArea getCurrentTextArea() {
RSyntaxTextArea currentTextArea = null;
try {
int pos = house.getSelectedIndex();
System.out.println(pos);
if (pos >= 0) {
RTextScrollPane co = (RTextScrollPane) house.getComponentAt(pos);
currentTextArea = (RSyntaxTextArea) co.getViewport().getView();
Expand Down

0 comments on commit 7e6be07

Please sign in to comment.