Skip to content

Commit

Permalink
gitextensions#5347 Hotkeys for focusing areas of Browse window
Browse files Browse the repository at this point in the history
  • Loading branch information
mstv committed Aug 30, 2018
1 parent da9e20b commit 69502a8
Show file tree
Hide file tree
Showing 4 changed files with 138 additions and 57 deletions.
70 changes: 62 additions & 8 deletions GitUI/CommandsDialogs/FormBrowse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2005,10 +2005,10 @@ internal enum Command
GitBash = 0,
GitGui = 1,
GitGitK = 2,
FocusRevisionGrid = 3,
FocusCommitInfo = 4,
FocusFileTree = 5,
FocusDiff = 6,
FocusLeftOfRevisionGridAndCommitInfo = 3,
FocusRightOfRevisionGridAndCommitInfo = 4,
FocusDiffList = 5,
FocusFileTree = 6,
Commit = 7,
AddNotes = 8,
FindFileInSelectedCommit = 9,
Expand All @@ -2028,6 +2028,9 @@ internal enum Command
EditFile = 22,
OpenAsTempFile = 23,
OpenAsTempFileWith = 24,
FocusBranchTree = 25,
FocusGitConsole = 26,
FocusRevisionContents = 27
}

internal Keys GetShortcutKeys(Command cmd)
Expand Down Expand Up @@ -2070,10 +2073,13 @@ protected override bool ExecuteCommand(int cmd)
case Command.GitBash: Module.RunBash(); break;
case Command.GitGui: Module.RunGui(); break;
case Command.GitGitK: Module.RunGitK(); break;
case Command.FocusRevisionGrid: RevisionGrid.Focus(); break;
case Command.FocusCommitInfo: CommitInfoTabControl.SelectedTab = CommitInfoTabPage; break;
case Command.FocusFileTree: CommitInfoTabControl.SelectedTab = TreeTabPage; fileTree.Focus(); break;
case Command.FocusDiff: CommitInfoTabControl.SelectedTab = DiffTabPage; revisionDiff.Focus(); break;
case Command.FocusBranchTree: FocusBranchTree(); break;
case Command.FocusLeftOfRevisionGridAndCommitInfo: FocusRevisionGridOrCommitInfo(revisionGrid: AppSettings.CommitInfoPosition != CommitInfoPosition.LeftwardFromList); break;
case Command.FocusRightOfRevisionGridAndCommitInfo: FocusRevisionGridOrCommitInfo(revisionGrid: AppSettings.CommitInfoPosition == CommitInfoPosition.LeftwardFromList); break;
case Command.FocusDiffList: CommitInfoTabControl.SelectedTab = DiffTabPage; revisionDiff.Focus(focusContents: false); break;
case Command.FocusFileTree: CommitInfoTabControl.SelectedTab = TreeTabPage; fileTree.Focus(focusContents: false); break;
case Command.FocusGitConsole: FocusGitConsole(); break;
case Command.FocusRevisionContents: FocusRevisionContents(); break;
case Command.FocusFilter: FocusFilter(); break;
case Command.Commit: CommitToolStripMenuItemClick(null, null); break;
case Command.AddNotes: AddNotes(); break;
Expand All @@ -2096,6 +2102,54 @@ protected override bool ExecuteCommand(int cmd)

return true;

void FocusBranchTree()
{
if (!MainSplitContainer.Panel1Collapsed)
{
repoObjectsTree.Focus();
}
}

void FocusRevisionGridOrCommitInfo(bool revisionGrid)
{
if (revisionGrid)
{
RevisionGrid.Focus();
}
else
{
if (AppSettings.CommitInfoPosition == CommitInfoPosition.BelowList)
{
CommitInfoTabControl.SelectedTab = CommitInfoTabPage;
}

RevisionInfo.Focus();
}
}

