mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-01-30 04:21:19 -08:00
refactor(terminalwidth): add debug info
This commit is contained in:
parent
f55da0ebcb
commit
3f1eb821f0
|
@ -55,15 +55,20 @@ func (env *Shell) IsWsl2() bool {
|
||||||
|
|
||||||
func (env *Shell) TerminalWidth() (int, error) {
|
func (env *Shell) TerminalWidth() (int, error) {
|
||||||
defer env.Trace(time.Now())
|
defer env.Trace(time.Now())
|
||||||
|
|
||||||
if env.CmdFlags.TerminalWidth > 0 {
|
if env.CmdFlags.TerminalWidth > 0 {
|
||||||
env.DebugF("terminal width: %d", env.CmdFlags.TerminalWidth)
|
env.DebugF("terminal width: %d", env.CmdFlags.TerminalWidth)
|
||||||
return env.CmdFlags.TerminalWidth, nil
|
return env.CmdFlags.TerminalWidth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
width, err := terminal.Width()
|
width, err := terminal.Width()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Error(err)
|
env.Error(err)
|
||||||
}
|
}
|
||||||
return int(width), err
|
|
||||||
|
env.DebugF("terminal width: %d", width)
|
||||||
|
env.CmdFlags.TerminalWidth = int(width)
|
||||||
|
return env.CmdFlags.TerminalWidth, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Shell) Platform() string {
|
func (env *Shell) Platform() string {
|
||||||
|
|
|
@ -87,22 +87,27 @@ func (env *Shell) IsWsl2() bool {
|
||||||
|
|
||||||
func (env *Shell) TerminalWidth() (int, error) {
|
func (env *Shell) TerminalWidth() (int, error) {
|
||||||
defer env.Trace(time.Now())
|
defer env.Trace(time.Now())
|
||||||
|
|
||||||
if env.CmdFlags.TerminalWidth > 0 {
|
if env.CmdFlags.TerminalWidth > 0 {
|
||||||
env.DebugF("terminal width: %d", env.CmdFlags.TerminalWidth)
|
env.DebugF("terminal width: %d", env.CmdFlags.TerminalWidth)
|
||||||
return env.CmdFlags.TerminalWidth, nil
|
return env.CmdFlags.TerminalWidth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
handle, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
handle, err := syscall.Open("CONOUT$", syscall.O_RDWR, 0)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Error(err)
|
env.Error(err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
|
|
||||||
info, err := winterm.GetConsoleScreenBufferInfo(uintptr(handle))
|
info, err := winterm.GetConsoleScreenBufferInfo(uintptr(handle))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
env.Error(err)
|
env.Error(err)
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
// return int(float64(info.Size.X) * 0.57), nil
|
|
||||||
return int(info.Size.X), nil
|
env.CmdFlags.TerminalWidth = int(info.Size.X)
|
||||||
|
env.DebugF("terminal width: %d", env.CmdFlags.TerminalWidth)
|
||||||
|
return env.CmdFlags.TerminalWidth, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (env *Shell) Platform() string {
|
func (env *Shell) Platform() string {
|
||||||
|
|
Loading…
Reference in a new issue