Skip to content

Commit

Permalink
command window now also have callbacks #7
Browse files Browse the repository at this point in the history
  • Loading branch information
GavriYashar committed Sep 15, 2016
1 parent 67f4114 commit 120bcb4
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions src/at/justin/matlab/KeyReleasedHandler.java
Expand Up @@ -7,6 +7,8 @@
import at.justin.matlab.gui.fileStructure.FileStructure;
import at.justin.matlab.prefs.Settings;
import at.justin.matlab.util.KeyStrokeUtil;
import com.mathworks.mde.cmdwin.XCmdWndView;
import com.mathworks.mde.editor.EditorSyntaxTextPane;
import matlabcontrol.MatlabInvocationException;

import javax.swing.*;
Expand Down Expand Up @@ -119,19 +121,27 @@ private static void doYourThing(KeyEvent e) {
boolean altOnlyFlag = !ctrlFlag && !shiftFlag && altFlag;
int mod = KeyStrokeUtil.keyEventModifiersToKeyStrokeModifiers(e.getModifiers());

if (ctrlFlag && e.getKeyCode() == KeyEvent.VK_C) doCopyAction(null);
boolean isCmdWin = e.getSource() instanceof XCmdWndView;
boolean isEditor = e.getSource() instanceof EditorSyntaxTextPane;

if (isEditor && !isCmdWin) {
// do only editor
if (ctrlFlag && e.getKeyCode() == KeyEvent.VK_C) doCopyAction(null);
// bookmark thing
if (KS_BOOKMARK.getModifiers() == mod && KS_BOOKMARK.getKeyCode() == e.getKeyCode()) {
ctrlf2 = true;
// Doing the bookmarks here is error prone and won't work correctly.
// this function ist called every time (afaik) before Matlab's keyRelease
} else if (KS_SHOWBOOKARKS.getModifiers() == mod && KS_SHOWBOOKARKS.getKeyCode() == e.getKeyCode()) {
BookmarksViewer.getInstance().showDialog();
}
} else if (!isEditor && isCmdWin) {
if (ctrlFlag && e.getKeyCode() == KeyEvent.VK_C) doCopyActionCmdView(null);
}
// do editor and cmdWin
if (ctrlShiftFlag && e.getKeyCode() == KeyEvent.VK_V) showClipboardStack(null);
if (ctrlOnlyFlag && e.getKeyCode() == KeyEvent.VK_F12) showFileStructure(null);
if (Settings.DEBUG && ctrlShiftFlag && e.getKeyCode() == KeyEvent.VK_E) DEBUG(null);

// bookmark thing
if (KS_BOOKMARK.getModifiers() == mod && KS_BOOKMARK.getKeyCode() == e.getKeyCode()) {
ctrlf2 = true;
// Doing the bookmarks here is error prone and won't work correctly.
// this function ist called every time (afaik) before Matlab's keyRelease
} else if (KS_SHOWBOOKARKS.getModifiers() == mod && KS_SHOWBOOKARKS.getKeyCode() == e.getKeyCode()) {
BookmarksViewer.getInstance().showDialog();
}
if (ctrlOnlyFlag && e.getKeyCode() == KeyEvent.VK_F12) showFileStructure(null);
}

private static void operatorEqualsThing(KeyEvent e) {
Expand Down Expand Up @@ -182,6 +192,10 @@ static void doCopyAction(ActionEvent event) {
// }
}

static void doCopyActionCmdView(ActionEvent event) {
ClipboardStack.getInstance().add(CommandWindow.getSelectedTxt());
}

static void showClipboardStack(ActionEvent event) {
ClipboardStack.getInstance().setVisible(true);
}
Expand Down

0 comments on commit 120bcb4

Please sign in to comment.