From 86c8314af349623b35b23e33fde82e2e5ce4ef42 Mon Sep 17 00:00:00 2001 From: Sven Strickroth Date: Mon, 7 Jan 2013 05:40:44 +0100 Subject: [PATCH] TGitBlame: Show (detected/selected) encoding in status bar Signed-off-by: Sven Strickroth --- src/Resources/TortoiseGitBlameENG.rc | 5 +++++ src/TortoiseGitBlame/MainFrm.cpp | 3 ++- src/TortoiseGitBlame/MainFrm.h | 4 ++-- src/TortoiseGitBlame/Resource.h | 1 + src/TortoiseGitBlame/TortoiseGitBlameView.cpp | 32 +++++++++++++++++++++++---- 5 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/Resources/TortoiseGitBlameENG.rc b/src/Resources/TortoiseGitBlameENG.rc index 17d4bd45b..215ec983b 100644 --- a/src/Resources/TortoiseGitBlameENG.rc +++ b/src/Resources/TortoiseGitBlameENG.rc @@ -546,6 +546,11 @@ BEGIN IDS_PROPERTIES_WND "Commit Info" END +STRINGTABLE +BEGIN + ID_INDICATOR_ENCODING " " +END + #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/TortoiseGitBlame/MainFrm.cpp b/src/TortoiseGitBlame/MainFrm.cpp index 1a5d588dd..15e3dae8a 100644 --- a/src/TortoiseGitBlame/MainFrm.cpp +++ b/src/TortoiseGitBlame/MainFrm.cpp @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2011 - TortoiseGit +// Copyright (C) 2008-2013 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -54,6 +54,7 @@ END_MESSAGE_MAP() static UINT indicators[] = { ID_SEPARATOR, // status line indicator + ID_INDICATOR_ENCODING, ID_INDICATOR_CAPS, ID_INDICATOR_NUM, ID_INDICATOR_SCRL, diff --git a/src/TortoiseGitBlame/MainFrm.h b/src/TortoiseGitBlame/MainFrm.h index 3bd093698..85a0942cf 100644 --- a/src/TortoiseGitBlame/MainFrm.h +++ b/src/TortoiseGitBlame/MainFrm.h @@ -1,6 +1,6 @@ // TortoiseGit - a Windows shell extension for easy version control -// Copyright (C) 2008-2011 - TortoiseGit +// Copyright (C) 2008-2011,2013 - TortoiseGit // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -56,10 +56,10 @@ public: COutputWnd m_wndOutput; CPropertiesWnd m_wndProperties; + CMFCStatusBar m_wndStatusBar; protected: // control bar embedded members CMFCMenuBar m_wndMenuBar; CMFCToolBar m_wndToolBar; - CMFCStatusBar m_wndStatusBar; CMFCToolBarImages m_UserImages; // Generated message map functions diff --git a/src/TortoiseGitBlame/Resource.h b/src/TortoiseGitBlame/Resource.h index 4a092490f..ade55fc44 100644 --- a/src/TortoiseGitBlame/Resource.h +++ b/src/TortoiseGitBlame/Resource.h @@ -51,6 +51,7 @@ #define IDC_COPYRIGHT 1001 #define IDC_SCINTILLA 1002 #define IDC_LOG 1003 +#define ID_INDICATOR_ENCODING 2000 #define IDS_STATUS_PANE1 20122 #define IDS_STATUS_PANE2 20123 #define IDS_TOOLBAR_STANDARD 20124 diff --git a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp index 9fa6bfdb0..4e26f4786 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameView.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameView.cpp @@ -178,10 +178,7 @@ struct EncodingUnit char *name; }; -void CTortoiseGitBlameView::OnChangeEncode(UINT nId) -{ - - static EncodingUnit encodings[] = { +static EncodingUnit encodings[] = { {1250, "windows-1250"}, //IDM_FORMAT_WIN_1250 {1251, "windows-1251"}, //IDM_FORMAT_WIN_1251 {1252, "windows-1252"}, //IDM_FORMAT_WIN_1252 @@ -235,6 +232,8 @@ void CTortoiseGitBlameView::OnChangeEncode(UINT nId) {1200, "UTF-16 LE"}, //IDM_FORMAT_UTF16LE {1201, "UTF-16 BE"}, //IDM_FORMAT_UTF16BE }; +void CTortoiseGitBlameView::OnChangeEncode(UINT nId) +{ if(nId >= IDM_FORMAT_ENCODE && nId <= IDM_FORMAT_ENCODE_END) this->UpdateInfo(encodings[nId - IDM_FORMAT_ENCODE].id); } @@ -1488,6 +1487,31 @@ void CTortoiseGitBlameView::UpdateInfo(int Encode) m_CommitHash.push_back(hash); pos = current+1; } + { + UINT nID; + UINT nStyle; + int cxWidth; + int nIndex = ((CMainFrame *)::AfxGetApp()->GetMainWnd())->m_wndStatusBar.CommandToIndex(ID_INDICATOR_ENCODING); + ((CMainFrame *)::AfxGetApp()->GetMainWnd())->m_wndStatusBar.GetPaneInfo(nIndex, nID, nStyle, cxWidth); + CString sBarText = L""; + for (int i = 0; i < _countof(encodings); ++i) + { + if (encodings[i].id == encoding) + { + sBarText = CString(encodings[i].name); + break; + } + } + //calculate the width of the text + CDC * pDC = ((CMainFrame *)::AfxGetApp()->GetMainWnd())->m_wndStatusBar.GetDC(); + if (pDC) + { + CSize size = pDC->GetTextExtent(sBarText); + ((CMainFrame *)::AfxGetApp()->GetMainWnd())->m_wndStatusBar.SetPaneInfo(nIndex, nID, nStyle, size.cx+2); + ReleaseDC(pDC); + } + ((CMainFrame *)::AfxGetApp()->GetMainWnd())->m_wndStatusBar.SetPaneText(nIndex, sBarText); + } #if 0 if(m_Buffer) -- 2.11.4.GIT