// Look for line number after filename in the form of FILE.EXT:NNN static void ParseLineNumberFromFilename(FXString &filename, FXString &line) { #ifdef WIN32 // Ignore colon in drive spec on WIN32 FXint colons=filename.contains(':'); if (FXPath::isAbsolute(filename)) { if (colons>1) { line=filename.section(':',2); filename=filename.section(':',0,2); } } else { if (colons>0) { line=filename.section(':',1) ; filename=filename.section(':',0); } } #else if (filename.contains(':')) { line=filename.section(':',1) ; filename=filename.section(':',0); } #endif for (FXint i=0; i<line.length(); i++) { if (!Ascii::isDigit(line[i])) { // If it's not all digits, forget it. line=FXString::null; break; } } }
// Remove anything containing a colon : from the beginning of the string. // Returns number of colons removed. FXint TagParserBase::StripNamespace(FXString &s) { FXint rv=s.contains(':'); if (rv) { s.erase(0,s.rfind(':')+1); } return rv; }
static void SaveSysIncPaths(FXSettings*reg) { reg->deleteSection(sysincs_sect); int n=SysIncs.contains('\n'); if (n>MAX_SYSINC_PATHS) { n=MAX_SYSINC_PATHS; } for (int i=0; i<n; i++) { const FXString value=SysIncs.section('\n',i); if (!value.empty()) { char key[16]; snprintf(key, sizeof(key)-1 ,"Path_%d", i+1); reg->writeStringEntry(sysincs_sect,key,value.text()); } } }
// Look for file in system include directories static bool OpenSystemIncludeFile(SciDoc*sci, const FXString &filename, const FXString &line) { const FXString paths=Settings::SystemIncludePaths(); for (FXint i=0; i<paths.contains('\n'); i++) { FXString fullpath=paths.section('\n',i); if (fullpath.empty()) { continue; } fullpath+=PATHSEPSTRING; fullpath+=filename; if (FXStat::exists(fullpath)) { TopWinPub::OpenFile(fullpath.text(),line.text(),false,true); return true; } } return false; }
void CmdIO::appendLine(FXString&s, FXSelector selid) { if (target&&message) { FXint nlines=s.contains('\n'); FXString trailer=s.section('\n', nlines); s.trunc(s.length()-trailer.length()); if (multiline_mode) { target->handle(this, FXSEL(selid,message), (void*)(&s)); } else { for (FXint i=0; i<nlines; i++) { FXString sect=s.section('\n',i); target->handle(this, FXSEL(selid,message), (void*)(§)); } } s=trailer; } }
// Check for an already-selected filename static void GetFilenameFromSelection(FXMainWindow*tw,SciDoc*sci, FXString &filename) { #ifdef WIN32 sci->GetSelText(filename); #else // On X11 platforms, try first to get a filename from the X-Selection FXuchar*xsel=NULL; FXuint xlen=0; FXDragType types[] = { tw->textType, tw->utf8Type, tw->stringType, 0 }; for ( FXDragType*type=types; *type; type++ ) { if (tw->getDNDData(FROM_SELECTION,*type, xsel, xlen) && xsel && *xsel) { FXuchar*eol=(FXuchar*)memchr(xsel,'\n', xlen); FXuint n = eol ? (eol-xsel) : xlen; filename.assign((FXchar*)xsel,n); filename=filename.simplify(); if (!FXStat::exists(filename.contains(':')?filename.section(':',0):filename)) { filename=FXString::null; } break; } if ( filename.empty() ) { sci->GetSelText(filename); } } #endif }
/** The text entered in the command textfield is sent (enter key pressed) * * * \param o A parameter used for FOX callbacks * \param s A parameter used for FOX callbacks * \param v The text comming from the command textfield * * \return Always 1 * */ long RainbruRPG::Gui::FtpClientWindow:: treatNewCommand(FXObject* o,FXSelector s,void* v){ FXString str; str=(FX::FXchar*)v; FXString filename=(FX::FXchar*)v; // If the entered text is not empty if (!str.empty()){ fxText->appendText( "> " ); fxText->appendText( str ); fxText->appendText( "\n" ); FXTextField* a=(FXTextField*)o; a->setText(""); str=str.upper(); if (str.contains("HELP")!=0){ if (str.contains("USER")!=0){ showHelpUser(); } else if (str.contains("PASS")!=0){ showHelpPass(); } else if (str.contains("PASV")!=0){ showHelpPasv(); } else if (str.contains("PWD")!=0){ showHelpPwd(); } else if (str.contains("LIST")!=0){ showHelpList(); } else if (str.contains("SYST")!=0){ showHelpSyst(); } else if (str.contains("BINARY")!=0){ showHelpBinary(); } else if (str.contains("ASCII")!=0){ showHelpAscii(); } else if (str.contains("STOR")!=0){ showHelpStore(); } else if (str.contains("RETR")!=0){ showHelpRetrieve(); } else{ onHelp(NULL,0,NULL); } } else if (str.contains("LIST")!=0){ string s=ftpClient->commandLIST(); FXString str=s.c_str(); str.substitute('\r', ' ', true ); logMessage(str); } else if (str.contains("PASV")!=0){ ftpClient->toggleTransferMode(); string s=ftpClient->waitControlResponse(); logMessage(s.c_str()); } else if (str.contains("PWD")!=0){ string s=ftpClient->commandPWD(); logMessage(s.c_str()); } else if (str.contains("SYST")!=0){ string s=ftpClient->commandSYST(); logMessage(s.c_str()); } else if (str.contains("BINARY")!=0){ string s=ftpClient->commandBINARY(); logMessage(s.c_str()); } else if (str.contains("ASCII")!=0){ string s=ftpClient->commandASCII(); logMessage(s.c_str()); } else if (str.contains("STOR")!=0){ // because str is in UPPER case // I get the no-upper string int pos = str.find("STOR", 0); filename.erase( pos, 5 ); LOGCATS("Filename :"); LOGCATS(filename.text()); LOGCAT(); std::string fn(filename.text()); // Get filename int filesize=ftpClient->getFilesize(fn); labTrPb->setTotal(filesize); // Change transfer information labTransName->setText(filename); labTransOrie->setText("Out"); labTransSize->setText(filesizeToString(filesize)); string s=ftpClient->commandSTOR(fn); logMessage(s.c_str()); } else if (str.contains("RETR")!=0){ // because str is in UPPER case // I get the no-upper string int pos = str.find("RETR", 0); filename.erase( pos, 5 ); LOGCATS("Filename :"); LOGCATS(filename.text()); LOGCAT(); std::string fn(filename.text()); // Change transfer information labTransName->setText(filename); labTransOrie->setText("In"); string s=ftpClient->commandRETR(fn); logMessage(s.c_str()); } else{ logMessage("Unknown command"); } } scrollDown(); return 1; }