📄 basic.c
字号:
break;
case cmVkF2 :
hEditWnd=GuiScrnEditGetEdit(handle);
GuiEditCut(hEditWnd);
break;
case cmVkF3 :
hEditWnd = GuiScrnEditGetEdit(handle);
GuiEditCopy(hEditWnd);
break;
case cmVkF4 :
hEditWnd = GuiScrnEditGetEdit(handle);
GuiEditPaste(hEditWnd);
break;
case cmVkEnter:
MsgPost(&ev);
break;
default :
break;
}
break;
case evQuit :
if (Strlen(pInBuf)==0||Strlen(pInBuf)==1&&*pInBuf==']')
{
BasicFileFind();
if (FileCount > -1 && pEvent->infoPtr != cmExitHotKey) ApExit(LISTMODE);
else ApExit(pEvent->infoPtr);
}
else
{
nMsgRet = GuiMsgBox(handle,ofStyle4,_Far("是否保存资料?"),_Far("Basic编程"),MT_YESNOCANCEL);
if (nMsgRet == cmMsgBoxYes)
{
if (pEvent->infoPtr == cmExitHotKey) HomeKeyDownFlag = 1;
Lastcurrent_mode = current_mode;
ApExit(SAVEMODE);
}
else if (nMsgRet==cmMsgBoxNo)
{
BasicFileFind();
if (FileCount > -1 && pEvent->infoPtr != cmExitHotKey) ApExit(LISTMODE);
else ApExit(pEvent->infoPtr);
}
}
return 0;
}
if(pEvent->type != evNothing) GuiScrnEditHandleEvent(handle,pEvent);
return 0;
}
UInt8 CreateEditModeWindow()
{
UInt16 edit_style;
MEditParam pEditParam;
UInt32 func;
UInt8 *hEditWnd;
edit_style = EDS_ENABLE|EDS_EDITOR|EDS_VISIBLE;
pEditParam.dwHandle = NullID;
pEditParam.dwCaption = NullID;
pEditParam.wAllowChar = EDITALLOW_ALL;
pEditParam.wMaxEditLen = BUFFERPROGRAM;
pEditParam.wFirstChar = EDITALLOW_ASCII;
HomeKeyDownFlag = 0;
func = _Far(Function_Button_New);
hBasicWnd = GuiScrnEditCreate((UInt8*)0,0,_Far("Basic编程"),IDH_EDITOR_01, func, False, edit_style, (UInt8 *)pInBuf, BUFFERPROGRAM, 1, &pEditParam);
hEditWnd = GuiScrnEditGetEdit(hBasicWnd);
GuiSetState(hEditWnd,sfFocused);
AssignFuncPtr((UInt8*)(&((MWindow*)hBasicWnd)->handleEvent), _Far(_BasicEditModeHandleEvent));
return 1;
}
FAR UInt32 _BasicEditModeHandleEvent(UInt8* handle, MEvent* pEvent)
{
UInt16 nMsgRet;
UInt8 *hEditWnd;
MEvent ev;
ev.type = evKeyDown;
ev.x = 0x5D;
ev.y = 0;
ev.infoPtr = 0;
hEditWnd = GuiScrnEditGetEdit(handle);
switch (pEvent->type)
{
case evCommand:
switch (pEvent->x)
{
case cmEditorBufferFull :
case cmEditorHaveMaxLen :
GuiMsgBox(handle,ofStyle4,_Far("编辑区已满,不能再编辑了!"),_Far("Basic编程"),MT_NONE);
return 0;
}
break;
case evKeyDown :
switch (pEvent->x)
{
case cmVkF1 : /***存储文件***/
if (Strlen(pInBuf) == 0 || Strlen(pInBuf) == 1 && *pInBuf == ']')
GuiMsgBox(handle,ofStyle4,_Far("请输入内容!"),_Far("Basic编程"),MT_NONE);
else
{
Lastcurrent_mode = current_mode;
ApExit(SAVEMODE);
return 0;
}
break;
case cmVkF2 :
GuiEditCut(hEditWnd);
break;
case cmVkF3 :
GuiEditCopy(hEditWnd);
break;
case cmVkF4 :
GuiEditPaste(hEditWnd);
break;
case cmVkEnter:
MsgPost(&ev);
break;
default:
break;
}
break;
case evQuit :
nMsgRet = GuiMsgBox(handle,ofStyle4,_Far("是否保存资料?"),_Far("Basic编程"),MT_YESNOCANCEL);
if (nMsgRet == cmMsgBoxYes)
{
if (Strlen(pInBuf) == 0 || Strlen(pInBuf) == 1 && *pInBuf == ']')
{
nMsgRet = GuiMsgBox(handle,ofStyle4,_Far("不可存空文件!"),_Far("Basic编程"),MT_OK_X);
return 0;
}
if (pEvent->infoPtr == cmExitHotKey) HomeKeyDownFlag = 1;
Lastcurrent_mode = current_mode;
ApExit(SAVEMODE);
}
else if (nMsgRet == cmMsgBoxNo)
{
BasicFileFind();
if (FileCount > -1 && pEvent->infoPtr != cmExitHotKey) ApExit(LISTMODE);
else ApExit(pEvent->infoPtr);
}
return 0;
}
if(pEvent->type != evNothing) GuiScrnEditHandleEvent(handle,pEvent);
return 0;
}
UInt8 CreateBrowseModeWindow()
{
UInt16 edit_style;
MEditParam pEditParam;
UInt32 func;
edit_style = EDS_ENABLE|EDS_EDITOR|EDS_VISIBLE|EDS_BROWSER;
pEditParam.dwHandle = NullID;
pEditParam.dwCaption = NullID;
pEditParam.wMaxEditLen = BUFFERPROGRAM;
pEditParam.wFirstChar = EDITALLOW_ASCII;
pEditParam.wAllowChar = EDITALLOW_NUMBER|EDITALLOW_ENCHAR|EDITALLOW_SYMBOL|EDITALLOW_ENTER|EDITALLOW_SBCCASE|EDITALLOW_NOMARK;
func = _Far(Function_Button_Browse);
hBasicWnd = GuiScrnEditCreate((UInt8*)0,0,_Far("Basic编程"),IDH_BASIC_01, func, False, edit_style, (UInt8 *)pInBuf, BUFFERPROGRAM, 1, &pEditParam);
AssignFuncPtr((UInt8*)(&((MWindow*)hBasicWnd)->handleEvent), _Far(_BasicBrowseModeHandleEvent));
return 1;
}
FAR UInt32 _BasicBrowseModeHandleEvent(UInt8* handle, MEvent* pEvent)
{
UInt16 nMsgRet;
switch(pEvent->type)
{
case evCommand:
switch(pEvent->x)
{
case cmDraw:
GuiSoftKBSetCurrent(IMNone,False);
break;
default:
break;
}
break;
case evKeyDown:
switch(pEvent->x)
{
case cmVkF1: /***新增***/
ApExit(NEWMODE);
return 0;
case cmVkF2 : /***修改***/
Lastcurrent_mode = current_mode;
ApExit(EDITMODE);
return 0;
case cmVkF3: /***删除***/
nMsgRet = GuiMsgBox(handle,ofStyle4|ofResource,IDS_MSGBOX_DELETEASK,IDS_MAIN_BASIC,MT_YESNO);
if (nMsgRet == cmMsgBoxYes)
{
_BasicFileDelete();
if (--FileCount < 0) ApExit(pEvent->infoPtr);
else ApExit(LISTMODE);
return 0;
}
break;
case cmVkF4: /***运行程序***/
InitialVariable();
Lastcurrent_mode = current_mode;
ApExit(RUNMODE);
return 0;
default:
break;
}
break;
case evQuit:
if (pEvent->infoPtr == cmExitHotKey) ApExit(pEvent->infoPtr);
else ApExit(LISTMODE);
return 0;
}
if(pEvent->type!=evNothing) GuiScrnEditHandleEvent(handle,pEvent);
return 0;
}
UInt8 CreateRunModeWindow()
{
UInt16 edit_style;
MEditParam pEditParam;
UInt32 func;
UInt8 *hEditWnd;
MEvent ev;
edit_style = EDS_ENABLE|EDS_EDITOR|EDS_VISIBLE;
pEditParam.wMaxEditLen = 500;
pEditParam.dwHandle = NullID;
pEditParam.dwCaption = NullID;
pEditParam.wAllowChar = EDITALLOW_ALL|EDITALLOW_NOMARK;
if (Lastcurrent_mode == BROWSEMODE) _BasicGetpInBuf();
hBasicWnd = GuiScrnEditCreate((UInt8*)0,0,_Far("Basic编程"),IDH_BASIC_01, 0, False, edit_style, (UInt8 *)pOutBuf, (UInt16)200, 1, &pEditParam);
GuiSoftKBSetCurrent(IMNone,True);
hEditWnd = GuiScrnEditGetEdit(hBasicWnd);
GuiEditSetReadOnly(hEditWnd,True);
if (!GTflag)
{
ev.type = evCommand;
ev.x = cmBack;
ev.y = 0;
ev.infoPtr = 0;
MsgPost(&ev);
}
AssignFuncPtr((UInt8*)(&((MWindow*)hBasicWnd)->handleEvent), _Far(_BasicRunModeHandleEvent));
return 1;
}
FAR UInt32 _BasicRunModeHandleEvent(UInt8* handle, MEvent* pEvent)
{
switch(pEvent->type)
{
case evKeyDown:
switch (pEvent->x)
{
case cmVkEnter:
ApExit(Lastcurrent_mode);
return 0;
default :
break;
}
break;
case evCommand:
switch (pEvent->x)
{
/*case cmDraw:
if (explain_over_flag) return 0;
break;*/
case cmBack:
_BasicExplain();
if (current_mode == RUNINPUTMODE)
{
ApExit(current_mode);
return 0;
}
/*explain_over_flag = 1;*/
MsgClear(evCommand); /*少这一句,画图后会清除屏幕*/
pEvent->type = evNothing;
break;
default:
break;
}
break;
case evQuit:
if (pEvent->infoPtr == cmExitHotKey) ApExit(pEvent->infoPtr);
else ApExit(Lastcurrent_mode);
return 0;
default:
break;
}
if(pEvent->type != evNothing) GuiScrnEditHandleEvent(handle,pEvent);
return 0;
}
UInt8 CreateSaveModeWindow()
{
char flag;
CreateBasicFileSaveWindow(flag);
AssignFuncPtr((UInt8*)(&((MWindow*)hBasicWnd)->handleEvent), _Far(_BasicSaveModeHandleEvent));
return 1;
}
FAR UInt32 _BasicSaveModeHandleEvent(UInt8* handle, MEvent* pEvent)
{
UInt16 temp;
UInt8 FileNameStr[14], ret_v, *temp_buf;
UInt16 winHeight,winWidth;
UInt16 idKbd;
InputMethod* pKbdInfo;
MEvent ev;
switch(pEvent->type)
{
case evKeyDown:
switch(pEvent->x)
{
case cmVkEnter:
Strncpy(FileNameStr,pOutBuf,14);
if (*FileNameStr == 0x20)
{
GuiMsgBox(handle, ofStyle4, _Far("文件名首字符不可为空格!"),_Far("Basic编程"),MT_OK_X);
return 0;
}
for (temp = 0; temp < Strlen(FileNameStr); temp++)
{
if (Strchr(".:?*><|\"",*(FileNameStr+temp)))
{
GuiMsgBox(handle, ofStyle4, _Far("文件名含有非法字符!"),_Far("Basic编程"),MT_OK_X);
return 0;
}
}
if (temp == Strlen(FileNameStr))
{
if (Strlen(FileNameStr) == 0)
return 0;
else
Strcat(FileNameStr,".bsc");
ret_v = _BasicFileSave(_Far(FileNameStr));
if (ret_v == 1)
{
Strcpy(pBasicFileName,FileNameStr);
ApExit(LISTMODE);
}
else if (ret_v == 2)
{
temp_buf = GetAllocBuf();
*temp_buf = 0;
GuiEditSetText(hMainEdit, temp_buf);
}
return 0;
}
break;
default:
break;
}
break;
case evCommand:
switch (pEvent->x)
{
case cmSetCursorLast:
*(pBasicFileName + Strlen(pBasicFileName) - 4) = 0;
GuiEditSetText(hMainEdit,pBasicFileName);
*(pBasicFileName + Strlen(pBasicFileName)) = '.';
temp = Strlen(pOutBuf);
GuiEditSetSel(hMainEdit,temp,temp);
pEvent->type = evNothing;
break;
case cmEditorBufferFull :
case cmEditorHaveMaxLen :
return 0;
case cmSelectKb:
pKbdInfo = (InputMethod*)(MAKEPOINTER(GuiSoftKBGetInfo((UInt16)(pEvent->infoPtr))));
winHeight = LcdGetHeight()-pKbdInfo->imIconHeight;
if (winHeight!=((MDC*)handle)->dcHeight)
{
winWidth=LcdGetWidth();
MsgSend2(handle,evCommand,cmChangeSize,winWidth,winHeight);
ev.type = evCommand;
ev.x = cmDraw;
ev.y = 0;
ev.infoPtr = 0;
MsgPost(&ev);
}
break;
default:
break;
}
break;
case evQuit:
if (pEvent->infoPtr==cmExitHotKey||HomeKeyDownFlag) ApExit(pEvent->infoPtr);
else ApExit(Lastcurrent_mode);
return 0;
}
if(pEvent->type != evNothing) GuiWindowHandleEvent(handle,pEvent);
return 0;
}
UInt8 CreateRunInputModeWindow()
{
UInt16 edit_style;
MEditParam pEditParam;
UInt32 func;
UInt8 *hEditWnd;
MEvent ev;
edit_style = EDS_ENABLE|EDS_EDITOR|EDS_VISIBLE;
pEditParam.dwHandle = NullID;
pEditParam.dwCaption = NullID;
pEditParam.wAllowChar = EDITALLOW_ALL;
pEditParam.wMaxEditLen = 200;
pEditParam.wFirstChar = EDITALLOW_ASCII;
hBasicWnd = GuiScrnEditCreate((UInt8*)0,0,_Far("Basic编程"),IDH_BASIC_01, 0, False, edit_style, (UInt8 *)pOutBuf, (UInt16)200, 1, &pEditParam);
hEditWnd = GuiScrnEditGetEdit(hBasicWnd);
GuiSetState(hEditWnd,sfFocused);
AssignFuncPtr((UInt8*)(&((MWindow*)hBasicWnd)->handleEvent), _Far(_BasicRunInputModeHandleEvent));
ev.type = evKeyDown;
ev.x = cmInputExplain;
ev.y = 0;
ev.infoPtr = 0;
MsgPost(&ev);
return 1;
}
FAR UInt32 _BasicRunInputModeHandleEvent(UInt8* handle, MEvent* pEvent)
{
UInt8 *hEditWnd;
MEvent ev;
hEditWnd = GuiScrnEditGetEdit(handle);
switch(pEvent->type)
{
case evCommand:
switch(pEvent->x)
{
case cmEditorBufferFull :
case cmEditorHaveMaxLen :
return 0;
case cmEditorIndicator :
GuiEditGetCursorMem(hEditWnd,&cur_pos);
if (cur_pos <= limit_pos && GetIndicator(LEFTARROW)) ClearIndicator(LEFTARROW,True);
if (cur_pos > limit_pos && (!GetIndicator(LEFTARROW))) SetIndicator(LEFTARROW,True);
if (cur_pos < Strlen(pOutBuf) && (!GetIndicator(RIGHTARROW))) SetIndicator(RIGHTARROW,True);
if (cur_pos == Strlen(pOutBuf) && GetIndicator(RIGHTARROW)) ClearIndicator(RIGHTARROW,True);
pEvent->type = evNothing;
break;
case cmSystem:
if(pEvent->infoPtr == cmExitPowerOff)
{
FreeOpMem();
FreeAllocMem();
}
break;
default:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -