📄 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:
*
*/
#include "ttyio.h"
#include "allpages.h"
#include "engine.h"
#include "eng_io.h"
/*--------------------- Export Variables --------------------------*/
/*--------------------- Static Variables --------------------------*/
/*--------------------- Static Definitions -------------------------*/
/*--------------------- Static Functions --------------------------*/
static void s_vIncrItemID(void) DIRECT_FUNTYPE_REENT
{
g_byCurItemID = (g_byCurItemID+1) % g_pSCurPage->byVarItemNum;
}
static void s_vDecrItemID(void) DIRECT_FUNTYPE_REENT
{
g_byCurItemID = (g_byCurItemID + g_pSCurPage->byVarItemNum -1) % g_pSCurPage->byVarItemNum;
}
static void s_vIncrLineID(void) DIRECT_FUNTYPE_REENT
{
g_byCurLineID = (g_byCurLineID +1) % g_byTotalLineNum;
}
static void s_vDecrLineID(void) DIRECT_FUNTYPE_REENT
{
g_byCurLineID = (g_byCurLineID+g_byTotalLineNum-1) % g_byTotalLineNum;
}
static void s_vMovingTypeRectTab(void) DIRECT_FUNTYPE_REENT
{
if (g_byCurLineID == g_byTotalLineNum-1) // last line
{
s_vIncrItemID();
g_byCurLineID = 0;
}
else
g_byCurLineID++;
}
static void s_vMovingTypeRectBkspc(void) DIRECT_FUNTYPE_REENT
{
if (g_byCurLineID == 0) // first line
{
s_vDecrItemID();
if (g_byTotalLineNum)
g_byCurLineID = g_byTotalLineNum-1;
}
else
g_byCurLineID--;
}
static void s_vMovingTypeNormal(void) DIRECT_FUNTYPE_REENT
{
switch(g_byCurKey)
{
case KEY_BKSPC:
case KEY_ARROW_LEFT:
case KEY_ARROW_UP:
{
s_vDecrItemID();
if ((g_SCurItem.f2RepeatType != REPEAT_TYPE_NONE) // if next item is repeat-item
&&(g_byTotalLineNum))
g_byCurLineID = g_byTotalLineNum-1;
// prevent from moving to repeat item if g_byTotalLineNum==0
if (g_byTotalLineNum == 0)
{
BYTE ui;
for (ui=0; ui<g_pSCurPage->byVarItemNum; ui++)
{
if (g_SCurItem.f2RepeatType == REPEAT_TYPE_NONE)
break;
s_vDecrItemID();
}
}
} break;
case KEY_TAB:
case KEY_ARROW_RIGHT:
case KEY_ARROW_DOWN:
{
s_vIncrItemID();
if (g_SCurItem.f2RepeatType != REPEAT_TYPE_NONE) // if next item is repeat-item
g_byCurLineID = 0;
// prevent from moving to repeat item if g_byTotalLineNum==0
if (g_byTotalLineNum == 0)
{
BYTE ui;
for (ui=0; ui<g_pSCurPage->byVarItemNum; ui++)
{
if (g_SCurItem.f2RepeatType == REPEAT_TYPE_NONE)
break;
s_vIncrItemID();
}
}
} break;
}
}
static void s_vMovingTypeRectSingle(void) DIRECT_FUNTYPE_REENT
{
switch(g_byCurKey)
{
case KEY_ARROW_LEFT:
{
if (g_byCurLineID < g_SCurItem.byLineNumPerColumn) // if first col => roll to last col
{
g_byCurLineID += ((g_byTotalLineNum / g_SCurItem.byLineNumPerColumn) * g_SCurItem.byLineNumPerColumn);
if (g_byCurLineID >= g_byTotalLineNum)
g_byCurLineID -= g_SCurItem.byLineNumPerColumn;
}
else
g_byCurLineID -= g_SCurItem.byLineNumPerColumn;
} break;
case KEY_BKSPC:
case KEY_ARROW_UP:
{
s_vMovingTypeRectBkspc();
} break;
case KEY_ARROW_RIGHT:
{
if (g_byCurLineID+g_SCurItem.byLineNumPerColumn >= g_byTotalLineNum) // if last col => roll to first col
g_byCurLineID %= g_SCurItem.byLineNumPerColumn;
else
{
g_byCurLineID += g_SCurItem.byLineNumPerColumn;
if (g_byCurLineID >= g_byTotalLineNum)
g_byCurLineID = g_byTotalLineNum-1;
}
} break;
case KEY_TAB:
case KEY_ARROW_DOWN:
{
s_vMovingTypeRectTab();
} break;
}
}
static void s_vMovingTypeRectMulti(void) DIRECT_FUNTYPE_REENT
{
switch(g_byCurKey)
{
case KEY_ARROW_LEFT:
{
// if first item => move to last col of previous block, else move to previous item
if (g_byCurItemID == 0)
{
if (g_byCurLineID < g_SCurItem.byLineNumPerColumn) // if in first col
g_byCurLineID += (((g_byTotalLineNum-1) / g_SCurItem.byLineNumPerColumn) * g_SCurItem.byLineNumPerColumn);
else
g_byCurLineID -= g_SCurItem.byLineNumPerColumn;
}
s_vDecrItemID();
} break;
case KEY_ARROW_RIGHT:
{
// if last item => move to first col of next block, else move to next item
if (g_byCurItemID == g_pSCurPage->byVarItemNum -1)
{
if (g_byCurLineID + g_SCurItem.byLineNumPerColumn >= g_byTotalLineNum)
g_byCurLineID %= g_SCurItem.byLineNumPerColumn;
else
g_byCurLineID += g_SCurItem.byLineNumPerColumn;
}
s_vIncrItemID();
} break;
case KEY_ARROW_UP:
{
s_vDecrLineID();
}
break;
case KEY_ARROW_DOWN:
{
s_vIncrLineID();
} break;
case KEY_BKSPC:
{
s_vMovingTypeRectBkspc();
} break;
case KEY_TAB:
{
s_vMovingTypeRectTab();
} break;
}
}
void ENGvMoveItem(void) DIRECT_FUNTYPE_REENT
{
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 + -