/* Here we draw all changed lines */ void ResetDISP(void) { int i; /* No need to redraw screen in near future */ kbhitcount=0; for (i=1; i<25; i++) if (DISP[i]!=0) { /* If line was changed, it won't stay changed any more */ DISP[i]=0; /* We don't want to erase input field definitons from ** screen, so check it carefully. */ switch (i) { case FIELD_SY: ShowLine(i, 1, FIELD_SX-1); if (i==FIELD_EY) { ShowLine(i, FIELD_EX+1, 80-FIELD_EX); } break; case FIELD_EY: ShowLine(i, FIELD_EX+1, 80-FIELD_EX); break; default: ShowLine(i, 1, 80); } } /* Okay, actually show something */ ResetScrBuf(); }
void WaitRemoveCard(STR *Line1,STR *Line2) { int iret; ShowLine(0,32,Med_Font_Size,Line1,TRUE); ShowLine(0,40+32,Med_Font_Size,Line2,TRUE); Setcolor(Color_black,Color_red); do { iret=inPPR_ReadCardNumber(); if(iret!=0x9000) return ; CTOS_Beep(); } while(1); }
void OutputCtrl::ActivateLine( int line, bool openFile ) { // Get the file name and line. bool isError = false; wxString File; long Line; if ( line != -1 ) { wxString Text = GetLine( line ); if ( m_ErrorExpr.Matches( Text ) && m_ErrorExpr.GetMatchCount() > 3 ) { isError = true; File = m_ErrorExpr.GetMatch( Text, 1 ); m_ErrorExpr.GetMatch( Text, 2 ).ToLong( &Line ); } else if ( m_WarnExpr.Matches( Text ) && m_WarnExpr.GetMatchCount() > 3 ) { isError = true; File = m_WarnExpr.GetMatch( Text, 1 ); m_WarnExpr.GetMatch( Text, 2 ).ToLong( &Line ); } } if ( m_Selected != -1 ) { int start = PositionFromLine( m_Selected ); int len = GetLineEndPosition( m_Selected ) - start; // Reverse the style! StartStyling( start, 0xFF ); SetStyling( len, 2 ); } m_Selected = line; if ( !isError ) m_Selected = -1; if ( m_Selected != -1 ) { int start = PositionFromLine( m_Selected ); int len = GetLineEndPosition( m_Selected ) - start; // Reverse the style! StartStyling( start, 0xFF ); SetStyling( len, 1 ); } if ( m_Selected != -1 ) ShowLine( m_Selected ); // Ok read the file name from the list. if ( openFile && !File.IsEmpty() ) { // TODO: Should we launch 3rd party apps here or allow the // file to be opened as text? wxASSERT( tsGetMainFrame() ); tsGetMainFrame()->OpenFile( File, Line-1 ); } }
void QuoteClass::ShowQuotePage(EditorFileClass *QuoteFile) { int i; LineStruct *Line; Line=QuoteFile->GetLine(QuoteBrowseLine); for(i=0;i<=QUOTE_DISPLAY_LINES;i++) { if (Line || i<=BottomLineUsed) { IO->MoveTo(0, i+QUOTE_TOP_LINE); ShowLine(Line); if (Line) BottomLineUsed=i; QuoteFile->Next(Line); } } }
int ESvnBase::ExecCommand(int Command, ExState &State) { switch (Command) { case ExChildClose: if (Running == 0 || PipeId == -1) break; ClosePipe (); { char s[30]; sprintf(s, "[aborted, status=%d]", ReturnCode); AddLine(0, -1, s); } return ErOK; case ExActivateInOtherWindow: ShowLine(View->Next, Row); return ErOK; } return EList::ExecCommand(Command, State); }
void QuoteClass::Quote(int LineNumber) { int i; LineStruct *Line, *NextLine; EditorFileClass QuoteFile(QuoteFileName, BREditArgs); if (strchr(QuoteFile.GetLine(0)->Text, '#')!=NULL) { // Quote file contains author info QuoteFile.RemoveLine(0); QuoteFile.RemoveLine(0); } BottomLineUsed=0; for(i=0;i<QuoteFile.FileLines;i++) { Line=QuoteFile.MakeNewLine(i); sprintf(Line->Text, "%-3d> ", i+1); memset(Line->Color, 2, sizeof(color_t) * 3); Line->Length=ARROW_SIZE; Line->Color[3]=7; Line->Color[4]=0; Line->Wrap=1; NextLine=QuoteFile.GetLine(i+1); if (NextLine->Length+(ARROW_SIZE+1)>BREditArgs->MaxColumns) NextLine->Length=BREditArgs->MaxColumns-(ARROW_SIZE+1); /* if (NextLine->Length+(ARROW_SIZE+1)>BREditArgs->MaxColumns) { int Count, NoSpaces=1; for(Count=BREditArgs->MaxColumns-(ARROW_SIZE+1);(Count>=0 && NoSpaces);Count--) if (NextLine->Text[Count]==' ') NoSpaces=0; if (NoSpaces) NextLine->Length=BREditArgs->MaxColumns-(ARROW_SIZE+1); } */ QuoteFile.JoinLines(i); } IO->SetColor(0); IO->ClearScreen(); ShowTopInfo(); IO->SetColor(7); IO->MoveTo(0, 2); for(i=1;i<BREditArgs->MaxColumns;i++) IO->Output('Ä'); ShowQuotePage(&QuoteFile); if (BREditArgs->EnhancedMode==ON) IO->EANSI_DefineRegion(QUOTE_TOP_LINE, QUOTE_DISPLAY_LINES+QUOTE_TOP_LINE); int QuoteAction=NOT_DONE, CurrentInputField=0; char QuoteData[2][4]; for(i=0;i<2;i++) QuoteData[i][0]=0; HighlightInput(FROM, HIGHLIGHT, QuoteData[FROM]); while(QuoteAction==NOT_DONE) { IO->MoveTo(INPUT_X+strlen(QuoteData[CurrentInputField]), CurrentInputField); switch(InputNumber(QuoteData[CurrentInputField])) { case ESC: QuoteAction=ABORT_QUOTE; break; case ENTER: if (strlen(QuoteData[CurrentInputField])==0) { QuoteAction=ABORT_QUOTE; break; } i=atoi(QuoteData[CurrentInputField]); if (i<1 || i>QuoteFile.FileLines || (CurrentInputField==1 && i<atoi(QuoteData[FROM]))) { IO->Output(BEEP); for(i=0;i<2;i++) QuoteData[i][0]=0; HighlightInput(TO, UNHIGHLIGHT, QuoteData[TO]); HighlightInput(FROM, HIGHLIGHT, QuoteData[FROM]); CurrentInputField=FROM; } else if (CurrentInputField==FROM) { CurrentInputField=TO; HighlightInput(FROM, UNHIGHLIGHT, QuoteData[FROM]); HighlightInput(TO, HIGHLIGHT, QuoteData[TO]); } else QuoteAction=DO_QUOTE; break; case KB_PGUP: if (QuoteBrowseLine>0) { QuoteBrowseLine-=QUOTE_DISPLAY_LINES-3; if (QuoteBrowseLine<0) QuoteBrowseLine=0; ShowQuotePage(&QuoteFile); } break; case KB_PGDN: if (QuoteBrowseLine+QUOTE_DISPLAY_LINES < QuoteFile.FileLines-1) { QuoteBrowseLine+=QUOTE_DISPLAY_LINES-3; if (QuoteBrowseLine+QUOTE_DISPLAY_LINES >= QuoteFile.FileLines) QuoteBrowseLine=QuoteFile.FileLines-1-QUOTE_DISPLAY_LINES; ShowQuotePage(&QuoteFile); } break; // NOTE: EnhancedMode must be on for these keys // // to be generated. InputNumber translates these // // keys into PGUP and PGDN for non enhanced mode // // users. // case KB_UP: if (QuoteBrowseLine>0) { QuoteBrowseLine--; IO->EANSI_ScrollRegionDown(); IO->MoveTo(0, QUOTE_TOP_LINE); ShowLine(QuoteFile.GetLine(QuoteBrowseLine)); } break; case KB_DOWN: if (QuoteBrowseLine+QUOTE_DISPLAY_LINES < QuoteFile.FileLines-1) { QuoteBrowseLine++; IO->EANSI_ScrollRegionUp(); IO->MoveTo(0, QUOTE_TOP_LINE+QUOTE_DISPLAY_LINES); ShowLine(QuoteFile.GetLine(QuoteBrowseLine+QUOTE_DISPLAY_LINES)); } } } if (QuoteAction==DO_QUOTE) { LineStruct *NewMainLine; int j; for(i=atoi(QuoteData[FROM])-1;i<=atoi(QuoteData[TO])-1;i++) { NewMainLine=MainFile->MakeNewLine(LineNumber); Line=QuoteFile.GetLine(i); for(j=3;j<Line->Length;j++) { NewMainLine->Text[j-3]=Line->Text[j]; NewMainLine->Color[j-3]=Line->Color[j]; NewMainLine->Length=Line->Length-3; } LineNumber++; } NewMainLine=MainFile->MakeNewLine(LineNumber); NewMainLine->Length=0; } }
int ESvnBase::Activate (int No) { ShowLine (View,No); return 1; }
int SearchRoot (int depth, int alpha, int beta) /************************************************************************** * * This perform searches at ply=1. For ply>1, it calls the more generic * search() routine. The rationale for splitting these is because at * ply==1, things are done slightly differently than from the other plies, * e.g. print PVs, not testing null move etc. * **************************************************************************/ { int best, score, savealpha; int side, xside; int ply, nodetype; leaf *p, *pbest; ply = 1; side = board.side; xside = 1^side; ChkCnt[2] = ChkCnt[1]; ThrtCnt[2] = ThrtCnt[1]; KingThrt[white][ply] = MateScan (white); KingThrt[black][ply] = MateScan (black); InChk[ply] = SqAtakd (board.king[side], xside); if (InChk[ply] && ChkCnt[ply] < 3*Idepth/DEPTH) { ChkExtCnt++; ChkCnt[ply+1]++; depth += DEPTH; } best = -INFINITY; savealpha = alpha; nodetype = PV; pbest = NULL; for (p = TreePtr[1]; p < TreePtr[2]; p++) { pick (p, 1); ShowThinking (p, ply); MakeMove (side, &p->move); NodeCnt++; /* If first move, search against full alpha-beta window */ if (p == TreePtr[1]) { score = -Search (2, depth-DEPTH, -beta, -alpha, nodetype); /* The following occurs when we are re-searching a fail high move and now it has fail low. This can be disastrous, so immediately adjust alpha and research. */ if (beta == INFINITY && score <= alpha) { alpha = -INFINITY; score = -Search (2, depth-DEPTH, -beta, -alpha, nodetype); } } /* Else search against zero window */ else { nodetype = CUT; alpha = MAX (best, alpha); score = -Search (2, depth-DEPTH, -alpha-1, -alpha, nodetype); if (score > best) { if (alpha < score && score < beta) { nodetype = PV; score = -Search (2, depth-DEPTH, -beta, -score, nodetype); } } } UnmakeMove (xside, &p->move); ply1score = p->score = score; if (score > best) { best = score; pbest = p; if (best > alpha) { rootscore = best; RootPV = p->move; if (best >= beta) goto done; ShowLine (RootPV, best, '&'); } } if (flags & TIMEOUT) { /* XXX: It seems that ply == 1 always at this point */ best = (ply & 1 ? rootscore : -rootscore ); return (best); } if (SearchDepth == 0 && (NodeCnt & TIMECHECK) == 0) { GetElapsed (); if ((et >= SearchTime && (rootscore == -INFINITY-1 || ply1score > lastrootscore - 25 || flags & SOLVE)) || et >= maxtime) SET (flags, TIMEOUT); } if (MATE+1 == best+1) return (best); } /* If none of the move is good, we still want to try the same first move */ if (best <= savealpha) TreePtr[1]->score = savealpha; /***************************************************************************** * * Out of main search loop. * *****************************************************************************/ done: /* Update history */ if (best > savealpha) history[side][pbest->move & 0x0FFF] += HISTSCORE(depth/DEPTH); rootscore = best; return (best); }
USHORT ECC_FTPGetFileShowStatusForTest(STR *title,STR *ip,STR *id,STR *pw,STR * Localfilename, STR * Remofilename,BYTE isSSL) { CURL *curl; CURLcode res; double totaltime,filesize; BYTE statusline2[64]; struct FtpFile ftpfile={ "tmpfile", /* name to store the file as if succesful */ NULL }; CTOS_LCDSelectMode(d_LCD_TEXT_320x240_MODE); CTOS_LCDGClearCanvas(); ShowTitle(title); ShowLine(0,40+16,Big_Font_Size,"資料下載中.",FALSE); ShowLine(0,40+40+16+10,Med_Font_Size,"下載進度",FALSE); curl_global_init(CURL_GLOBAL_DEFAULT); BYTE processstr[32]; curl = curl_easy_init(); if(curl) { BYTE URL[128]; BYTE IDPW[64]; BYTE DNS[64]; BYTE *errstr; memset(URL,0x00,sizeof(URL)); sprintf(URL,"FTPS://%s%s",ip,Remofilename); memset(IDPW,0x00,sizeof(IDPW)); sprintf(IDPW,"%s:%s",id,pw); curl_easy_setopt(curl, CURLOPT_URL,URL); curl_easy_setopt(curl, CURLOPT_USERPWD,IDPW); /* Define our callback to get called when there's data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); BYTE len=sizeof(DNS); USHORT ret = CTOS_EthernetConfigGet(d_ETHERNET_CONFIG_DNSIP, DNS,&len); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 1024L*1000); curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, 600); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 600); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 600); curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, DNS); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); /* Switch on full protocol/debug output */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); if(CURLE_OK != res) { /* we failed */ errstr=(BYTE*)curl_easy_strerror(res); ErrorMessageBox(gTransTitle,"錯誤訊息",errstr,"","",d_MB_CHECK); CTOS_PrinterPutString (errstr); SystemLog("ECC_FTPGetFile",errstr); return res; } res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize); if((CURLE_OK == res) && (filesize>0.0)) { sprintf(statusline2,"filesize : %0.0f bytes", filesize); ShowLine(0,40+40+40+16+10,Med_Font_Size,statusline2,FALSE); CTOS_PrinterPutString (statusline2); } res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &totaltime); if((CURLE_OK == res) && (totaltime>0.0)) { sprintf(statusline2,"totaltime : %0.0f sec", totaltime); ShowLine(0,40+40+40+40+16+10,Med_Font_Size,statusline2,FALSE); CTOS_PrinterPutString (statusline2); } } //curl_easy_cleanup(curl); curl_global_cleanup(); CTOS_Delay(2000); return d_OK; }
USHORT ECC_FTPGetFileShowStatus_S(STR *ip,STR *id,STR *pw,STR * Localfilename, STR * Remofilename,BYTE isSSL) { CURL *curl; CURLcode res; double filesize = 0.0; double totaltime = 0.0; BYTE statusline2[64]; struct FtpFile ftpfile={ "tmpfile", /* name to store the file as if succesful */ NULL }; CTOS_LCDSelectMode(d_LCD_TEXT_320x240_MODE); CTOS_LCDGClearCanvas(); ShowTitle(gTransTitle); ShowLine(0,40+16,Big_Font_Size,"資料下載中.",FALSE); ShowLine(0,40+40+16+10,Med_Font_Size,"下載進度",FALSE); curl_global_init(CURL_GLOBAL_DEFAULT); BYTE processstr[32]; USHORT ret= Eth_Connect(bgNETWORKChannel,ip,990); curl_socket_t sockfd=Socketfd; curl = curl_easy_init(); if(curl) { BYTE URL[128]; BYTE IDPW[64]; BYTE DNS[64]; BYTE *errstr; memset(URL,0x00,sizeof(URL)); sprintf(URL,"FTPS://%s%s",ip,Remofilename); memset(IDPW,0x00,sizeof(IDPW)); sprintf(IDPW,"%s:%s",id,pw); curl_easy_setopt(curl, CURLOPT_URL,URL); curl_easy_setopt(curl, CURLOPT_USERPWD,IDPW); /* Define our callback to get called when there's data to be written */ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, my_fwrite); /* Set a pointer to our struct to pass to the callback */ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ftpfile); BYTE len=sizeof(DNS); USHORT ret = CTOS_EthernetConfigGet(d_ETHERNET_CONFIG_DNSIP, DNS,&len); curl_easy_setopt(curl, CURLOPT_NOSIGNAL, 1); /* call this function to get a socket */ curl_easy_setopt(curl, CURLOPT_OPENSOCKETFUNCTION, opensocket); curl_easy_setopt(curl, CURLOPT_OPENSOCKETDATA, &sockfd); /* call this function to set options for the socket */ curl_easy_setopt(curl, CURLOPT_SOCKOPTFUNCTION, sockopt_callback); curl_easy_setopt(curl, CURLOPT_BUFFERSIZE, 2024L); curl_easy_setopt(curl, CURLOPT_FTP_RESPONSE_TIMEOUT, 10); curl_easy_setopt(curl, CURLOPT_CONNECTTIMEOUT, 3); curl_easy_setopt(curl, CURLOPT_TIMEOUT, 600); curl_easy_setopt(curl, CURLOPT_FTP_USE_EPSV, 0L); curl_easy_setopt(curl, CURLOPT_DNS_SERVERS, DNS); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL); curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L); curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, my_progress_func); /* Switch on full protocol/debug output */ curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); res = curl_easy_perform(curl); if(CURLE_OK != res) { /* we failed */ errstr=(char*)curl_easy_strerror(res); ErrorMessageBox(gTransTitle,"錯誤訊息",errstr,"","",d_MB_CHECK); SystemLog("ECC_FTPGetFile",errstr); return d_Fail; } res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &filesize); if((CURLE_OK == res) && (filesize>0.0)) { sprintf(statusline2,"filesize : %0.0f bytes\n", filesize); ShowLine(0,40+40+40+16+10,Med_Font_Size,statusline2,FALSE); } res = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &totaltime); if((CURLE_OK == res) && (totaltime>0.0)) { sprintf(statusline2,"totaltime : %0.0f sec\n", totaltime); ShowLine(0,40+40+40+40+16+10,Med_Font_Size,statusline2,FALSE); } } if(ftpfile.stream) fclose(ftpfile.stream); /* close the local file */ // rename(ftpfile.filename,Localfilename); ULONG lsize=File_GetLen((char *)ftpfile.filename); if(lsize<=0) return d_Fail; remove(Localfilename); int iret= copyFiles((char *)ftpfile.filename, Localfilename); remove(ftpfile.filename); /* always cleanup */ curl_easy_cleanup(curl); curl_global_cleanup(); CTOS_Delay(2000); return d_OK; }
void OutputCtrl::AppendText( const wxString& text ) { SetReadOnly( false ); bool scrollEnd = false; int pos = GetLength(); if ( GetCurrentPos() == pos && GetAnchor() == pos ) scrollEnd = true; // For each line... const wxChar* ptr = text.c_str(); const wxChar* const end = ptr + text.Length(); const wxChar* next; wxString line; bool isError = false; bool isWarn = false; //wxTextAttr errorStyle( *wxRED, *wxWHITE ); //wxTextAttr warnStyle( *wxRED, *wxWHITE ); //wxColour( 255, 128, 0 ), *wxWHITE ); long lnumb; while( ptr != end ) { wxASSERT( ptr < end ); next = std::find( ptr, end, '\n' ); if ( next != end ) ++next; line.assign( ptr, next ); ptr = next; // Look for error lines and highlight them... // // TODO: I need to optimize the regex here... maybe i // shouldn't use a regex, but use my own logic to spot // errors... could be much faster. // if ( m_ErrorExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isError = true; else if ( m_WarnExpr.Matches( line ) && m_ErrorExpr.GetMatchCount() > 3 ) isWarn = true; pos = GetLength(); SetTargetStart( pos ); SetTargetEnd( pos ); ReplaceTarget( line ); if ( isError ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, errorStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_ErrorExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_ErrorExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_ErrorExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = false; AddError( error ); isError = false; } else if ( isWarn ) { StartStyling( pos, 0xFF ); SetStyling( line.Len(), 2 ); // TODO: SetStyle will screw with the current scroll position. The // trick is to disable ECO_AUTOVSCROLL and ECO_AUTOHSCROLL before // changing the selection to change the style. We need to submit this // fix back to wxWindows. //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_XOR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); //SetStyle( start, last, warnStyle ); //::SendMessage( GetHwnd(), EM_SETOPTIONS, ECOOP_OR, ECO_AUTOVSCROLL | ECO_AUTOHSCROLL ); // Add the error to the debugger state. m_WarnExpr.GetMatch( line, 2 ).ToLong( &lnumb ); ScriptError* error = new ScriptError; error->file = m_WarnExpr.GetMatch( line, 1 ); error->line = lnumb; error->start = pos; error->end = pos + line.Len(); error->row = LineFromPosition( pos ); error->error = m_WarnExpr.GetMatch( line, 3 ); error->error.Trim(); error->warning = true; AddError( error ); isWarn = false; } } if ( scrollEnd ) { const int endPos = GetLength(); SetAnchor( endPos ); SetCurrentPos( endPos ); ShowLine( LineFromPosition( endPos ) ); } EmptyUndoBuffer(); SetReadOnly( true ); }