// 
// Decompiled by Procyon v0.6.0
// 

package org.jline.terminal;

public class Size
{
    private int rows;
    private int cols;
    
    public Size() {
    }
    
    public Size(final int columns, final int rows) {
        this();
        this.setColumns(columns);
        this.setRows(rows);
    }
    
    public int getColumns() {
        return this.cols;
    }
    
    public void setColumns(final int columns) {
        this.cols = (short)columns;
    }
    
    public int getRows() {
        return this.rows;
    }
    
    public void setRows(final int rows) {
        this.rows = (short)rows;
    }
    
    public int cursorPos(final int row, final int col) {
        return row * (this.cols + 1) + col;
    }
    
    public void copy(final Size size) {
        this.setColumns(size.getColumns());
        this.setRows(size.getRows());
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o instanceof Size) {
            final Size size = (Size)o;
            return this.rows == size.rows && this.cols == size.cols;
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return this.rows * 31 + this.cols;
    }
    
    @Override
    public String toString() {
        return "Size[cols=" + this.cols + ", rows=" + this.rows + ']';
    }
}
