Xcode + swift + Darwin.ncurses =“A_BOLD 未找到”编译错误。我买不到鲜艳的颜色

问题描述 投票:0回答:1

我正在 XCode 10.2.1 下创建一个愚蠢的实用程序,使用 swift + ncurses 模板。 编译环境似乎非常容易设置:

1.- 在 main.swift 文件的开头导入一些 Darwin.ncurses

2.- 您开始调用典型的 ncurses 原语(以创建一些“颜色画笔”)

3.- 您将字符串添加到 ncurses 画布中,您的文本就会顺利呈现。

到目前为止一切顺利,但我需要的不仅仅是 Darwin.ncurses 显然提供的 8 种深色。我用谷歌搜索了一下,然后我发现除了我的颜色画笔之外,我还应该将“A_BOLD”属性发送到我的“ncurses attribute manager”™。

好吧,这就是我在打印文本之前所做的,使用此指令的变体:

attron(A_BOLD) 

接下来发生了什么? Xcode(在编译时)抱怨“我不知道什么是 A_BOLD”。

显然所有其他对 ncurses 有疑问的人都抱怨他们的终端无法渲染明亮/粗体的颜色(因为他们的终端通常错误地配置为明亮的颜色)。但我的终端配置正常。 我的问题是在编译时,我完全不知道该做什么,以及如何更改以呈现纯白色字母。

所有其他人似乎都能够使用(显然是标准的)A_BOLD 属性编译他们的 ncurses 代码,为什么我不能?我应该使用不同/更好的 Darwin.ncurses 替代方案吗?

谢谢。

PS:这里我添加了一些代码片段,这样你就可以看到我的代码如何让 Xcode 窒息:

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()    
swift cocoa console-application ncurses curses
1个回答
0
投票

一个不太理想的解决方案是简单地重新定义所有内容,就像这个 SwiftNCurses 包装器所做的那样。

© www.soinside.com 2019 - 2024. All rights reserved.