You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tableprinter.go
    path of file: ./repos/plumber/vendor/github.com/lensesio/tableprinter
    
    the code of the file until where you have to start completion: package tableprinter

import (
	"fmt"
	"io"
	"os"
	"reflect"
	"strings"

	"github.com/kataras/tablewriter"
)

// Alignment is the alignment type (int).
//
// See `Printer#DefaultColumnAlignment` and `Printer#DefaultColumnAlignment` too.
type Alignment int

const (
	// AlignDefault is the default alignment (0).
	AlignDefault Alignment = iota
	// AlignCenter is the center aligment (1).
	AlignCenter
	// AlignRight is the right aligment (2).
	AlignRight
	// AlignLeft is the left aligment (3).
	AlignLeft
)

// Printer 
    
func (p *Printer) formatTableBasedOnWidth(headers []string, rows [][]string, fontSize int) ([]string, [][]string) {
	totalWidthPreCalculated := p.calcWidth(headers)
	var rowsWidth int

	for _, rs := range rows {
		w := p.calcWidth(rs)
		if w > rowsWidth {
			rowsWidth = w
		}
	}

	if rowsWidth > totalWidthPreCalculated {
		totalWidthPreCalculated = rowsWidth
	}

	pd := float64(fontSize/9) * 1.2
	pdTrail := fontSize + fontSize/3
	totalWidthPreCalculated = int(float64(totalWidthPreCalculated)*pd + float64(pdTrail))

	termWidth := int(getTerminalWidth())
	if totalWidthPreCalculated > termWidth {
		dif := totalWidthPreCalculated - termWidth
		difSpace := int(float64(fontSize) * 0.6)
		// remove the last element of the rows and the last header.
		if dif >= difSpace {
			for idx, r := range rows {
				rLastIdx := len(r) - 1
				r = append(r[:rLastIdx], r[rLastIdx+1:]...)
				rows[idx] = r
			}
			if len(headers) > 0 {
				hLastIdx := len(headers) - 1
				headers = append(headers[:hLastIdx], headers[hLastIdx+1:]...)
			}
			return p.formatTableBasedOnWidth(headers, rows, fontSize)
		}
	}

	return headers, rows
}