Code Monkey home page Code Monkey logo

concol's Introduction

concol - a library for colourful terminal apps

most modern terminal emulators feature plenty of colors, between 64 - 256. the major hindrance to its usage is that the (n)curses library makes it very difficult to use them. it sees colors as colorpairs which have to be set up one after the other, resulting in a ton of code and work to do so.

concol offers a simple API that allows the programmer to just throw an RGB value at it (either for background or foreground color) and use that at once. the tedious colorpair manipulation is all done automatically by the library.

as a bonus, there are 3 different backends:

  • (n)curses backend (works as well with netbsd curses)
  • SDL backend
  • termbox backend (8 colors only)

the SDL backend is perfect for developing the app as it allows to debug the application without interference between the terminal modes used by GDB and the app itself, which is usually a major pain when developing ncurses apps.

the termbox backend otoh is good to make tiny static linked programs when 8 colors are sufficient, since it is much smaller than (n)curses. (note that termbox development diverged a lot from its original goals after commit 66c3f91b. thus it is advised to use the parent of this commit, or use the fork cursebox ( https://github.com/strake/cursebox.c ) (untested). later termbox version weren't tested as well, so they may not work due to changed API.

see the examples directory for usage of this library.

Compilation

make BACKEND=SDL

or

make BACKEND=SDL2

or

make BACKEND=NCURSES

or

make BACKEND=TERMBOX

if you want to build the example programs, do the same, but use the examples target, e.g.

make BACKEND=NCURSES examples

TODO

it might make sense to start using the colors internally from 256 downwards, as this has the advantage that the original 16 terminal colors never get changed when using less than 240 colors (ncurses backend).

concol's People

Contributors

rofl0r avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

concol's Issues

build broken with gcc 4.8

[    2s] cc  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -Wno-unused -D_GNU_SOURCE -std=c99 -DCONSOLE_BACKEND=NCURSES_CONSOLE -DCONSOLE_FONT=NOFONT   -c -o macgeiger.o macgeiger.c
[    2s] cc  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -Wno-unused -D_GNU_SOURCE -std=c99 -DCONSOLE_BACKEND=NCURSES_CONSOLE -DCONSOLE_FONT=NOFONT   -c -o concol/console.o concol/console.c
[    2s] cc  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -Wno-unused -D_GNU_SOURCE -std=c99 -DCONSOLE_BACKEND=NCURSES_CONSOLE -DCONSOLE_FONT=NOFONT   -c -o concol/ncconsole.o concol/ncconsole.c
[    2s] cc  -fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g -Wall -Wno-unused -D_GNU_SOURCE -std=c99 -DCONSOLE_BACKEND=NCURSES_CONSOLE -DCONSOLE_FONT=NOFONT   -c -o concol/color_reader.o concol/color_reader.c
[    2s] In file included from concol/ncconsole.c:162:0:
[    2s] concol/nearestcolor.c:28:2: error: initializer element is not constant
[    2s]   [TB_BLACK] = RGB3(BLACK),
[    2s]   ^
[    2s] concol/nearestcolor.c:28:2: error: (near initialization for 'defcolors[0]')
[    2s] Makefile:39: recipe for target 'concol/ncconsole.o' failed
[    2s] make: *** [concol/ncconsole.o] Error 1
[    2s] make: *** Waiting for unfinished jobs....
[    2s] macgeiger.c: In function 'process_frame':
[    2s] macgeiger.c:294:10: warning: missing braces around initializer [-Wmissing-braces]
[    2s]    struct wlaninfo temp = {0};
[    2s]           ^
[    2s] macgeiger.c:294:10: warning: (near initialization for 'temp.essid') [-Wmissing-braces]
[    2s] macgeiger.c: In function 'ifdownup':
[    2s] macgeiger.c:712:9: warning: missing braces around initializer [-Wmissing-braces]
[    2s]   struct ifreq ifr = {0};
[    2s]          ^
[    2s] macgeiger.c:712:9: warning: (near initialization for 'ifr.ifr_ifrn') [-Wmissing-braces]
[    2s] macgeiger.c: In function 'getiwmode':
[    2s] macgeiger.c:732:9: warning: missing braces around initializer [-Wmissing-braces]
[    2s]   struct iwreq iwr = {0};
[    2s]          ^
[    2s] macgeiger.c:732:9: warning: (near initialization for 'iwr.ifr_ifrn') [-Wmissing-braces]
[    2s] macgeiger.c: In function 'main':
[    2s] macgeiger.c:777:9: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
[    2s]     write(outfd, "\xD4\xC3\xB2\xA1" "\x02\x00\x04\x00"
[    2s]          ^
[    2s] macgeiger.c: In function 'pcap_next_wrapper':
[    2s] macgeiger.c:198:9: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
[    2s]     write(outfd, &hdr_out, sizeof hdr_out);
[    2s]          ^
[    2s] macgeiger.c:199:9: warning: ignoring return value of 'write', declared with attribute warn_unused_result [-Wunused-result]
[    2s]     write(outfd, ret, h_out->len);
[    2s]          ^
[    2s] macgeiger.c: In function 'main':
[    2s] macgeiger.c:867:43: warning: 'orgmode' may be used uninitialized in this function [-Wmaybe-uninitialized]
[    2s]    if(orgmode != IW_MODE_MONITOR) setiwmode(argv[1], orgmode);
[    2s]                                            ^
[    2s] macgeiger.c:783:11: warning: 'wasdown' may be used uninitialized in this function [-Wmaybe-uninitialized]
[    2s]   int ret, wasdown, orgmode;
[    2s]            ^
[    2s] macgeiger.c:792:18: warning: 'ret' may be used uninitialized in this function [-Wmaybe-uninitialized]
[    2s]    wasdown = (ret == 2);
[    2s]                   ^
[    2s] error: Bad exit status from /var/tmp/rpm-tmp.BCpUbQ (%build)

License?

I'm a bit confused about the licensing conditions for this library. Some files say LGPL 2.1+ with linking exception, but it'd be nice to have that clearly stated.

Error building

make BACKEND=ncurses gives:

cc -fPIC    -DCONSOLE_BACKEND=ncurses_CONSOLE  -c -o console.o console.c
In file included from console.h:4,
                 from console.c:1:
console_sel.h:10:2: error: #error "CONSOLE_BACKEND macro isn't set to one of the possible values!"
   10 | #error "CONSOLE_BACKEND macro isn't set to one of the possible values!"
      |  ^~~~~
make: *** [Makefile:100: console.o] Error 1

This happens for sdl and termbox as well.

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.