From b4cb23e7ca59308565dacd81e8876dbd41265c71 Mon Sep 17 00:00:00 2001 From: Alex Alabuzhev Date: Wed, 23 Mar 2016 18:32:42 +0000 Subject: [PATCH] message exit code fix & better checking --- far/changelog | 6 +++- far/config.cpp | 8 +++--- far/configdb.cpp | 2 +- far/copy.cpp | 6 ++-- far/datetime.hpp | 6 ++-- far/delete.cpp | 2 +- far/dirmix.cpp | 2 +- far/diskmenu.cpp | 10 +++---- far/fileedit.cpp | 22 +++++++-------- far/filefilter.cpp | 4 +-- far/filelist.cpp | 4 +-- far/filetype.cpp | 2 +- far/hilight.cpp | 4 +-- far/history.cpp | 6 ++-- far/language.cpp | 2 +- far/manager.cpp | 4 +-- far/message.hpp | 7 +++++ far/plist.cpp | 4 +-- far/print.cpp | 2 +- far/setcolor.cpp | 70 +++++++++++++++++++++++++--------------------- far/shortcuts.cpp | 2 +- far/usermenu.cpp | 2 +- far/vbuild.m4 | 2 +- far/viewer.cpp | 8 +++--- 24 files changed, 101 insertions(+), 86 deletions(-) diff --git a/far/changelog b/far/changelog index b909586c7d..50a714e992 100644 --- a/far/changelog +++ b/far/changelog @@ -1,4 +1,8 @@ -w17 23.03.2016 17:59:00 +0300 - build 4591 +drkns 23.03.2016 20:31:08 +0200 - build 4592 + +1. С форума: Не логичное поведение при удалении сетевого диска + +w17 23.03.2016 17:59:00 +0300 - build 4591 1. M#3089: Мелкая правка в панели информации (Ctrl+L) diff --git a/far/config.cpp b/far/config.cpp index 5d10e70117..93ac2cae4a 100644 --- a/far/config.cpp +++ b/far/config.cpp @@ -460,7 +460,7 @@ void Options::MaskGroupsSettings() { case KEY_NUMDEL: case KEY_DEL: - if(Item && !Message(0,2,MSG(MMenuMaskGroups),MSG(MMaskGroupAskDelete), Item->data(), MSG(MDelete), MSG(MCancel))) + if(Item && Message(0,2,MSG(MMenuMaskGroups),MSG(MMaskGroupAskDelete), Item->data(), MSG(MDelete), MSG(MCancel)) == Message::first_button) { ConfigProvider().GeneralCfg()->DeleteValue(L"Masks", *Item); Changed = true; @@ -505,10 +505,10 @@ void Options::MaskGroupsSettings() case KEY_CTRLR: case KEY_RCTRLR: { - if (!Message(MSG_WARNING, 2, + if (Message(MSG_WARNING, 2, MSG(MMenuMaskGroups), MSG(MMaskGroupRestore), - MSG(MYes),MSG(MCancel))) + MSG(MYes),MSG(MCancel)) == Message::first_button) { ApplyDefaultMaskGroups(); Changed = true; @@ -2080,7 +2080,7 @@ void Options::Save(bool Manual) { InitConfig(); - if (Manual && Message(0,2,MSG(MSaveSetupTitle),MSG(MSaveSetupAsk1),MSG(MSaveSetupAsk2),MSG(MSaveSetup),MSG(MCancel))) + if (Manual && Message(0,2,MSG(MSaveSetupTitle),MSG(MSaveSetupAsk1),MSG(MSaveSetupAsk2),MSG(MSaveSetup),MSG(MCancel)) != Message::first_button) return; /* <ПРЕПРОЦЕССЫ> *************************************************** */ diff --git a/far/configdb.cpp b/far/configdb.cpp index d192ae3d4c..e3c1a75d91 100644 --- a/far/configdb.cpp +++ b/far/configdb.cpp @@ -2503,7 +2503,7 @@ int config_provider::ShowProblems() rc = Message(MSG_WARNING, MSG(MProblemDb), m_Problems, make_vector(MSG(MShowConfigFolders), MSG(MIgnore)) - ) == 0 ? +1 : -1; + ) == Message::first_button ? +1 : -1; } return rc; } diff --git a/far/copy.cpp b/far/copy.cpp index 0ce5b1fd30..d0edaab1c3 100644 --- a/far/copy.cpp +++ b/far/copy.cpp @@ -1908,7 +1908,7 @@ COPY_CODES ShellCopy::CopyFileTree(const string& Dest) CP->SetNames(strSelName,strDestPath); if (Message(MSG_WARNING,2,MSG(MError),MSG(MCopyCannotFind), - strSelName.data(),MSG(MSkip),MSG(MCancel))==1) + strSelName.data(),MSG(MSkip),MSG(MCancel)) == Message::second_button) { return COPY_FAILURE; } @@ -3368,8 +3368,8 @@ int ShellCopy::ShellCopyFile(const string& SrcName,const os::FAR_FIND_DATA &SrcD else { if (!SplitCancelled && !SplitSkipped && - !Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MError), - MSG(MCopyWriteError),strDestName.data(),MSG(MRetry),MSG(MCancel))) + Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MError), + MSG(MCopyWriteError),strDestName.data(),MSG(MRetry),MSG(MCancel)) == Message::first_button) { continue; } diff --git a/far/datetime.hpp b/far/datetime.hpp index 95db7bea14..bf2b002c3e 100644 --- a/far/datetime.hpp +++ b/far/datetime.hpp @@ -49,16 +49,14 @@ string MkStrFTime(const wchar_t* Format = nullptr); inline uint64_t FileTimeToUI64(const FILETIME& ft) { - ULARGE_INTEGER t = {ft.dwLowDateTime, ft.dwHighDateTime}; - return t.QuadPart; + return ULARGE_INTEGER {ft.dwLowDateTime, ft.dwHighDateTime}.QuadPart; } inline FILETIME UI64ToFileTime(uint64_t time) { ULARGE_INTEGER i; i.QuadPart = time; - FILETIME ft = { i.LowPart, i.HighPart }; - return ft; + return FILETIME { i.LowPart, i.HighPart }; } inline int CompareFileTime(const FILETIME& a, const FILETIME& b) diff --git a/far/delete.cpp b/far/delete.cpp index fa9a6ff33f..62a70062e2 100644 --- a/far/delete.cpp +++ b/far/delete.cpp @@ -1058,7 +1058,7 @@ bool ShellDelete::RemoveToRecycleBin(const string& Name, bool dir, DEL_RESULT& r ), make_vector(MSG(MYes), MSG(MCancel)), nullptr, nullptr, &RecycleFolderConfirmDeleteLinkId - ) != 0) + ) != Message::first_button) { ret = DELETE_CANCEL; return false; diff --git a/far/dirmix.cpp b/far/dirmix.cpp index 53cec2a3d5..1fc6f2523f 100644 --- a/far/dirmix.cpp +++ b/far/dirmix.cpp @@ -192,7 +192,7 @@ bool CheckShortcutFolder(string& pTestPath, bool TryClosest, bool Silent) } else // попытка найти! { - if (Silent || !Message(MSG_WARNING | MSG_ERRORTYPE, 2, MSG(MError), strTarget.data(), MSG(MNeedNearPath), MSG(MHYes),MSG(MHNo))) + if (Silent || Message(MSG_WARNING | MSG_ERRORTYPE, 2, MSG(MError), strTarget.data(), MSG(MNeedNearPath), MSG(MHYes),MSG(MHNo)) == Message::first_button) { string strTestPathTemp = pTestPath; for (;;) diff --git a/far/diskmenu.cpp b/far/diskmenu.cpp index ee12dcca2b..2180675cf5 100644 --- a/far/diskmenu.cpp +++ b/far/diskmenu.cpp @@ -355,7 +355,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType) if (Message(MSG_WARNING, MSG(MChangeSUBSTDisconnectDriveTitle), make_vector(Question, MappedTo, SubstitutedPath), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &SUBSTDisconnectDriveId)) + nullptr, nullptr, &SUBSTDisconnectDriveId) != Message::first_button) { return DRIVE_DEL_FAIL; } @@ -374,7 +374,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType) if (Message(MSG_WARNING | MSG_ERRORTYPE, MSG(MError), make_vector(strMsgText, L"\x1", MSG(MChangeDriveOpenFiles), MSG(MChangeDriveAskDisconnect)), make_vector(MSG(MOk), MSG(MCancel)), - nullptr, nullptr, &SUBSTDisconnectDriveError1Id)) + nullptr, nullptr, &SUBSTDisconnectDriveError1Id) == Message::first_button) { if (DelSubstDrive(DiskLetter)) { @@ -424,7 +424,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType) if (Message(MSG_WARNING | MSG_ERRORTYPE, MSG(MError), make_vector(strMsgText, L"\x1", MSG(MChangeDriveOpenFiles), MSG(MChangeDriveAskDisconnect)), make_vector(MSG(MOk), MSG(MCancel)), - nullptr, nullptr, &RemoteDisconnectDriveError1Id)) + nullptr, nullptr, &RemoteDisconnectDriveError1Id) == Message::first_button) { if (WNetCancelConnection2(DiskLetter.data(), UpdateProfile, TRUE) == NO_ERROR) { @@ -458,7 +458,7 @@ static int ProcessDelDisk(panel_ptr Owner, wchar_t Drive, int DriveType) if (Message(MSG_WARNING, MSG(MChangeVHDDisconnectDriveTitle), make_vector(Question), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &VHDDisconnectDriveId)) + nullptr, nullptr, &VHDDisconnectDriveId) != Message::first_button) { return DRIVE_DEL_FAIL; } @@ -587,7 +587,7 @@ static void RemoveHotplugDevice(panel_ptr Owner, const PanelMenuItem *item, VMen MSG(MError), make_vector(string_format(MChangeCouldNotEjectHotPlugMedia, item->cDrive)), make_vector(MSG(MHRetry), MSG(MHCancel)), - nullptr, nullptr, &EjectHotPlugMediaErrorId); + nullptr, nullptr, &EjectHotPlugMediaErrorId) != Message::first_button; } else DoneEject = TRUE; diff --git a/far/fileedit.cpp b/far/fileedit.cpp index 7725c97179..b87b368667 100644 --- a/far/fileedit.cpp +++ b/far/fileedit.cpp @@ -599,7 +599,7 @@ void FileEditor::Init( if (Message(MSG_WARNING, MSG(MEditTitle), make_vector(Name, MSG(MEditRSH), MSG(MEditROOpen)), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &EditorOpenRSHId)) + nullptr, nullptr, &EditorOpenRSHId) != Message::first_button) { SetExitCode(XC_OPEN_ERROR); return; @@ -1388,13 +1388,13 @@ int FileEditor::SetCodePage(uintptr_t cp, bool redetect_default, bool ascii2def) { if (IsFileModified()) { - int res = Message( + if (Message( MSG_WARNING, 2, MSG(MEditTitle), MSG(MEditorReloadCPWarnLost1), MSG(MEditorReloadCPWarnLost2), - MSG(MOk), MSG(MCancel)); - - if (res != 0) + MSG(MOk), MSG(MCancel)) != Message::first_button) + { return EC_CP_NOTRELOAD_MODIFIED; + } } ReloadFile(cp); } @@ -1516,7 +1516,7 @@ int FileEditor::LoadFile(const string& Name,int &UserBreak) string_format(MEditFileLong2, RemoveExternalSpaces(strTempStr2)), MSG(MEditROOpen)), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &EditorFileLongId)) + nullptr, nullptr, &EditorFileLongId) != Message::first_button) { EditFile.Close(); SetLastError(ERROR_OPEN_FAILED); //???? @@ -1532,7 +1532,7 @@ int FileEditor::LoadFile(const string& Name,int &UserBreak) if (Message(MSG_WARNING, MSG(MEditTitle), make_vector(Name, MSG(MEditFileGetSizeError), MSG(MEditROOpen)), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &EditorFileGetSizeErrorId)) + nullptr, nullptr, &EditorFileGetSizeErrorId) != Message::first_button) { EditFile.Close(); SetLastError(ERROR_OPEN_FAILED); //???? @@ -1860,13 +1860,13 @@ int FileEditor::SaveFile(const string& Name,int Ask, bool bSaveAs, int TextForma if (BadConversion) { - if(Message(MSG_WARNING,2,MSG(MWarning),MSG(MEditDataLostWarn),MSG(MEditorSaveNotRecommended),MSG(MEditorSave),MSG(MCancel))) + if(Message(MSG_WARNING,2,MSG(MWarning),MSG(MEditDataLostWarn),MSG(MEditorSaveNotRecommended),MSG(MEditorSave),MSG(MCancel)) == Message::first_button) { - return SAVEFILE_CANCEL; + BadConversion = false; } else { - BadConversion = false; + return SAVEFILE_CANCEL; } } @@ -2873,7 +2873,7 @@ bool FileEditor::AskOverwrite(const string& FileName) if (Message(MSG_WARNING, MSG(MEditTitle), make_vector(FileName, MSG(MEditExists), MSG(MEditOvr)), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &EditorAskOverwriteId)) + nullptr, nullptr, &EditorAskOverwriteId) != Message::first_button) { result=false; } diff --git a/far/filefilter.cpp b/far/filefilter.cpp index 580cf15d3e..2bda661ada 100644 --- a/far/filefilter.cpp +++ b/far/filefilter.cpp @@ -348,8 +348,8 @@ bool FileFilter::FilterEdit() string strQuotedTitle = FilterData()[SelPos].GetTitle(); InsertQuote(strQuotedTitle); - if (!Message(0,2,MSG(MFilterTitle),MSG(MAskDeleteFilter), - strQuotedTitle.data(),MSG(MDelete),MSG(MCancel))) + if (Message(0,2,MSG(MFilterTitle),MSG(MAskDeleteFilter), + strQuotedTitle.data(),MSG(MDelete),MSG(MCancel)) == Message::first_button) { FilterData().erase(FilterData().begin() + SelPos); FilterList->DeleteItem(SelPos); diff --git a/far/filelist.cpp b/far/filelist.cpp index 7abff49bfa..7301063519 100644 --- a/far/filelist.cpp +++ b/far/filelist.cpp @@ -1685,7 +1685,7 @@ int FileList::ProcessKey(const Manager::Key& Key) if (Message(MSG_WARNING, MSG(MWarning), make_vector(MSG(MEditNewPath1), MSG(MEditNewPath2), MSG(MEditNewPath3)), make_vector(MSG(MHYes), MSG(MHNo)), - L"WarnEditorPath") != 0) + L"WarnEditorPath") != Message::first_button) return FALSE; } } @@ -1696,7 +1696,7 @@ int FileList::ProcessKey(const Manager::Key& Key) if (Message(MSG_WARNING, MSG(MWarning), make_vector(MSG(MEditNewPlugin1), MSG(MEditNewPath3)), make_vector(MSG(MCancel)), - L"WarnEditorPluginName") != 0) + L"WarnEditorPluginName") != Message::first_button) return FALSE; } else diff --git a/far/filetype.cpp b/far/filetype.cpp index 47e637299e..55e9a218df 100644 --- a/far/filetype.cpp +++ b/far/filetype.cpp @@ -512,7 +512,7 @@ bool DeleteTypeRecord(unsigned __int64 DeletePos) ConfigProvider().AssocConfig()->GetMask(DeletePos,strMask); InsertQuote(strMask); - if (!Message(MSG_WARNING,2,MSG(MAssocTitle),MSG(MAskDelAssoc),strMask.data(),MSG(MDelete),MSG(MCancel))) + if (Message(MSG_WARNING,2,MSG(MAssocTitle),MSG(MAskDelAssoc),strMask.data(),MSG(MDelete),MSG(MCancel)) == Message::first_button) { ConfigProvider().AssocConfig()->DelType(DeletePos); return true; diff --git a/far/hilight.cpp b/far/hilight.cpp index e28077b9ad..248be394e7 100644 --- a/far/hilight.cpp +++ b/far/hilight.cpp @@ -629,7 +629,7 @@ void HighlightFiles::HiEdit(int MenuPos) if (Message(MSG_WARNING,2,MSG(MHighlightTitle), MSG(MHighlightWarning),MSG(MHighlightAskRestore), - MSG(MYes),MSG(MCancel)) != 0) + MSG(MYes),MSG(MCancel)) != Message::first_button) break; const auto cfg = ConfigProvider().CreateHighlightConfig(); @@ -650,7 +650,7 @@ void HighlightFiles::HiEdit(int MenuPos) { if (Message(MSG_WARNING,2,MSG(MHighlightTitle), MSG(MHighlightAskDel), HiData[RealSelectPos].GetMask().data(), - MSG(MDelete),MSG(MCancel)) != 0) + MSG(MDelete),MSG(MCancel)) != Message::first_button) break; HiData.erase(HiData.begin()+RealSelectPos); (*Count)--; diff --git a/far/history.cpp b/far/history.cpp index d1e83d8753..53d8c5c87c 100644 --- a/far/history.cpp +++ b/far/history.cpp @@ -457,11 +457,11 @@ history_return_type History::ProcessMenu(string &strStr, GUID* Guid, string *pst if (!HistoryMenu.empty() && (!Global->Opt->Confirm.HistoryClear || (Global->Opt->Confirm.HistoryClear && - !Message(MSG_WARNING,2, + Message(MSG_WARNING,2, MSG((m_TypeHistory==HISTORYTYPE_CMD || m_TypeHistory==HISTORYTYPE_DIALOG?MHistoryTitle: (m_TypeHistory==HISTORYTYPE_FOLDER?MFolderHistoryTitle:MViewHistoryTitle))), MSG(MHistoryClear), - MSG(MClear),MSG(MCancel))))) + MSG(MClear),MSG(MCancel)) == Message::first_button))) { HistoryCfgRef()->DeleteAllUnlocked(m_TypeHistory,m_HistoryName); @@ -502,7 +502,7 @@ history_return_type History::ProcessMenu(string &strStr, GUID* Guid, string *pst if (SelectedRecordType == HR_EDITOR && m_TypeHistory == HISTORYTYPE_VIEW) // Edit? тогда спросим и если надо создадим { - if (!Message(MSG_WARNING|MSG_ERRORTYPE,2,Title,strSelectedRecordName.data(),MSG(MViewHistoryIsCreate),MSG(MHYes),MSG(MHNo))) + if (Message(MSG_WARNING|MSG_ERRORTYPE,2,Title,strSelectedRecordName.data(),MSG(MViewHistoryIsCreate),MSG(MHYes),MSG(MHNo)) == Message::first_button) break; } else diff --git a/far/language.cpp b/far/language.cpp index f926fe84c2..58b807d086 100644 --- a/far/language.cpp +++ b/far/language.cpp @@ -474,7 +474,7 @@ bool Language::CheckMsgId(LNGID MsgId) const L"Error", strMsg1.data(), (L"Message " + std::to_wstring(MsgId) + L" not found").data(), - L"Ok", L"Quit")==1) + L"Ok", L"Quit") == Message::second_button) exit(0); } diff --git a/far/manager.cpp b/far/manager.cpp index 8943c20fcd..ab61ee93d6 100644 --- a/far/manager.cpp +++ b/far/manager.cpp @@ -668,10 +668,10 @@ void Manager::ExitMainLoop(int Ask) Global->CloseFARMenu=TRUE; }; - if (!Ask || !Global->Opt->Confirm.Exit || !Message(0, MSG(MQuit), + if (!Ask || !Global->Opt->Confirm.Exit || Message(0, MSG(MQuit), make_vector(MSG(MAskQuit)), make_vector(MSG(MYes), MSG(MNo)), - nullptr, nullptr, &FarAskQuitId)) + nullptr, nullptr, &FarAskQuitId) == Message::first_button) { /* $ 29.12.2000 IS + Проверяем, сохранены ли все измененные файлы. Если нет, то не выходим diff --git a/far/message.hpp b/far/message.hpp index 007201ec8e..8b59d1e83c 100644 --- a/far/message.hpp +++ b/far/message.hpp @@ -67,6 +67,13 @@ class Message: noncopyable const wchar_t *Str6=nullptr, const wchar_t *Str7=nullptr, const wchar_t *Str8=nullptr, const wchar_t *Str9=nullptr, const wchar_t *Str10=nullptr, const wchar_t *Str11=nullptr, const wchar_t *Str12=nullptr); + enum + { + first_button, + second_button, + third_button, + }; + int GetExitCode() const {return m_ExitCode;} void GetMessagePosition(int &X1,int &Y1,int &X2,int &Y2) const; operator int() const { return GetExitCode(); } diff --git a/far/plist.cpp b/far/plist.cpp index 47b8968578..2528cdf809 100644 --- a/far/plist.cpp +++ b/far/plist.cpp @@ -122,8 +122,8 @@ void ShowProcessList() DWORD ProcID; GetWindowThreadProcessId(ProcWnd,&ProcID); - if (!Message(MSG_WARNING,2,MSG(MKillProcessTitle),MSG(MAskKillProcess), - NullToEmpty(Title.get()),MSG(MKillProcessWarning),MSG(MKillProcessKill),MSG(MCancel))) + if (Message(MSG_WARNING,2,MSG(MKillProcessTitle),MSG(MAskKillProcess), + NullToEmpty(Title.get()),MSG(MKillProcessWarning),MSG(MKillProcessKill),MSG(MCancel)) == Message::first_button) { if (!KillProcess(ProcID)) { diff --git a/far/print.cpp b/far/print.cpp index c0d6933a24..f9a66d47df 100644 --- a/far/print.cpp +++ b/far/print.cpp @@ -262,7 +262,7 @@ void PrintFiles(FileList* SrcPanel) else { if (Message(MSG_WARNING|MSG_ERRORTYPE,2,MSG(MPrintTitle),MSG(MCannotPrint), - strSelName.data(),MSG(MSkip),MSG(MCancel))) + strSelName.data(),MSG(MSkip),MSG(MCancel)) != Message::first_button) break; } } diff --git a/far/setcolor.cpp b/far/setcolor.cpp index ac069a573f..5e2415b52f 100644 --- a/far/setcolor.cpp +++ b/far/setcolor.cpp @@ -74,8 +74,6 @@ void GetColor(PaletteColors PaletteIndex) } } -#define CheckSize(a, b) static_assert(std::size(a) == std::size(b), "wrong array size"); - enum list_mode { lm_list_normal, @@ -321,17 +319,21 @@ void SetColors() } Groups[] = { - { MSetColorPanel, PanelItems, std::size(PanelItems) }, - { MSetColorDialog, DialogItems, std::size(DialogItems) }, - { MSetColorWarning, WarnDialogItems, std::size(WarnDialogItems) }, - { MSetColorMenu, MenuItems, std::size(MenuItems) }, - { MSetColorHMenu, HMenuItems, std::size(HMenuItems) }, - { MSetColorKeyBar, KeyBarItems, std::size(KeyBarItems) }, - { MSetColorCommandLine, CommandLineItems, std::size(CommandLineItems) }, - { MSetColorClock, ClockItems, std::size(ClockItems) }, - { MSetColorViewer, ViewerItems, std::size(ViewerItems) }, - { MSetColorEditor, EditorItems, std::size(EditorItems) }, - { MSetColorHelp, HelpItems, std::size(HelpItems) }, + #define NAME_AND_SIZE(x) x, std::size(x) + + { MSetColorPanel, NAME_AND_SIZE(PanelItems) }, + { MSetColorDialog, NAME_AND_SIZE(DialogItems) }, + { MSetColorWarning, NAME_AND_SIZE(WarnDialogItems) }, + { MSetColorMenu, NAME_AND_SIZE(MenuItems) }, + { MSetColorHMenu, NAME_AND_SIZE(HMenuItems) }, + { MSetColorKeyBar, NAME_AND_SIZE(KeyBarItems) }, + { MSetColorCommandLine, NAME_AND_SIZE(CommandLineItems) }, + { MSetColorClock, NAME_AND_SIZE(ClockItems) }, + { MSetColorViewer, NAME_AND_SIZE(ViewerItems) }, + { MSetColorEditor, NAME_AND_SIZE(EditorItems) }, + { MSetColorHelp, NAME_AND_SIZE(HelpItems) }, + + #undef NAME_AND_SIZE }; const auto GroupsMenu = VMenu2::create(MSG(MSetColorGroupsTitle), nullptr, 0); @@ -412,26 +414,30 @@ static void SetItemColors(const color_item* Items, size_t Size) }); } -int ColorIndex[]= +template +constexpr auto distinct(T value) +{ + return (~value & 0xff) >> 4 | value; +} + +int ColorIndex[] = { -#define DISTINCT(x) ((~x & 0xff) >> 4 | x) - DISTINCT(B_BLACK), - DISTINCT(B_RED), - DISTINCT(B_DARKGRAY), - DISTINCT(B_LIGHTRED), - DISTINCT(B_BLUE), - DISTINCT(B_MAGENTA), - DISTINCT(B_LIGHTBLUE), - DISTINCT(B_LIGHTMAGENTA), - DISTINCT(B_GREEN), - DISTINCT(B_BROWN), - DISTINCT(B_LIGHTGREEN), - DISTINCT(B_YELLOW), - DISTINCT(B_CYAN), - DISTINCT(B_LIGHTGRAY), - DISTINCT(B_LIGHTCYAN), - DISTINCT(B_WHITE) -#undef DISTINCT + distinct(B_BLACK), + distinct(B_RED), + distinct(B_DARKGRAY), + distinct(B_LIGHTRED), + distinct(B_BLUE), + distinct(B_MAGENTA), + distinct(B_LIGHTBLUE), + distinct(B_LIGHTMAGENTA), + distinct(B_GREEN), + distinct(B_BROWN), + distinct(B_LIGHTGREEN), + distinct(B_YELLOW), + distinct(B_CYAN), + distinct(B_LIGHTGRAY), + distinct(B_LIGHTCYAN), + distinct(B_WHITE) }; static intptr_t GetColorDlgProc(Dialog* Dlg, intptr_t Msg, intptr_t Param1, void* Param2) diff --git a/far/shortcuts.cpp b/far/shortcuts.cpp index 4a8ada639b..3ad2f47030 100644 --- a/far/shortcuts.cpp +++ b/far/shortcuts.cpp @@ -526,7 +526,7 @@ void Shortcuts::EditItem(VMenu2& Menu, shortcut& Item, bool Root, bool raw) if ((!raw || !strTemp.empty()) && !os::fs::exists(strTemp)) { Global->CatchError(); - Save=!Message(MSG_WARNING | MSG_ERRORTYPE, 2, MSG(MError), NewItem.strFolder.data(), MSG(MSaveThisShortcut), MSG(MYes), MSG(MNo)); + Save = Message(MSG_WARNING | MSG_ERRORTYPE, 2, MSG(MError), NewItem.strFolder.data(), MSG(MSaveThisShortcut), MSG(MYes), MSG(MNo)) == Message::first_button; } } diff --git a/far/usermenu.cpp b/far/usermenu.cpp index 8c6da8f975..35196d876c 100644 --- a/far/usermenu.cpp +++ b/far/usermenu.cpp @@ -1110,7 +1110,7 @@ bool UserMenu::DeleteMenuRecord(std::list& Menu, const std::liststrLabel; InsertQuote(strItemName); - if (Message(MSG_WARNING,2,MSG(MUserMenuTitle),MSG(!MenuItem->Submenu?MAskDeleteMenuItem:MAskDeleteSubMenuItem),strItemName.data(),MSG(MDelete),MSG(MCancel))) + if (Message(MSG_WARNING,2,MSG(MUserMenuTitle),MSG(!MenuItem->Submenu?MAskDeleteMenuItem:MAskDeleteSubMenuItem),strItemName.data(),MSG(MDelete),MSG(MCancel)) != Message::first_button) return false; m_MenuModified=true; diff --git a/far/vbuild.m4 b/far/vbuild.m4 index 1ed1f267bf..52bde0a164 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -m4_define(BUILD,4591)m4_dnl +m4_define(BUILD,4592)m4_dnl diff --git a/far/viewer.cpp b/far/viewer.cpp index b94c5ba378..b4f912f8c0 100644 --- a/far/viewer.cpp +++ b/far/viewer.cpp @@ -3565,14 +3565,14 @@ void Viewer::Search(int Next,int FirstChar) static_assert(MViewSearchFromEnd - MViewSearchBod==1, "Wrong .lng file order"); static_assert(MViewSearchRepeat -MViewSearchCycle==1, "Wrong .lng file order"); static_assert(MViewSearchBod-MViewSearchEod==2 && MViewSearchCycle-MViewSearchEod==4, "Wrong .lng file order"); - int choice = Message( + if (Message( 0, 2, MSG(MViewSearchTitle), MSG(MViewSearchEod+2*(found-Search_Eof)), MSG(MViewSearchFromBegin+2*(found-Search_Eof)), - strMsgStr.data(), MSG(MYes), MSG(MCancel) - ); - if (choice < 0 || choice == 1) // cancel search + strMsgStr.data(), MSG(MYes), MSG(MCancel)) != Message::first_button) // cancel search + { return; + } } if (TimeCheck)