diff --git a/README.md b/README.md index 8edb167..0f79974 100644 --- a/README.md +++ b/README.md @@ -77,62 +77,60 @@ Special thanks to github.com/k0kubun/go\-ansi which this project is based on. ## Index -- [cursor](#cursor) - - [Index](#index) - - [func Bottom](#func-bottom) - - [func Clear](#func-clear) - - [func ClearLine](#func-clearline) - - [func ClearLinesDown](#func-clearlinesdown) - - [func ClearLinesUp](#func-clearlinesup) - - [func Down](#func-down) - - [func DownAndClear](#func-downandclear) - - [func Hide](#func-hide) - - [func HorizontalAbsolute](#func-horizontalabsolute) - - [func Left](#func-left) - - [func Move](#func-move) - - [func Right](#func-right) - - [func SetTarget](#func-settarget) - - [func Show](#func-show) - - [func StartOfLine](#func-startofline) - - [func StartOfLineDown](#func-startoflinedown) - - [func StartOfLineUp](#func-startoflineup) - - [func TestCustomIOWriter](#func-testcustomiowriter) - - [func Up](#func-up) - - [func UpAndClear](#func-upandclear) - - [type Area](#type-area) - - [func NewArea](#func-newarea) - - [func (\*Area) Bottom](#func-area-bottom) - - [func (\*Area) Clear](#func-area-clear) - - [func (\*Area) ClearLinesDown](#func-area-clearlinesdown) - - [func (\*Area) ClearLinesUp](#func-area-clearlinesup) - - [func (\*Area) Down](#func-area-down) - - [func (\*Area) DownAndClear](#func-area-downandclear) - - [func (\*Area) Move](#func-area-move) - - [func (\*Area) StartOfLine](#func-area-startofline) - - [func (\*Area) StartOfLineDown](#func-area-startoflinedown) - - [func (\*Area) StartOfLineUp](#func-area-startoflineup) - - [func (\*Area) Top](#func-area-top) - - [func (\*Area) Up](#func-area-up) - - [func (\*Area) UpAndClear](#func-area-upandclear) - - [func (\*Area) Update](#func-area-update) - - [func (\*Area) WithWriter](#func-area-withwriter) - - [type Cursor](#type-cursor) - - [func NewCursor](#func-newcursor) - - [func (\*Cursor) Clear](#func-cursor-clear) - - [func (\*Cursor) ClearLine](#func-cursor-clearline) - - [func (\*Cursor) Down](#func-cursor-down) - - [func (\*Cursor) Hide](#func-cursor-hide) - - [func (\*Cursor) HorizontalAbsolute](#func-cursor-horizontalabsolute) - - [func (\*Cursor) Left](#func-cursor-left) - - [func (\*Cursor) Right](#func-cursor-right) - - [func (\*Cursor) Show](#func-cursor-show) - - [func (\*Cursor) Up](#func-cursor-up) - - [func (\*Cursor) WithWriter](#func-cursor-withwriter) - - [type Writer](#type-writer) +- [func Bottom\(\)](<#Bottom>) +- [func Clear\(\)](<#Clear>) +- [func ClearLine\(\)](<#ClearLine>) +- [func ClearLinesDown\(n int\)](<#ClearLinesDown>) +- [func ClearLinesUp\(n int\)](<#ClearLinesUp>) +- [func Down\(n int\)](<#Down>) +- [func DownAndClear\(n int\)](<#DownAndClear>) +- [func Hide\(\)](<#Hide>) +- [func HorizontalAbsolute\(n int\)](<#HorizontalAbsolute>) +- [func Left\(n int\)](<#Left>) +- [func Move\(x, y int\)](<#Move>) +- [func Right\(n int\)](<#Right>) +- [func SetTarget\(w Writer\)](<#SetTarget>) +- [func Show\(\)](<#Show>) +- [func StartOfLine\(\)](<#StartOfLine>) +- [func StartOfLineDown\(n int\)](<#StartOfLineDown>) +- [func StartOfLineUp\(n int\)](<#StartOfLineUp>) +- [func TestCustomIOWriter\(t \*testing.T\)](<#TestCustomIOWriter>) +- [func Up\(n int\)](<#Up>) +- [func UpAndClear\(n int\)](<#UpAndClear>) +- [type Area](<#Area>) + - [func NewArea\(\) Area](<#NewArea>) + - [func \(area \*Area\) Bottom\(\)](<#Area.Bottom>) + - [func \(area \*Area\) Clear\(\)](<#Area.Clear>) + - [func \(area \*Area\) ClearLinesDown\(n int\)](<#Area.ClearLinesDown>) + - [func \(area \*Area\) ClearLinesUp\(n int\)](<#Area.ClearLinesUp>) + - [func \(area \*Area\) Down\(n int\)](<#Area.Down>) + - [func \(area \*Area\) DownAndClear\(n int\)](<#Area.DownAndClear>) + - [func \(area \*Area\) Move\(x, y int\)](<#Area.Move>) + - [func \(area \*Area\) StartOfLine\(\)](<#Area.StartOfLine>) + - [func \(area \*Area\) StartOfLineDown\(n int\)](<#Area.StartOfLineDown>) + - [func \(area \*Area\) StartOfLineUp\(n int\)](<#Area.StartOfLineUp>) + - [func \(area \*Area\) Top\(\)](<#Area.Top>) + - [func \(area \*Area\) Up\(n int\)](<#Area.Up>) + - [func \(area \*Area\) UpAndClear\(n int\)](<#Area.UpAndClear>) + - [func \(area \*Area\) Update\(content string\)](<#Area.Update>) + - [func \(area Area\) WithWriter\(writer Writer\) Area](<#Area.WithWriter>) +- [type Cursor](<#Cursor>) + - [func NewCursor\(\) \*Cursor](<#NewCursor>) + - [func \(c \*Cursor\) Clear\(\)](<#Cursor.Clear>) + - [func \(c \*Cursor\) ClearLine\(\)](<#Cursor.ClearLine>) + - [func \(c \*Cursor\) Down\(n int\)](<#Cursor.Down>) + - [func \(c \*Cursor\) Hide\(\)](<#Cursor.Hide>) + - [func \(c \*Cursor\) HorizontalAbsolute\(n int\)](<#Cursor.HorizontalAbsolute>) + - [func \(c \*Cursor\) Left\(n int\)](<#Cursor.Left>) + - [func \(c \*Cursor\) Right\(n int\)](<#Cursor.Right>) + - [func \(c \*Cursor\) Show\(\)](<#Cursor.Show>) + - [func \(c \*Cursor\) Up\(n int\)](<#Cursor.Up>) + - [func \(c \*Cursor\) WithWriter\(w Writer\) \*Cursor](<#Cursor.WithWriter>) +- [type Writer](<#Writer>) -## func [Bottom]() +## func [Bottom]() ```go func Bottom() @@ -141,7 +139,7 @@ func Bottom() Bottom moves the cursor to the bottom of the terminal. This is done by calculating how many lines were moved by Up and Down. -## func [Clear]() +## func [Clear]() ```go func Clear() @@ -150,7 +148,7 @@ func Clear() Clear clears the current position and moves the cursor to the left. -## func [ClearLine]() +## func [ClearLine]() ```go func ClearLine() @@ -159,7 +157,7 @@ func ClearLine() ClearLine clears the current line and moves the cursor to it's start position. -## func [ClearLinesDown]() +## func [ClearLinesDown]() ```go func ClearLinesDown(n int) @@ -168,7 +166,7 @@ func ClearLinesDown(n int) ClearLinesDown clears n lines downwards from the current position and moves the cursor. -## func [ClearLinesUp]() +## func [ClearLinesUp]() ```go func ClearLinesUp(n int) @@ -177,7 +175,7 @@ func ClearLinesUp(n int) ClearLinesUp clears n lines upwards from the current position and moves the cursor. -## func [Down]() +## func [Down]() ```go func Down(n int) @@ -186,7 +184,7 @@ func Down(n int) Down moves the cursor n lines down relative to the current position. -## func [DownAndClear]() +## func [DownAndClear]() ```go func DownAndClear(n int) @@ -195,7 +193,7 @@ func DownAndClear(n int) DownAndClear moves the cursor down by n lines, then clears the line. -## func [Hide]() +## func [Hide]() ```go func Hide() @@ -204,7 +202,7 @@ func Hide() Hide the cursor. Don't forget to show the cursor at least at the end of your application with Show. Otherwise the user might have a terminal with a permanently hidden cursor, until they reopen the terminal. -## func [HorizontalAbsolute]() +## func [HorizontalAbsolute]() ```go func HorizontalAbsolute(n int) @@ -213,7 +211,7 @@ func HorizontalAbsolute(n int) HorizontalAbsolute moves the cursor to n horizontally. The position n is absolute to the start of the line. -## func [Left]() +## func [Left]() ```go func Left(n int) @@ -222,7 +220,7 @@ func Left(n int) Left moves the cursor n characters to the left relative to the current position. -## func [Move]() +## func [Move]() ```go func Move(x, y int) @@ -231,7 +229,7 @@ func Move(x, y int) Move moves the cursor relative by x and y. -## func [Right]() +## func [Right]() ```go func Right(n int) @@ -240,16 +238,16 @@ func Right(n int) Right moves the cursor n characters to the right relative to the current position. -## func [SetTarget]() +## func [SetTarget]() ```go func SetTarget(w Writer) ``` - +SetTarget sets to output target of the default curser to the provided cursor.Writer \(wrapping io.Writer\). -## func [Show]() +## func [Show]() ```go func Show() @@ -258,7 +256,7 @@ func Show() Show the cursor if it was hidden previously. Don't forget to show the cursor at least at the end of your application. Otherwise the user might have a terminal with a permanently hidden cursor, until they reopen the terminal. -## func [StartOfLine]() +## func [StartOfLine]() ```go func StartOfLine() @@ -267,7 +265,7 @@ func StartOfLine() StartOfLine moves the cursor to the start of the current line. -## func [StartOfLineDown]() +## func [StartOfLineDown]() ```go func StartOfLineDown(n int) @@ -276,7 +274,7 @@ func StartOfLineDown(n int) StartOfLineDown moves the cursor down by n lines, then moves to cursor to the start of the line. -## func [StartOfLineUp]() +## func [StartOfLineUp]() ```go func StartOfLineUp(n int) @@ -294,7 +292,7 @@ func TestCustomIOWriter(t *testing.T) TestCustomIOWriter tests the cursor functions with a custom Writer. -## func [Up]() +## func [Up]() ```go func Up(n int) @@ -303,7 +301,7 @@ func Up(n int) Up moves the cursor n lines up relative to the current position. -## func [UpAndClear]() +## func [UpAndClear]() ```go func UpAndClear(n int) @@ -312,7 +310,7 @@ func UpAndClear(n int) UpAndClear moves the cursor up by n lines, then clears the line. -## type [Area]() +## type [Area]() Area displays content which can be updated on the fly. You can use this to create live output, charts, dropdowns, etc. @@ -323,16 +321,16 @@ type Area struct { ``` -### func [NewArea]() +### func [NewArea]() ```go -func NewArea() *Area +func NewArea() Area ``` NewArea returns a new Area. -### func \(\*Area\) [Bottom]() +### func \(\*Area\) [Bottom]() ```go func (area *Area) Bottom() @@ -341,7 +339,7 @@ func (area *Area) Bottom() Bottom moves the cursor to the bottom of the terminal. This is done by calculating how many lines were moved by Up and Down. -### func \(\*Area\) [Clear]() +### func \(\*Area\) [Clear]() ```go func (area *Area) Clear() @@ -350,7 +348,7 @@ func (area *Area) Clear() Clear clears the content of the Area. -### func \(\*Area\) [ClearLinesDown]() +### func \(\*Area\) [ClearLinesDown]() ```go func (area *Area) ClearLinesDown(n int) @@ -359,7 +357,7 @@ func (area *Area) ClearLinesDown(n int) ClearLinesDown clears n lines downwards from the current position and moves the cursor. -### func \(\*Area\) [ClearLinesUp]() +### func \(\*Area\) [ClearLinesUp]() ```go func (area *Area) ClearLinesUp(n int) @@ -368,7 +366,7 @@ func (area *Area) ClearLinesUp(n int) ClearLinesUp clears n lines upwards from the current position and moves the cursor. -### func \(\*Area\) [Down]() +### func \(\*Area\) [Down]() ```go func (area *Area) Down(n int) @@ -377,7 +375,7 @@ func (area *Area) Down(n int) Down moves the cursor of the area down one line. -### func \(\*Area\) [DownAndClear]() +### func \(\*Area\) [DownAndClear]() ```go func (area *Area) DownAndClear(n int) @@ -395,7 +393,7 @@ func (area *Area) Move(x, y int) Move moves the cursor relative by x and y. -### func \(\*Area\) [StartOfLine]() +### func \(\*Area\) [StartOfLine]() ```go func (area *Area) StartOfLine() @@ -404,7 +402,7 @@ func (area *Area) StartOfLine() StartOfLine moves the cursor to the start of the current line. -### func \(\*Area\) [StartOfLineDown]() +### func \(\*Area\) [StartOfLineDown]() ```go func (area *Area) StartOfLineDown(n int) @@ -413,7 +411,7 @@ func (area *Area) StartOfLineDown(n int) StartOfLineDown moves the cursor down by n lines, then moves to cursor to the start of the line. -### func \(\*Area\) [StartOfLineUp]() +### func \(\*Area\) [StartOfLineUp]() ```go func (area *Area) StartOfLineUp(n int) @@ -422,7 +420,7 @@ func (area *Area) StartOfLineUp(n int) StartOfLineUp moves the cursor up by n lines, then moves to cursor to the start of the line. -### func \(\*Area\) [Top]() +### func \(\*Area\) [Top]() ```go func (area *Area) Top() @@ -431,7 +429,7 @@ func (area *Area) Top() Top moves the cursor to the top of the area. This is done by calculating how many lines were moved by Up and Down. -### func \(\*Area\) [Up]() +### func \(\*Area\) [Up]() ```go func (area *Area) Up(n int) @@ -440,7 +438,7 @@ func (area *Area) Up(n int) Up moves the cursor of the area up one line. -### func \(\*Area\) [UpAndClear]() +### func \(\*Area\) [UpAndClear]() ```go func (area *Area) UpAndClear(n int) @@ -449,25 +447,25 @@ func (area *Area) UpAndClear(n int) UpAndClear moves the cursor up by n lines, then clears the line. -### func \(\*Area\) [Update]() +### func \(\*Area\) [Update]() ```go func (area *Area) Update(content string) ``` -Update overwrites the content of the Area. +Update overwrites the content of the Area and adjusts its height based on content. -### func \(\*Area\) [WithWriter]() +### func \(Area\) [WithWriter]() ```go -func (area *Area) WithWriter(writer Writer) *Area +func (area Area) WithWriter(writer Writer) Area ``` -WithWriter sets the custom writer +WithWriter sets the custom writer. -## type [Cursor]() +## type [Cursor]() Cursor displays content which can be updated on the fly. You can use this to create live output, charts, dropdowns, etc. @@ -478,16 +476,16 @@ type Cursor struct { ``` -### func [NewCursor]() +### func [NewCursor]() ```go func NewCursor() *Cursor ``` - +NewCursor creates a new Cursor instance writing to os.Stdout. -### func \(\*Cursor\) [Clear]() +### func \(\*Cursor\) [Clear]() ```go func (c *Cursor) Clear() @@ -496,7 +494,7 @@ func (c *Cursor) Clear() Clear clears the current position and moves the cursor to the left. -### func \(\*Cursor\) [ClearLine]() +### func \(\*Cursor\) [ClearLine]() ```go func (c *Cursor) ClearLine() @@ -505,7 +503,7 @@ func (c *Cursor) ClearLine() ClearLine clears the current line and moves the cursor to it's start position. -### func \(\*Cursor\) [Down]() +### func \(\*Cursor\) [Down]() ```go func (c *Cursor) Down(n int) @@ -514,7 +512,7 @@ func (c *Cursor) Down(n int) Down moves the cursor n lines down relative to the current position. -### func \(\*Cursor\) [Hide]() +### func \(\*Cursor\) [Hide]() ```go func (c *Cursor) Hide() @@ -523,7 +521,7 @@ func (c *Cursor) Hide() Hide the cursor. Don't forget to show the cursor at least at the end of your application with Show. Otherwise the user might have a terminal with a permanently hidden cursor, until they reopen the terminal. -### func \(\*Cursor\) [HorizontalAbsolute]() +### func \(\*Cursor\) [HorizontalAbsolute]() ```go func (c *Cursor) HorizontalAbsolute(n int) @@ -532,7 +530,7 @@ func (c *Cursor) HorizontalAbsolute(n int) HorizontalAbsolute moves the cursor to n horizontally. The position n is absolute to the start of the line. -### func \(\*Cursor\) [Left]() +### func \(\*Cursor\) [Left]() ```go func (c *Cursor) Left(n int) @@ -541,7 +539,7 @@ func (c *Cursor) Left(n int) Left moves the cursor n characters to the left relative to the current position. -### func \(\*Cursor\) [Right]() +### func \(\*Cursor\) [Right]() ```go func (c *Cursor) Right(n int) @@ -550,7 +548,7 @@ func (c *Cursor) Right(n int) Right moves the cursor n characters to the right relative to the current position. -### func \(\*Cursor\) [Show]() +### func \(\*Cursor\) [Show]() ```go func (c *Cursor) Show() @@ -559,7 +557,7 @@ func (c *Cursor) Show() Show the cursor if it was hidden previously. Don't forget to show the cursor at least at the end of your application. Otherwise the user might have a terminal with a permanently hidden cursor, until they reopen the terminal. -### func \(\*Cursor\) [Up]() +### func \(\*Cursor\) [Up]() ```go func (c *Cursor) Up(n int) @@ -568,7 +566,7 @@ func (c *Cursor) Up(n int) Up moves the cursor n lines up relative to the current position. -### func \(\*Cursor\) [WithWriter]() +### func \(\*Cursor\) [WithWriter]() ```go func (c *Cursor) WithWriter(w Writer) *Cursor @@ -577,7 +575,7 @@ func (c *Cursor) WithWriter(w Writer) *Cursor WithWriter allows for any arbitrary Writer to be used for cursor movement abstracted. -## type [Writer]() +## type [Writer]() Writer is an expanded io.Writer interface with a file descriptor. @@ -590,6 +588,7 @@ type Writer interface { Generated by [gomarkdoc]() + ---