Coder Social home page Coder Social logo

terminal-color's Introduction

terminal-color

A Racket library to output colored text to the terminal on any platform, including Windows.

NOTE: This library is currently in development so things may change before v1.0 is released. The current version should be usable on all platforms with Racket 5.3.6 and 6.x series. Compatability will try to be kept for existing users.

Documentation

A rendered version of the documentation for this library is available via Github Pages:

Example

In short this library provides corresponding procedures for the standard display, displayln, print and write procedures, allowing you to write things like

(require terminal-color)

(displayln-color "1: Default colors")
(displayln-color "2: Green" #:fg 'green)
(displayln-color "3: White on red" #:fg 'white #:bg 'red)

Requirements

It should be possible to install this package as normal using raco on both Racket 5.3.6 and 6.x.

terminal-color's People

Contributors

hopkinsr avatar takikawa avatar

Stargazers

ᴍᴜǫɪᴜ ʜᴀɴ (韩暮秋) avatar Jeff avatar Brendan McGloin avatar  avatar Lîm Tsú-thuàn avatar Yanying Wang avatar  avatar Jimmy Ruska avatar Hady Mahmoud avatar Brian Clements avatar Daniel Lewan avatar Lehi Toskin avatar Adolfo Pérez Álvarez avatar  avatar Ha-Duong Nguyen avatar Edward Earnest avatar  avatar Christoffer Sawicki avatar

Watchers

James Cloos avatar  avatar

Forkers

takikawa matijasi

terminal-color's Issues

Issues in combination with charterm

Obviously not a bug per se. More a plea for help from someone who understands terminal internals.

I'm on Ubuntu 14.04 (gnome-terminal; TERM=xterm). I'm trying to use http://www.neilvandyke.org/racket-charterm to move the cursor around, etc. and terminal-color to print in color after moving around. It seems to work just enough to keep me interested. For example (after requireing charterm and terminal-color):

(open-charterm)
(charterm-clear-screen)
(charterm-cursor 5 5)
(displayln-color "Hello" #:fg 'green)  ; works
(close-charterm)

This works great. The screen shows "Hello" at 5,5 on the screen. However, replacing the displayln-color with display-color causes the text to appear at row 5, col 1. Using charterm-newline or charterm-clear-line sometimes gives me the sense that display doesn't immediately update the screen. Do you have any idea what might be going on? Is combining these two libraries just a bad idea because of incompatible internals or something? Thanks.

True Color Syntax

I like this library. One thing I would add as a feature request is a syntax for 24-bit "true color" support. In recent years they've made a standard for specifying 24-bit color for terminals and most terminal emulators support it. Here is an old gist that explains what ones support it so far:

https://gist.github.com/XVilka/8346728

You could have the interface be something like this (maybe accepting the strings with or without the leading # sign):

(displayln-color "Purple on orange" #:fg "#9C0874" #:bg "#F09C26")

The sequences to get 24-bit color are:

\e[38;2;R;G;Bm

Where R, G, and B range from 0 to 255. Replace 38 with 48 for background.

This is pretty well supported currently for Unix terminal emulators (including OSX), and I expect it to gradually take off as the norm for most console applications that want to deal with more than 8 colors. Windows may never support such a thing, but I think it's worth having for those who program for Unix.

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.