• R/O
  • HTTP
  • SSH
  • HTTPS

winmerge-jp: Commit


Commit MetaInfo

Revision1fc3baeab76c91d4d8c41c86cef1bf33f313f24d (tree)
Time2013-09-29 09:59:53
Authorsdottaka <none@none>
Commitersdottaka

Log Message

HexView: left only file or right only file can be now opened in Hex view

--HG--
branch : stable

Change Summary

Incremental Difference

--- a/Src/HexMergeDoc.cpp
+++ b/Src/HexMergeDoc.cpp
@@ -341,28 +341,22 @@ BOOL CHexMergeDoc::SaveModified()
341341 */
342342 void CHexMergeDoc::OnFileSave()
343343 {
344- BOOL bUpdate = FALSE;
345344 for (int nBuffer = 0; nBuffer < m_nBuffers; nBuffer++)
346- {
347- if (m_pView[nBuffer]->GetModified())
348- {
349- const String &path = m_filePaths.GetPath(nBuffer);
350- if (Try(m_pView[nBuffer]->SaveFile(path.c_str())) == IDCANCEL)
351- return;
352- bUpdate = TRUE;
353- }
354- }
355- if (bUpdate)
356- UpdateDiffItem(m_pDirDoc);
345+ DoFileSave(nBuffer);
357346 }
358347
359348 void CHexMergeDoc::DoFileSave(int nBuffer)
360349 {
361350 if (m_pView[nBuffer]->GetModified())
362351 {
363- const String &path = m_filePaths.GetPath(nBuffer);
364- if (Try(m_pView[nBuffer]->SaveFile(path.c_str())) == IDCANCEL)
365- return;
352+ if (m_nBufferType[nBuffer] == BUFFER_UNNAMED)
353+ DoFileSaveAs(nBuffer);
354+ else
355+ {
356+ const String &path = m_filePaths.GetPath(nBuffer);
357+ if (Try(m_pView[nBuffer]->SaveFile(path.c_str())) == IDCANCEL)
358+ return;
359+ }
366360 UpdateDiffItem(m_pDirDoc);
367361 }
368362 }
@@ -382,8 +376,16 @@ void CHexMergeDoc::DoFileSaveAs(int nBuffer)
382376 {
383377 if (Try(m_pView[nBuffer]->SaveFile(strPath.c_str())) == IDCANCEL)
384378 return;
379+ if (path.empty())
380+ {
381+ // We are saving scratchpad (unnamed file)
382+ m_nBufferType[nBuffer] = BUFFER_UNNAMED_SAVED;
383+ m_strDesc[nBuffer].erase();
384+ }
385+
385386 m_filePaths.SetPath(nBuffer, strPath);
386387 UpdateDiffItem(m_pDirDoc);
388+ UpdateHeaderPath(nBuffer);
387389 }
388390 }
389391
@@ -488,16 +490,25 @@ BOOL CHexMergeDoc::CloseNow()
488490 */
489491 HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly)
490492 {
491- if (Try(m_pView[index]->LoadFile(filename), MB_ICONSTOP) != 0)
492- return E_FAIL;
493- m_pView[index]->SetReadOnly(readOnly);
494- m_filePaths.SetPath(index, filename);
495- ASSERT(m_nBufferType[index] == BUFFER_NORMAL); // should have been initialized to BUFFER_NORMAL in constructor
496- String strDesc = GetMainFrame()->m_strDescriptions[index];
497- if (!strDesc.empty())
493+ if (filename[0])
498494 {
499- m_strDesc[index] = strDesc;
500- m_nBufferType[index] = BUFFER_NORMAL_NAMED;
495+ if (Try(m_pView[index]->LoadFile(filename), MB_ICONSTOP) != 0)
496+ return E_FAIL;
497+ m_pView[index]->SetReadOnly(readOnly);
498+ m_filePaths.SetPath(index, filename);
499+ ASSERT(m_nBufferType[index] == BUFFER_NORMAL); // should have been initialized to BUFFER_NORMAL in constructor
500+ String strDesc = GetMainFrame()->m_strDescriptions[index];
501+ if (!strDesc.empty())
502+ {
503+ m_strDesc[index] = strDesc;
504+ m_nBufferType[index] = BUFFER_NORMAL_NAMED;
505+ }
506+ }
507+ else
508+ {
509+ m_nBufferType[index] = BUFFER_UNNAMED;
510+ m_strDesc[index] = GetMainFrame()->m_strDescriptions[index];
511+
501512 }
502513 UpdateHeaderPath(index);
503514 m_pView[index]->ResizeWindow();
Show on old repository browser