void FocusGitConsole()
{
FillTerminalTab();
var tabPageCaption = _consoleTabCaption.Text;
if (CommitInfoTabControl.TabPages.ContainsKey(tabPageCaption))
{
CommitInfoTabControl.SelectedTab = CommitInfoTabControl.TabPages[tabPageCaption];
}
}

void FocusRevisionContents()
{
if (fileTree.Visible)
{
fileTree.Focus(focusContents: true);
}
else
{
CommitInfoTabControl.SelectedTab = DiffTabPage;
revisionDiff.Focus(focusContents: true);
}
}

void OpenWithDifftool()
{
if (revisionDiff.Visible)
Expand Down
12 changes: 12 additions & 0 deletions GitUI/CommandsDialogs/RevisionDiffControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -885,5 +885,17 @@ private void diffSubmoduleSummaryMenuItem_Click(object sender, EventArgs e)
frm.ShowDialog(this);
}
}

public void Focus(bool focusContents)
{
if (focusContents)
{
DiffText.Focus();
}
else
{
DiffFiles.Focus();
}
}
}
}
12 changes: 12 additions & 0 deletions GitUI/CommandsDialogs/RevisionFileTreeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -770,5 +770,17 @@ private void tvGitTree_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs
tvGitTree.SelectedNode = e.Node;
}
}

