termlib

package module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 25, 2025 License: AGPL-3.0 Imports: 6 Imported by: 0

README

termlib

A minimalist terminal display library written in Go. I often find myself wanting a little more than display control than fmt packages provides but don't want to commit to a rich library like tcell. This project, termlib, explores that space.

Release Notes

  • version: 0.0.2
  • status: concept
  • released: 2025-11-21

A quick exploration of collecting the funcs I use for manipulating and display content in the terminal.

Authors
  • Doiel, R. S.

Software Requirements

  • Go >= 1.25
  • CMTools >= 0.0.40
Software Suggestions
  • Pandoc >= 3.1
  • GNU Make >= 3.0

Documentation

Overview

termlib is a light weight terminal interface library. Sort of a ncurse light. Copyright (C) 2025 R. S. Doiel

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License

termlib is a light weight terminal interface library. Copyright (C) 2025 R. S. Doiel

Index

Constants

View Source
const (
	Reset     = "\033[0m"
	Bold      = "\033[1m"
	Italic    = "\033[3m"
	Black     = "\033[30m"
	Red       = "\033[31m"
	Green     = "\033[32m"
	Yellow    = "\033[33m"
	Blue      = "\033[34m"
	Magenta   = "\033[35m"
	Cyan      = "\033[36m"
	White     = "\033[37m"
	BlackBg   = "\033[40m"
	RedBg     = "\033[41m"
	GreenBg   = "\033[42m"
	YellowBg  = "\033[43m"
	BlueBg    = "\033[44m"
	MagentaBg = "\033[45m"
	CyanBg    = "\033[46m"
	WhiteBg   = "\033[47m"
)

ANSI escape codes for colors and styles

View Source
const (
	// Version number of release
	Version = "0.0.4"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2025-12-24"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "001ee9a"
	LicenseText = `` /* 34525-byte string literal not displayed */

)
View Source
const (
	DemoHelpText = `` /* 435-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func FmtHelp

func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string

FmtHelp lets you process a text block with simple curly brace markup.

Types

type Terminal added in v0.0.4

type Terminal struct {
	// contains filtered or unexported fields
}

Terminal represents a terminal controller.

func New

func New(writer io.Writer) *Terminal

New creates a new Terminal instance with the specified writer and default styles.

func (*Terminal) Clear added in v0.0.4

func (t *Terminal) Clear()

Clear clears the screen and moves the cursor to the top-left corner.

func (*Terminal) ClrToBOL added in v0.0.4

func (t *Terminal) ClrToBOL()

ClrToBOL clears from the current cursor position to the start of the line.

func (*Terminal) ClrToEOL added in v0.0.4

func (t *Terminal) ClrToEOL()

ClrToEOL clears from the current cursor position to the end of the line.

func (*Terminal) GetBgColor added in v0.0.4

func (t *Terminal) GetBgColor() string

GetBgColor retrieves the background color code.

func (*Terminal) GetCurPos added in v0.0.4

func (t *Terminal) GetCurPos() (int, int)

GetCurPos returns the current cursor position.

func (*Terminal) GetFgColor added in v0.0.4

func (t *Terminal) GetFgColor() string

GetFgColor retrives the foreground color code.

func (*Terminal) GetTerminalHeight added in v0.0.4

func (t *Terminal) GetTerminalHeight() int

GetTerminalHeight returns the terminal height.

func (*Terminal) GetTerminalWidth added in v0.0.4

func (t *Terminal) GetTerminalWidth() int

GetTerminalWidth returns the terminal width.

func (*Terminal) Move added in v0.0.4

func (t *Terminal) Move(row, col int)

Move moves the cursor to the specified row and column (1-based).

func (*Terminal) Print added in v0.0.4

func (t *Terminal) Print(s string)

Print writes a string to the terminal with current style and updates the cursor position.

func (*Terminal) Printf added in v0.0.4

func (t *Terminal) Printf(format string, a ...interface{})

Printf writes a format string to the terminal with the current style and updates the cursor position.

func (*Terminal) Println added in v0.0.4

func (t *Terminal) Println(a ...interface{})

Println writes parameters as a string with a trailing new line

func (*Terminal) Refresh added in v0.0.4

func (t *Terminal) Refresh()

Refresh ensures all buffered output is written to the terminal.

func (*Terminal) ResetStyle added in v0.0.4

func (t *Terminal) ResetStyle()

ResetStyle resets all styles to default.

func (*Terminal) SetBgColor added in v0.0.4

func (t *Terminal) SetBgColor(color string)

SetBgColor sets the background color.

func (*Terminal) SetBold added in v0.0.4

func (t *Terminal) SetBold()

SetBold enables bold text.

func (*Terminal) SetFgColor added in v0.0.4

func (t *Terminal) SetFgColor(color string)

SetFgColor sets the foreground color.

func (*Terminal) SetItalic added in v0.0.4

func (t *Terminal) SetItalic()

SetItalic enables italic text.

func (*Terminal) UpdateTerminalSize added in v0.0.4

func (t *Terminal) UpdateTerminalSize()

UpdateTerminalSize updates the terminal width and height.

Directories

Path Synopsis
cmd
tldemo command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL