* Implementing SSH (changes from ap/ssh branch). * Implemented opening links in the last active window. * Using settings to determine where to open link (tab or window). * Adding FluentTerminal.App_TemporaryKey.pfx back to repo, to solve bug with keys. * App activation on mosh schema launching; mosh protocol parsing. (#35) * SSH handling changed to improve links. * Creating shortcuts from SSH dialog. * Trivial Mosh checkbox label fix It's "Mosh" not "MOSH". * Obtain mosh key from ssh connection (#40) * Prepopulate SSH username with Windows username (#50) * Undoing Max's mosh authentication changes. * Adding the new mosh wrapper. * Request user name from tray process (#51) * Mosh implemented, but still doesn't work (cannot find mosh.exe). * Add New Remote Shell menu; Rename New Tab into New Local Shell (#52) * Mosh works like charm. * Mosh wrapper improved to print an error. * Changing mosh wrapper to always exit with 0 (to ensure that the tab gets closed). * Changing mosh wrapper again to return error codes. * Slightly optimizing getting the username. * Saving links improved. * Fixed an issue in mosh wrapper, related to mosh to hostname. * mosh-client.exe updated with 32 bit version for x86 platform (#59) * Set line endings for remote shell connection; Left focus on SSH info dialog if input validation error occured; Update DataContext object on each key entered into target host text box control. * Simplifying SSH dialog. * Fixing some leftovers after merging. * Fixing some after-merge issues. * Avoiding some unintentional upstream changes. * Fix review findings
91 lines
3.3 KiB
C#
91 lines
3.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.RegularExpressions;
|
|
using FluentTerminal.Models.Enums;
|
|
using System.Linq;
|
|
|
|
namespace FluentTerminal.Models
|
|
{
|
|
public class ShellProfile
|
|
{
|
|
/// <summary>
|
|
/// Replace all instances of anything resembling a newline, treating pairs of \r\n in either order as a single linebreak.
|
|
/// </summary>
|
|
public static Regex NewlinePattern = new Regex(@"\n\r|\r\n|\r|\n", RegexOptions.Compiled);
|
|
|
|
public ShellProfile()
|
|
{
|
|
|
|
}
|
|
|
|
public ShellProfile(ShellProfile other)
|
|
{
|
|
Id = other.Id;
|
|
PreInstalled = other.PreInstalled;
|
|
Name = other.Name;
|
|
Arguments = other.Arguments;
|
|
Location = other.Location;
|
|
WorkingDirectory = other.WorkingDirectory;
|
|
TabThemeId = other.TabThemeId;
|
|
TerminalThemeId = other.TerminalThemeId;
|
|
LineEndingTranslation = other.LineEndingTranslation;
|
|
KeyBindings = other.KeyBindings.Select(x => new KeyBinding(x)).ToList();
|
|
}
|
|
|
|
public Guid Id { get; set; }
|
|
public bool PreInstalled { get; set; }
|
|
public string Name { get; set; }
|
|
public virtual string Arguments { get; set; }
|
|
public virtual string Location { get; set; }
|
|
public string WorkingDirectory { get; set; }
|
|
public int TabThemeId { get; set; }
|
|
public LineEndingStyle LineEndingTranslation { get; set; }
|
|
public Dictionary<string, string> EnvironmentVariables { get; } = new Dictionary<string, string>();
|
|
|
|
public string TranslateLineEndings(string content)
|
|
{
|
|
switch (LineEndingTranslation)
|
|
{
|
|
case LineEndingStyle.ToCR:
|
|
return NewlinePattern.Replace(content, "\r");
|
|
case LineEndingStyle.ToCRLF:
|
|
return NewlinePattern.Replace(content, "\r\n");
|
|
case LineEndingStyle.ToLF:
|
|
return NewlinePattern.Replace(content, "\n");
|
|
case LineEndingStyle.DoNotModify:
|
|
default:
|
|
return content;
|
|
}
|
|
}
|
|
|
|
public Guid TerminalThemeId { get; set; }
|
|
public ICollection<KeyBinding> KeyBindings { get; set; } = new List<KeyBinding>();
|
|
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (obj is ShellProfile other)
|
|
{
|
|
return other.Id.Equals(Id)
|
|
&& other.PreInstalled.Equals(PreInstalled)
|
|
&& other.Name.Equals(Name)
|
|
&& other.Arguments.Equals(Arguments)
|
|
&& other.Location.Equals(Location)
|
|
&& other.WorkingDirectory.Equals(WorkingDirectory)
|
|
&& other.TabThemeId.Equals(TabThemeId)
|
|
&& other.TerminalThemeId.Equals(TerminalThemeId)
|
|
&& other.LineEndingTranslation == LineEndingTranslation
|
|
&& other.KeyBindings.SequenceEqual(KeyBindings);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Checks the profile for errors and returns string describing the found errors, if any.
|
|
/// Returns null if no errors found.
|
|
/// </summary>
|
|
public virtual string ValidateAndGetErrors()
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
} |