public void Focus(bool focusContents)
{
if (focusContents)
{
FileText.Focus();
}
else
{
tvGitTree.Focus();
}
}
}
}
101 changes: 52 additions & 49 deletions GitUI/Hotkey/HotkeySettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -243,49 +243,70 @@ public static HotkeySettings[] CreateDefaultSettings()
FormCommit.HotkeySettingsName,
Hk(FormCommit.Command.AddToGitIgnore, Keys.None),
Hk(FormCommit.Command.DeleteSelectedFiles, Keys.Delete),
Hk(FormCommit.Command.EditFile, EditFileHotkey),
Hk(FormCommit.Command.FocusUnstagedFiles, Keys.Control | Keys.D1),
Hk(FormCommit.Command.FocusSelectedDiff, Keys.Control | Keys.D2),
Hk(FormCommit.Command.FocusStagedFiles, Keys.Control | Keys.D3),
Hk(FormCommit.Command.FocusCommitMessage, Keys.Control | Keys.D4),
Hk(FormCommit.Command.OpenFile, OpenFileHotkey),
Hk(FormCommit.Command.OpenFileWith, OpenFileWithHotkey),
Hk(FormCommit.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(FormCommit.Command.ResetSelectedFiles, Keys.R),
Hk(FormCommit.Command.StageSelectedFile, Keys.S),
Hk(FormCommit.Command.UnStageSelectedFile, Keys.U),
Hk(FormCommit.Command.ShowHistory, ShowHistoryHotkey),
Hk(FormCommit.Command.ToggleSelectionFilter, Keys.Control | Keys.F),
Hk(FormCommit.Command.StageAll, Keys.Control | Keys.S),
Hk(FormCommit.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(FormCommit.Command.OpenFile, OpenFileHotkey),
Hk(FormCommit.Command.OpenFileWith, OpenFileWithHotkey),
Hk(FormCommit.Command.EditFile, EditFileHotkey)),
Hk(FormCommit.Command.ToggleSelectionFilter, Keys.Control | Keys.F)),
new HotkeySettings(
FormBrowse.HotkeySettingsName,
Hk(FormBrowse.Command.AddNotes, Keys.Control | Keys.Shift | Keys.N),
Hk(FormBrowse.Command.CheckoutBranch, Keys.Control | Keys.Decimal),
Hk(FormBrowse.Command.CloseRepository, Keys.Control | Keys.W),
Hk(FormBrowse.Command.Commit, Keys.Control | Keys.Space),
Hk(FormBrowse.Command.EditFile, EditFileHotkey),
Hk(FormBrowse.Command.FindFileInSelectedCommit, Keys.Control | Keys.Shift | Keys.F),
Hk(FormBrowse.Command.FocusBranchTree, Keys.Control | Keys.D0),
Hk(FormBrowse.Command.FocusLeftOfRevisionGridAndCommitInfo, Keys.Control | Keys.D1),
Hk(FormBrowse.Command.FocusRightOfRevisionGridAndCommitInfo, Keys.Control | Keys.D2),
Hk(FormBrowse.Command.FocusDiffList, Keys.Control | Keys.D3),
Hk(FormBrowse.Command.FocusFileTree, Keys.Control | Keys.D4),
Hk(FormBrowse.Command.FocusGitConsole, Keys.Control | Keys.D5),
Hk(FormBrowse.Command.FocusRevisionContents, Keys.Control | Keys.D6),
Hk(FormBrowse.Command.FocusFilter, Keys.Control | Keys.E),
Hk(FormBrowse.Command.GitBash, Keys.Control | Keys.G),
Hk(FormBrowse.Command.GitGui, Keys.None),
Hk(FormBrowse.Command.GitGitK, Keys.None),
Hk(FormBrowse.Command.FocusRevisionGrid, Keys.Control | Keys.D1),
Hk(FormBrowse.Command.FocusCommitInfo, Keys.Control | Keys.D2),
Hk(FormBrowse.Command.FocusFileTree, Keys.Control | Keys.D3),
Hk(FormBrowse.Command.FocusDiff, Keys.Control | Keys.D4),
Hk(FormBrowse.Command.FocusFilter, Keys.Control | Keys.E),
Hk(FormBrowse.Command.Commit, Keys.Control | Keys.Space),
Hk(FormBrowse.Command.AddNotes, Keys.Control | Keys.Shift | Keys.N),
Hk(FormBrowse.Command.FindFileInSelectedCommit, Keys.Control | Keys.Shift | Keys.F),
Hk(FormBrowse.Command.CheckoutBranch, Keys.Control | Keys.Decimal),
Hk(FormBrowse.Command.OpenAsTempFile, OpenAsTempFileHotkey),
Hk(FormBrowse.Command.OpenAsTempFileWith, OpenAsTempFileWithHotkey),
Hk(FormBrowse.Command.OpenSettings, Keys.Control | Keys.Oemcomma),
Hk(FormBrowse.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(FormBrowse.Command.QuickFetch, Keys.Control | Keys.Shift | Keys.Down),
Hk(FormBrowse.Command.QuickPull, Keys.Control | Keys.Shift | Keys.P),
Hk(FormBrowse.Command.QuickPush, Keys.Control | Keys.Shift | Keys.Up),
Hk(FormBrowse.Command.Stash, Keys.Control | Keys.Alt | Keys.Up),
Hk(FormBrowse.Command.StashPop, Keys.Control | Keys.Alt | Keys.Down),
Hk(FormBrowse.Command.CloseRepository, Keys.Control | Keys.W),
Hk(FormBrowse.Command.OpenSettings, Keys.Control | Keys.Oemcomma),
Hk(FormBrowse.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(FormBrowse.Command.ToggleBranchTreePanel, Keys.Control | Keys.Alt | Keys.C),
Hk(FormBrowse.Command.EditFile, EditFileHotkey),
Hk(FormBrowse.Command.OpenAsTempFile, OpenAsTempFileHotkey),
Hk(FormBrowse.Command.OpenAsTempFileWith, OpenAsTempFileWithHotkey)),
Hk(FormBrowse.Command.ToggleBranchTreePanel, Keys.Control | Keys.Alt | Keys.C)),
new HotkeySettings(
RevisionGridControl.HotkeySettingsName,
Hk(RevisionGridControl.Commands.CompareSelectedCommits, Keys.None),
Hk(RevisionGridControl.Commands.CompareToBase, Keys.Control | Keys.R),
Hk(RevisionGridControl.Commands.CompareToBranch, Keys.None),
Hk(RevisionGridControl.Commands.CompareToCurrentBranch, Keys.None),
Hk(RevisionGridControl.Commands.CompareToWorkingDirectory, Keys.Control | Keys.D),
Hk(RevisionGridControl.Commands.CreateFixupCommit, Keys.Control | Keys.X),
Hk(RevisionGridControl.Commands.GoToCommit, Keys.Control | Keys.Shift | Keys.G),
Hk(RevisionGridControl.Commands.GoToParent, Keys.Control | Keys.P),
Hk(RevisionGridControl.Commands.GoToChild, Keys.Control | Keys.N),
Hk(RevisionGridControl.Commands.NextQuickSearch, Keys.Alt | Keys.Down),
Hk(RevisionGridControl.Commands.PrevQuickSearch, Keys.Alt | Keys.Up),
Hk(RevisionGridControl.Commands.RevisionFilter, Keys.Control | Keys.F),
Hk(RevisionGridControl.Commands.SelectCurrentRevision, Keys.Control | Keys.Shift | Keys.C),
Hk(RevisionGridControl.Commands.SelectAsBaseToCompare, Keys.Control | Keys.L),
Hk(RevisionGridControl.Commands.ShowAllBranches, Keys.Control | Keys.Shift | Keys.A),
Hk(RevisionGridControl.Commands.ShowCurrentBranchOnly, Keys.Control | Keys.Shift | Keys.U),
Hk(RevisionGridControl.Commands.ShowFilteredBranches, Keys.Control | Keys.Shift | Keys.T),
Hk(RevisionGridControl.Commands.ShowFirstParent, Keys.Control | Keys.Shift | Keys.S),
Hk(RevisionGridControl.Commands.ShowRemoteBranches, Keys.Control | Keys.Shift | Keys.R),
Hk(RevisionGridControl.Commands.ToggleRevisionGraph, Keys.None),
Hk(RevisionGridControl.Commands.ToggleAuthorDateCommitDate, Keys.None),
Hk(RevisionGridControl.Commands.ToggleOrderRevisionsByDate, Keys.None),
Expand All @@ -294,25 +315,7 @@ public static HotkeySettings[] CreateDefaultSettings()
Hk(RevisionGridControl.Commands.ToggleShowGitNotes, Keys.None),
Hk(RevisionGridControl.Commands.ToggleShowMergeCommits, Keys.Control | Keys.Shift | Keys.M),
Hk(RevisionGridControl.Commands.ToggleShowTags, Keys.Control | Keys.Alt | Keys.T),
Hk(RevisionGridControl.Commands.ShowAllBranches, Keys.Control | Keys.Shift | Keys.A),
Hk(RevisionGridControl.Commands.ShowCurrentBranchOnly, Keys.Control | Keys.Shift | Keys.U),
Hk(RevisionGridControl.Commands.ShowFilteredBranches, Keys.Control | Keys.Shift | Keys.T),
Hk(RevisionGridControl.Commands.ShowRemoteBranches, Keys.Control | Keys.Shift | Keys.R),
Hk(RevisionGridControl.Commands.ShowFirstParent, Keys.Control | Keys.Shift | Keys.S),
Hk(RevisionGridControl.Commands.GoToParent, Keys.Control | Keys.P),
Hk(RevisionGridControl.Commands.GoToChild, Keys.Control | Keys.N),
Hk(RevisionGridControl.Commands.ToggleHighlightSelectedBranch, Keys.Control | Keys.Shift | Keys.B),
Hk(RevisionGridControl.Commands.NextQuickSearch, Keys.Alt | Keys.Down),
Hk(RevisionGridControl.Commands.PrevQuickSearch, Keys.Alt | Keys.Up),
Hk(RevisionGridControl.Commands.SelectCurrentRevision, Keys.Control | Keys.Shift | Keys.C),
Hk(RevisionGridControl.Commands.SelectAsBaseToCompare, Keys.Control | Keys.L),
Hk(RevisionGridControl.Commands.CompareToBase, Keys.Control | Keys.R),
Hk(RevisionGridControl.Commands.GoToCommit, Keys.Control | Keys.Shift | Keys.G),
Hk(RevisionGridControl.Commands.CreateFixupCommit, Keys.Control | Keys.X),
Hk(RevisionGridControl.Commands.CompareToWorkingDirectory, Keys.Control | Keys.D),
Hk(RevisionGridControl.Commands.CompareToCurrentBranch, Keys.None),
Hk(RevisionGridControl.Commands.CompareToBranch, Keys.None),
Hk(RevisionGridControl.Commands.CompareSelectedCommits, Keys.None)),
Hk(RevisionGridControl.Commands.ToggleHighlightSelectedBranch, Keys.Control | Keys.Shift | Keys.B)),
new HotkeySettings(
FileViewer.HotkeySettingsName,
Hk(FileViewer.Commands.Find, Keys.Control | Keys.F),
Expand All @@ -321,10 +324,10 @@ public static HotkeySettings[] CreateDefaultSettings()
Hk(FileViewer.Commands.GoToLine, Keys.Control | Keys.G),
Hk(FileViewer.Commands.IncreaseNumberOfVisibleLines, Keys.None),
Hk(FileViewer.Commands.DecreaseNumberOfVisibleLines, Keys.None),
Hk(FileViewer.Commands.ShowEntireFile, Keys.None),
Hk(FileViewer.Commands.TreatFileAsText, Keys.None),
Hk(FileViewer.Commands.NextChange, Keys.Alt | Keys.Down),
Hk(FileViewer.Commands.PreviousChange, Keys.Alt | Keys.Up)),
Hk(FileViewer.Commands.PreviousChange, Keys.Alt | Keys.Up),
Hk(FileViewer.Commands.ShowEntireFile, Keys.None),
Hk(FileViewer.Commands.TreatFileAsText, Keys.None)),
new HotkeySettings(
FormResolveConflicts.HotkeySettingsName,
Hk(FormResolveConflicts.Commands.ChooseBase, Keys.B),
Expand All @@ -334,19 +337,19 @@ public static HotkeySettings[] CreateDefaultSettings()
Hk(FormResolveConflicts.Commands.Rescan, Keys.F5)),
new HotkeySettings(
RevisionDiffControl.HotkeySettingsName,
Hk(RevisionDiffControl.Command.DeleteSelectedFiles, Keys.Delete),
Hk(RevisionDiffControl.Command.ShowHistory, ShowHistoryHotkey),
Hk(RevisionDiffControl.Command.Blame, BlameHotkey),
Hk(RevisionDiffControl.Command.DeleteSelectedFiles, Keys.Delete),
Hk(RevisionDiffControl.Command.EditFile, EditFileHotkey),
Hk(RevisionDiffControl.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(RevisionDiffControl.Command.EditFile, EditFileHotkey)),
Hk(RevisionDiffControl.Command.ShowHistory, ShowHistoryHotkey)),
new HotkeySettings(
RevisionFileTreeControl.HotkeySettingsName,
Hk(RevisionFileTreeControl.Command.ShowHistory, ShowHistoryHotkey),
Hk(RevisionFileTreeControl.Command.Blame, BlameHotkey),
Hk(RevisionFileTreeControl.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(RevisionFileTreeControl.Command.EditFile, EditFileHotkey),
Hk(RevisionFileTreeControl.Command.OpenAsTempFile, OpenAsTempFileHotkey),
Hk(RevisionFileTreeControl.Command.OpenAsTempFileWith, OpenAsTempFileWithHotkey),
Hk(RevisionFileTreeControl.Command.EditFile, EditFileHotkey)),
Hk(RevisionFileTreeControl.Command.OpenWithDifftool, OpenWithDifftoolHotkey),
Hk(RevisionFileTreeControl.Command.ShowHistory, ShowHistoryHotkey)),
new HotkeySettings(
FormSettings.HotkeySettingsName,
LoadScriptHotkeys())
Expand Down

0 comments on commit 69502a8

Please sign in to comment.