diff --git a/doc.cpp b/doc.cpp index fc5eeb0a..00540a4f 100644 --- a/doc.cpp +++ b/doc.cpp @@ -7659,12 +7659,12 @@ long CMUSHclientDoc::AddSpecialFont (LPCTSTR PathName) return eNoSuchCommand; - // same one again - just leave well enough alone - if (m_strSpecialFontName == PathName) + ci_set::const_iterator iter = m_strSpecialFontName.find (PathName); + + // same one as earlier - just leave well enough alone + if (iter != m_strSpecialFontName.end ()) return eOK; - // get rid of old one, if any - RemoveSpecialFont (); void * pbFont = NULL; @@ -7678,25 +7678,26 @@ long CMUSHclientDoc::AddSpecialFont (LPCTSTR PathName) if (cFonts == 0) return eFileNotFound; - m_strSpecialFontName = PathName; // remember, so we can remove it + m_strSpecialFontName.insert (PathName); // remember, so we can remove it return eOK; } // end of CMUSHclientDoc::AddSpecialFont -void CMUSHclientDoc::RemoveSpecialFont (void) +void CMUSHclientDoc::RemoveSpecialFonts (void) { - if (m_strSpecialFontName.IsEmpty ()) - return; - if (pRemoveFontResourceEx == NULL) return; - void * pbFont = NULL; + for (ci_set::const_iterator iter = m_strSpecialFontName.begin (); iter != m_strSpecialFontName.end (); iter++) + { - pRemoveFontResourceEx (m_strSpecialFontName, // original file name - FR_PRIVATE, // flags - pbFont); // Reserved. Must be 0. - - m_strSpecialFontName.Empty (); + void * pbFont = NULL; + + pRemoveFontResourceEx (iter->c_str (), // original file name + FR_PRIVATE, // flags + pbFont); // Reserved. Must be 0. + } + + m_strSpecialFontName.clear (); } diff --git a/doc.h b/doc.h index 22cc0186..493b5df3 100644 --- a/doc.h +++ b/doc.h @@ -450,6 +450,31 @@ typedef struct typedef map tDatabaseMap; typedef tDatabaseMap::iterator tDatabaseMapIterator; +// case-independent (ci) string less_than +// returns true if s1 < s2 +struct ci_less : binary_function + { + + // case-independent (ci) compare_less binary function + struct nocase_compare : public binary_function + { + bool operator() (const unsigned char& c1, const unsigned char& c2) const + { return tolower (c1) < tolower (c2); } + }; + + bool operator() (const string & s1, const string & s2) const + { + + return lexicographical_compare + (s1.begin (), s1.end (), // source range + s2.begin (), s2.end (), // dest range + nocase_compare ()); // comparison + } + }; // end of ci_less + + +typedef set ci_set; + class ScriptItem { public: @@ -1294,11 +1319,10 @@ class CMUSHclientDoc : public CDocument deque m_sRecentLines; // for multi-line triggers - CString m_strSpecialFontName; - HANDLE m_hSpecialFontHandle; + ci_set m_strSpecialFontName; // all the special fonts we loaded (could be none) long AddSpecialFont (LPCTSTR PathName); - void RemoveSpecialFont (void); + void RemoveSpecialFonts (void); // background image CString m_strBackgroundImageName; diff --git a/doc_construct.cpp b/doc_construct.cpp index b2b5e5f5..1be74649 100644 --- a/doc_construct.cpp +++ b/doc_construct.cpp @@ -63,7 +63,6 @@ int i; m_nBytesIn = 0; m_nBytesOut = 0; m_bTabCompleteFunctions = true; - m_hSpecialFontHandle = 0; m_iTriggersEvaluatedCount = 0; m_iTriggersMatchedCount = 0; @@ -625,7 +624,7 @@ int i; DestroyAcceleratorTable (m_accelerator); // if they loaded a special font, get rid of it - RemoveSpecialFont (); + RemoveSpecialFonts (); #ifdef PANE diff --git a/scripting/methods/methods_info.cpp b/scripting/methods/methods_info.cpp index 77ec54ce..071732e1 100644 --- a/scripting/methods/methods_info.cpp +++ b/scripting/methods/methods_info.cpp @@ -523,7 +523,16 @@ VARIANT CMUSHclientDoc::GetInfo(long InfoType) case 73: SetUpVariantString (vaResult, __DATE__ " " __TIME__); break; case 74: SetUpVariantString (vaResult, ExtractDirectory (App.m_strMUSHclientFileName) + "sounds\\"); break; case 75: SetUpVariantString (vaResult, m_IAC_subnegotiation_data.c_str ()); break; - case 76: SetUpVariantString (vaResult, m_strSpecialFontName); break; + case 76: + { + // for backwards compatibility, return the first special font + ci_set::const_iterator iter = m_strSpecialFontName.begin (); + if (iter != m_strSpecialFontName.end ()) + SetUpVariantString (vaResult, iter->c_str ()); + else + SetUpVariantString (vaResult, ""); + break; + } case 77: SetUpVariantString (vaResult, os_version.szCSDVersion); break; case 78: SetUpVariantString (vaResult, m_strForegroundImageName); break;