Xcode + swift + Darwin.ncurses = “A_BOLD not found” compilation error. I can't get bright colors

若如初见. 提交于 2019-12-11 15:23:41

问题


I'm creating a silly utility under XCode 10.2.1, with a swift + ncurses template. The compilation environment seems amazingly easy to setup:

1.- You import some Darwin.ncurses at the beginning of your main.swift file

2.- You start to invoke the typical ncurses primitives (to create some "color brushes")

3.- You addstrings to the ncurses canvas and your text appears happily rendered.

So far so good, but I need something more than the 8 dark colors my Darwin.ncurses apparently gives. I googled a bit and then I discovered I should emit the "A_BOLD" attribute to my "ncurses attribute manager"™ besides my color brush.

Ok then, that's what I did right before printing my texts, using variations of this instruction:

attron(A_BOLD) 

What happened next? Xcode complains (at compilation time) with a "I have no idea what's an A_BOLD".

Apparently all other people with doubts about ncurses complain about their terminals not being able to render bright/bold colors (as their terminals are normally configured wrongly for bright colors). But my terminal IS configured ok. My problem is at compilation time and I have not the slightest idea about what to do, and what to change to render pure white letters.

All other people seem to be able to compile their ncurses code using the (apparently standard) A_BOLD attribute, why can't I? Is there a different/better Darwin.ncurses alternative which I should use instead?

Thanks.

PS: Here I've added some code snippet so you can see how my code makes Xcode choke:

import Foundation
import Darwin.ncurses

initscr()
start_color()
noecho()    // Turn on noecho, though it doesn't matter in this example
curs_set(1) // 0 is invisible, 1 is visible, 2 is very visible

init_pair(1, Int16(COLOR_WHITE), Int16(COLOR_BLUE) )
init_pair(2, Int16(COLOR_WHITE), Int16(COLOR_GREEN) )


move(0, 0)    
attron(COLOR_PAIR(1))
addstr("text 1")
attroff(COLOR_PAIR(1))
// nice text appears on screen (with dark dull color palette)

move(2, 0)
attron(COLOR_PAIR(2))
addstr("text 2")
attroff(COLOR_PAIR(2))
// nice text appears below (with dark dull color palette also)

attron(A_BOLD)  //  <-- THIS line is the one complaining
addstr("text 3")
attroff(A_BOLD) //  <-- THIS line is also complaining

attron(COLOR_PAIR(2)|A_BOLD)  //  <-- THIS line is also complaining
addstr("text 4")
attroff(COLOR_PAIR(2)|A_BOLD) //  <-- THIS line is also complaining

refresh()    

来源:https://stackoverflow.com/questions/56260059/xcode-swift-darwin-ncurses-a-bold-not-found-compilation-error-i-cant-g

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!