📄 engine.c
字号:
/*
* Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
* All rights reserved.
*
* This software is copyrighted by and is the sole property of
* VIA Networking Technologies, Inc. This software may only be used
* in accordance with the corresponding license agreement. Any unauthorized
* use, duplication, transmission, distribution, or disclosure of this
* software is expressly forbidden.
*
* This software is provided by VIA Networking Technologies, Inc. "as is"
* and any express or implied warranties, including, but not limited to, the
* implied warranties of merchantability and fitness for a particular purpose
* are disclaimed. In no event shall VIA Networking Technologies, Inc.
* be liable for any direct, indirect, incidental, special, exemplary, or
* consequential damages.
*
*
* File: engine.c
*
* Purpose: UI engine main body
*
* Author: Jenda Jao
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#include "str.h"
#include "ttyio.h"
#include "allpages.h"
#include "engine.h"
#include "eng_io.h"
#include "eng_move.h"
#include "eng_act.h"
#if !defined(__BITOP_H__)
#include "bitop.h"
#endif
#ifdef __MODULE_DEBUG_MENU
#include "dbgmenu.h"
#endif
/*--------------------- Export Variables --------------------------*/
BYTE g_byRootPageID;
BYTE g_byCurPageID;
BYTE g_byTotalLineNum;
BYTE g_byCurLineID;
BYTE g_byCurItemID;
BOOL g_bDataDirty;
BYTE g_byCurKey;
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Functions --------------------------*/
void ENGvEnterPage(void) DIRECT_FUNTYPE_REENT
{
g_byCurPageID = g_byRootPageID;
while (g_byCurPageID != PAGE_LOGIN)
{
g_byTotalLineNum = 0;
// The returned main menu page is always PAGE_MAIN_MENU, defined in g_abyPreviousPageID,
// but the root page may be PAGE_MAIN_MENU or PAGE_MAIN_MENU_NOLOGOUT
if (g_byCurPageID == PAGE_MAIN_MENU)
g_byCurPageID = g_byRootPageID;
if (g_pSCurPage->bLoadPage)
if (g_pSCurPage->bLoadPage())
continue;
//// if item page
if (g_pSCurPage->byActItemNum)
{
g_bDataDirty = FALSE;
g_byCurLineID = 0; // g_byCurLineID should be zero before print page
ENGvPrintPage();
ENGvRunActionBar();
} // end if item page
//// menu page (ITEM_MENU_PAGESEL)
else
{
g_byCurLineID = g_byCurItemID = 0;
ENGvPrintPage();
ENGvItemSelect();
if (g_byCurPageID == PAGE_LOGIN) // for disconnection (auto logout)
return;
if (g_byCurKey == KEY_ESC) // goto previous page
g_byCurPageID = g_abyPreviousPageID[g_byCurPageID];
else // goto selected page
g_byCurPageID = ((SItemPageSel*)(g_SCurItem.pvItem))->byPageID;
} // end if menu page
} // end while
}
// select a var item, return the array index of aSVarItem
void ENGvItemSelect(void) DIRECT_FUNTYPE_REENT
{
BOOL bRtnKey = FALSE;
g_byCurKey = 1; // print the first item at first time
// To generate msg bar
ENGvClearMsgBar();
while(1)
{
if (g_byCurKey)
ENGvPrintItem(g_byCurLineID, g_byCurItemID, PRINT_ITEM_HIGHLIGHT);
if (bRtnKey)
bRtnKey = FALSE;
else
g_byCurKey = TTYcGetChar();
// for auto-logout
if (g_byCurKey == KEY_DISCONNECT)
{
g_byCurPageID = PAGE_LOGIN;
return;
}
#ifdef __MODULE_DEBUG_MENU
else if (g_byCurKey == '_')
{
DBGvMainMenu();
ENGvPrintPage();
}
#endif
// move item
else if ( (KEY_ARROW_UP <= g_byCurKey && g_byCurKey <= KEY_ARROW_LEFT) ||
(g_byCurKey == KEY_TAB) || (g_byCurKey == KEY_BKSPC) )
{
ENGvPrintItem(g_byCurLineID, g_byCurItemID, PRINT_ITEM_NORMAL);
ENGvMoveItem();
}
// for listbox only
else if ((g_byCurKey == KEY_SPACE)&&(g_SCurItem.f4DataType == ITEM_LISTBOX))
{
SItemListbox* pSIListbox = (SItemListbox*)(g_SCurItem.pvItem);
BYTE byValue;
BITvExtractBits(pSIListbox->pbyIndex + (pSIListbox->byVarBitOffset>>3) * g_byCurLineID,
pSIListbox->byStartBit + (pSIListbox->byVarBitOffset&0x07) * g_byCurLineID,
pSIListbox->byEndBit + (pSIListbox->byVarBitOffset&0x07) * g_byCurLineID,
&byValue);
byValue = (byValue + 1) % pSIListbox->byListNum;
BITvModifyBits(pSIListbox->pbyIndex + (pSIListbox->byVarBitOffset>>3) * g_byCurLineID,
pSIListbox->byStartBit + (pSIListbox->byVarBitOffset&0x07) * g_byCurLineID,
pSIListbox->byEndBit + (pSIListbox->byVarBitOffset&0x07) * g_byCurLineID,
&byValue);
g_bDataDirty = TRUE;
}
// for var-listbox only
else if ((g_byCurKey == KEY_SPACE)&&(g_SCurItem.f4DataType == ITEM_VAR_LISTBOX))
{
SItemVarListbox* pSIListbox = (SItemListbox*)(g_SCurItem.pvItem);
BYTE byValue;
if (! pSIListbox->pSStrTblMap->byListNum)
continue;
// The ITEM_VAR_LISTBOX item does not support repeat-type in this smart version
BITvExtractBits(pSIListbox->pbyIndex,
pSIListbox->byStartBit,
pSIListbox->byEndBit,
&byValue);
byValue = (byValue + 1) % (pSIListbox->pSStrTblMap->byListNum);
BITvModifyBits(pSIListbox->pbyIndex,
pSIListbox->byStartBit,
pSIListbox->byEndBit,
&byValue);
g_bDataDirty = TRUE;
}
// jump to action bar or goto selected page (LINK_TYPE_EDITPAGE includes ITEM_MENU_PAGESEL)
else if ((g_byCurKey == KEY_ENTER && (g_SCurItem.f2LinkType == LINK_TYPE_LISTBOX || g_SCurItem.f2LinkType == LINK_TYPE_EDITPAGE))
|| (g_byCurKey == KEY_ESC))
{
ENGvPrintItem(g_byCurLineID, g_byCurItemID, PRINT_ITEM_NORMAL);
return;
}
// deal with hotkey for ITEM_MENU_PAGESEL, support hot key
else if (g_SCurItem.f4DataType == ITEM_MENU_PAGESEL)
{
if (('0' <= g_byCurKey) && (g_byCurKey < '0'+g_pSCurPage->byVarItemNum))
{
if (g_byCurKey == '0')
g_byCurItemID = g_pSCurPage->byVarItemNum-1;
else
g_byCurItemID = g_byCurKey-'1';
return;
}
g_byCurKey = 0; // input key not valid
}
// accept user input for ITEM_DECNUM, ITEM_HEXNUM, ITEM_STRING, ITEM_PASSWORD
else if (g_SCurItem.f4DataType < ITEM_LISTBOX && g_SCurItem.f2LinkType == LINK_TYPE_NONE)
{
ENGvInputItem(&(g_SCurItem));
g_bDataDirty = TRUE;
bRtnKey = g_byCurKey;
}
// input key not valid
else
g_byCurKey = 0;
} // end while(1)
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -