Search in sources :

Example 1 with ATEGutterColumnManager

use of org.antlr.works.ate.gutter.ATEGutterColumnManager in project antlrworks by antlr.

the class ATEGutter method updateInfo.

public void updateInfo(Rectangle clip) {
    /** Make sure we are only updating objects in the current visible range
         *
         */
    int startIndex = textEditor.textPane.viewToModel(new Point(clip.x, clip.y));
    int endIndex = textEditor.textPane.viewToModel(new Point(clip.x + clip.width, clip.y + clip.height));
    items.clear();
    if (textEditor.gutterColumnsManager != null) {
        ATEGutterColumnManager manager = textEditor.gutterColumnsManager;
        int offsetX = offsetForLineNumber;
        for (String column : manager.getColumns()) {
            for (ATEGutterItem item : manager.getGutterItems(column)) {
                int index = item.getItemIndex();
                if (index >= startIndex && index <= endIndex) {
                    int y = getLineYPixelPosition(item.getItemIndex());
                    int width = item.getItemWidth();
                    int height = item.getItemHeight();
                    Rectangle r = new Rectangle(offsetX, y - height / 2, width, height);
                    this.items.add(new ItemInfo(item, r));
                }
            }
            offsetX += manager.getColumnWidth(column);
        }
    }
    foldingInfos.clear();
    if (textEditor.foldingManager != null) {
        List<ATEFoldingEntity> entities = textEditor.foldingManager.getFoldingEntities();
        for (ATEFoldingEntity entity : entities) {
            int entityStartIndex = entity.foldingEntityGetStartIndex();
            int entityEndIndex = entity.foldingEntityGetEndIndex();
            if (!(entityStartIndex > endIndex || entityEndIndex < startIndex)) {
                int top_y = getLineYPixelPosition(entity.foldingEntityGetStartIndex());
                int bottom_y = getLineYPixelPosition(entity.foldingEntityGetEndIndex());
                Point top = new Point(getWidth() - getOffsetFromText(), top_y);
                Point bottom = new Point(getWidth() - getOffsetFromText(), bottom_y);
                foldingInfos.add(new FoldingInfo(entity, top, bottom));
            }
        }
    }
}
Also used : ATEGutterColumnManager(org.antlr.works.ate.gutter.ATEGutterColumnManager) ATEGutterItem(org.antlr.works.ate.gutter.ATEGutterItem) ATEFoldingEntity(org.antlr.works.ate.folding.ATEFoldingEntity)

Example 2 with ATEGutterColumnManager

use of org.antlr.works.ate.gutter.ATEGutterColumnManager in project antlrworks by antlr.

the class ATEGutter method handleClickInColumn.

private boolean handleClickInColumn(Point point) {
    if (textEditor.gutterColumnsManager == null)
        return false;
    ATEGutterColumnManager manager = textEditor.gutterColumnsManager;
    if (point.x < offsetForLineNumber)
        return false;
    String column = null;
    int width = offsetForLineNumber;
    for (String c : manager.getColumns()) {
        width += manager.getColumnWidth(c);
        if (point.x < width) {
            column = c;
            break;
        }
    }
    if (column == null)
        return false;
    // use only y-axis
    point.x = 0;
    int index = textEditor.textPane.viewToModel(point);
    return manager.handleClickInColumn(column, index);
}
Also used : ATEGutterColumnManager(org.antlr.works.ate.gutter.ATEGutterColumnManager)

Aggregations

ATEGutterColumnManager (org.antlr.works.ate.gutter.ATEGutterColumnManager)2 ATEFoldingEntity (org.antlr.works.ate.folding.ATEFoldingEntity)1 ATEGutterItem (org.antlr.works.ate.gutter.ATEGutterItem)1