Files
Aleksandar Pesic e88fb78e9d Quick command implementation (#472)
* Separating "SSH Info" and "Quick Launch", and updating translations.

* Adding "Quick Launch" to menu.

* Auto-complete, initial version.

* Builds, but not finished.

* Improved, but there are still some bugs...

* Minor changes.

* Refactroing request/response identifiers.

* Improving command history.

* Minor refactoring.

* Deleting history by using "Del" key.

* Handling mosh special case in quick commands.

* SSH command handled as any other command in the path.

* New resource strings.

* Fixing quick command links.

* Fixing after-merging bugs.

* Improving filtering.

* Finishing filtering.

* Changing placeholder text.

* Minor refactoring.

* Updating resources.

* Renaming NewRemoteTab back to NewSshTab.
2019-08-08 08:02:09 +02:00

35 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace FluentTerminal.Models
{
public static class StringExtensions
{
private static readonly Regex RxNonWhiteSpace = new Regex(@"\S+", RegexOptions.Compiled);
/// <summary>
/// Compares two strings for equality, but assumes that null string is equal to an empty string.
/// </summary>
public static bool NullableEqualTo(this string original, string other,
StringComparison stringComparison = StringComparison.Ordinal) => string.IsNullOrEmpty(original)
? string.IsNullOrEmpty(other)
: original.Equals(other, stringComparison);
/// <summary>
/// Splits input text into words, by splitting at white-space characters. It doesn't take care about quotes.
/// </summary>
public static IEnumerable<string> SplitWords(this string text)
{
if (string.IsNullOrWhiteSpace(text))
{
yield break;
}
foreach (Match match in RxNonWhiteSpace.Matches(text.Trim()))
{
yield return match.Value;
}
}
}
}