// WinMerge: an interactive diff/merge utility
// Copyright (C) 1997-2000 Thingamahoochie Software
// Author: Dean Grimm
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation; either version 2 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-//
+// SPDX-License-Identifier: GPL-2.0-or-later
/////////////////////////////////////////////////////////////////////////////
/**
* @file HexMergeView.cpp
#define new DEBUG_NEW
#endif
+/** @brief Location for hex compare specific help to open. */
+static TCHAR HexMergeViewHelpLocation[] = _T("::/htmlhelp/Compare_bin.html");
+
/**
* @brief Turn bool api result into success/error code
*/
if (f)
return S_OK;
HRESULT hr = (HRESULT)::GetLastError();
- ASSERT(hr);
- if (hr == 0)
+ ASSERT(hr != NULL);
+ if (hr == NULL)
hr = E_UNEXPECTED;
return hr;
}
ON_WM_CREATE()
ON_WM_HSCROLL()
ON_WM_VSCROLL()
+ ON_WM_MOUSEWHEEL()
ON_WM_NCCALCSIZE()
+ ON_COMMAND(ID_HELP, OnHelp)
ON_COMMAND(ID_EDIT_FIND, OnEditFind)
ON_COMMAND(ID_EDIT_REPLACE, OnEditReplace)
ON_COMMAND(ID_EDIT_REPEAT, OnEditRepeat)
* @brief Constructor.
*/
CHexMergeView::CHexMergeView()
-: m_pif(0)
+: m_pif(nullptr)
, m_nThisPane(0)
{
}
*/
void CHexMergeView::OnDraw(CDC *)
{
- ASSERT(FALSE);
+ ASSERT(false);
}
/**
*/
bool CHexMergeView::IsLoadable()
{
- static void *pv = NULL;
- if (pv == NULL)
+ static void *pv = nullptr;
+ if (pv == nullptr)
{
pv = LoadLibrary(_T("Frhed\\hekseditU.dll"));
}
if (CView::OnCreate(lpCreateStruct) == -1)
return -1;
m_pif = reinterpret_cast<IHexEditorWindow *>(::GetWindowLongPtr(m_hWnd, GWLP_USERDATA));
- if (m_pif == 0 || m_pif->get_interface_version() < HEKSEDIT_INTERFACE_VERSION)
+ if (m_pif == nullptr || m_pif->get_interface_version() < HEKSEDIT_INTERFACE_VERSION)
return -1;
return 0;
}
SetScrollInfo(SB_HORZ, &si);
}
CView::OnHScroll(nSBCode, nPos, pScrollBar);
- if (pScrollBar)
+ if (pScrollBar != nullptr)
{
GetScrollInfo(SB_HORZ, &si, SIF_ALL | SIF_DISABLENOSCROLL);
if (nSBCode != SB_THUMBTRACK)
}
}
+BOOL CHexMergeView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
+{
+ if ((GetAsyncKeyState(VK_CONTROL) &0x8000) != 0) // if (nFlags & MK_CONTROL)
+ {
+ PostMessage(WM_COMMAND, zDelta < 0 ? ID_VIEW_ZOOMOUT : ID_VIEW_ZOOMIN);
+ return 1;
+ }
+ return 0;
+}
+
/**
* @brief Synchronize file path bar activation states
*/
* @param [in] path File to check
* @return `true` if file is changed.
*/
-bool CHexMergeView::IsFileChangedOnDisk(LPCTSTR path)
+IMergeDoc::FileChange CHexMergeView::IsFileChangedOnDisk(LPCTSTR path)
{
DiffFileInfo dfi;
- dfi.Update(path);
+ if (!dfi.Update(path))
+ return IMergeDoc::FileChange::Removed;
int tolerance = 0;
if (GetOptionsMgr()->GetBool(OPT_IGNORE_SMALL_FILETIME))
tolerance = SmallTimeDiff; // From MainFrm.h
int64_t timeDiff = dfi.mtime - m_fileInfo.mtime;
if (timeDiff < 0) timeDiff = -timeDiff;
if ((timeDiff > tolerance * Poco::Timestamp::resolution()) || (dfi.size != m_fileInfo.size))
- return true;
- return false;
+ return IMergeDoc::FileChange::Changed;
+ return IMergeDoc::FileChange::NoChange;
}
/**
HRESULT CHexMergeView::SaveFile(LPCTSTR path)
{
// Warn user in case file has been changed by someone else
- if (IsFileChangedOnDisk(path))
+ if (IsFileChangedOnDisk(path) == IMergeDoc::FileChange::Changed)
{
String msg = strutils::format_string1(_("Another application has updated file\n%1\nsince WinMerge loaded it.\n\nOverwrite changed file?"), path);
if (AfxMessageBox(msg.c_str(), MB_ICONWARNING | MB_YESNO) == IDNO)
// Ask user what to do about FILE_ATTRIBUTE_READONLY
String strPath = path;
bool bApplyToAll = false;
- if (theApp.HandleReadonlySave(strPath, false, bApplyToAll) == IDCANCEL)
+ if (CMergeApp::HandleReadonlySave(strPath, false, bApplyToAll) == IDCANCEL)
return S_OK;
path = strPath.c_str();
// Take a chance to create a backup
- if (!theApp.CreateBackup(false, path))
+ if (!CMergeApp::CreateBackup(false, path))
return S_OK;
// Write data to an intermediate file
String tempPath = env::GetTemporaryPath();
if (hr != S_OK)
{
LogErrorString(strutils::format(_T("DeleteFile(%s) failed: %s"),
- sIntermediateFilename.c_str(), GetSysError(hr).c_str()));
+ sIntermediateFilename, GetSysError(hr)));
}
return S_OK;
}
*/
bool CHexMergeView::GetModified()
{
- return m_pif->get_status()->bFileChanged;
+ return m_pif->get_status()->iFileChanged != 0;
}
/**
if (pMsg->message == WM_KEYDOWN)
{
// Close window in response to VK_ESCAPE if user has allowed it from options
- if (pMsg->wParam == VK_ESCAPE && GetOptionsMgr()->GetBool(OPT_CLOSE_WITH_ESC))
+ if (pMsg->wParam == VK_ESCAPE && GetOptionsMgr()->GetInt(OPT_CLOSE_WITH_ESC) != 0)
{
GetParentFrame()->PostMessage(WM_CLOSE, 0, 0);
return TRUE;
m_pif->select_prev_diff(FALSE);
}
+/** @brief Open help from mainframe when user presses F1*/
+void CHexMergeView::OnHelp()
+{
+ theApp.ShowHelp(HexMergeViewHelpLocation);
+}
+
void CHexMergeView::ZoomText(int amount)
{
m_pif->CMD_zoom(amount);