Skip to content

Commit dfd5c5f

Browse files
committed
experimental 'Crop Log to Selection' feature, use with care :)
1 parent 38209b7 commit dfd5c5f

File tree

5 files changed

+35
-15
lines changed

5 files changed

+35
-15
lines changed

DebugView++/DebugView++.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ BEGIN
105105
POPUP "&Log"
106106
BEGIN
107107
MENUITEM "&Clear Log\tCtrl+Shift+X", ID_LOG_CLEAR
108-
// MENUITEM "Crop Log to &Selection", ID_LOG_CROP
108+
MENUITEM "Crop Log to &Selection", ID_LOG_CROP
109109
MENUITEM "&Pause\tPause", ID_LOG_PAUSE
110110
MENUITEM "Capture &Global Win32", ID_LOG_GLOBAL
111111
MENUITEM "Connect DebugView &Agent", ID_LOG_DEBUGVIEW_AGENT

DebugView++/LogView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ class CLogView :
178178
void MeasureItem(MEASUREITEMSTRUCT* pMeasureItemStruct) const;
179179
void DrawItem(DRAWITEMSTRUCT* pDrawItemStruct) const;
180180
void DeleteItem(DELETEITEMSTRUCT* lParam);
181+
void ResetToLine(int line);
181182

182183
private:
183184
DECLARE_MSG_MAP()
@@ -235,7 +236,6 @@ class CLogView :
235236
void OnViewColumn(UINT uNotifyCode, int nID, CWindow wndCtl);
236237

237238
std::vector<std::string> GetSelectedMessages() const;
238-
void ResetToLine(int line);
239239
void UpdateColumnInfo();
240240
void UpdateColumns();
241241
int ColumnToSubItem(Column::type column) const;

DebugView++/MainFrame.cpp

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1151,19 +1151,22 @@ void CMainFrame::OnLogCrop(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wndCtl*/
11511151
auto selection = GetView().GetSelectedRange();
11521152
if (selection.count < 2) return;
11531153

1154-
//LogFile temp = m_logFile.Copy(selection.beginLine, selection.endLine);
1155-
//m_logFile.Swap(temp);
1156-
//
1157-
//m_logSources.ResetTimer();
1158-
//int views = GetViewCount();
1159-
//for (int i = 0; i < views; ++i)
1160-
//{
1161-
// GetView(i).Clear();
1162-
// SetModifiedMark(i, false);
1163-
// GetTabCtrl().UpdateLayout();
1164-
// GetTabCtrl().Invalidate();
1165-
//}
1166-
//UpdateStatusBar();
1154+
LogFile temp;
1155+
m_logFile.Copy(selection.beginLine, selection.endLine, temp);
1156+
std::swap(temp, m_logFile);
1157+
1158+
m_logSources.ResetTimer();
1159+
int views = GetViewCount();
1160+
for (int i = 0; i < views; ++i)
1161+
{
1162+
auto& view = GetView(i);
1163+
view.Clear();
1164+
view.ResetToLine(0);
1165+
SetModifiedMark(i, false);
1166+
GetTabCtrl().UpdateLayout();
1167+
GetTabCtrl().Invalidate();
1168+
}
1169+
UpdateStatusBar();
11671170
}
11681171

11691172
void CMainFrame::OnLinkViews(UINT /*uNotifyCode*/, int /*nID*/, CWindow /*wndCtl*/)

DebugView++Lib/LogFile.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,5 +82,19 @@ void LogFile::SetHistorySize(size_t size)
8282
m_historySize = size;
8383
}
8484

85+
void LogFile::Copy(size_t beginIndex, size_t endIndex, LogFile& logfile)
86+
{
87+
for (size_t i = beginIndex; i <= endIndex; ++i)
88+
logfile.Add((*this)[i]);
89+
}
90+
91+
void LogFile::Swap(LogFile& logfile)
92+
{
93+
std::swap(m_messages, logfile.m_messages);
94+
std::swap(m_processInfo, logfile.m_processInfo);
95+
std::swap(m_storage, logfile.m_storage);
96+
std::swap(m_historySize, logfile.m_historySize);
97+
}
98+
8599
} // namespace debugviewpp
86100
} // namespace fusion

include/DebugView++Lib/LogFile.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class LogFile
4343
size_t GetHistorySize() const;
4444
void SetHistorySize(size_t size);
4545

46+
void Copy(size_t beginIndex, size_t endIndex, LogFile&);
47+
void Swap(LogFile& logfile);
48+
4649
private:
4750
struct InternalMessage
4851
{

0 commit comments

Comments
 (0)