Skip to content

Commit

Permalink
Update naming and move GUI Blame command to the blameFileFiles() sub
Browse files Browse the repository at this point in the history
The new Git-GUI blame must only be done on Git Blames, not executed
for all non-Tortoise git commands.  Therefore, the additional logic to
execute Git-GUI blame must happen in the blameFileFiles() sub.  There,
we can also send the line number.

Sending line number to standard `git blame -L #` starts the blame from
that line and does not allow scrolling to lower line numbers, which is
undesirable, though starting at the target line would be nice.
  • Loading branch information
VinsWorldcom committed Nov 1, 2024
1 parent 5a28d08 commit d1f90d7
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
12 changes: 6 additions & 6 deletions DockingFeature/SettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ extern TCHAR g_GitPath[MAX_PATH];
extern TCHAR g_GitPrompt[MAX_PATH];
extern bool g_RefScnFocus;
extern bool g_DiffWordDiff;
extern bool g_runwithgitgui;
extern bool g_gitGuiBlame;

static int __stdcall BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM, LPARAM pData)
{
Expand All @@ -35,7 +35,7 @@ INT_PTR CALLBACK SettingsDlg( HWND hWndDlg, UINT msg, WPARAM wParam,
SendMessage( GetDlgItem( hWndDlg, IDC_EDT_GITPROMPT ), WM_SETTEXT, 0, ( LPARAM )g_GitPrompt );
SendMessage( GetDlgItem( hWndDlg, IDC_CHK_SCNFOCUS ), BM_SETCHECK, ( LPARAM )( g_RefScnFocus ? 1 : 0 ), 0 );
SendMessage( GetDlgItem( hWndDlg, IDC_CHK_WORDDIFF ), BM_SETCHECK, ( LPARAM )( g_DiffWordDiff ? 1 : 0 ), 0 );
SendMessage( GetDlgItem( hWndDlg, IDC_CHK_GITGUI), BM_SETCHECK, ( LPARAM )( g_runwithgitgui ? 1 : 0), 0);
SendMessage( GetDlgItem( hWndDlg, IDC_CHK_GITGUIBLAME), BM_SETCHECK, ( LPARAM )( g_gitGuiBlame ? 1 : 0), 0);

std::string version;
version = "<a>";
Expand Down Expand Up @@ -156,15 +156,15 @@ INT_PTR CALLBACK SettingsDlg( HWND hWndDlg, UINT msg, WPARAM wParam,
return TRUE;
}

case IDC_CHK_GITGUI:
case IDC_CHK_GITGUIBLAME:
{
int check = (int)::SendMessage(GetDlgItem(hWndDlg, IDC_CHK_GITGUI),
int check = (int)::SendMessage(GetDlgItem(hWndDlg, IDC_CHK_GITGUIBLAME),
BM_GETCHECK, 0, 0);

if (check & BST_CHECKED)
g_runwithgitgui = true;
g_gitGuiBlame = true;
else
g_runwithgitgui = false;
g_gitGuiBlame = false;
return TRUE;
}

Expand Down
2 changes: 1 addition & 1 deletion DockingFeature/gitPanel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ BEGIN
CONTROL "--word-&diff (non-TortoiseGit)",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE,170,110,105,9
CONTROL "",IDC_CHK_WORDDIFF,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|BS_AUTOCHECKBOX,155,111,10,9
CONTROL "Blame with Git GUI", IDC_STATIC, "Static", WS_CHILDWINDOW | WS_VISIBLE, 25, 126, 120, 9
CONTROL "", IDC_CHK_GITGUI, "Button", WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, 10, 127, 10, 9
CONTROL "", IDC_CHK_GITGUIBLAME, "Button", WS_CHILDWINDOW | WS_VISIBLE | WS_TABSTOP | BS_AUTOCHECKBOX, 10, 127, 10, 9
CONTROL "Version",IDC_STATIC,"Static",WS_CHILDWINDOW|WS_VISIBLE|WS_DISABLED|WS_GROUP,10,146,30,11
CONTROL "<a></a>",IDC_STC_VER,"SysLink",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP|LWS_TRANSPARENT,40,146,40,11
END
Expand Down
20 changes: 10 additions & 10 deletions DockingFeature/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#define IDB_PAGER1 1701
#define IDB_PAGER2 1702

// The following MUST stay in order so GetNameStrFromCmd()
// The following MUST stay in order so GetNameStrFromCmd()
// tooltip lookups from szToolTip will work

#define IDC_BTN_GITGUI (IDB_TOOLBAR1 + 1)
Expand Down Expand Up @@ -66,15 +66,15 @@
// Settings
#define IDD_SETTINGS 2600

#define IDB_OK (IDD_SETTINGS + 1)
#define IDC_GRP1 (IDD_SETTINGS + 2)
#define IDC_BTN_GITPATH (IDD_SETTINGS + 3)
#define IDC_EDT_GITPATH (IDD_SETTINGS + 4)
#define IDC_EDT_GITPROMPT (IDD_SETTINGS + 5)
#define IDC_CHK_SCNFOCUS (IDD_SETTINGS + 6)
#define IDC_CHK_WORDDIFF (IDD_SETTINGS + 7)
#define IDC_CHK_GITGUI (IDD_SETTINGS + 8)
#define IDB_OK (IDD_SETTINGS + 1)
#define IDC_GRP1 (IDD_SETTINGS + 2)
#define IDC_BTN_GITPATH (IDD_SETTINGS + 3)
#define IDC_EDT_GITPATH (IDD_SETTINGS + 4)
#define IDC_EDT_GITPROMPT (IDD_SETTINGS + 5)
#define IDC_CHK_SCNFOCUS (IDD_SETTINGS + 6)
#define IDC_CHK_WORDDIFF (IDD_SETTINGS + 7)
#define IDC_CHK_GITGUIBLAME (IDD_SETTINGS + 8)

#define IDC_STC_VER (IDD_SETTINGS + 9)
#define IDC_STC_VER (IDD_SETTINGS + 9)

#endif // DOCKINGFEATURE_RESOURCE_H
29 changes: 17 additions & 12 deletions PluginDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const TCHAR iniKeyRefScnFocus[] = TEXT( "RefreshScnFocus" );
const TCHAR iniKeyDiffWordDiff[] = TEXT( "DiffWordDiff" );
const TCHAR iniKeyDebug[] = TEXT( "Debug" );
const TCHAR iniKeyLVDelay[] = TEXT( "LVDelay" );
const TCHAR iniKeyRunWithGITGUI[] = TEXT( "RunWithGITGUI" );
const TCHAR iniKeyGitGuiBlame[] = TEXT( "GitGuiBlame" );

DemoDlg _gitPanel;

Expand All @@ -63,7 +63,7 @@ bool g_useNppColors = false;
bool g_RaisePanel = false;
bool g_RefScnFocus = false;
bool g_DiffWordDiff = false;
bool g_runwithgitgui = false;
bool g_gitGuiBlame = false;

// g_Debug and g_LVDelay must be set manually in config file ($NPP_DIR\plugins\config\GitSCM.ini)
// ON => Debug=1
Expand Down Expand Up @@ -104,8 +104,8 @@ void pluginCleanUp()
g_RefScnFocus ? TEXT( "1" ) : TEXT( "0" ), iniFilePath );
::WritePrivateProfileString( sectionName, iniKeyDiffWordDiff,
g_DiffWordDiff ? TEXT( "1" ) : TEXT( "0" ), iniFilePath );
::WritePrivateProfileString( sectionName, iniKeyRunWithGITGUI,
g_runwithgitgui ? TEXT( "1" ) : TEXT( "0" ), iniFilePath);
::WritePrivateProfileString( sectionName, iniKeyGitGuiBlame,
g_gitGuiBlame ? TEXT( "1" ) : TEXT( "0" ), iniFilePath);

if (g_TBGit.hToolbarBmp) {
::DeleteObject(g_TBGit.hToolbarBmp);
Expand Down Expand Up @@ -152,7 +152,7 @@ void commandMenuInit()
0, iniFilePath );
g_DiffWordDiff = ::GetPrivateProfileInt( sectionName, iniKeyDiffWordDiff,
0, iniFilePath );
g_runwithgitgui = ::GetPrivateProfileInt(sectionName, iniKeyRunWithGITGUI,
g_gitGuiBlame = ::GetPrivateProfileInt(sectionName, iniKeyGitGuiBlame,
0, iniFilePath);

g_Debug = ::GetPrivateProfileInt( sectionName, iniKeyDebug,
Expand Down Expand Up @@ -405,10 +405,6 @@ void ExecGitCommand(
std::wstring command = TEXT( "cmd /d/c \"\"" );
command += getGitLocation();
command += TEXT( "git" );
if (g_runwithgitgui)
{
command += TEXT("-gui");
}
command += cmd + TEXT( " " );

if ( !ignoreFiles )
Expand Down Expand Up @@ -667,16 +663,25 @@ void blameFileFiles( std::vector<std::wstring> files = {} )
if ( files.size() == 0 )
files.push_back( getCurrentFile() );

Sci_Position pos = (Sci_Position)::SendMessage( getCurScintilla(), SCI_GETCURRENTPOS, 0, 0 );
Sci_Position line = (Sci_Position)::SendMessage( getCurScintilla(), SCI_LINEFROMPOSITION, pos, 0 );
if ( g_useTortoise )
{
Sci_Position pos = (Sci_Position)::SendMessage( getCurScintilla(), SCI_GETCURRENTPOS, 0, 0 );
Sci_Position line = (Sci_Position)::SendMessage( getCurScintilla(), SCI_LINEFROMPOSITION, pos, 0 );
std::wstring blame = TEXT( "blame /line:" );
blame += std::to_wstring( line + 1 );
ExecTortoiseCommand( blame, files, false, true );
}
else
ExecGitCommand( TEXT( "\" blame" ), files, false, true );
{
if (g_gitGuiBlame)
{
std::wstring blame = TEXT( "-gui\" blame --line=" );
blame += std::to_wstring( line + 1 );
ExecGitCommand( blame, files, false, false );
}
else
ExecGitCommand( TEXT( "\" blame" ), files, false, true );
}
}

void branchFile()
Expand Down
2 changes: 1 addition & 1 deletion resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/* VERSION DEFINITIONS */
#define VER_MAJOR 1
#define VER_MINOR 4
#define VER_RELEASE 9
#define VER_RELEASE 10
#define VER_BUILD 1
#define VER_STRING STR(VER_MAJOR) "." STR(VER_MINOR) "." STR(VER_RELEASE) "." STR(VER_BUILD)

Expand Down

0 comments on commit d1f90d7

Please sign in to comment.