Giter Club home page Giter Club logo

Comments (14)

haikalpribadi avatar haikalpribadi commented on May 23, 2024 1

I think this is of higher priority, @jmsfltchr @lolski. This affects the user experience at the first point of entry. @vmax can you take this on?

from typedb-console.

lolski avatar lolski commented on May 23, 2024

My suspicion is that Windows have their own colour code characters.

from typedb-console.

vmax avatar vmax commented on May 23, 2024

@jmsfltchr @haikalpribadi @lolski I did a few tests on Windows and can confirm it's indeed an issue if you use CMD or PowerShell

Cmd
PowerShell

However, there's a simple workaround that our users could do: use modern Windows Terminal!

WindowsTerminal

To ease the pain of those who don't use it, I suggest we add an argument to Console binary named --nocolor (or --color=no), which, as name suggests, would skip printing the escape codes.

from typedb-console.

haikalpribadi avatar haikalpribadi commented on May 23, 2024

Can we detect the terminal at bootup of the console application and configure the colour options, @vmax ? Having to manually add the argument by the user feels clunky and not elegant.

from typedb-console.

vmax avatar vmax commented on May 23, 2024

@haikalpribadi @lolski I verified it's possible to know if we're running under Windows Terminal by checking WT_SESSION presence of environment variable, ref. Therefore the heuristic for determining if we want to show colors would be:

if OS == Windows:
    if environment variable WT_SESSION is present:
        show colors
    else
        show colors
else:
    show colors

from typedb-console.

haikalpribadi avatar haikalpribadi commented on May 23, 2024

Where should you implement this heuristic, @vmax ? Do you know how to implement it?

from typedb-console.

vmax avatar vmax commented on May 23, 2024

@haikalpribadi os detection would probably go into @graknlabs_common; logic on enabling/disabling colors goes into Console. Yup, I'll implement this one.

from typedb-console.

haikalpribadi avatar haikalpribadi commented on May 23, 2024

I think it would be better if we can identify the OS in Java, and then configure the default colour setting also in Java, @vmax. I think that would be much cleaner. Is that possible?

from typedb-console.

vmax avatar vmax commented on May 23, 2024

@haikalpribadi all of the logic would be in Java, no doubt - it's just which Java package to put it one. Sorry I wasn't clear on this one; when I said @graknlabs_common I in fact meant https://github.com/graknlabs/common/tree/master/util (not grakn or grakn.bat scripts)

from typedb-console.

haikalpribadi avatar haikalpribadi commented on May 23, 2024

Ah okay. Good. Let's do the logic in Java. Put the class in grakn.common.util.. Use the library in Console to determine if it should output colour.

from typedb-console.

alexjpwalker avatar alexjpwalker commented on May 23, 2024

Detecting if a user's terminal supports colours is actually pretty involved. Here's one (NodeJS based) tool designed to perform such detection: https://github.com/chalk/supports-color

from typedb-console.

haikalpribadi avatar haikalpribadi commented on May 23, 2024

well, I think we can just detect the OS like how max suggests above, right, @alexjpwalker ?

from typedb-console.

alexjpwalker avatar alexjpwalker commented on May 23, 2024

It's not an OS-specific issue, but a terminal-specific one. The terminal I use most often when developing in Windows is the terminal built into Visual Studio Code, which does support colours - including on Windows.

So the most correct solution here is terminal detection, which - granted - is a little more involved than OS detection, @haikalpribadi

from typedb-console.

vmax avatar vmax commented on May 23, 2024

@haikalpribadi we went for a better and easier solution which just allows to print colors on Windows.

from typedb-console.

Related Issues (20)

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.