2012-11-30 37 views
1

問題我升級到一個新的服務器,因此也有新的軟件,如庫,標題等,使用curses一些代碼的問題。 問題是使用l​​dat結構字段「firstchar」,「lastchar」和「text」,它們在curses.h的較新版本中隱藏在curses.priv.h中,因此它們未被解析。與舊的C代碼與新的ncurses版本(ldat結構)

我真的可以使用一些指針來說明我可以如何解決這些問題。

下面的代碼表示使用該結構域,但它只是一個完整的代碼,因爲它幾千行的一部分......

如果有需要額外的代碼,我可以添加此。

我還要補充一點,我還沒有做出這個節目我自己,我只是爲了使它與我們的新的服務器工作負責......

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); 
} 

我感謝所有幫助我能!

回答

0

struct ldat的成員在June 2001中被設爲私人。讀取函數及其提及滾動提示它正在編寫用於模仿滾動的某個窗口的一部分(通過將一組行寫入實際窗口),並嘗試繞過檢查已更改行的ncurses邏輯。

對於這樣的函數,唯一的解決方案是確定開發人員試圖做什麼,然後編寫一個新函數,它使用所提供的庫函數執行此操作。