📄 utils.c
字号:
if (Key == 'e' || Key == 'E') { clearok(Window, TRUE); if (getstring(Window, 6+Menu->Focus, 41, Strings[Suffix1+Menu->Focus],ValidEdit,"\n\e",29,-1,Temp) == '\n') { Strings[Suffix1+Menu->Focus] = (char *)realloc(Strings[Suffix1+Menu->Focus], strlen(Temp)+1); strcpy(Strings[Suffix1+Menu->Focus], Temp); Tmp = Menu->Base; for (i=0;i<Menu->Focus;i++) Tmp = Tmp->Next; Tmp->Text = (char *)realloc(Tmp->Text, strlen(Temp)+1); strcpy(Tmp->Text, Temp); } Menu->Show(); wrefresh(Window); } Menu->GetInput(Key); } i = Menu->Focus+1; delete Menu; delete Win; wmove(Window, y, x); return i;}int ChooseInit(WINDOW *Window, int init){ int Key, i, y, x; tWindow *Win; char Temp[256]; tMenu *Menu; menuItem *Tmp; getyx(Window, y, x); Win = new tWindow(Window, 40, 5, 70, 16, Integers[cMenu] >> 4, Integers[cMenu] % 16); Win->Frame(1, Integers[cMenu]); Win->Headline("Choose initstring, E - edits", Integers[cMenuTitle]); Menu = new tMenu(Window, Integers[cMenu], Integers[cMenuHot], Integers[cMenuBar], Integers[cMenuText], ALIGNLEFT); for (i=0;i<10;i++) { if (strlen(Strings[InitStr1+i])<28) { Menu->Add(Strings[InitStr1+i], 41, 70, 6+i); } else { strncpy(Temp, Strings[InitStr1+i], 28); Temp[28] = 0; Menu->Add(Temp, 41, 70, 6+i); } } Menu->Focus = init; Menu->Show(); wrefresh(Window); Key = 0; while (Key != '\e' && Key != '\n'){ Key = getEscChar(); if (Key == 'e' || Key == 'E') { clearok(Window, TRUE); if (getstring(Window, 6+Menu->Focus, 41, Strings[InitStr1+Menu->Focus], ValidEdit,"\n\e",29,-1,Temp) == '\n') { Strings[InitStr1+Menu->Focus] = (char *)realloc(Strings[InitStr1+Menu->Focus], strlen(Temp)+1); strcpy(Strings[InitStr1+Menu->Focus], Temp); Tmp = Menu->Base; for (i=0;i<Menu->Focus;i++) Tmp = Tmp->Next; Tmp->Text = (char *)realloc(Tmp->Text, strlen(Temp)+1); strcpy(Tmp->Text, Temp); } Menu->Show(); wrefresh(Window); } Menu->GetInput(Key); } i = Menu->Focus; delete Menu; delete Win; wmove(Window, y, x); return i;}int ChooseNoConnect(WINDOW *Window, int Noconnect){ int Key, i, y, x; tWindow *Win; char Temp[256]; tMenu *Menu; menuItem *Tmp; getyx(Window, y, x); Win = new tWindow(Window, 40,5,70,11, Integers[cMenu] >> 4, Integers[cMenu] % 16); Win->Frame(1, Integers[cMenu]); Win->Headline("Edit strings, E - edits", Integers[cMenuTitle]); Menu = new tMenu(Window, Integers[cMenu], Integers[cMenuHot], Integers[cMenuBar], Integers[cMenuText], ALIGNLEFT); for (i=0;i<5;i++) { if (strlen(Strings[NoConnect1+i])<28) { Menu->Add(Strings[NoConnect1+i], 41, 70, 6+i); } else { strncpy(Temp, Strings[NoConnect1+i], 28); Temp[28] = 0; Menu->Add(Temp, 41, 70, 6+i); } } Menu->Focus = Noconnect; Menu->Show(); wrefresh(Window); Key = 0; while (Key != '\e' && Key != '\n'){ Key = getEscChar(); if (Key == 'e' || Key == 'E') { clearok(Window, TRUE); if (getstring(Window, 6+Menu->Focus, 41, Strings[NoConnect1+Menu->Focus], ValidEdit,"\n\e",29,-1,Temp) == '\n') { Strings[NoConnect1+Menu->Focus] = (char *)realloc(Strings[NoConnect1+Menu->Focus], strlen(Temp)+1); strcpy(Strings[NoConnect1+Menu->Focus], Temp); Tmp = Menu->Base; for (i=0;i<Menu->Focus;i++) Tmp = Tmp->Next; Tmp->Text = (char *)realloc(Tmp->Text, strlen(Temp)+1); strcpy(Tmp->Text, Temp); } Menu->Show(); wrefresh(Window); } Menu->GetInput(Key); } i = Menu->Focus; delete Menu; delete Win; wmove(Window, y, x); return i;}int ChooseMacro(WINDOW *Window, int WhichMacro){ int Key, i, y, x; tWindow *Win; char Temp[256]; tMenu *Menu; menuItem *Tmp; getyx(Window, y, x); Win = new tWindow(Window, 40,5,70,16, Integers[cMenu] >> 4, Integers[cMenu] % 16); Win->Frame(1, Integers[cMenu]); Win->Headline("Edit macros, E - edits", Integers[cMenuTitle]); Menu = new tMenu(Window, Integers[cMenu], Integers[cMenuHot], Integers[cMenuBar], Integers[cMenuText], ALIGNLEFT); for (i=0;i<10;i++) { if (strlen(Strings[Macro1+i])<28) { Menu->Add(Strings[Macro1+i], 41, 70, 6+i); } else { strncpy(Temp, Strings[Macro1+i], 28); Temp[28] = 0; Menu->Add(Temp, 41, 70, 6+i); } } Menu->Focus = WhichMacro; Menu->Show(); wrefresh(Window); Key = 0; while (Key != '\e' && Key != '\n'){ Key = getEscChar(); if (Key == 'e' || Key == 'E') { clearok(Window, TRUE); if (getstring(Window, 6+Menu->Focus, 41, Strings[Macro1+Menu->Focus], ValidEdit,"\n\e",29,-1,Temp) == '\n') { Strings[Macro1+Menu->Focus] = (char *)realloc(Strings[Macro1+Menu->Focus], strlen(Temp)+1); strcpy(Strings[Macro1+Menu->Focus], Temp); Tmp = Menu->Base; for (i=0;i<Menu->Focus;i++) Tmp = Tmp->Next; Tmp->Text = (char *)realloc(Tmp->Text, strlen(Temp)+1); strcpy(Tmp->Text, Temp); } Menu->Show(); wrefresh(Window); } Menu->GetInput(Key); } i = Menu->Focus; delete Menu; delete Win; wmove(Window, y, x); return i;}int ChooseDeviceInit(WINDOW *Window, int Which){ int Key, i, y, x, j, len; tWindow *Win; char TempInit[4][11], Temp[256]; tMenu *Menu; menuItem *Tmp; getyx(Window, y, x); Win = new tWindow(Window, 40,5,70,10, Integers[cMenu] >> 4, Integers[cMenu] % 16); Win->Frame(1, Integers[cMenu]); Win->Headline("Edit strings, E - edits", Integers[cMenuTitle]); Menu = new tMenu(Window, Integers[cMenu], Integers[cMenuHot], Integers[cMenuBar], Integers[cMenuText], ALIGNLEFT); for (i=0;i<4;i++){ len = 0; for (j=0;j<10;j++) if (DeviceInit[i][j] >= 0){ len++; TempInit[i][j] = DeviceInit[i][j]+48; } TempInit[i][len] = 0; } for (i=0;i<4;i++) { if (strlen(TempInit[i])<28) { Menu->Add(TempInit[i], 41, 70, 6+i); } else { strncpy(Temp, TempInit[i], 28); Temp[28] = 0; Menu->Add(Temp, 41, 70, 6+i); } } Menu->Focus = Which; Menu->Show(); wrefresh(Window); Key = 0; while (Key != '\e' && Key != '\n'){ Key = getEscChar(); clearok(Window, TRUE); Menu->GetInput(Key); if (Key == 'e' || Key == 'E') { clearok(Window, TRUE); if (getstring(Window, 6+Menu->Focus, 41, TempInit[Menu->Focus],NumberEdit,"\n\e",29,-1,Temp) == '\n') { strcpy(TempInit[Menu->Focus], Temp); Tmp = Menu->Base; for (i=0;i<Menu->Focus;i++) Tmp = Tmp->Next; Tmp->Text = (char *)realloc(Tmp->Text, strlen(Temp)+1); strcpy(Tmp->Text, Temp); } Menu->Show(); wrefresh(Window); } } for (i=0;i<4;i++){ len = strlen(TempInit[i]); for (j=0;j<10;j++) if (j < len) DeviceInit[i][j] = TempInit[i][j]-48; else DeviceInit[i][j] = -1; } i = Menu->Focus; delete Menu; delete Win; wmove(Window, y, x); return i;}int ChooseTerminal(WINDOW *Window, int Terminal){ int Key, i, Attr, y, x; tWindow *Win; tMenu *Menu; getyx(Window, y, x); Attr = Window->_attrs; Win = new tWindow(Window, 20,5,70,11, Integers[cMenu] >> 4, Integers[cMenu] % 16); Win->Frame(1, Integers[cMenu]); Win->Headline("Choose terminal", Integers[cMenuTitle]); Menu = new tMenu(Window, Integers[cMenu], Integers[cMenuHot], Integers[cMenuBar], Integers[cMenuText], ALIGNLEFT); for (i=0;i<5;i++) { Menu->Add(TermEmu[i], 21, 70, 6+i); } Menu->Focus = Terminal; Menu->Show(); wrefresh(Window); Key = 0; while (Key != '\e' && Key != '\n'){ Key = getEscChar(); Menu->GetInput(Key); } i = Menu->Focus; delete Menu; delete Win; wmove(Window, y, x); Window->_attrs = Attr; return i;}int ChooseDevice(WINDOW *Window, int Device, char Configure){ int Key, i, Attr, y, x; tWindow *Win; char Temp[256]; tMenu *Menu; menuItem *Tmp; getyx(Window, y, x); Attr = Window->_attrs; Win = new tWindow(Window, 20,5,70,11, Integers[cMenu] >> 4, Integers[cMenu] % 16); Win->Frame(1, Integers[cMenu]); if (Configure) Win->Headline("Edit strings, E - edits, O - options", Integers[cMenuTitle]); else Win->Headline("Edit strings, E - edits", Integers[cMenuTitle]); Menu = new tMenu(Window, Integers[cMenu], Integers[cMenuHot], Integers[cMenuBar], Integers[cMenuText], ALIGNLEFT); Menu->Add("Default device", 21, 70, 6); for (i=0;i<4;i++) { if (strlen(Strings[Device1+i])<48) { Menu->Add(Strings[Device1+i], 21, 70, 7+i); } else { strncpy(Temp, Strings[Device1+i], 48); Temp[48] = 0; Menu->Add(Temp, 21, 70, 7+i); } } Menu->Focus = Device; Menu->Show(); wrefresh(Window); Key = 0; while (Key != '\e' && Key != '\n'){ Key = getEscChar(); Menu->GetInput(Key); if (Key == 'e' || Key == 'E') { if (Menu->Focus != 0){ clearok(Window, TRUE); if (getstring(Window, 6+Menu->Focus, 21, Strings[Device1+Menu->Focus-1],FileEdit,"\n\e",49,-1,Temp) == '\n') { Strings[Device1+Menu->Focus-1] = (char *)realloc(Strings[Device1+Menu->Focus-1], strlen(Temp)+1); strcpy(Strings[Device1+Menu->Focus-1], Temp); Tmp = Menu->Base; for (i=0;i<Menu->Focus;i++) Tmp = Tmp->Next; Tmp->Text = (char *)realloc(Tmp->Text, strlen(Temp)+1); strcpy(Tmp->Text, Temp); } } } if ((Key == 'o' || Key == 'O') && (Configure)){ if (Menu->Focus != 0){ Integers[Bauds1+Menu->Focus-1] = ChooseBaud(Window, Integers[Bauds1+Menu->Focus-1]); clearok(Window, TRUE); Integers[Parities1+Menu->Focus-1] = ChooseParity(Window, Integers[Parities1+Menu->Focus-1]); clearok(Window, TRUE); Integers[Databits1+Menu->Focus-1] = ChooseDatabits(Window, Integers[Databits1+Menu->Focus-1]); clearok(Window, TRUE); Integers[Stopbits1+Menu->Focus-1] = ChooseStopbits(Window, Integers[Stopbits1+Menu->Focus-1]); clearok(Window, TRUE); Integers[FlowCtrl1+Menu->Focus-1] = ChooseFlow(Window, Integers[FlowCtrl1+Menu->Focus-1]); clearok(Window, TRUE); } } Menu->Show(); wrefresh(Window); } i = Menu->Focus; delete Menu; delete Win; wmove(Window, y, x); Window->_attrs = Attr; return i;}int chwait(){ fd_set set; timeval timeout; timeout.tv_sec = 0; timeout.tv_usec = 20; FD_ZERO(&set); FD_SET(0, &set); if (select(1, &set, NULL, NULL, &timeout) > 0) { if (FD_ISSET(0, &set)) return TRUE; } return FALSE;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -