ncurses 中的线图

发布于 2024-10-07 12:56:40 字数 369 浏览 0 评论 0原文

我一整天都在尝试在 ncurses 中进行简单的线条绘制(例如框),但我无法让它工作。我正在尝试打印扩展的 ASCII 字符,例如此处找到的字符: http://www.theasciicode.com.ar/ascii-table-codes/ascii-codes-219.html 我已经看到了一些对 wchar_t 的提及,但它显然需要 ncursesw,我不知道如何包含它(我知道它已安装)

我在 OS X 10.6.2 和 GCC 4.2 下使用 XCode。

有什么想法吗?

I've been trying to do simple line drawing (e.g. boxes) in ncurses all day, but I can't get it to work. I'm trying to print extended ASCII characters like the ones found here: http://www.theasciicode.com.ar/ascii-table-codes/ascii-codes-219.html
I've seen a few mentions to wchar_t, but it apparently requires ncursesw, which I can't figure out how to include (I know it's installed)

I'm using XCode under OS X 10.6.2 and GCC 4.2.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丑疤怪 2024-10-14 12:56:40

你不需要 wchar_t。 “扩展”代码(约 1985 年)小于 255。例如,要绘制双线框的左下角,请使用代码 200 十进制、310 八进制(“\310”)或 0xc8(“\xc8”) ”)。

这些字符需要您正在使用的终端模拟器的支持,但它应该可以正常工作。


编辑
我对旧的 Curses 的 7 位与 8 位模式有一个模糊的记忆,但我在 FSF ncurses 1.190 (2008/12/20) 中找不到任何提及,也被标识为 v5.7.3.20090207我在 Linux 上有。 curs_addch 的手册页 提到了画线字符的符号常量,因此也许您应该使用这些字符而不是文字线条画字符:

addch (ACS_ULCORNER);   // upper left corner
for (int j = 0;  j < boxwidth-2;  ++j)
    addch (ACS_HLINE);
addch (ACS_URCORNER);   // upper right
...

You don't need wchar_t. The "extended" codes (c. 1985) are less than 255. For example, to draw the left lower corner of a double-lined box, use code 200 decimal, 310 octal ("\310") or 0xc8 ("\xc8").

Those characters need support from the terminal emulator you are using, but it should work fine.


edit
I have a vague memory of a 7-bit vs. 8-bit mode for old curses, but I cannot find any mention of it in the FSF ncurses 1.190 (2008/12/20), also identified as v5.7.3.20090207 which I have on Linux. The man page for curs_addch mentions symbolic constants for line drawing characters, so perhaps you are expected to use those instead of literal line drawing characters:

addch (ACS_ULCORNER);   // upper left corner
for (int j = 0;  j < boxwidth-2;  ++j)
    addch (ACS_HLINE);
addch (ACS_URCORNER);   // upper right
...
找个人就嫁了吧 2024-10-14 12:56:40
void boxAround( int y, int x, int h, int w ) {
    move( y, x );
    addch (ACS_ULCORNER);   // upper left corner
    int j;
    for (j = 0;  j < w;  ++j)
        addch (ACS_HLINE);
    addch (ACS_URCORNER);   // upper right

    for( j = 0; j < h; ++j ) {
            move(  y+1+j, x );
            addch (ACS_VLINE);
            move( y+1+j, x+w+1 );
            addch (ACS_VLINE);
    }

    move( y+h+1,x );
    addch (ACS_LLCORNER);   // lower left corner

    for (j = 0;  j < w;  ++j)
        addch (ACS_HLINE);
    addch (ACS_LRCORNER);   // lower right
}
void boxAround( int y, int x, int h, int w ) {
    move( y, x );
    addch (ACS_ULCORNER);   // upper left corner
    int j;
    for (j = 0;  j < w;  ++j)
        addch (ACS_HLINE);
    addch (ACS_URCORNER);   // upper right

    for( j = 0; j < h; ++j ) {
            move(  y+1+j, x );
            addch (ACS_VLINE);
            move( y+1+j, x+w+1 );
            addch (ACS_VLINE);
    }

    move( y+h+1,x );
    addch (ACS_LLCORNER);   // lower left corner

    for (j = 0;  j < w;  ++j)
        addch (ACS_HLINE);
    addch (ACS_LRCORNER);   // lower right
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文