-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6646 from djdv/feat/GUI-launcher
cmd: ipfs handle GUI environment on Windows
- Loading branch information
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
//+build !windows | ||
|
||
package util | ||
|
||
func InsideGUI() bool { | ||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package util | ||
|
||
import "golang.org/x/sys/windows" | ||
|
||
func InsideGUI() bool { | ||
conhostInfo := &windows.ConsoleScreenBufferInfo{} | ||
if err := windows.GetConsoleScreenBufferInfo(windows.Stdout, conhostInfo); err != nil { | ||
return false | ||
} | ||
|
||
if (conhostInfo.CursorPosition.X | conhostInfo.CursorPosition.Y) == 0 { | ||
// console cursor has not moved prior to our execution | ||
// high probability that we're not in a terminal | ||
return true | ||
} | ||
|
||
return false | ||
} |