【问题标题】:problems with old c code with new ncurses version (ldat struct)旧 c 代码与新 ncurses 版本(ldat 结构)的问题
【发布时间】:2012-11-30 08:42:02
【问题描述】:

升级到新服务器后,我遇到了一些使用 curses 的代码问题,因此也遇到了诸如库、标头等新软件的问题。 问题是 ldat 结构字段“firstchar”、“lastchar”和“text”的使用,它们在较新版本的 curses.h 中隐藏在 curses.priv.h 中,因此它们没有得到解决。

我真的可以使用一些指针来解决这些问题。

下面的代码表明了结构字段的使用,但它只是完整代码的一部分,因为它有几千行......

如果需要其他代码,我可以添加。

我还可以补充一点,我没有自己制作这个程序,我只是负责让它与我们的新服务器一起工作......

int
update_window(changed, dw, sw, win_shared)
bool *changed;
WINDOW *dw;         /* Destination window */
window_t *sw;       /* Source window */
bool win_shared;
{
    int y, x;
    int yind, nx, first, last;
    chtype *pd, *ps;    /* pd = pointer destination, ps = pointer source */
    int nscrolls;       /* Number of scrolls to make */


    if(! sw->changed) {
        *changed = FALSE;
        return(0);
    }
    /****************************************
    * Determine number of times window is 
    * scrolled since last update
    ****************************************/
    nscrolls = sw->scrollcount; if(nscrolls >= sw->ny)
    nscrolls = 0;

    sw->scrollcount = 0L;

    dw->_flags = _HASMOVED;
    dw->_cury = sw->cury;
    dw->_curx = sw->curx;

    if(nscrolls > 0) {
        /* Don't copy lines that is scolled away */
        for(y = nscrolls; y < sw->ny; y++) {
            yind = GETYIND(y - nscrolls, sw->toprow, sw->ny);
            if(sw->lastch[yind] != _NOCHANGE) {
                first = dw->_line[y].firstchar = sw->firstch[yind];
                last = dw->_line[y].lastchar = sw->lastch[yind];

                ps = &sw->screen[yind][first];
                pd = (chtype *)&dw->_line[y].text[first];
                nx = last - first + 1;

                LOOPDN(x, nx)
                    d++ = *ps++;

                if(! win_shared) {
                    sw->firstch[yind] = sw->nx;
                    sw->lastch[yind] = _NOCHANGE;
                }
            }
        }
    } else {
        LOOPUP(y, sw->ny) {
            yind = GETYIND(y, sw->toprow, sw->ny);
            if(sw->lastch[yind] != _NOCHANGE) {
                first = dw->_line[y].firstchar = sw->firstch[yind];
                last = dw->_line[y].lastchar = sw->lastch[yind];

                ps = &sw->screen[yind][first];
                pd = (chtype *)&dw->_line[y].text[first];
                nx = last - first + 1;

                LOOPDN(x, nx)
                    *pd++ = *ps++;

                if(! win_shared) {
                    sw->firstch[yind] = sw->nx;
                    sw->lastch[yind] = _NOCHANGE;
                }
            }
        }

        if(! win_shared)
            sw->changed = FALSE;
    }

    *changed = TRUE;
    return(nscrolls);
}

感谢我能得到的所有帮助!

【问题讨论】:

    标签: c ncurses curses


    【解决方案1】:

    struct ldat 的成员在June 2001 中被设为私有。阅读该函数及其对 scrolls 的提及暗示它正在编写一些用于模拟滚动的窗口的一部分(通过向真实窗口写入一组行),并试图绕过 ncurses 逻辑检查更改的行。

    对于这样的函数,唯一的解决方案是确定开发人员试图做什么,然后编写一个新函数来执行此操作 - 使用提供的库函数。

    【讨论】:

      猜你喜欢
      • 2016-12-25
      • 2015-02-15
      • 2016-10-25
      • 2020-10-21
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多