Created
March 12, 2017 02:19
-
-
Save yu-tang/ebe5a3aa32e0e6a0234edc6294801fda to your computer and use it in GitHub Desktop.
Display segment at the bottom of the Editor when you activate new segment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* :name=Display segment at the bottom :description=Display segment at the bottom of the Editor when you activate new segment | |
* | |
* Usage: move this script to | |
* <your-scripts-folder>/entry_activated/ sub-folder | |
* for event driven automatically execution. | |
* | |
* @author Yu Tang | |
* @date 2017-03-12 | |
* @version 0.1.0 | |
*/ | |
package me.goat.groovy.scripting | |
import java.awt.Rectangle | |
// see org.omegat.gui.editor.EditorController#scrollForDisplayNearestSegments(CaretPosition) for details | |
int displayedEntryIndex = editor.displayedEntryIndex | |
Rectangle rect = editor.getSegmentBounds(displayedEntryIndex) | |
if (rect) { | |
// Expand rect vertically to fill height of viewport. | |
int viewportHeight = editor.scrollPane.viewport.height | |
int fontSize = editor.editor.font.size | |
rect.y -= (viewportHeight - rect.height + fontSize) | |
rect.height = viewportHeight | |
editor.editor.scrollRectToVisible(rect) | |
} | |
"display_segment_at_the_bottom.groovy executed." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment