int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ) { wchar_t buf0[MAX_PATH]; GetModuleFileNameW(NULL, buf0, MAX_PATH-1); lString16 str016(buf0); #ifdef _UNICODE lString16 str116(lpCmdLine); #else lString8 str18(lpCmdLine); lString16 str116 = LocalToUnicode(str18); #endif lString8 str0 = UnicodeToUtf8(str016); lString8 str1 = UnicodeToUtf8(str116); if ( !str1.empty() && str1[0]=='\"' ) { // quoted filename support str1.erase(0, 1); int pos = str1.pos(lString8("\"")); if ( pos>=0 ) str1 = str1.substr(0, pos); } char * argv[2]; argv[0] = str0.modify(); argv[1] = str1.modify(); int argc = str1.empty() ? 1 : 2; return main(argc, argv); }
BOOL CSpecialApp::CleanKugooEx(CString strFileName, CString strTable) { BOOL bRet = FALSE; CString strFileNameEx; CString strTableEx; strFileNameEx = strFileName; strTableEx = strTable; std::string szFileName; std::string szTable; szTable =UnicodeToUtf8(strTableEx.GetBuffer()); strTableEx.ReleaseBuffer(); szFileName = UnicodeToUtf8(strFileNameEx.GetBuffer()); strFileNameEx.ReleaseBuffer(); sqlite3* pDB = NULL; sqlite3_stmt* sspStart = NULL; char szSql[MAX_PATH] = {0}; int nResult = sqlite3_open(szFileName.c_str(), &pDB); if (nResult != SQLITE_OK) { goto clean0; } if (szTable.empty()) goto clean0; sprintf_s(szSql, "select * from %s", szTable.c_str()); nResult = sqlite3_prepare(pDB, szSql, -1, &sspStart, 0); if (nResult != SQLITE_OK) { goto clean0; } nResult = sqlite3_step(sspStart); if(nResult == SQLITE_ROW) { CString strOutPut = strFileName; strOutPut += L"|"; strOutPut += strTable; g_fnScanFile(g_pMain, 9010, strOutPut, 0, 0); bRet = TRUE; } clean0: if (sspStart) { sqlite3_finalize(sspStart); sspStart = NULL; } if (pDB) { sqlite3_close(pDB); pDB = NULL; } return bRet; }
BOOL CKSogoClean::ScanDbTable(std::wstring strFileName, std::wstring strTable, int nType) { BOOL bRet = FALSE; sqlite3* pDb = NULL; sqlite3_stmt* sspStart = NULL; int nResult = -1; std::string szFileName; std::string szTable; char szSql[MAX_PATH] = {0}; szFileName = UnicodeToUtf8(strFileName); szTable = UnicodeToUtf8(strTable); nResult = sqlite3_open(szFileName.c_str(), &pDb); if (nResult != SQLITE_OK) { bRet = FALSE; goto clean0; } if (szTable.empty()) goto clean0; sprintf_s(szSql, MAX_PATH - 1, "select * from %s", szTable.c_str()); nResult = sqlite3_prepare(pDb, szSql, -1, &sspStart, 0); if (nResult != SQLITE_OK) { bRet = FALSE; goto clean0; } nResult = sqlite3_step(sspStart); if (nResult == SQLITE_ROW) { std::wstring strOutput; strOutput = strFileName; strOutput += L"|"; strOutput += strTable; g_fnScanFile(g_pMain, nType, strOutput.c_str(), 0, 0); } clean0: if (sspStart) { sqlite3_finalize(sspStart); sspStart = NULL; } if (pDb) { sqlite3_close(pDb); pDb = NULL; } return bRet; }
// 保存杂项配置 BOOL SaveMiscConfig(LPCTSTR lpszFileName) { unsigned char cUtf8Header[3] = {0xEF,0xBB,0xBF}; const wchar_t * lpFontFmt = _T("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Misc>\r\n<!--字体信息-->\r\n<FontInfo Name=\"%s\" Size=\"%d\" Color=\"%s\" Bold=\"%d\" Italic=\"%d\" UnderLine=\"%d\"></FontInfo>\r\n<!--提取消息热键,目前只支持Ctrl+Alt+某键-->\r\n<HotKey>%c</HotKey>\r\n</Misc>\r\n"); if (NULL == lpszFileName) return FALSE; FILE * fp = _tfopen(lpszFileName, _T("wb")); if (NULL == fp) return FALSE; wchar_t szColor[32] = {0}; RGBToHexStr(g_fontInfo.m_clrText, szColor, sizeof(szColor)/sizeof(WCHAR)); wchar_t szBuf[4096] = {0}; wsprintf(szBuf, lpFontFmt, g_fontInfo.m_strName.c_str(), g_fontInfo.m_nSize, szColor, g_fontInfo.m_bBold, g_fontInfo.m_bItalic, g_fontInfo.m_bUnderLine, g_cHotKey); char * lpBuf = UnicodeToUtf8(szBuf); if (NULL == lpBuf) { fclose(fp); return FALSE; } fwrite(cUtf8Header, 3, 1, fp); fwrite(lpBuf, strlen(lpBuf), 1, fp); fclose(fp); delete []lpBuf; return TRUE; }
static lString8 encodeText(lString16 text16) { if (text16.empty()) return lString8::empty_str; lString8 text = UnicodeToUtf8(text16); lString8 buf; for (int i=0; i<text.length(); i++) { char ch = text[i]; switch (ch) { case '\\': buf << "\\\\"; break; case '\n': buf << "\\n"; break; case '\r': buf << "\\r"; break; case '\t': buf << "\\t"; break; default: buf << ch; break; } } return buf; }
bool getDirectoryFonts( lString16Collection & pathList, lString16 ext, lString16Collection & fonts, bool absPath ) { int foundCount = 0; lString16 path; for (int di=0; di<pathList.length();di++ ) { path = pathList[di]; LVContainerRef dir = LVOpenDirectory(path.c_str()); if(!dir.isNull()) { CRLog::trace("Checking directory %s", UnicodeToUtf8(path).c_str() ); for(int i=0; i < dir->GetObjectCount(); i++ ) { const LVContainerItemInfo * item = dir->GetObjectInfo(i); lString16 fileName = item->GetName(); if ( !item->IsContainer() && fileName.length()>4 && lString16(fileName, fileName.length()-4, 4)==ext ) { lString16 fn; if ( absPath ) { fn = path; if (!fn.empty() && fn[fn.length()-1]!=PATH_SEPARATOR_CHAR) fn << PATH_SEPARATOR_CHAR; } fn << fileName; foundCount++; fonts.add(fn); } } } } return foundCount > 0; }
jboolean initInternal(JNIEnv * penv, jclass obj, jobjectArray fontArray) { CRJNIEnv env(penv); // to catch crashes and remove current cache file on crash (SIGSEGV etc.) crSetSignalHandler(); LOGI("initInternal called"); // set fatal error handler crSetFatalErrorHandler( &cr3androidFatalErrorHandler ); LOGD("Redirecting CDRLog to Android"); CRLog::setLogger( new JNICDRLogger() ); CRLog::setLogLevel( CRLog::LL_TRACE ); CRLog::info("CREngine log redirected"); CRLog::info("CRENGINE version %s %s", CR_ENGINE_VERSION, CR_ENGINE_BUILD_DATE); CRLog::info("initializing hyphenation manager"); HyphMan::initDictionaries(lString16::empty_str); //don't look for dictionaries HyphMan::activateDictionary(lString16(HYPH_DICT_ID_NONE)); CRLog::info("creating font manager"); InitFontManager(lString8::empty_str); CRLog::debug("converting fonts array: %d items", (int)env->GetArrayLength(fontArray)); lString16Collection fonts; env.fromJavaStringArray(fontArray, fonts); int len = fonts.length(); CRLog::debug("registering fonts: %d fonts in list", len); for ( int i=0; i<len; i++ ) { lString8 fontName = UnicodeToUtf8(fonts[i]); CRLog::debug("registering font %s", fontName.c_str()); if ( !fontMan->RegisterFont( fontName ) ) CRLog::error("cannot load font %s", fontName.c_str()); } CRLog::info("%d fonts registered", fontMan->GetFontCount()); return fontMan->GetFontCount() ? JNI_TRUE : JNI_FALSE; }
CString& StrToUtf8Hex(const TCHAR* src, CString& strDec) { char* t = nullptr; WCHAR* temp = nullptr; int src_length = 0; strDec.Empty(); #ifndef UNICODE MbcsToUnicode(src, &temp, src_length); #else temp = (TCHAR*)src; #endif UnicodeToUtf8(temp, &t, src_length); src_length -= 1; for(int i = 0; i < src_length; ++i) { TCHAR tc[3] = {0, 0, 0}; VALUETODOUBLECHAR(tc, t[i]); strDec += tc; } #ifndef UNICODE delete[] temp; #endif delete[] t; return strDec; }
/* * Class: org_coolreader_crengine_Engine * Method: initInternal * Signature: ([Ljava/lang/String;)Z */ JNIEXPORT jboolean JNICALL Java_org_coolreader_crengine_Engine_initInternal (JNIEnv * penv, jobject obj, jobjectArray fontArray) { CRJNIEnv env(penv); LOGI("initInternal called"); // set fatal error handler crSetFatalErrorHandler( &cr3androidFatalErrorHandler ); LOGD("Redirecting CDRLog to Android"); CRLog::setLogger( new JNICDRLogger() ); CRLog::setLogLevel( CRLog::LL_TRACE ); CRLog::info("CREngine log redirected"); CRLog::info("initializing hyphenation manager"); HyphMan::initDictionaries(lString16()); //don't look for dictionaries HyphMan::activateDictionary(lString16(HYPH_DICT_ID_NONE)); CRLog::info("creating font manager"); InitFontManager(lString8()); CRLog::debug("converting fonts array: %d items", (int)env->GetArrayLength(fontArray)); lString16Collection fonts; env.fromJavaStringArray(fontArray, fonts); int len = fonts.length(); CRLog::debug("registering fonts: %d fonts in list", len); for ( int i=0; i<len; i++ ) { lString8 fontName = UnicodeToUtf8(fonts[i]); CRLog::debug("registering font %s", fontName.c_str()); if ( !fontMan->RegisterFont( fontName ) ) CRLog::error("cannot load font %s", fontName.c_str()); } CRLog::info("%d fonts registered", (int)fontMan->GetFontCount()); return fontMan->GetFontCount() ? JNI_TRUE : JNI_FALSE; }
inline void Encode(Unicode::const_iterator begin, Unicode::const_iterator end, string& res) { #ifdef CPPJIEBA_GBK gbkTrans(begin, end, res); #else UnicodeToUtf8(begin, end, res); #endif }
bool V3DocViewWin::loadHistory( lString16 filename ) { CRLog::trace("V3DocViewWin::loadHistory( %s )", UnicodeToUtf8(filename).c_str()); _historyFileName = filename; LVStreamRef stream = LVOpenFileStream( filename.c_str(), LVOM_READ ); return loadHistory( stream ); }
/// format detection finished void V3DocViewWin::OnLoadFileFormatDetected( doc_format_t fileFormat ) { CRLog::trace("OnLoadFileFormatDetected(%d)", (int)fileFormat); lString16 filename = L"fb2.css"; if ( _cssDir.length() > 0 ) { switch ( fileFormat ) { case doc_format_txt: filename = L"txt.css"; break; case doc_format_rtf: filename = L"rtf.css"; break; case doc_format_epub: filename = L"epub.css"; break; case doc_format_html: filename = L"htm.css"; break; case doc_format_chm: filename = L"chm.css"; break; default: // do nothing ; } CRLog::debug( "CSS file to load: %s", UnicodeToUtf8(filename).c_str() ); if ( LVFileExists( _cssDir + filename ) ) { loadCSS( _cssDir + filename ); } else if ( LVFileExists( _cssDir + L"fb2.css" ) ) { loadCSS( _cssDir + L"fb2.css" ); } } }
IMAGELIB_ERROR_CODE imagelib_save_frame_to_file_asyn(IMAGELIB_SESSION*_session,IMAGELIB_RECT _src_rect, const WCHAR* _dest_pathname,INT32 _dest_width,INT32 _dest_height, IMAGELIB_EFFECT_PARA _effect_para,DECODE_FRAME_ENDING_CB cb) { IMAGE_INSTANCE *decoder_instance,*encoder_instance=NULL; IMAGELIB_MSG_PARA_LIST* para_list = NULL; char utf_pathname[UTA_MAX_PATHNAME_LEN*2+1]; if(_session == NULL || _session->instance_p == NULL) { return IMAGELIB_RAM_EXECPTION; } wait_sem(_session->decode_sem); if(_session ->state == IMAGELIB_DECODING) { signal_sem(_session->decode_sem); return IMAGELIB_CURRENT_SESSION_BUSY; } decoder_instance = _session->instance_p; UnicodeToUtf8(utf_pathname,_dest_pathname); _session->error_code=image_open_by_filename(utf_pathname, "wb",NULL,&encoder_instance); if(_session->error_code != IMAGELIB_SUCCESS || encoder_instance==NULL) { signal_sem(_session->decode_sem); return _session->error_code; } _session ->state = IMAGELIB_DECODING; para_list = imagelib_copy_msg_paralist(IMAGELIB_SAVEFRAMEDATA_MSG,_session,decoder_instance,encoder_instance,_src_rect,_dest_width,_dest_height,_effect_para,cb); imagelib_postworkmessage(¶_list); signal_sem(_session->decode_sem); return _session->error_code; }
/* * Class: org_coolreader_crengine_Engine * Method: drawBookCoverInternal * Signature: (Landroid/graphics/Bitmap;[BLjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;II)V */ JNIEXPORT void JNICALL Java_org_coolreader_crengine_Engine_drawBookCoverInternal (JNIEnv * _env, jobject _engine, jobject bitmap, jbyteArray _data, jstring _fontFace, jstring _title, jstring _authors, jstring _seriesName, jint seriesNumber, jint bpp) { CRJNIEnv env(_env); //CRLog::debug("drawBookCoverInternal called"); lString8 fontFace = UnicodeToUtf8(env.fromJavaString(_fontFace)); lString16 title = env.fromJavaString(_title); lString16 authors = env.fromJavaString(_authors); lString16 seriesName = env.fromJavaString(_seriesName); LVStreamRef stream; LVImageSourceRef image; if (_data != NULL && _env->GetArrayLength(_data) > 0) { stream = env.jbyteArrayToStream(_data); if (!stream.isNull()) image = LVCreateStreamImageSource(stream); } LVDrawBuf * drawbuf = BitmapAccessorInterface::getInstance()->lock(_env, bitmap); if (drawbuf != NULL) { int factor = 1; int dx = drawbuf->GetWidth(); int dy = drawbuf->GetHeight(); int MIN_WIDTH = 300; int MIN_HEIGHT = 400; if (dx < MIN_WIDTH || dy < MIN_HEIGHT) { if (dx * 2 < MIN_WIDTH || dy * 2 < MIN_HEIGHT) { dx *= 3; dy *= 3; factor = 3; } else { dx *= 2; dy *= 2; factor = 2; } } LVDrawBuf * drawbuf2 = drawbuf; if (factor > 1) drawbuf2 = new LVColorDrawBuf(dx, dy, drawbuf->GetBitsPerPixel()); if (bpp >= 16) { // native color resolution LVDrawBookCover(*drawbuf2, image, fontFace, title, authors, seriesName, seriesNumber); } else { LVGrayDrawBuf grayBuf(drawbuf2->GetWidth(), drawbuf2->GetHeight(), bpp); LVDrawBookCover(grayBuf, image, fontFace, title, authors, seriesName, seriesNumber); grayBuf.DrawTo(drawbuf2, 0, 0, 0, NULL); } if (factor > 1) { drawbuf->DrawRescaled(drawbuf2, 0, 0, drawbuf->GetWidth(), drawbuf->GetHeight(), 0); delete drawbuf2; } //CRLog::trace("getPageImageInternal calling bitmap->unlock"); BitmapAccessorInterface::getInstance()->unlock(_env, bitmap, drawbuf); } else { CRLog::error("bitmap accessor is invalid"); } //CRLog::debug("drawBookCoverInternal finished"); }
void AnsiToUtf8(char** dest, const char* src) { ASSERT(dest!= NULL || src != NULL); WCHAR* pwszStr = NULL; C2W(&pwszStr, src); UnicodeToUtf8(dest, pwszStr); SAFE_ARRYDELETE(pwszStr); }
char* Util::String::MbcsToUtf8(const char* pMbcs) { assert(pMbcs); wchar_t* pUnicode = MbcsToUnicode(pMbcs); char*pRet = UnicodeToUtf8(pUnicode); ReleaseData(pUnicode); return pRet; }
void TcharToUtf8(char** dest, const TCHAR* src) { #ifdef _UNICODE UnicodeToUtf8(dest, src); #else AnsiToUtf8(dest, src); #endif }
/* * Class: org_coolreader_crengine_ReaderView * Method: setStylesheet * Signature: (Ljava/lang/String;)V */ JNIEXPORT void JNICALL Java_org_coolreader_crengine_ReaderView_setStylesheetInternal (JNIEnv * _env, jobject _view, jstring jcss) { CRJNIEnv env(_env); ReaderViewNative * p = getNative(_env, _view); DocViewCallback callback( _env, p->_docview, _view ); lString8 css8 = UnicodeToUtf8(env.fromJavaString(jcss)); p->_docview->setStyleSheet(css8); }
static void SetFieldValue( char * dst, lString16 src ) { *dst = 0; if ( src.empty() ) return; lString8 utf8 = UnicodeToUtf8( src ); strncpy( dst, utf8.c_str(), MAX_PROPERTY_LEN-1); dst[MAX_PROPERTY_LEN-1] = 0; }
BOOL CKSogoClean::CleanDbTable(std::wstring strInFile) { BOOL bRet = FALSE; sqlite3* pDb = NULL; std::vector<std::wstring> vec_String; std::string szFileName; std::string szTable; int nResult = -1; char szSql[MAX_PATH] = {0}; char* szError = NULL; if (SplitCString(strInFile, vec_String, L'|') < 2) { bRet = FALSE; goto clean0; } bRet = TRUE; szFileName = UnicodeToUtf8(vec_String[0]); szTable = UnicodeToUtf8(vec_String[1]); nResult = sqlite3_open(szFileName.c_str(), &pDb); if (nResult != SQLITE_OK) { goto clean0; } if(szTable.empty()) goto clean0; sprintf_s(szSql, "delete from %s", szTable.c_str()); nResult = sqlite3_exec(pDb, szSql, 0, 0, &szError); if (nResult != SQLITE_OK) { goto clean0; } clean0: if (pDb) { sqlite3_close(pDb); pDb = NULL; } return bRet; }
BOOL CChromClean::CleanChromCookies(CString& strInPath) { std::wstring strFile; std::wstring strSection; std::string szFile; std::string szSection; int nPos = -1; sqlite3* pDb = NULL; int nResult = -1; char* szError = NULL; char szSql[MAX_PATH] = {0}; nPos = strInPath.Find(L"|"); if (nPos == -1) { return FALSE; } strFile = strInPath.Left(nPos).GetBuffer(); strSection = strInPath.Right(strInPath.GetLength() - nPos - 1).GetBuffer(); szFile = UnicodeToUtf8(strFile); szSection = UnicodeToUtf8(strSection); nResult = sqlite3_open(szFile.c_str(), &pDb); if (nResult != SQLITE_OK) { goto clean0; } if(szSection.empty()) goto clean0; sprintf_s(szSql, "delete from %s", szSection.c_str()); nResult = sqlite3_exec(pDb, szSql, 0, 0, &szError); if (nResult != SQLITE_OK) { goto clean0; } clean0: if (pDb) { sqlite3_close(pDb); pDb = NULL; } return TRUE; }
bool V3DocViewWin::loadDocument( lString16 filename ) { if ( !_docview->LoadDocument( filename.c_str() ) ) { CRLog::error("V3DocViewWin::loadDocument( %s ) - failed!", UnicodeToUtf8(filename).c_str() ); return false; } //_docview->swapToCache(); _docview->restorePosition(); return true; }
std::string AnsiToUtf8(const std::string& strAnsi) { std::string retval; std::wstring strTemp; strTemp = AnsiToUnicode(strAnsi); retval = UnicodeToUtf8(strTemp); return retval; }
static void putTagValue( LVStream * stream, int level, const char * tag, lString16 value ) { for ( int i=0; i<level; i++ ) *stream << " "; *stream << "<" << tag; if ( value.empty() ) { *stream << "/>\r\n"; } else { *stream << ">" << UnicodeToUtf8( value ).c_str() << "</" << tag << ">\r\n"; } }
/// format detection finished virtual void OnLoadFileFormatDetected( doc_format_t fileFormat ) { CRLog::info("DocViewCallback::OnLoadFileFormatDetected() called"); jobject e = _env.enumByNativeId("org/coolreader/crengine/DocumentFormat", (int)fileFormat); jstring css = (jstring)_env->CallObjectMethod(_obj, _OnLoadFileFormatDetected, e); if ( css ) { lString16 s = _env.fromJavaString(css); CRLog::info("OnLoadFileFormatDetected: setting CSS for format %d", (int)fileFormat); _docview->setStyleSheet( UnicodeToUtf8(s) ); } }
IMAGELIB_ERROR_CODE imagelib_getinfo_by_filename(const WCHAR* _pathname,IMAGELIB_INFO* _info) { char utf_pathname[UTA_MAX_PATHNAME_LEN*2]; if(_pathname == NULL) return IMAGELIB_OTHER_ERROR;//return FALSE; UnicodeToUtf8(utf_pathname,_pathname); return image_get_info_by_filename(utf_pathname,_info); //return image_get_info_by_filename(utf_pathname,&_info->m_width,&_info->m_height); }
BOOL AnsiToUtf8(const CHAR * lpszAnsi, CHAR * lpszUtf8, int nLen) { WCHAR * lpszUnicode = AnsiToUnicode(lpszAnsi); if (NULL == lpszUnicode) return FALSE; int nRet = UnicodeToUtf8(lpszUnicode, lpszUtf8, nLen); delete []lpszUnicode; return (0 == nRet) ? FALSE : TRUE; }
void InitCREngineLog( const char * cfgfile ) { if ( !cfgfile ) { CRLog::setStdoutLogger(); CRLog::setLogLevel( CRLog::LL_TRACE ); return; } lString16 logfname; lString16 loglevelstr = #ifdef _DEBUG L"TRACE"; #else L"INFO"; #endif bool autoFlush = false; CRPropRef logprops = LVCreatePropsContainer(); { LVStreamRef cfg = LVOpenFileStream( cfgfile, LVOM_READ ); if ( !cfg.isNull() ) { logprops->loadFromStream( cfg.get() ); logfname = logprops->getStringDef( PROP_LOG_FILENAME, "stdout" ); loglevelstr = logprops->getStringDef( PROP_LOG_LEVEL, "TRACE" ); autoFlush = logprops->getBoolDef( PROP_LOG_AUTOFLUSH, false ); } } CRLog::log_level level = CRLog::LL_INFO; if ( loglevelstr==L"OFF" ) { level = CRLog::LL_FATAL; logfname.clear(); } else if ( loglevelstr==L"FATAL" ) { level = CRLog::LL_FATAL; } else if ( loglevelstr==L"ERROR" ) { level = CRLog::LL_ERROR; } else if ( loglevelstr==L"WARN" ) { level = CRLog::LL_WARN; } else if ( loglevelstr==L"INFO" ) { level = CRLog::LL_INFO; } else if ( loglevelstr==L"DEBUG" ) { level = CRLog::LL_DEBUG; } else if ( loglevelstr==L"TRACE" ) { level = CRLog::LL_TRACE; } if ( !logfname.empty() ) { if ( logfname==L"stdout" ) CRLog::setStdoutLogger(); else if ( logfname==L"stderr" ) CRLog::setStderrLogger(); else CRLog::setFileLogger( UnicodeToUtf8( logfname ).c_str(), autoFlush ); } CRLog::setLogLevel( level ); CRLog::trace("Log initialization done."); }
extern void SDL_ANDROID_MainThreadPushText( int ascii, int unicode ) { int shiftRequired; #if SDL_VERSION_ATLEAST(1,3,0) { char text[32]; UnicodeToUtf8(unicode, text); SDL_SendKeyboardText(text); } #endif if( !deferredTextMutex ) deferredTextMutex = SDL_CreateMutex(); SDL_mutexP(deferredTextMutex); shiftRequired = checkShiftRequired(&ascii); if( shiftRequired ) { deferredTextIdx2++; if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT ) deferredTextIdx2 = 0; deferredText[deferredTextIdx2].down = SDL_PRESSED; deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT; deferredText[deferredTextIdx2].unicode = 0; } deferredTextIdx2++; if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT ) deferredTextIdx2 = 0; deferredText[deferredTextIdx2].down = SDL_PRESSED; deferredText[deferredTextIdx2].scancode = ascii; deferredText[deferredTextIdx2].unicode = unicode; deferredTextIdx2++; if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT ) deferredTextIdx2 = 0; deferredText[deferredTextIdx2].down = SDL_RELEASED; deferredText[deferredTextIdx2].scancode = ascii; deferredText[deferredTextIdx2].unicode = 0; if( shiftRequired ) { deferredTextIdx2++; if( deferredTextIdx2 >= DEFERRED_TEXT_COUNT ) deferredTextIdx2 = 0; deferredText[deferredTextIdx2].down = SDL_RELEASED; deferredText[deferredTextIdx2].scancode = SDLK_LSHIFT; deferredText[deferredTextIdx2].unicode = 0; } SDL_mutexV(deferredTextMutex); }
//TODO: place TinyDictionary to separate file CRTinyDict::CRTinyDict( const lString16& config ) { lString16 path = config; LVAppendPathDelimiter( path ); LVContainerRef dir = LVOpenDirectory( config.c_str() ); if ( !dir ) dir = LVOpenDirectory( LVExtractPath(config).c_str() ); if ( !dir.isNull() ) { int count = dir->GetSize(); lString16 indexExt(".index"); for ( int i=0; i<count; i++ ) { const LVContainerItemInfo * item = dir->GetObjectInfo( i ); if ( !item->IsContainer() ) { lString16 name = item->GetName(); if ( name.endsWith( indexExt ) ) { lString16 nameBase = name.substr( 0, name.length() - indexExt.length() ); lString16 name1 = nameBase + ".dict"; lString16 name2 = nameBase + ".dict.dz"; lString16 dataName; int index = -1; for ( int n=0; n<count; n++ ) { const LVContainerItemInfo * item2 = dir->GetObjectInfo( n ); if ( !item2->IsContainer() ) { if ( item2->GetName() == name1 || item2->GetName() == name2 ) { index = n; dataName = item2->GetName(); break; } } } if ( index>=0 ) { // found pair dicts.add(UnicodeToUtf8(path + name).c_str(), UnicodeToUtf8(path + dataName).c_str()); } } } } } CRLog::info( "%d dictionaries opened", dicts.length() ); }