|
30 | 30 | import java.awt.Font;
|
31 | 31 | import java.awt.event.ActionEvent;
|
32 | 32 | import java.awt.event.ActionListener;
|
| 33 | +import java.awt.event.MouseWheelListener; |
| 34 | +import java.awt.event.MouseWheelEvent; |
| 35 | + |
33 | 36 | import java.io.IOException;
|
34 | 37 |
|
35 | 38 | import javax.swing.Action;
|
|
64 | 67 | /**
|
65 | 68 | * Single tab, editing a single file, in the main window.
|
66 | 69 | */
|
67 |
| -public class EditorTab extends JPanel implements SketchFile.TextStorage { |
| 70 | +public class EditorTab extends JPanel implements SketchFile.TextStorage, MouseWheelListener { |
68 | 71 | protected Editor editor;
|
69 | 72 | protected SketchTextArea textarea;
|
70 | 73 | protected RTextScrollPane scrollPane;
|
@@ -106,6 +109,7 @@ public EditorTab(Editor editor, SketchFile file, String contents)
|
106 | 109 | file.setStorage(this);
|
107 | 110 | applyPreferences();
|
108 | 111 | add(scrollPane, BorderLayout.CENTER);
|
| 112 | + textarea.addMouseWheelListener(this); |
109 | 113 | }
|
110 | 114 |
|
111 | 115 | private RSyntaxDocument createDocument(String contents) {
|
@@ -178,6 +182,18 @@ private SketchTextArea createTextArea(RSyntaxDocument document)
|
178 | 182 | return textArea;
|
179 | 183 | }
|
180 | 184 |
|
| 185 | + public void mouseWheelMoved(MouseWheelEvent e) { |
| 186 | + if (e.isControlDown()) { |
| 187 | + if (e.getWheelRotation() < 0) { |
| 188 | + editor.base.handleFontSizeChange(1); |
| 189 | + } else { |
| 190 | + editor.base.handleFontSizeChange(-1); |
| 191 | + } |
| 192 | + } else { |
| 193 | + e.getComponent().getParent().dispatchEvent(e); |
| 194 | + } |
| 195 | + } |
| 196 | + |
181 | 197 | private void configurePopupMenu(final SketchTextArea textarea){
|
182 | 198 |
|
183 | 199 | JPopupMenu menu = textarea.getPopupMenu();
|
|
0 commit comments