mirror of
https://github.com/java-decompiler/jd-gui.git
synced 2024-12-03 10:10:55 +00:00
Adds “Change font size (Zoom) with Ctrl or Meta+Mouse Wheel“
This commit is contained in:
parent
fd2a78d54d
commit
c41d6749cb
@ -55,20 +55,26 @@ abstract class HyperlinkPage extends TextPage {
|
||||
if (entry) {
|
||||
def entryData = entry.value
|
||||
if (entryData && (offset < entryData.endPosition) && (offset >= entryData.startPosition) && isHyperlinkEnabled(entryData)) {
|
||||
textArea.cursor = HAND_CURSOR
|
||||
if (textArea.cursor != HAND_CURSOR) {
|
||||
textArea.cursor = HAND_CURSOR
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
textArea.cursor = DEFAULT_CURSOR
|
||||
if (textArea.cursor!= DEFAULT_CURSOR) {
|
||||
textArea.cursor = DEFAULT_CURSOR
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void mouseWheelMoved(MouseWheelEvent e) {
|
||||
mouseMoved(e)
|
||||
textArea.parent.dispatchEvent(e)
|
||||
if (e.modifiers == 0) {
|
||||
mouseMoved(e)
|
||||
textArea.parent.dispatchEvent(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,7 @@ import jd.gui.api.feature.LineNumberNavigable
|
||||
import jd.gui.api.feature.UriOpenable
|
||||
import org.fife.ui.rsyntaxtextarea.DocumentRange
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea
|
||||
import org.fife.ui.rsyntaxtextarea.RSyntaxTextAreaEditorKit
|
||||
import org.fife.ui.rsyntaxtextarea.SyntaxConstants
|
||||
import org.fife.ui.rsyntaxtextarea.Theme
|
||||
import org.fife.ui.rsyntaxtextarea.folding.FoldManager
|
||||
@ -27,6 +28,8 @@ import java.awt.datatransfer.StringSelection
|
||||
import java.awt.event.KeyEvent
|
||||
import java.awt.event.MouseAdapter
|
||||
import java.awt.event.MouseEvent
|
||||
import java.awt.event.MouseWheelEvent
|
||||
import java.awt.event.MouseWheelListener
|
||||
|
||||
@CompileStatic
|
||||
class TextPage extends JPanel implements ContentCopyable, ContentSelectable, LineNumberNavigable, ContentSearchable, UriOpenable {
|
||||
@ -37,6 +40,9 @@ class TextPage extends JPanel implements ContentCopyable, ContentSelectable, Lin
|
||||
protected static final Color SEARCH_HIGHLIGHT_COLOR = new Color(0xffff66)
|
||||
protected static final Color SELECT_HIGHLIGHT_COLOR = new Color(0xF49810)
|
||||
|
||||
protected static final RSyntaxTextAreaEditorKit.DecreaseFontSizeAction DECREASE_FONT_SIZE_ACTION = new RSyntaxTextAreaEditorKit.DecreaseFontSizeAction()
|
||||
protected static final RSyntaxTextAreaEditorKit.IncreaseFontSizeAction INCREASE_FONT_SIZE_ACTION = new RSyntaxTextAreaEditorKit.IncreaseFontSizeAction()
|
||||
|
||||
protected RSyntaxTextArea textArea
|
||||
protected RTextScrollPane scrollPane
|
||||
|
||||
@ -59,6 +65,28 @@ class TextPage extends JPanel implements ContentCopyable, ContentSelectable, Lin
|
||||
}
|
||||
}
|
||||
})
|
||||
textArea.addMouseWheelListener(new MouseWheelListener() {
|
||||
void mouseWheelMoved(MouseWheelEvent e) {
|
||||
if ((e.modifiers & (Event.META_MASK|Event.CTRL_MASK)) != 0) {
|
||||
int offset = textArea.viewToModel(new Point(e.x, e.y))
|
||||
|
||||
// Update font size
|
||||
if (e.wheelRotation > 0) {
|
||||
INCREASE_FONT_SIZE_ACTION.actionPerformedImpl(null, textArea)
|
||||
} else {
|
||||
DECREASE_FONT_SIZE_ACTION.actionPerformedImpl(null, textArea)
|
||||
}
|
||||
|
||||
Rectangle newRectangle = textArea.modelToView(offset)
|
||||
int newY = newRectangle.@y + (newRectangle.@height >> 1)
|
||||
|
||||
// Scroll
|
||||
Point viewPosition = scrollPane.viewport.viewPosition
|
||||
viewPosition.translate(0, newY-e.y)
|
||||
scrollPane.viewport.viewPosition = viewPosition
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
def ctrlA = KeyStroke.getKeyStroke(KeyEvent.VK_A, Toolkit.defaultToolkit.menuShortcutKeyMask)
|
||||
def ctrlC = KeyStroke.getKeyStroke(KeyEvent.VK_C, Toolkit.defaultToolkit.menuShortcutKeyMask)
|
||||
|
Loading…
Reference in New Issue
Block a user