Skip to content

Commit

Permalink
Allow edit functions on focused editor control
Browse files Browse the repository at this point in the history
  • Loading branch information
maccasoft committed Apr 23, 2024
1 parent bd74bfc commit 828f217
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 44 deletions.
16 changes: 0 additions & 16 deletions modules/spin-tools/src/com/maccasoft/propeller/EditorTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -831,22 +831,6 @@ public CTabItem getTabItem() {
return tabItem;
}

public void cut() {
editor.cut();
}

public void copy() {
editor.copy();
}

public void paste() {
editor.paste();
}

public void selectAll() {
editor.selectAll();
}

public void undo() {
editor.undo();
}
Expand Down
50 changes: 22 additions & 28 deletions modules/spin-tools/src/com/maccasoft/propeller/SpinTools.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.program.Program;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.FileDialog;
Expand Down Expand Up @@ -1271,10 +1272,9 @@ public void widgetSelected(SelectionEvent e) {

@Override
public void widgetSelected(SelectionEvent e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.cut();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).cut();
}
}
});
Expand All @@ -1286,10 +1286,9 @@ public void widgetSelected(SelectionEvent e) {

@Override
public void widgetSelected(SelectionEvent e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.copy();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).copy();
}
}
});
Expand All @@ -1301,10 +1300,9 @@ public void widgetSelected(SelectionEvent e) {

@Override
public void widgetSelected(SelectionEvent e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.paste();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).paste();
}
}
});
Expand Down Expand Up @@ -2133,10 +2131,9 @@ public void handleEvent(Event e) {

@Override
public void handleEvent(Event e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.cut();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).cut();
}
}
});
Expand All @@ -2148,10 +2145,9 @@ public void handleEvent(Event e) {

@Override
public void handleEvent(Event e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.copy();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).copy();
}
}
});
Expand All @@ -2163,10 +2159,9 @@ public void handleEvent(Event e) {

@Override
public void handleEvent(Event e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.paste();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).paste();
}
}
});
Expand All @@ -2178,10 +2173,9 @@ public void handleEvent(Event e) {

@Override
public void handleEvent(Event e) {
CTabItem tabItem = tabFolder.getSelection();
if (tabItem != null) {
EditorTab editorTab = (EditorTab) tabItem.getData();
editorTab.selectAll();
Control focusControl = shell.getDisplay().getFocusControl();
if (focusControl instanceof StyledText) {
((StyledText) focusControl).selectAll();
}
}
});
Expand Down

0 comments on commit 828f217

Please sign in to comment.