簡體   English   中英

使用 termcaps 刪除 output

[英]Deleting output with termcaps

我正在嘗試將字符從 cursor 刪除到行尾,問題是當我打印一個新行('\n')之后,刪除的字符重新出現,我還嘗試在新字符之前打印一個 null 字符行,它也一樣。 最小代碼:

#include <ncurses.h>
#include <term.h>
#include <unistd.h>
#include <stdlib.h>

int ft_putchar(int ch)
{
    char c = (char)ch;
    return (write(1, &c, 1));
}

int main(void)
{
    tgetent(getenv("TERM"), NULL);
    char * LE = tgetstr("LE", NULL); // termcap for cursor left
    char * kL = tgetstr("kL", NULL); // termcap for cursor right

    write(1, "Hello World", 11);
    tputs(tparm(LE, 5), 1, ft_putchar); // move the cursor 5 cases left
    tputs(kL, 1, ft_putchar); // delete to end of line
    write(1, "\n", 1);
    return (0);
}

Output: Hello World

並且沒有最后一次write(1, "\n", 1)

Output: Hello

我花了幾個小時才發現是新線路造成的,現在我不知道該怎么做。

而且我還嘗試了write(1, "\0\n", 2)並且它也是如此。

關於如何避免這種情況的任何線索?

查看 ce termcap 條目,這意味着從 cursor 到行尾清除。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM