📄 show.c
字号:
pTempWindow->nTextAttrs(nRow) = nAttrs;
sSrcStr += length;
if ( nCurrentRow>=nStartRow+pTempWindow->nMaxTotalRow )
{
nStartRow = nCurrentRow-pTempWindow->nMaxTotalRow+1;
if ( nStartRow>=pTempWindow->nMaxTotalRow )
{
nStartRow -= pTempWindow->nMaxTotalRow;
nCurrentRow -= pTempWindow->nMaxTotalRow;
}
}
if ( nCurrentRow+1==pTempWindow->nMaxTotalRow )
sDstStr = pTempWindow->sWinContent;
else
sDstStr += 80;
}
if ( nCurrentRow>=pTempWindow->nMaxTotalRow )
pTempWindow->nCurrentRow = nCurrentRow-pTempWindow->nMaxTotalRow;
else
pTempWindow->nCurrentRow = nCurrentRow;
/* Add % in Jul 22, 1998 */
pTempWindow->nStartRow = nStartRow % pTempWindow->nMaxTotalRow;
if ( pTempWindow->nCurrentRow>=pTempWindow->nStartRow+pTempWindow->nSubWinMaxRow )
pTempWindow->nCurWinFirstRow = pTempWindow->nCurrentRow
- pTempWindow->nSubWinMaxRow + 1;
else if ( pTempWindow->nCurrentRow>=pTempWindow->nStartRow )
pTempWindow->nCurWinFirstRow = pTempWindow->nStartRow;
else if ( pTempWindow->nCurrentRow>=0 )
{
pTempWindow->nCurWinFirstRow = pTempWindow->nCurrentRow
- pTempWindow->nSubWinMaxRow + 1;
if ( pTempWindow->nCurWinFirstRow<0 )
pTempWindow->nCurWinFirstRow += pTempWindow->nMaxTotalRow;
}
} /* end showAttrMessage() */
/**************************************************************
* Name: displayAttrMessage(int nWindowNo, short nAttrs, *
* char *spErrMsg); *
* Description: Display the new message in window. *
* Inputs: int nWindowNo . the window for display. *
* short nAttrs, . the show attributes. *
* char *sMessage . the messages. *
* Output: the specified messages to window. *
* Return: 0 if success, -1 if fail. *
* Cautions: none. *
**************************************************************/
#define MaxMessLen 1024
int displayAttrMessage( int nWindowNo, short nAttrs, char *sMessage )
{
char sTmpBuff[MaxMessLen];
ShowWindow *pTempWindow;
char *sNextStr, *sShowErr;
if( strlen(sMessage) >= MaxMessLen )
strncpy( sTmpBuff, sMessage, MaxMessLen-1 );
else
strcpy( sTmpBuff, sMessage );
if ( g_nHaveInCurses!=1 || sMessage==NULL )
return (-1);
if ( nWindowNo > MaxWindowNum )
return (-1);
else if ( nWindowNo == -1 )
pTempWindow = g_pErrMsgWindow;
else if ( nWindowNo == -2 )
pTempWindow = g_pPromptWindow;
else if ( nWindowNo < 0 )
return (-1);
else
pTempWindow = g_apWindow[nWindowNo];
if ( pTempWindow == NULL )
return (-1);
if ( pTempWindow->nWinType==UnknownWin )
pTempWindow->nWinType = PureTextWin;
else if ( pTempWindow->nWinType!=PureTextWin )
return (-1);
sNextStr = sTmpBuff;
while ( 1 )
{
sShowErr = sNextStr;
sNextStr = strchr( sShowErr, '\n' );
if ( sNextStr!=NULL )
{
*sNextStr = '\0';
}
showAttrMessage( pTempWindow, nAttrs, sShowErr );
if ( sNextStr==NULL )
break;
if ( sNextStr!=NULL )
{
*sNextStr = '\n';
sNextStr++;
}
if ( strlen( sNextStr ) <= 0 )
break;
}
if ( g_nShowImmediate==1 && g_pCurWindow==pTempWindow )
displayShowWindow( pTempWindow );
return 0;
} /* end displayAttrMessage() */
/**************************************************************
* Name: displayAttrWindowTitle(int nWindowNo, *
* short nAttrs, char *strTitle); *
* Description: display title in ShowWindow. *
* Inputs: int nWindowNo . the window number for display. *
* short nAttrs, . the show attributes. *
* char *strTitle . the title contents. *
* Output: none. *
* Return: 0 for success, -1 for fail. *
* Cautions: none. *
**************************************************************/
int displayAttrWindowTitle( int nWindowNo, short nAttrs, char *strTitle )
{
ShowWindow *tempWindow;
int length,i,j;
if ( nWindowNo>=0 && nWindowNo<MaxWindowNum )
tempWindow = g_apWindow[nWindowNo];
else if ( nWindowNo == -1 )
tempWindow = g_pErrMsgWindow;
#ifdef EnterHand
else if ( nWindowNo == -2 )
tempWindow = g_pPromptWindow;
#endif
else
return (-1);
if ( tempWindow==NULL )
return (-1);
length = strlen( strTitle );
if ( length > tempWindow->nSubWinMaxCol ) {
length = tempWindow->nSubWinMaxCol;
j = 0;
for ( i=length-1; i>=0&&(strTitle[i]<0||strTitle[i]>=128); i-- )
j++;
length -= j%2;
strTitle[length] = '\0';
}
if ( g_nHaveInColors==1 && nAttrs!=0 )
wattrset( tempWindow->pWin, COLOR_PAIR(nAttrs) );
else
wstandout( tempWindow->pWin );
mvwaddstr( tempWindow->pWin,0,
( tempWindow->nSubWinMaxCol - length ) / 2, strTitle );
if ( g_nHaveInColors==1 && nAttrs!=0 )
wattrset( tempWindow->pWin, COLOR_PAIR(0) );
else
wstandend( tempWindow->pWin );
if ( g_pCurMainWindow==tempWindow || g_pCurWindow == tempWindow )
wrefresh( tempWindow->pWin );
return 0;
} /* end displayAttrWindowTitle() */
/**************************************************************
* Name: displayInformRand(ShowWindow *tempWindow, *
* int nRow, int nCol, char *sInform *
* Description: display information to the special window *
* directly by random *
* Inputs: ShowWindow *tempWindow . the window for display. *
* int nRow . the display row. *
* int nCol . the display col. *
* char *sInform . the display information. *
* Output: none. *
* Return: none. *
* Cautions: none. *
**************************************************************/
void displayInformRand( ShowWindow *tempWindow,
int nRow, int nCol, char *sInform )
{
int length, lines, i;
char tmpstr[100], *sSrcStr;
if ( g_nHaveInCurses!=1 || tempWindow == NULL )
return ;
length = strlen( sInform );
if ( nCol<0 )
nCol = 0;
else if ( nCol>=tempWindow->nSubWinMaxCol )
nCol = tempWindow->nSubWinMaxCol-1;
lines = ( length+nCol+1 ) / tempWindow->nSubWinMaxCol;
if ( nRow<0 )
nRow = 0;
else if ( nRow >= tempWindow->nSubWinMaxRow - lines )
nRow = tempWindow->nSubWinMaxRow-1-lines;
sSrcStr = sInform;
for (i=0; i<lines; i++) {
length = getoutString( tmpstr, sSrcStr, nCol,
tempWindow->nSubWinMaxCol, 1 );
mvwaddstr( tempWindow->sWin, nRow+i, nCol, tmpstr );
if ( length < tempWindow->nSubWinMaxCol - 2 )
break;
sSrcStr += length;
nCol = 0;
}
wrefresh( tempWindow->sWin );
} /* displayInformRand() */
/**************************************************************
* Name: displayFlag(); *
* Description: display the running sign. *
* Inputs: none. *
* Output: none. *
* Return: none. *
* Cautions: none. *
**************************************************************/
void displayFlag( void )
{
char *sSignArr = "-\\|/", sRunSign[2];
static int nCurs = 4;
if ( g_nHaveInCurses!=1 || g_pCurMainWindow==NULL )
return ;
if ( nCurs>3 )
nCurs = 0;
sRunSign[0] = sSignArr[nCurs++];
sRunSign[1] = '\0';
displayInformRand( g_pCurMainWindow, 0, 80, sRunSign );
wmove( g_pCurMainWindow->sWin, 0,
g_pCurMainWindow->nSubWinMaxCol-1 );
wrefresh( g_pCurMainWindow->sWin );
} /* end displayFlag() */
/**************************************************************
* Name: displayStringFlag(char *sRunSign); *
* Description: display the running sign specified by sRunSign*
* Inputs: char *sRunSign . the sign of running. *
* Output: none. *
* Return: none. *
* Cautions: none. *
**************************************************************/
void displayStringFlag( char *sRunSign )
{
int nLength;
char sShowSign[56];
if ( g_nHaveInCurses!=1 || g_pCurMainWindow==NULL )
return ;
nLength = strlen( sRunSign );
if ( nLength > g_pCurMainWindow->nSubWinMaxCol / 2 )
nLength = g_pCurMainWindow->nSubWinMaxCol / 2;
strncpy( sShowSign, sRunSign, nLength );
sShowSign[nLength] = '\0';
mvwaddstr( g_pCurMainWindow->pWin,
0, g_pCurMainWindow->nSubWinMaxCol - nLength,
sShowSign );
wmove( g_pCurMainWindow->pWin, 0,
g_pCurMainWindow->nSubWinMaxCol-1 );
wrefresh( g_pCurMainWindow->pWin );
} /* end displayStringFlag() */
/**************************************************************
* Name: getCharNoDelay(); *
* Description: get a key pressed from current window. *
* If timeout before get a key pressed, return -1*
* The waiting time is set by half_delay(). *
* Inputs: none. *
* Output: none. *
* Return: the key gotten. *
* -1 if timeout. *
* Cautions: none. *
**************************************************************/
int getCharNoDelay( void )
{
int i, retval;
WINDOW *tWin;
if ( g_pCurWindow == NULL )
return -1;
tWin = g_pCurWindow->sWin;
if (tWin == NULL)
return -1;
i = wgetch( tWin );
if ( i==27 ) {
i = wgetch( tWin );
if ( i==ERR )
retval = 27;
else if ( i==91 ) {
i = wgetch( tWin );
if ( i>=65 && i<=73 )
retval = 0x0400+i;
else
retval = ERR;
} else
retval = ERR;
} else
retval = i;
return retval;
} /* end getCharNoDelay() */
/**************************************************************
* Name: getCharDelay(); *
* Description: get a key pressed from current window. *
* If timeout before get a key pressed, return -1*
* The waiting time is set by half_delay(). *
* Inputs: none. *
* Output: none. *
* Return: the key gotten. *
* -1 if timeout. *
* Cautions: none. *
**************************************************************/
int getCharDelay( void )
{
int i, retval;
WINDOW *tWin;
if ( g_pCurWindow == NULL )
return -1;
tWin = g_pCurWindow->sWin;
nodelay( tWin, FALSE );
i = wgetch( tWin );
if ( i==27 ) {
i = wgetch( tWin );
if ( i==ERR )
retval = 27;
else if ( i==91 ) {
i = wgetch( tWin );
if ( i>=65 && i<=73 )
retval = 0x0400+i;
else
retval = ERR;
} else
retval = ERR;
} else
retval = i;
nodelay( tWin, TRUE );
return retval;
} /* end getCharDelay() */
/**************************************************************
* Name: displayAttrOneProcInfo(int nWindowNo, *
* int nSerno, short nIdAttrs, short nStsAttrs, *
* char *sTitle, char *sContents); *
* Description: display one information in specified window. *
* Inputs: int nWindowNo . window number of display. *
* int nSerno . serial number of contents. *
* short nIdAttrs, nStsAttrs . the show attributes. *
* char *sTitle . title contents. *
* char *sContents . status contents. *
* Output: none. *
* Return: 0 for success, -1 for fail. *
* Cautions: none. *
**************************************************************/
int displayAttrOneProcInfo( int nWindowNo, int nSerno, short nIdAttrs,
short nStsAttrs, char *sTitle, char *sContents )
{
ShowWindow *tempWindow;
if ( g_nHaveInCurses!=1 || nWindowNo<0 || nWindowNo>=MaxWindowNum )
return (-1);
if ( ( tempWindow = g_apWindow[nWindowNo] ) == NULL )
return (-2);
if ( nSerno >= ( tempWindow->nMaxTotalRow / LinesPerItem )
* NumberPerLine )
return (-3);
if ( tempWindow->nWinType==UnknownWin )
tempWindow->nWinType = SingleItemWin;
else if ( tempWindow->nWinType==PureTextWin )
return (-4);
else if ( tempWindow->nWinType!=SingleItemWin )
return (-5);
showAttrOneProcInfo( tempWindow, nSerno, nIdAttrs, nStsAttrs, sTitle, sContents );
if ( g_nShowImmediate==1 && g_pCurWindow==tempWindow )
{
displayShowWindow( tempWindow );
}
return 0;
} /* end displayAttrOneProcInfo() */
/**************************************************************
* Name: pageupWindow(); *
* Description: let current window pageup. *
* Inouts: none. *
* Output: none. *
* Return: none. *
* Cautions: none. *
**************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -