Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keybinding to change the (current) tab title #193

Merged
merged 2 commits into from Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 13 additions & 0 deletions FluentTerminal.App.Services/Implementation/DefaultValueProvider.cs
Expand Up @@ -116,6 +116,19 @@ public ICollection<KeyBinding> GetDefaultKeyBindings(Command command)
}
};

case Command.ChangeTabTitle:
return new List<KeyBinding>
{
new KeyBinding
{
Command = nameof(Command.ChangeTabTitle),
Ctrl = true,
Alt = false,
Shift = true,
Key = (int)ExtendedVirtualKey.R
}
};

case Command.CloseTab:
return new List<KeyBinding>
{
Expand Down
1 change: 1 addition & 0 deletions FluentTerminal.App.ViewModels/MainViewModel.cs
Expand Up @@ -45,6 +45,7 @@ public class MainViewModel : ViewModelBase
_keyboardCommandService = keyboardCommandService;
_keyboardCommandService.RegisterCommandHandler(nameof(Command.NewTab), () => AddTerminal(null, false, Guid.Empty));
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ConfigurableNewTab), () => AddTerminal(null, true, Guid.Empty));
_keyboardCommandService.RegisterCommandHandler(nameof(Command.ChangeTabTitle), () => SelectedTerminal.EditTitle());
_keyboardCommandService.RegisterCommandHandler(nameof(Command.CloseTab), CloseCurrentTab);

// Add all of the commands for switching to a tab of a given ID, if there's one open there
Expand Down
18 changes: 9 additions & 9 deletions FluentTerminal.App.ViewModels/TerminalViewModel.cs
Expand Up @@ -221,6 +221,15 @@ public Task FocusTerminal()
return _terminalView?.FocusTerminal();
}

public async Task EditTitle()
{
var result = await _dialogService.ShowInputDialogAsync("Edit Title");
if (result != null)
{
Title = result;
}
}

public async Task OnViewIsReady(ITerminalView terminalView)
{
_terminalView = terminalView;
Expand Down Expand Up @@ -406,15 +415,6 @@ private void SelectTabTheme(string name)
TabTheme = TabThemes.FirstOrDefault(t => t.Name == name);
}

private async Task EditTitle()
{
var result = await _dialogService.ShowInputDialogAsync("Edit Title");
if (result != null)
{
Title = result;
}
}

private async Task TryClose()
{
if (ApplicationSettings.ConfirmClosingTabs)
Expand Down
3 changes: 3 additions & 0 deletions FluentTerminal.Models/Enums/Command.cs
Expand Up @@ -19,6 +19,9 @@ public enum Command
[Description("Configurable new tab")]
ConfigurableNewTab,

[Description("Change tab title")]
ChangeTabTitle,

[Description("Close tab")]
CloseTab,

Expand Down
1 change: 1 addition & 0 deletions FluentTerminal.Models/KeyBindings.cs
Expand Up @@ -9,6 +9,7 @@ public class KeyBindings
public ICollection<KeyBinding> PreviousTab { get; set; }
public ICollection<KeyBinding> NewTab { get; set; }
public ICollection<KeyBinding> ConfigurableNewTab { get; set; }
public ICollection<KeyBinding> ChangeTabTitle { get; set; }
public ICollection<KeyBinding> CloseTab { get; set; }
public ICollection<KeyBinding> NewWindow { get; set; }
public ICollection<KeyBinding> ShowSettings { get; set; }
Expand Down