-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStatusLine.cs
41 lines (33 loc) · 1.26 KB
/
StatusLine.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace FluentAutomation.REPL
{
public class StatusLine
{
private UserSettings settings = null;
private StatusViewModel viewModel = null;
public StatusLine(UserSettings settings, StatusViewModel viewModel)
{
this.settings = settings;
this.viewModel = viewModel;
}
public override string ToString()
{
// token replacement
var formatString = this.settings.StatusLineString;
if (this.viewModel.Url != null)
formatString = formatString.Replace("$site", this.viewModel.Url.DnsSafeHost);
if (!string.IsNullOrEmpty(this.viewModel.Name))
formatString = formatString.Replace("$name", this.viewModel.Name);
if (this.viewModel.Browser.HasValue)
formatString = formatString.Replace("$browser", this.viewModel.Browser.ToString().ToLower());
// strip any unreplaced tokens
formatString = Regex.Replace(formatString, "\\$\\w+", "");
return formatString + settings.StatusLineSeparator;
}
}
}