Revision | 1fc3baeab76c91d4d8c41c86cef1bf33f313f24d (tree) |
---|---|
Time | 2013-09-29 09:59:53 |
Author | sdottaka <none@none> |
Commiter | sdottaka |
HexView: left only file or right only file can be now opened in Hex view
--HG--
branch : stable
@@ -341,28 +341,22 @@ BOOL CHexMergeDoc::SaveModified() | ||
341 | 341 | */ |
342 | 342 | void CHexMergeDoc::OnFileSave() |
343 | 343 | { |
344 | - BOOL bUpdate = FALSE; | |
345 | 344 | 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); | |
357 | 346 | } |
358 | 347 | |
359 | 348 | void CHexMergeDoc::DoFileSave(int nBuffer) |
360 | 349 | { |
361 | 350 | if (m_pView[nBuffer]->GetModified()) |
362 | 351 | { |
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 | + } | |
366 | 360 | UpdateDiffItem(m_pDirDoc); |
367 | 361 | } |
368 | 362 | } |
@@ -382,8 +376,16 @@ void CHexMergeDoc::DoFileSaveAs(int nBuffer) | ||
382 | 376 | { |
383 | 377 | if (Try(m_pView[nBuffer]->SaveFile(strPath.c_str())) == IDCANCEL) |
384 | 378 | 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 | + | |
385 | 386 | m_filePaths.SetPath(nBuffer, strPath); |
386 | 387 | UpdateDiffItem(m_pDirDoc); |
388 | + UpdateHeaderPath(nBuffer); | |
387 | 389 | } |
388 | 390 | } |
389 | 391 |
@@ -488,16 +490,25 @@ BOOL CHexMergeDoc::CloseNow() | ||
488 | 490 | */ |
489 | 491 | HRESULT CHexMergeDoc::LoadOneFile(int index, LPCTSTR filename, BOOL readOnly) |
490 | 492 | { |
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]) | |
498 | 494 | { |
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 | + | |
501 | 512 | } |
502 | 513 | UpdateHeaderPath(index); |
503 | 514 | m_pView[index]->ResizeWindow(); |