📄 readbox.c
字号:
/*
******************************************************************
* XIAMEN YAXON NETWORK CO.LTD.
* XINXI BUILDING,HULI,XIAMEN
* (c) Copyright 2002,XIAMEN YAXON NETWORK CO.LTD. ,XIAMEN
* All Rights Reserved
*
* FileName : TEXTBOX.C
* Programmer(s): WuJingYu
* Description :
******************************************************************
*/
/*
*****************************************************************
* REVISION HISTORY
*
* Date: 2002-10-20
*****************************************************************
*/
#define READBOX_GLOBALS
#include "includes.h"
#include "ErrTask.H"
#include "Lcd.h"
static INT8U LineSize,NumLine;
static void GetReadBoxPara(READBOX *readbox)
{
NumLine = readbox->box->numrow;
LineSize = readbox->box->numcol;
}
static void PlotPage(READBOX *readbox)
{
INT16U i,lineheadpos;
INT8U curline,curpage,totalpage;
INT8U curpos,nexttext;
INT8U *ptr;
GetReadBoxPara(readbox);
curline = 0;
curpage = 0;
totalpage = 0;
curpos = 0;
lineheadpos = 0;
ptr = readbox->text;
for (i=0;i<readbox->textlen;i++) {
nexttext = *(ptr+1);
if (*ptr == 0x0D && nexttext == 0x0A) {
curline++;
i++;
curpos = 0;
lineheadpos = i+1;
ptr++;
ptr++;
if (curline == NumLine) {
readbox->pagepos[curpage++] = i;
totalpage++;
curline = 0;
continue;
}
}
if (!(++curpos % LineSize)) {
if (NeedRoundLine((INT8U*)(readbox->text+lineheadpos),LineSize)) {
i--;
} else {
ptr++;
}
curpos = 0;
curline++;
lineheadpos = i+1;
if (curline == NumLine) {
if (curpage >= MAXPAGE) {
// ErrExit(ERR_READBOX_MAXPAGE);
}
readbox->pagepos[curpage++] = lineheadpos;
totalpage++;
curline = 0;
continue;
}
} else {
ptr++;
}
}
readbox->curpage = 0;
readbox->totalpage = totalpage;
}
static void UpdateReadBoxArrow(READBOX *readbox)
{
if (readbox->totalpage == 0) {
return;
} else {
if (readbox->curpage == 0) {
ShowUpArrow(OFF);
ShowDownArrow(ON);
} else if (readbox->curpage == readbox->totalpage) {
ShowUpArrow(ON);
ShowDownArrow(OFF);
} else {
ShowUpArrow(ON);
ShowDownArrow(ON);
}
}
}
static void ShowReadBoxText(READBOX *readbox,INT8U updatelcd)
{
INT8U totalpage,curpage;
INT16U textlen;
INT8U *textptr;
LockOutBox(readbox->box);
ClearOutBox();
GetReadBoxPara(readbox);
curpage = readbox->curpage;
totalpage = readbox->totalpage;
textptr = readbox->text + readbox->pagepos[curpage];
if (totalpage == 0) {
textptr = readbox->text;
textlen = readbox->textlen;
} else if (curpage == 0) {
textptr = readbox->text;
textlen = readbox->pagepos[curpage];
} else if (curpage == totalpage) {
textptr = readbox->text + readbox->pagepos[curpage-1];
textlen = readbox->textlen - readbox->pagepos[curpage-1] ;
} else {
textptr = readbox->text + readbox->pagepos[curpage-1] ;
textlen = readbox->pagepos[curpage] - readbox->pagepos[curpage-1];
}
Print_Text(textptr,textlen);
UpdateReadBoxArrow(readbox);
UpdateOutBox_MEM();
if (updatelcd) {
UpdateOutBox_LCD();
}
}
static void PageDown(READBOX *readbox)
{
if (readbox->curpage == readbox->totalpage) return;
++readbox->curpage ;
ShowReadBoxText(readbox,1);
}
static void PageUp(READBOX *readbox)
{
if (readbox->totalpage == 0 || readbox->curpage == 0) return;
--readbox->curpage;
ShowReadBoxText(readbox,1);
}
void InitReadBox(READBOX *readbox)
{
PlotPage(readbox);
}
void CreateReadBox(READBOX *readbox)
{
ShowReadBoxText(readbox,0);
CreateBorder(readbox->box);
}
void ClearReadBox(READBOX *readbox)
{
LockOutBox(readbox->box);
ClearOutBox();
UpdateOutBox_MEM();
UpdateOutBox_LCD();
UnLockOutBox(readbox->box);
}
void RefreshReadBox(READBOX *readbox)
{
PlotPage(readbox);
ShowReadBoxText(readbox,1);
}
void AddRaadBoxText(READBOX *readbox,INT8U *text,INT16U textlen)
{
readbox->text = text;
readbox->textlen = textlen;
}
BOOLEAN ReadBox_HdlKey(READBOX *readbox)
{
INT8U key;
void (*ExecFunc)(void);
key = GetCurLcdKey();
switch (key) {
case KEY_UP:
PageUp(readbox);
return TRUE;
case KEY_DOWN:
PageDown(readbox);
return TRUE;
case KEY_ACK:
ExecFunc = readbox->execfunc;
if (ExecFunc != NULL) {
(*ExecFunc)();
return TRUE;
}else{
return FALSE;
}
default:
return FALSE;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -