Skip to content

Commit

Permalink
1. gcc build fix
Browse files Browse the repository at this point in the history
2. Рефакторинг.
  • Loading branch information
alabuzhev committed Sep 29, 2015
1 parent 2d0dca8 commit 8b44b93
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 48 deletions.
8 changes: 7 additions & 1 deletion 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

Expand Down
2 changes: 1 addition & 1 deletion far/dialog.cpp
Expand Up @@ -2710,7 +2710,7 @@ int Dialog::ProcessKey(const Manager::Key& Key)
string strMove;
if (CurPos < static_cast<int>(strStr.size()))
{
strMove = strStr.data() + CurPos;
strMove = strStr.substr(CurPos);
strStr.resize(CurPos);
focus->SetString(strStr, true, 0);
}
Expand Down
2 changes: 1 addition & 1 deletion far/farwinapi.hpp
Expand Up @@ -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<Provider, ResultType>::value_type(Begin, End);
value = typename enum_strings_t<Provider, ResultType>::value_type(Begin, End);
return !value.empty();
}

Expand Down
4 changes: 2 additions & 2 deletions far/help.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion far/history.cpp
Expand Up @@ -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;

Expand Down
35 changes: 13 additions & 22 deletions far/hmenu.cpp
Expand Up @@ -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;
Expand Down Expand Up @@ -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<Item[i + 1].XPos)
{
if (m_SubmenuOpened && SelectPos==i)
return FALSE;

Item[SelectPos].Selected=0;
Item[i].Selected=1;
SelectPos=i;
ShowMenu();
ProcessKey(Manager::Key(KEY_ENTER));
}
const auto SubmenuIterator = std::find_if(REVERSE_RANGE(Item, i) { return 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));
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion far/mix.cpp
Expand Up @@ -209,7 +209,7 @@ void ReloadEnvironment()
return std::make_pair(i, os::env::get_variable(i));
});

FOR(const auto& i, (os::enum_strings_t<os::env::provider::block>()))
FOR(const auto& i, os::enum_strings_t<os::env::provider::block>())
{
const auto Data = os::env::split(i.data());
os::env::set_variable(Data.first, Data.second);
Expand Down
2 changes: 1 addition & 1 deletion far/panel.cpp
Expand Up @@ -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;
Expand Down
14 changes: 4 additions & 10 deletions far/pathmix.cpp
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion far/treelist.cpp
Expand Up @@ -447,7 +447,8 @@ class TreeListCache: noncopyable, swapable<TreeListCache>
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())
Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
@@ -1 +1 @@
m4_define(BUILD,4427)m4_dnl
m4_define(BUILD,4428)m4_dnl
14 changes: 9 additions & 5 deletions far/vmenu.cpp
Expand Up @@ -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
Expand Down Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion far/vmenu.hpp
Expand Up @@ -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, // ðàìêà
Expand Down

0 comments on commit 8b44b93

Please sign in to comment.