Esempio n. 1
0
// SetCursor sets the cursor position in the current buffer.
func (g *TermboxGui) SetCursor(screenColumn, screenLine int) (err error) {
	b := g.CurrBuff

	if !b.ValidScreenLine(screenLine) {
		return vigoerror.Err(0, screenLine)
	}
	if !b.ValidScreenColumn(screenColumn, screenLine) {
		return vigoerror.Err(1, screenColumn)
	}

	termbox.SetCursor(screenColumn-1, screenLine-1)
	return err
}
Esempio n. 2
0
// SetScreenPos sets the Line number and Column position of this Buffer's Cursor.
func (b *Buffer) SetScreenPos(screenLine, screenColumn int) error {
	if !b.ValidScreenLine(screenLine) {
		return vigoerror.Err(0, screenLine)
	}
	if !b.ValidScreenColumn(screenColumn, screenLine) {
		return vigoerror.Err(1, screenColumn)
	}

	b.setLine(screenLine - 1)
	b.setCol(screenColumn - 1)

	return nil
}
Esempio n. 3
0
// SetCol sets the column position of this Buffer's Cursor.
func (b *Buffer) SetScreenCol(screenColumn int) error {
	screenLine := b.Cursor.Line + 1
	if !b.ValidScreenColumn(screenColumn, screenLine) {
		return vigoerror.Err(1, screenColumn)
	}

	b.setCol(screenColumn - 1)

	return nil
}
Esempio n. 4
0
// SetScreenLine returns the line number of this Buffer's Cursor.
func (b *Buffer) SetScreenLine(screenLine int) error {
	if !b.ValidScreenLine(screenLine) {
		return vigoerror.Err(0, screenLine)
	}

	b.setLine(screenLine - 1)

	screenColumn := b.Cursor.Col + 1
	if !b.ValidScreenColumn(screenColumn, screenLine) {
		b.setCol(len(b.Lines[b.Cursor.Line]) - 1)
	}

	return nil
}