// Go to next directory entry and return its name FXbool FXDir::next(FXString& name){ if(isOpen()){ #ifdef WIN32 if(((SPACE*)space)->first || FindNextFile(((SPACE*)space)->handle,&((SPACE*)space)->result)){ ((SPACE*)space)->first=false; name.assign(((SPACE*)space)->result.cFileName); return true; } #else #if defined(FOX_THREAD_SAFE) && !defined(__FreeBSD__) && !defined(__OpenBSD__) if(!readdir_r(((SPACE*)space)->handle,&((SPACE*)space)->result,&((SPACE*)space)->dp) && ((SPACE*)space)->dp){ name.assign(((SPACE*)space)->dp->d_name); return true; } #else if((((SPACE*)space)->dp=readdir(((SPACE*)space)->handle))!=NULL){ name.assign(((SPACE*)space)->dp->d_name); return true; } #endif #endif } name.clear(); return false; }
// Somebody wants our clipped text long TextLabel::onClipboardRequest(FXObject* sender,FXSelector sel,void* ptr) { FXEvent *event=(FXEvent*)ptr; FXString string; // Perhaps the target wants to supply its own data for the clipboard if (FXFrame::onClipboardRequest(sender,sel,ptr)) return 1; // Recognize the request? if (event->target==stringType || event->target==textType || event->target==utf8Type || event->target==utf16Type) { // Get clipped string string=clipped; // If password mode, replace by stars if (options&TEXTFIELD_PASSWD) string.assign('*',string.count()); // Return clipped text as as UTF-8 if (event->target==utf8Type) { setDNDData(FROM_CLIPBOARD,event->target,string); return 1; } // Return clipped text translated to 8859-1 if (event->target==stringType || event->target==textType) { FX88591Codec ascii; setDNDData(FROM_CLIPBOARD,event->target,ascii.utf2mb(string)); return 1; } // Return text of the selection translated to UTF-16 if (event->target==utf16Type) { FXUTF16LECodec unicode; // FIXME maybe other endianness for unix setDNDData(FROM_CLIPBOARD,event->target,unicode.utf2mb(string)); return 1; } } return 0; }
// 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 }
// Somebody wants our selection; the text field will furnish it if the target doesn't long TextLabel::onSelectionRequest(FXObject* sender,FXSelector sel,void* ptr) { FXEvent *event=(FXEvent*)ptr; FXString string; FXuint start; FXuint len; // Make sure FXASSERT(0<=anchor && anchor<=contents.length()); FXASSERT(0<=cursor && cursor<=contents.length()); // Perhaps the target wants to supply its own data for the selection if (FXFrame::onSelectionRequest(sender,sel,ptr)) return 1; // Recognize the request? if (event->target==stringType || event->target==textType || event->target==utf8Type || event->target==utf16Type) { // Figure selected bytes if (anchor<cursor) { start=anchor; len=cursor-anchor; } else { start=cursor; len=anchor-cursor; } // Get selected fragment string=contents.mid(start,len); // If password mode, replace by stars if (options&TEXTFIELD_PASSWD) string.assign('*',string.count()); // Return text of the selection as UTF-8 if (event->target==utf8Type) { setDNDData(FROM_SELECTION,event->target,string); return 1; } // Return text of the selection translated to 8859-1 if (event->target==stringType || event->target==textType) { FX88591Codec ascii; setDNDData(FROM_SELECTION,event->target,ascii.utf2mb(string)); return 1; } // Return text of the selection translated to UTF-16 if (event->target==utf16Type) { FXUTF16LECodec unicode; // FIXME maybe other endianness for unix setDNDData(FROM_SELECTION,event->target,unicode.utf2mb(string)); return 1; } } return 0; }