Git Product home page Git Product logo

Comments (3)

LunarWatcher avatar LunarWatcher commented on June 27, 2024

Blocked by #14

from taskranger.

LunarWatcher avatar LunarWatcher commented on June 27, 2024

This turned into a rabbit hole reeeeeally fast. I noticed ANSI isn't stripped when I pipe stuff into files, which means I end up with files containing ANSI. That might not be the biggest problem ever per se, but it's kinda sorta pointless and easily fixable with one check.

So the takeaway from this mess is:

  1. SetConsoleMode fails (WOOHOO!) if ANSI isn't supported. This happens at runtime, and it happens controlled.
  2. Detecting terminals is a mess
  3. We need to make assumptions

One of said assumptions is that anyone with access to a C++17 compiler also has access to a half-decent ANSI-supported terminal. Feel free to prove me wrong with a PR disabling ANSI for whatever terminal that could be.

The second assumption is that the first assumption applies if /dev/null (yes, really) exists. MinGW and Cygwin both come with this, Linux and Mac does too. This means that, at runtime, we have a roughly accurate measure on Windows to determine Bash from cmd/powershell.

SetConsoleWhateverISaid failing also means we have an accurate way to tell whether cmd ansi is supported or not. Windows being extremely uniform fortunately makes testing there easy; Mac, Linux, and UNIXes are more complicated in terms of terminal support, because there's so many more terminals.

Of course, there's a chance some of these assumptions are wrong, in which case, that needs to be addressed. The main difference between individual cases and what I'm doing now is that I'll actually have something to reference. "Look at everything" is not a good starting point, so there's no other good alternatives

That being said, there's also a chance this doesn't work if mingw/cygwin doesn't support Windows' _isatty function, so that's fun. I don't run Windows, nor do I have a chance of checking this, soooooo yeah.

from taskranger.

LunarWatcher avatar LunarWatcher commented on June 27, 2024

Gonna close this for now and assume it's hacked together good enough. Will rather deal with other ANSI issues on Windows and other systems when they become a problem

from taskranger.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.