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

Disable Colors on Windows unless ENABLE_VIRTUAL_TERMINAL_PROCESSING is set #86

Closed
guilt opened this issue Apr 8, 2019 · 7 comments
Closed

Comments

@guilt
Copy link

guilt commented Apr 8, 2019

The ANSI sequences/colors only work when enabled within a process on Windows.

To do that, one has to roughly do the equivalent of:

  DWORD lpMode;
  HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
  GetConsoleMode(hOut, &lpMode);
  lpMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING;
  SetConsoleMode(hOut, lpMode);

and then call print() in Python. I know that pywin32 supports calling these functions, but as of now, these specific functions are not implemented yet in an available whl/release.

So, you'd have to set them yourself for it to work across Win32. The other option is disable colors on Windows till this is implemented.

I'm just reporting this so this can be useful to folks like me. :)

@jarun
Copy link
Owner

jarun commented Apr 8, 2019

You can disable colors. Please use the option -C, --nocolor.

@jarun
Copy link
Owner

jarun commented Apr 8, 2019

Does that work for you?

@guilt
Copy link
Author

guilt commented Apr 8, 2019

I understand that option, but the default shouldn't be true without getopt. It should be a detected value.

It only makes this tool unusable out of the box unless people know how to ignore the escape sequences.

@jarun
Copy link
Owner

jarun commented Apr 8, 2019

I must admit Windows support is not great in ddgr. I don't use Windows myself. Please raise a PR for this.

@guilt
Copy link
Author

guilt commented Apr 9, 2019

Raised a PR #87

@jarun
Copy link
Owner

jarun commented Apr 9, 2019

Thank you!

@jarun
Copy link
Owner

jarun commented Apr 10, 2019

Closing the issue. Need to wait for the relevant patch in googler.

@jarun jarun closed this as completed Apr 10, 2019
jarun added a commit that referenced this issue Apr 10, 2019
@github-actions github-actions bot locked and limited conversation to collaborators Jun 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants