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: cursor.go
    path of file: ./repos/devspace/vendor/github.com/AlecAivazis/survey/v2/terminal
    
    the code of the file until where you have to start completion: // +build !windows

package terminal

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"regexp"
	"strconv"
)

var COORDINATE_SYSTEM_BEGIN Short = 1

var dsrPattern = regexp.MustCompile(`\x1b\[(\d+);(\d+)R$`)

type Cursor struct {
	In  FileReader
	Out FileWriter
}

// Up moves the cursor n cells to up.
func (c *Cursor) Up(n int) {
	fmt.Fprintf(c.Out, "\x1b[%dA", n)
}

// Down moves the cursor n cells to down.
func (c *Cursor) Down(n int) {
	fmt.Fprintf(c.Out, "\x1b[%dB", n)
}

// Forward moves the cursor n cells to right.
func (c *Cursor) Forward(n int) {
	fmt.Fprintf(c.Out, "\x1b[%dC", n)
}

// Back moves the cursor n cells to left.
func (c *Cursor) Back(n int) {
	fmt.Fprintf(c.Out, "\x1b[%dD", n)
}

// NextLine moves cursor to beginning of the line n lines down.
func (c *Cursor) NextLine(n int) {
	c.Down(1)
	c.HorizontalAbsolute(0)
}

// PreviousLine moves cursor to beginning of the line n lines up.
func (c *Cursor) PreviousLine(n int) {
	c.Up(1)
	c.HorizontalAbsolute(0)
}

// HorizontalAbsolute moves cursor horizontally to x.
func (c *Cursor) HorizontalAbsolute(x int) {
	fmt.Fprintf(c.Out, "\x1b[%dG", x)
}

// Show shows the cursor.
func (c *Cursor) Show() {
	fmt.Fprint(c.Out, "\x1b[?25h")
}

// Hide hide the cursor.
func (c *Cursor) Hide() {
	fmt.Fprint(c.Out, "\x1b[?25l")
}

// Move moves the cursor to a specific x,y location.
func (c *Cursor) Move(x int, y int) {
	fmt.Fprintf(c.Out, "\x1b[%d;%df", x, y)
}

// Save saves the current position
    
func (c *Cursor) Location(buf *bytes.Buffer) (*Coord, error) {
	// ANSI escape sequence for DSR - Device Status Report
	// https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_sequences
	fmt.Fprint(c.Out, "\x1b[6n")

	// There may be input in Stdin prior to CursorLocation so make sure we don't
	// drop those bytes.
	var loc []int
	var match string
	for loc == nil {
		// Reports the cursor position (CPR) to the application as (as though typed at
		// the keyboard) ESC[n;mR, where n is the row and m is the column.
		reader := bufio.NewReader(c.In)
		text, err := reader.ReadSlice(byte('R'))
		if err != nil {
			return nil, err
		}

		loc = dsrPattern.FindStringIndex(string(text))
		if loc == nil {
			// After reading slice to byte 'R', the bufio Reader may have read more
			// bytes into its internal buffer which will be discarded on next ReadSlice.
			// We create a temporary buffer to read the remaining buffered slice and
			// write them to output buffer.
			buffered := make([]byte, reader.Buffered())
			_, err = io.ReadFull(reader, buffered)
			if err != nil {
				return nil, err
			}

			// Stdin contains R that doesn't match DSR, so pass the bytes along to
			// output buffer.
			buf.Write(text)
			buf.Write(buffered)
		} else {
			// Write the non-matching leading bytes to output buffer.
			buf.Write(text[:loc[0]])

			// Save the matching bytes to extract the row and column of the cursor.
			match = string(text[loc[0]:loc[1]])
		}
	}

	matches := dsrPattern.FindStringSubmatch(string(match))
	if len(matches) != 3 {
		return nil, fmt.Errorf("incorrect number of matches: %d", len(matches))
	}

	col, err := strconv.Atoi(matches[2])
	if err != nil {
		return nil, err
	}

	row, err := strconv.Atoi(matches[1])
	if err != nil {
		return nil, err
	}

	return &Coord{Short(col), Short(row)}, nil
}