mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-19 08:52:15 +01:00
Add CTRL +/-/scroll shortcuts to adjust editor console font size
Add CTRL +/- and CTRL scroll shortcuts to increase/decrease editor console output text size. This font size is shared with the editor and serial/network monitor. Adjusting the font size on any of these will update them all. Partially fixes #8615.
This commit is contained in:
parent
91fc80ba69
commit
3aa81b0a89
@ -315,7 +315,7 @@ public class Editor extends JFrame implements RunnerListener {
|
||||
status = new EditorStatus(this);
|
||||
consolePanel.add(status, BorderLayout.NORTH);
|
||||
|
||||
console = new EditorConsole();
|
||||
console = new EditorConsole(base);
|
||||
console.setName("console");
|
||||
// windows puts an ugly border on this guy
|
||||
console.setBorder(null);
|
||||
|
@ -26,6 +26,9 @@ import cc.arduino.ConsoleOutputStream;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.KeyAdapter;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.awt.event.MouseWheelEvent;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import static processing.app.Theme.scale;
|
||||
@ -61,7 +64,7 @@ public class EditorConsole extends JScrollPane {
|
||||
private SimpleAttributeSet stdOutStyle;
|
||||
private SimpleAttributeSet stdErrStyle;
|
||||
|
||||
public EditorConsole() {
|
||||
public EditorConsole(final Base base) {
|
||||
document = new DefaultStyledDocument();
|
||||
|
||||
consoleTextPane = new JTextPane(document);
|
||||
@ -110,6 +113,40 @@ public class EditorConsole extends JScrollPane {
|
||||
setMinimumSize(new Dimension(100, (height * lines)));
|
||||
|
||||
EditorConsole.init(stdOutStyle, System.out, stdErrStyle, System.err);
|
||||
|
||||
// Add "CTRL scroll" hotkey for font size adjustment.
|
||||
consoleTextPane.addMouseWheelListener((MouseWheelEvent e) -> {
|
||||
if (e.isControlDown()) {
|
||||
if (e.getWheelRotation() < 0) {
|
||||
base.handleFontSizeChange(1);
|
||||
} else {
|
||||
base.handleFontSizeChange(-1);
|
||||
}
|
||||
} else {
|
||||
e.getComponent().getParent().dispatchEvent(e);
|
||||
}
|
||||
});
|
||||
|
||||
// Add "CTRL (SHIFT) =/+" and "CTRL -" hotkeys for font size adjustment.
|
||||
consoleTextPane.addKeyListener(new KeyAdapter() {
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (e.getModifiersEx() == KeyEvent.CTRL_DOWN_MASK
|
||||
|| e.getModifiersEx() == (KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK)) {
|
||||
switch (e.getKeyCode()) {
|
||||
case KeyEvent.VK_PLUS:
|
||||
case KeyEvent.VK_EQUALS:
|
||||
base.handleFontSizeChange(1);
|
||||
break;
|
||||
case KeyEvent.VK_MINUS:
|
||||
if (!e.isShiftDown()) {
|
||||
base.handleFontSizeChange(-1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void applyPreferences() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user