We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 1cef686 + 02435dc commit 7cd719eCopy full SHA for 7cd719e
_examples/terminal/progress_bar/main.go
@@ -0,0 +1,30 @@
1
+package main
2
+
3
+import (
4
+ "fmt"
5
+ "strings"
6
+ "time"
7
8
+ "github.com/debeando/go-common/terminal"
9
+)
10
11
+func main() {
12
+ terminal.Reset()
13
+ terminal.Clear()
14
+ terminal.Flush()
15
16
+ for i := 0; i < 10; i++ {
17
+ // fmt.Print("\x1B7") // Save the cursor position
18
+ // fmt.Print("\x1B[2K") // Erase the entire line
19
+ // fmt.Print("\x1B[0J") // Erase from cursor to end of screen
20
+ // fmt.Print("\x1B[?47h") // Save screen
21
+ // fmt.Print("\x1B[1J") // Erase from cursor to beginning of screen
22
+ // fmt.Print("\x1B[?47l") // Restore screen
23
+ // defer fmt.Print("\x1B8") // Restore the cursor position util new size is calculated
24
25
+ terminal.Cursor(0, i)
26
+ fmt.Println(strings.Repeat("=", i))
27
+ // fmt.Printf("Progress: [\x1B[33m%3d%%\x1B[0m] %s", 2, "===")
28
+ time.Sleep(100 * time.Millisecond)
29
+ }
30
+}
_examples/terminal/table/main.go
@@ -26,10 +26,10 @@ func main() {
tbl.Add("Batman v Superman: Dawn of Justice", 2017, 6.5, "742K")
tbl.Add("Justice League", 2017, 6.1, "741K")
tbl.Add("Zack Snyder's Justice League", 2021, 7.9, "427K")
- tbl.Column(0, table.Column{ Name: "Movie", Alignment: table.Right, Truncate: 20, Width: 21 })
- tbl.Column(1, table.Column{ Name: "Year"})
31
- tbl.Column(2, table.Column{ Name: "Rate", Percentage: true, Alignment: table.Right })
32
- tbl.Column(3, table.Column{ Name: "Votes"})
+ tbl.Column(0, table.Column{Name: "Movie", Alignment: table.Right, Truncate: 20, Width: 21})
+ tbl.Column(1, table.Column{Name: "Year"})
+ tbl.Column(2, table.Column{Name: "Rate", Percentage: true, Alignment: table.Right})
+ tbl.Column(3, table.Column{Name: "Votes"})
33
// tbl.Column(2, table.Column{ZeroFill: true, Precision:3, Scale:1})
34
tbl.FilterBy(1, ">= 2000")
35
tbl.SortBy(2).Print()
table/value.go
@@ -44,10 +44,10 @@ func (f *Field) Truncate(t int) {
44
func (f *Field) Clear() {
45
if f.IsString() {
46
t := f.ToString()
47
- t = strings.TrimSpace(t)
48
- t = strings.ReplaceAll(t, "\n", " ")
49
- t = strings.ReplaceAll(t, "\r", " ")
50
- t = strings.ReplaceAll(t, " ", " ")
+ t = strings.TrimSpace(t)
+ t = strings.ReplaceAll(t, "\n", " ")
+ t = strings.ReplaceAll(t, "\r", " ")
+ t = strings.ReplaceAll(t, " ", " ")
51
52
(*f).Value = t
53
}
terminal/main.go
@@ -147,7 +147,7 @@ func Refresh(wait int, f func()) {
147
ScreenRestore()
148
defer CursorRestore()
149
150
- CursorSet(0,0)
+ CursorSet(0, 0)
151
Flush()
152
f()
153
time.Sleep(time.Duration(wait) * time.Second)
0 commit comments