Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Determine correct window handle #12

Open
maja42 opened this issue Feb 22, 2019 · 1 comment
Open

Determine correct window handle #12

maja42 opened this issue Feb 22, 2019 · 1 comment

Comments

@maja42
Copy link

maja42 commented Feb 22, 2019

When setting the terminal color, ansicolor uses the file handle syscall.Stdout for the windows system calls.

In my use case, this is not sufficient. I am compiling my go application as a windows GUI application (no terminal) and, if the command-line argument "-console" is provided, I allocate a new console.

I'm using the following syscalls for that:

procAttachConsole = kernel32.MustFindProc("AttachConsole")
procAllocConsole  = kernel32.MustFindProc("AllocConsole")
procFreeConsole   = kernel32.MustFindProc("FreeConsole")

As a result, the syscall.stdout handle (=1) is not correct, but there is no way to configure another window handle.

@maja42
Copy link
Author

maja42 commented Mar 11, 2019

I managed to solve this issue by overwriting syscall.Stdout, syscall.Stderr and syscall.Stdin to the streams acquired after creating a new terminal window (Before, my code only overwrote os.Stdout/err/in).

I suppose it is not an intended use case to overwrite these exported variables, but on the other hand go itself doesn't seep to support attaching different terminal windows at runtime.

So this issue can be closed from my side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant