Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

charms/ll:has_colors is charms/ll:FALSE on a truecolor terminal #64

Open
ArnaudValette opened this issue Oct 12, 2023 · 2 comments
Open

Comments

@ArnaudValette
Copy link

When I use <curses.h> in a C program, has_colors() is true.
When following along the charms crash course linked in the README,
charms/ll:has_colors is charms/ll:FALSE on my terminal (kitty).

Removing the test indeed lead to a situation in which the code written in the article doesn't display any color.

@vindarel
Copy link

vindarel commented Dec 14, 2023

I can reproduce with this code: https://stackoverflow.com/questions/77614661/getting-your-terminal-does-not-support-color-error-in-common-lisp-cl-charms

There's a preliminary check:

(defun start-color ()
  (when (eql (charms/ll:has-colors) charms/ll:FALSE)
     (error "Your terminal does not support color."))
  (let ((ret-code (charms/ll:start-color)))
    (if (= ret-code 0)
        T
         (error "start-color error ~s." ret-code))))

which errors out. If I replace its call in the main function by charms/ll:start-color, I can see a grey rectangle window, but no "hello world" message.

libncurses5 v6.2, SBCL 2.1.5, cl-charms from quicklisp "2023-02-15".

@Dotrar
Copy link

Dotrar commented Jul 14, 2024

I also had this issue, (following the same tutorial as all you) -- I had a look at what the LEM project is doing, and their code works fine.

define-color-pair is actually a ncurses call, which you must call from within a ncurses form.

(defmacro define-color-pair ((name pair) foreground background)
  `(progn
     (start-color)
     (defparameter ,name (progn (charms/ll:init-pair ,pair ,foreground ,background)
                                (charms/ll:color-pair ,pair)))))

Move the define-color-pair into the charms:with-curses form like this:

(defun main ()
  (charms:with-curses ()
    (charms:disable-echoing)
    (charms:enable-raw-input :interpret-control-characters t)
    (charms:enable-non-blocking-mode charms:*standard-window*)
; here is where i define my color pairs
    (define-color-pair (+white/blue+ 1) +white+ +blue+)
    (define-color-pair (+black/red+ 2) +black+ +red+)
    (define-color-pair (+green/black+ 3) +green+ +black+)
    (loop :named driver-loop
          ....other forms)))

Then I get the expected output, no error.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants