📄 eng_move.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: eng_move.c
*
* Purpose: UI engine module to support item moving operations
*
* Author: Jenda Jao
*
* Date: Jan 08, 2002
*
* Functions:
*
* Revision History:
*
*/
#if !defined(__ASCII_H__)
#include "ascii.h"
#endif
#if !defined(__KEY_H__)
#include "key.h"
#endif
#include "tty.h"
#include "allpages.h"
#include "engine.h"
#include "eng_io.h"
/*--------------------- Export Variables --------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Functions --------------------------*/
static void s_vIncrItemID(void)
{
g_wCurItemID = (g_wCurItemID+1) % g_pSCurPage->wVarItemNum;
}
static void s_vDecrItemID(void)
{
g_wCurItemID = (g_wCurItemID + g_pSCurPage->wVarItemNum -1) % g_pSCurPage->wVarItemNum;
}
static void s_vIncrLineID(void)
{
g_wCurLineID = (g_wCurLineID +1) % g_wTotalLineNum;
}
static void s_vDecrLineID(void)
{
g_wCurLineID = (g_wCurLineID+g_wTotalLineNum-1) % g_wTotalLineNum;
}
static void s_vMovingTypeRectTab(void)
{
if (g_wCurLineID == g_wTotalLineNum-1) // last line
{
s_vIncrItemID();
g_wCurLineID = 0;
}
else
g_wCurLineID++;
}
static void s_vMovingTypeRectBkspc(void)
{
if (g_wCurLineID == 0) // first line
{
s_vDecrItemID();
if (g_wTotalLineNum)
g_wCurLineID = g_wTotalLineNum-1;
}
else
g_wCurLineID--;
}
static void s_vMovingTypeNormal(void)
{
switch(g_byCurKey)
{
case MK_BACKSPACE:
case MK_V_LEFT:
case MK_V_UP:
{
s_vDecrItemID();
if ((g_SCurItem.f2RepeatType != REPEAT_TYPE_NONE) // if next item is repeat-item
&&(g_wTotalLineNum))
g_wCurLineID = g_wTotalLineNum-1;
// prevent from moving to repeat item if g_wTotalLineNum==0
if (g_wTotalLineNum == 0)
{
UINT16 ui;
for (ui=0; ui<g_pSCurPage->wVarItemNum; ui++)
{
if (g_SCurItem.f2RepeatType == REPEAT_TYPE_NONE)
break;
s_vDecrItemID();
}
}
} break;
case MK_TAB:
case MK_V_RIGHT:
case MK_V_DOWN:
{
s_vIncrItemID();
if (g_SCurItem.f2RepeatType != REPEAT_TYPE_NONE) // if next item is repeat-item
g_wCurLineID = 0;
// prevent from moving to repeat item if g_wTotalLineNum==0
if (g_wTotalLineNum == 0)
{
UINT16 ui;
for (ui=0; ui<g_pSCurPage->wVarItemNum; ui++)
{
if (g_SCurItem.f2RepeatType == REPEAT_TYPE_NONE)
break;
s_vIncrItemID();
}
}
} break;
}
}
static void s_vMovingTypeRectSingle(void)
{
switch(g_byCurKey)
{
case MK_V_LEFT:
{
if (g_wCurLineID < g_SCurItem.byLineNumPerColumn) // if first col => roll to last col
{
g_wCurLineID += ((g_wTotalLineNum / g_SCurItem.byLineNumPerColumn) * g_SCurItem.byLineNumPerColumn);
if (g_wCurLineID >= g_wTotalLineNum)
g_wCurLineID -= g_SCurItem.byLineNumPerColumn;
}
else
g_wCurLineID -= g_SCurItem.byLineNumPerColumn;
} break;
case MK_BACKSPACE:
case MK_V_UP:
{
s_vMovingTypeRectBkspc();
} break;
case MK_V_RIGHT:
{
if (g_wCurLineID+g_SCurItem.byLineNumPerColumn >= g_wTotalLineNum) // if last col => roll to first col
g_wCurLineID %= g_SCurItem.byLineNumPerColumn;
else
{
g_wCurLineID += g_SCurItem.byLineNumPerColumn;
if (g_wCurLineID >= g_wTotalLineNum)
g_wCurLineID = g_wTotalLineNum-1;
}
} break;
case MK_TAB:
case MK_V_DOWN:
{
s_vMovingTypeRectTab();
} break;
}
}
static void s_vMovingTypeRectMulti(void)
{
switch(g_byCurKey) {
case MK_V_LEFT: {
// if first item => move to last col of previous block, else move to previous item
if (g_wCurItemID == 0)
{
if (g_wCurLineID < g_SCurItem.byLineNumPerColumn) // if in first col
g_wCurLineID += (((g_wTotalLineNum-1) / g_SCurItem.byLineNumPerColumn) * g_SCurItem.byLineNumPerColumn);
else
g_wCurLineID -= g_SCurItem.byLineNumPerColumn;
}
s_vDecrItemID();
} break;
case MK_V_RIGHT: {
// if last item => move to first col of next block, else move to next item
if (g_wCurItemID == g_pSCurPage->wVarItemNum -1)
{
if (g_wCurLineID + g_SCurItem.byLineNumPerColumn >= g_wTotalLineNum)
g_wCurLineID %= g_SCurItem.byLineNumPerColumn;
else
g_wCurLineID += g_SCurItem.byLineNumPerColumn;
}
s_vIncrItemID();
} break;
case MK_V_UP: {
s_vDecrLineID();
} break;
case MK_V_DOWN: {
s_vIncrLineID();
} break;
case MK_BACKSPACE: {
s_vMovingTypeRectBkspc();
} break;
case MK_TAB: {
s_vMovingTypeRectTab();
} break;
}
}
void ENGvMoveItem(void)
{
switch (g_SCurItem.f2RepeatType)
{
case REPEAT_TYPE_NONE:
s_vMovingTypeNormal();
break;
case REPEAT_TYPE_RECT_SINGLE:
s_vMovingTypeRectSingle();
break;
case REPEAT_TYPE_RECT_MULTI:
s_vMovingTypeRectMulti();
break;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -