gofmt
This commit is contained in:
parent
083deec663
commit
63da2e1ec6
@ -24,7 +24,7 @@ import (
|
|||||||
var RootCmd *cobra.Command
|
var RootCmd *cobra.Command
|
||||||
|
|
||||||
func GetTTYSize() (*unix.Winsize, error) {
|
func GetTTYSize() (*unix.Winsize, error) {
|
||||||
if (stdout_is_terminal) {
|
if stdout_is_terminal {
|
||||||
return unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ)
|
return unix.IoctlGetWinsize(int(os.Stdout.Fd()), unix.TIOCGWINSZ)
|
||||||
}
|
}
|
||||||
return nil, fmt.Errorf("STDOUT is not a TTY")
|
return nil, fmt.Errorf("STDOUT is not a TTY")
|
||||||
@ -78,7 +78,6 @@ var yellow_fmt = color.New(color.FgYellow).SprintFunc()
|
|||||||
var blue_fmt = color.New(color.FgBlue).SprintFunc()
|
var blue_fmt = color.New(color.FgBlue).SprintFunc()
|
||||||
var green_fmt = color.New(color.FgGreen).SprintFunc()
|
var green_fmt = color.New(color.FgGreen).SprintFunc()
|
||||||
|
|
||||||
|
|
||||||
func format_line_with_indent(output io.Writer, text string, indent string, screen_width int) {
|
func format_line_with_indent(output io.Writer, text string, indent string, screen_width int) {
|
||||||
x := len(indent)
|
x := len(indent)
|
||||||
fmt.Fprint(output, indent)
|
fmt.Fprint(output, indent)
|
||||||
@ -105,9 +104,11 @@ func format_line_with_indent(output io.Writer, text string, indent string, scree
|
|||||||
|
|
||||||
for i, r := range text {
|
for i, r := range text {
|
||||||
if in_escape > 0 {
|
if in_escape > 0 {
|
||||||
if (in_escape == 1 && (r == ']' || r == '[')) {
|
if in_escape == 1 && (r == ']' || r == '[') {
|
||||||
in_escape = 2
|
in_escape = 2
|
||||||
if (r == ']') { in_escape = 3 }
|
if r == ']' {
|
||||||
|
in_escape = 3
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (in_escape == 2 && r == 'm') || (in_escape == 3 && r == '\\' && text[i-1] == 0x1b) {
|
if (in_escape == 2 && r == 'm') || (in_escape == 3 && r == '\\' && text[i-1] == 0x1b) {
|
||||||
in_escape = 0
|
in_escape = 0
|
||||||
@ -323,7 +324,7 @@ func show_usage(cmd *cobra.Command) error {
|
|||||||
}
|
}
|
||||||
output_text := output.String()
|
output_text := output.String()
|
||||||
if stdout_is_terminal && cmd.Annotations["allow-pager"] != "no" {
|
if stdout_is_terminal && cmd.Annotations["allow-pager"] != "no" {
|
||||||
pager := exec.Command(kitty.DefaultPager[0], kitty.DefaultPager[1:]...);
|
pager := exec.Command(kitty.DefaultPager[0], kitty.DefaultPager[1:]...)
|
||||||
pager.Stdin = strings.NewReader(output_text)
|
pager.Stdin = strings.NewReader(output_text)
|
||||||
pager.Stdout = os.Stdout
|
pager.Stdout = os.Stdout
|
||||||
pager.Stderr = os.Stderr
|
pager.Stderr = os.Stderr
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user