14 May 2018 |
@mgmeier:matrix.org | I see. The issue seems to imply that only Win 10 is affected? | 13:48:29 |
Michael Snoyman | That might be the case, but I tested on Win 10 | 13:48:51 |
@mgmeier:matrix.org | I'm using Win 7, so I'll give it a spin, see how the terminal output looks like | 13:49:28 |
@mgmeier:matrix.org | Disabling ANSI colors would be one way to go, the other utilizing the ANSI encoding resulting from ansi-terminal verbatim in the loggerFunc (we're talking about <10 literal values being defined locally, I'd say that's justifiable). | 13:51:39 |
Michael Snoyman | SGTM | 13:54:00 |
15 May 2018 |
@mgmeier:matrix.org | Ok, my research shows that things aren't as straightforward as I assumed. Of course :) | 09:16:09 |
@mgmeier:matrix.org | Right now, RIO logger confirms for a handle only that it's connected to a terminal, assuming ANSI capabality. | 09:16:53 |
@mgmeier:matrix.org | On Win, however, one should 1) unwrap the Win API HANDLE from GHC Handle, and check for ANSI capability. | 09:17:49 |
@mgmeier:matrix.org | This succeds eg. for minTTY based solutions (like cygwin and git-bash), and ANSI emulation is enabled natively. On Win10 conhost terminals, it succeds, but ANSI emulation must first be enabled via some SetMode API call (this would account for seeing ANSI sequences in the console output). On older Win versions, capability check fails. cf. https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences | 09:21:13 |
@mgmeier:matrix.org | what ansi-terminal does is perform all this, and fall back to mapping ANSI sequences to Win Conhost API calls, and return empty strings for all actual ANSI sequences. The detection code is here: https://github.com/feuerbach/ansi-terminal/blob/master/src/System/Console/ANSI/Windows/Detect.hs | 09:23:25 |
@mgmeier:matrix.org | So where does that leave us? Disabling ANSI based on os(windows) is not an option, since that negatively affects users of minTTY, where all is actually fine. Using ANSI sequences without performing a SetConsoleMode may result in garbage output. | 09:29:09 |
@mgmeier:matrix.org | The emulation layer of ansi-terminal seems overkill to me; some simplified version of Detect.hs could be acceptable; there is however quite some system-level code involved (Win API calls, safely unwrapping a Handle , ...) | 09:31:27 |
@mgmeier:matrix.org | What's your take on the issue? | 09:32:08 |
Michael Snoyman | Disabling completely based on os(windows) would be unfortunate, but not an automatic no IMO. Yes, it'll hurt minTTY users, but it may be a valid trade-off | 09:35:58 |
Michael Snoyman | The emulation layer does seem like too much to me | 09:36:15 |
Michael Snoyman | Let me look at Detect.hs , that sounds about right | 09:36:23 |
@mgmeier:matrix.org | I'm asking because RIO intends to be lightweight :) so if that means, no colors on windows whilst avoiding quite some extra code for a very special case.... that's a design decision IMO | 09:37:39 |
Michael Snoyman | Alright, so it seems like you'd be modifying logOptionsHandle to try using SetConsoleMode and, if it fails, just turn off color, right? | 09:38:02 |
Michael Snoyman | Yeah, I think you're advocating the right trade-off here | 09:38:14 |
@mgmeier:matrix.org |
- yes and 2) 70% yes
| 09:38:46 |
| Michael Snoyman invited @appservice-irc:matrix.org. | 12:20:23 |
| Michael Snoymanchanged room power levels. | 12:20:25 |
| @appservice-irc:matrix.org joined the room. | 12:20:26 |
| @freenode_snoyberg2:matrix.org joined the room. | 12:21:03 |
| @appservice-irc:matrix.orgchanged room power levels. | 12:21:03 |
| @freenode_snoyberg2:matrix.org left the room. | 12:29:05 |
| @freenode_snoyberg2:matrix.org joined the room. | 13:09:27 |
| @freenode_snoyberg2:matrix.org left the room. | 13:14:47 |
| @freenode_bitemyapp:matrix.org joined the room. | 14:17:36 |
| @bitemyapp:matrix.org joined the room. | 15:48:40 |