* Update settings window layout with consistent margins Updated the layout of the different views of the settings window so that there is always margin at the bottom. In some cases this was achieved using <StackPanels> for clarity and extensibility, grouping e.g. a title and some radio options together with one unified margin. Also made some small consistency changes to the .xaml files. * Add width to Themes text input * Normalize margins in settings * Add default display values in Terminal settings ... for Arguments and Working Directory * Generalize TemplateSelector for empty strings * Add default display value for profile keybindings * Update margins and fontsize in theme preview * Update 'loading...' message in About ... to "Checking for updates..." and a spinner as suggested by @skipmeister123 * No popup when cancelling profile edit no changes * Delete profile when new and cancelled * Open new and cloned themes in edit mode ... and make it so canceling deletes the theme. * No popup when cancelling theme edit no changes * Add resources for margin definitions * Check for null Author in TerminalTheme * Add resource for header margin definition * Moved createdBy text to code behind
79 lines
2.8 KiB
C#
79 lines
2.8 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 string Arguments { get; set; }
|
|
public string Location { get; set; }
|
|
public string WorkingDirectory { get; set; }
|
|
public int TabThemeId { get; set; }
|
|
public LineEndingStyle LineEndingTranslation { get; set; }
|
|
|
|
public string TranslateLineEndings(string content)
|
|
{
|
|
switch (LineEndingTranslation)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
} |