gpt4 book ai didi

c - 旧 C 代码与新 ncurses 版本(ldat 结构)的问题

转载 作者:太空宇宙 更新时间:2023-11-04 04:52:38 24 4
gpt4 key购买 nike

我在升级到新服务器后使用 curses 的一些代码有问题,因此也有新软件,如 libs、headers 等。问题是 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);
}

我很感激能得到的所有帮助!

最佳答案

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

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

关于c - 旧 C 代码与新 ncurses 版本(ldat 结构)的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13641631/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com