From 8b44b930b24a917bb2b125d8fe1b84f9aa2f8971 Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Tue, 29 Sep 2015 06:07:19 +0000 Subject: [PATCH] =?UTF-8?q?1.=20gcc=20build=20fix=202.=20=D0=A0=D0=B5?= =?UTF-8?q?=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B8=D0=BD=D0=B3.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- far/changelog | 8 +++++++- far/dialog.cpp | 2 +- far/farwinapi.hpp | 2 +- far/help.cpp | 4 ++-- far/history.cpp | 2 +- far/hmenu.cpp | 35 +++++++++++++---------------------- far/mix.cpp | 2 +- far/panel.cpp | 2 +- far/pathmix.cpp | 14 ++++---------- far/treelist.cpp | 3 ++- far/vbuild.m4 | 2 +- far/vmenu.cpp | 14 +++++++++----- far/vmenu.hpp | 2 +- 13 files changed, 44 insertions(+), 48 deletions(-) diff --git a/far/changelog b/far/changelog index 4987aeea22..8f86be0ff1 100644 --- a/far/changelog +++ b/far/changelog @@ -1,4 +1,10 @@ -drkns 26.09.2015 21:44:35 +0200 - build 4427 +drkns 29.09.2015 09:06:03 +0200 - build 4428 + +1. gcc build fix + +2. Рефакторинг. + +drkns 26.09.2015 21:44:35 +0200 - build 4427 1. 0003093: Не закрывается по нажатию Esc диалог "Диск" (Alt-F1,Alt-F2), если текущая папка в панели - UNC diff --git a/far/dialog.cpp b/far/dialog.cpp index b34b0e6744..b80ae235c8 100644 --- a/far/dialog.cpp +++ b/far/dialog.cpp @@ -2710,7 +2710,7 @@ int Dialog::ProcessKey(const Manager::Key& Key) string strMove; if (CurPos < static_cast(strStr.size())) { - strMove = strStr.data() + CurPos; + strMove = strStr.substr(CurPos); strStr.resize(CurPos); focus->SetString(strStr, true, 0); } diff --git a/far/farwinapi.hpp b/far/farwinapi.hpp index 4f0a8f4462..38b64a0c0c 100644 --- a/far/farwinapi.hpp +++ b/far/farwinapi.hpp @@ -477,7 +477,7 @@ namespace os { auto Begin = index? value.data() + value.size() + 1 : m_Provider, End = Begin; while (*End) ++End; - value = enum_strings_t::value_type(Begin, End); + value = typename enum_strings_t::value_type(Begin, End); return !value.empty(); } diff --git a/far/help.cpp b/far/help.cpp index 9d69790544..2f22b314ca 100644 --- a/far/help.cpp +++ b/far/help.cpp @@ -274,7 +274,7 @@ int Help::ReadHelp(const string& Mask) if (pos == string::npos) return FALSE; - StackData->strHelpTopic = strPath.data() + pos + 1; + StackData->strHelpTopic = strPath.substr(pos + 1); strPath.resize(pos); DeleteEndSlash(strPath); AddEndSlash(strPath); @@ -1554,7 +1554,7 @@ int Help::JumpTopic() } else { - strNewTopic = StackData->strSelTopic.data() + (StackData->strSelTopic == HelpOnHelpTopic? 1 : 0); + strNewTopic = StackData->strSelTopic.substr(StackData->strSelTopic == HelpOnHelpTopic? 1 : 0); } // .DLL diff --git a/far/history.cpp b/far/history.cpp index cea324f39d..a0e070ca3f 100644 --- a/far/history.cpp +++ b/far/history.cpp @@ -601,7 +601,7 @@ bool History::GetSimilar(string &strStr, int LastCmdPartLength, bool bAppend) if (!StrCmpNI(strStr.data(),strName.data(),Length) && strStr != strName) { if (bAppend) - strStr += strName.data() + Length; + strStr.append(strName.data() + Length, strName.size() - Length); else strStr = strName; diff --git a/far/hmenu.cpp b/far/hmenu.cpp index 7fb6879794..5b0cf4ee0a 100644 --- a/far/hmenu.cpp +++ b/far/hmenu.cpp @@ -92,10 +92,7 @@ void HMenu::ShowMenu() { i.XPos = WhereX(); - if (i.Selected) - SetColor(COL_HMENUSELECTEDTEXT); - else - SetColor(COL_HMENUTEXT); + SetColor(i.Selected? COL_HMENUSELECTEDTEXT : COL_HMENUTEXT); strTmpStr=L" "; strTmpStr+=i.Name; @@ -372,18 +369,17 @@ int HMenu::ProcessMouse(const MOUSE_EVENT_RECORD *MouseEvent) if (MsY==m_Y1 && MsX>=m_X1 && MsX<=m_X2) { - for (size_t i = 0; i < Item.size(); i++) - if (MsX >= Item[i].XPos && MsX= i.XPos; }); + const size_t NewPos = std::distance(SubmenuIterator, Item.rend()) - 1; + + if (m_SubmenuOpened && SelectPos == NewPos) + return FALSE; + + Item[SelectPos].Selected = 0; + SubmenuIterator->Selected = 1; + SelectPos = NewPos; + ShowMenu(); + ProcessKey(Manager::Key(KEY_ENTER)); } else if (!(MouseEvent->dwButtonState & 3) && !MouseEvent->dwEventFlags) ProcessKey(Manager::Key(KEY_ESC)); @@ -469,12 +465,7 @@ void HMenu::ProcessSubMenu(const MenuDataEx *Data,int DataCount, void HMenu::ResizeConsole() { - if (SaveScr) - { - SaveScr->Discard(); - SaveScr.reset(); - } - + SaveScr.reset(); Hide(); Modal::ResizeConsole(); SetPosition(0,0,::ScrX,0); diff --git a/far/mix.cpp b/far/mix.cpp index 7097601691..503535792c 100644 --- a/far/mix.cpp +++ b/far/mix.cpp @@ -209,7 +209,7 @@ void ReloadEnvironment() return std::make_pair(i, os::env::get_variable(i)); }); - FOR(const auto& i, (os::enum_strings_t())) + FOR(const auto& i, os::enum_strings_t()) { const auto Data = os::env::split(i.data()); os::env::set_variable(Data.first, Data.second); diff --git a/far/panel.cpp b/far/panel.cpp index 118ee279d0..83a138c1a7 100644 --- a/far/panel.cpp +++ b/far/panel.cpp @@ -710,7 +710,7 @@ int Panel::ChangeDiskMenu(int Pos,int FirstCall) } else { - string strName = ChDisk->at(SelPos).strName.data() + 3; + string strName = ChDisk->at(SelPos).strName.substr(3); RemoveExternalSpaces(strName); if(Global->CtrlObject->Plugins->SetHotKeyDialog(item->pPlugin, item->Guid, PluginsHotkeysConfig::DRIVE_MENU, strName)) RetCode=SelPos; diff --git a/far/pathmix.cpp b/far/pathmix.cpp index 5f9533a24a..a66db178d8 100644 --- a/far/pathmix.cpp +++ b/far/pathmix.cpp @@ -486,7 +486,7 @@ string ExtractFileName(const string &Path) auto p = FindLastSlash(Path); p = p == string::npos? 0 : p + 1; p = std::max(p, GetPathRootLength(Path)); - return string(Path.data() + p, Path.size() - p); + return Path.substr(p); } string ExtractFilePath(const string &Path) @@ -511,15 +511,9 @@ string ExtractFilePath(const string &Path) bool IsRootPath(const string &Path) { - size_t PathRootLen = GetPathRootLength(Path); - - if (Path.size() == PathRootLen) - return true; - - if (Path.size() == PathRootLen + 1 && IsSlash(Path[Path.size() - 1])) - return true; - - return false; + bool IsRoot = false; + ParsePath(Path, nullptr, &IsRoot); + return IsRoot || IsRelativeRoot(Path); } bool PathStartsWith(const string &Path, const string &Start) diff --git a/far/treelist.cpp b/far/treelist.cpp index d4077498eb..9e023cf24a 100644 --- a/far/treelist.cpp +++ b/far/treelist.cpp @@ -447,7 +447,8 @@ class TreeListCache: noncopyable, swapable size_t iLen = i->size(); if ((iLen == SrcLength || (iLen > SrcLength && IsSlash((*i)[SrcLength]))) && !StrCmpNI(OldName, i->data(), SrcLength)) { - string newName = string(NewName) + (i->data() + SrcLength); + string newName(NewName); + newName.append(i->data() + SrcLength, i->size() - SrcLength); i = m_Names.erase(i); m_Names.insert(std::move(newName)); if (i == m_Names.end()) diff --git a/far/vbuild.m4 b/far/vbuild.m4 index f7663f86b6..5e70dbe2e8 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4427)m4_dnl +m4_define(BUILD,4428)m4_dnl diff --git a/far/vmenu.cpp b/far/vmenu.cpp index b1aa00b94a..17b3ccf2e5 100644 --- a/far/vmenu.cpp +++ b/far/vmenu.cpp @@ -2212,7 +2212,7 @@ void VMenu::ShowMenu(bool IsParent) strMenuLine.push_back(CheckMark); strMenuLine.push_back(L' '); // left scroller (<<) placeholder int ShowPos = HiFindRealPos(Items[I].strName, Items[I].ShowPos, CheckFlags(VMENU_SHOWAMPERSAND)); - string strMItemPtr(Items[I].strName.data() + ShowPos); + string strMItemPtr = Items[I].strName.substr(ShowPos); const auto strMItemPtrLen = CheckFlags(VMENU_SHOWAMPERSAND)? strMItemPtr.size() : HiStrlen(strMItemPtr); // fit menu string into available space @@ -2240,10 +2240,14 @@ void VMenu::ShowMenu(bool IsParent) if (!(Items[I].Flags & LIF_DISABLE)) { - if (Items[I].Flags & LIF_SELECTED) - Col = Colors[Items[I].Flags & LIF_GRAYED ? VMenuColorSelGrayed : VMenuColorHSelect]; - else - Col = Colors[Items[I].Flags & LIF_GRAYED ? VMenuColorGrayed : VMenuColorHilite]; + static const vmenu_colors ItemColors[][2] = + { + { VMenuColorHilite, VMenuColorHSelect }, + { VMenuColorGrayed, VMenuColorSelGrayed }, + }; + + const auto Index = ItemColors[Items[I].Flags & LIF_GRAYED ? 1 : 0][Items[I].Flags & LIF_SELECTED ? 1 : 0]; + Col = Colors[Index]; } else { diff --git a/far/vmenu.hpp b/far/vmenu.hpp index 69bb28ad2e..4edca2287d 100644 --- a/far/vmenu.hpp +++ b/far/vmenu.hpp @@ -43,7 +43,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "colors.hpp" // - -enum +enum vmenu_colors { VMenuColorBody = 0, // VMenuColorBox = 1, //