/// <summary> /// The number of lines in a given terminal. /// </summary> /// <param name="target"></param> public int LineCount(TerminalTarget target) { switch (target) { case TerminalTarget.None: return(0); case TerminalTarget.Main: return(App.MainWindow.GameTerminal.LineCount); case TerminalTarget.Terminal1: return(App.MainWindow.Terminal1.LineCount); case TerminalTarget.Terminal2: return(App.MainWindow.Terminal2.LineCount); case TerminalTarget.BackBuffer: return(App.MainWindow.GameBackBufferTerminal.LineCount); case TerminalTarget.Terminal3: return(App.MainWindow.Terminal3.LineCount); } return(0); }
/// <summary> /// Clears the contents of the specified terminal. /// </summary> /// <param name="target"></param> public void ClearTerminal(TerminalTarget target) { Application.Current.Dispatcher.Invoke(new Action(() => { switch (target) { case TerminalTarget.None: break; case TerminalTarget.Main: App.MainWindow.GameTerminal.Text = ""; break; case TerminalTarget.Communication: App.MainWindow.CommunicationTerminal.Text = ""; break; case TerminalTarget.OutOfCharacterCommunication: App.MainWindow.OocCommunicationTerminal.Text = ""; break; case TerminalTarget.BackBuffer: App.MainWindow.GameBackBufferTerminal.Text = ""; break; } })); }
/// <summary> /// Gets the selected text from the requested window. /// </summary> /// <param name="target"></param> /// <returns></returns> public string GetSelectedText(TerminalTarget target, bool removeColors) { var sb = new StringBuilder(); Application.Current.Dispatcher.Invoke(new Action(() => { switch (target) { case TerminalTarget.Main: sb.Append(App.MainWindow.GameTerminal.SelectedText); break; case TerminalTarget.Communication: sb.Append(App.MainWindow.CommunicationTerminal.SelectedText); break; case TerminalTarget.OutOfCharacterCommunication: sb.Append(App.MainWindow.OocCommunicationTerminal.SelectedText); break; } })); if (removeColors) { Colorizer.RemoveAllAnsiCodes(sb); } return(sb.ToString()); }
/// <summary> /// Clears the contents of the specified terminal. /// </summary> /// <param name="target"></param> public void ClearTerminal(TerminalTarget target) { // If it doesn't have access then execute the same function on the UI thread, otherwise just run it. if (!Application.Current.Dispatcher.CheckAccess()) { Application.Current.Dispatcher.BeginInvoke(new Action(() => ClearTerminal(target))); return; } switch (target) { case TerminalTarget.None: break; case TerminalTarget.Main: App.MainWindow.GameTerminal.ClearText(); break; case TerminalTarget.Terminal1: App.MainWindow.Terminal1.ClearText(); break; case TerminalTarget.Terminal2: App.MainWindow.Terminal2.ClearText(); break; case TerminalTarget.BackBuffer: App.MainWindow.GameBackBufferTerminal.ClearText(); break; case TerminalTarget.Terminal3: App.MainWindow.Terminal3.ClearText(); break; } }
/// <summary> /// Writes output to the specified terminal window. This procedure writes directly to the /// terminal and does not go through processing as when other data comes in through the OnEcho /// event (that gets processed for triggers). We don't want triggers processed from here. /// </summary> /// <param name="line"></param> /// <param name="target"></param> public void EchoText(Line line, TerminalTarget target) { switch (target) { case TerminalTarget.None: case TerminalTarget.Main: Application.Current.Dispatcher.Invoke(new Action(() => { App.MainWindow.GameTerminal.Append(line); })); break; case TerminalTarget.Communication: Application.Current.Dispatcher.Invoke(new Action(() => { App.MainWindow.CommunicationTerminal.Append(line); })); break; case TerminalTarget.OutOfCharacterCommunication: Application.Current.Dispatcher.Invoke(new Action(() => { App.MainWindow.OocCommunicationTerminal.Append(line); })); break; } }
/// <summary> /// Writes output to the main terminal window. /// </summary> /// <param name="text"></param> /// <param name="foregroundColor"></param> /// <param name="terminal"></param> public void EchoText(string text, AnsiColor foregroundColor, TerminalTarget terminal) { var line = text.ToLine(); line.ForegroundColor = foregroundColor; line.IgnoreLastColor = true; EchoText(line, terminal); }
/// <summary> /// The number of lines in a given terminal. /// </summary> /// <param name="target"></param> public int LineCount(TerminalTarget target) { switch (target) { case TerminalTarget.None: return(0); case TerminalTarget.Main: return(App.MainWindow.GameTerminal.LineCount); case TerminalTarget.Communication: return(App.MainWindow.CommunicationTerminal.LineCount); case TerminalTarget.OutOfCharacterCommunication: return(App.MainWindow.OocCommunicationTerminal.LineCount); } return(0); }
/// <summary> /// Gets the selected text from the requested window. /// </summary> /// <param name="target"></param> /// <param name="removeColors"></param> public string GetSelectedText(TerminalTarget target, bool removeColors) { // If it doesn't have access then execute the same function on the UI thread, otherwise just run it. if (!Application.Current.Dispatcher.CheckAccess()) { string buf = ""; Application.Current.Dispatcher.Invoke(new Action(() => buf = GetSelectedText(target, removeColors))); return(buf); } var sb = new StringBuilder(); switch (target) { case TerminalTarget.Main: sb.Append(App.MainWindow.GameTerminal.SelectedText); break; case TerminalTarget.Terminal1: sb.Append(App.MainWindow.Terminal1.SelectedText); break; case TerminalTarget.Terminal2: sb.Append(App.MainWindow.Terminal2.SelectedText); break; case TerminalTarget.BackBuffer: sb.Append(App.MainWindow.GameBackBufferTerminal.SelectedText); break; case TerminalTarget.Terminal3: sb.Append(App.MainWindow.Terminal3.SelectedText); break; } if (removeColors) { Colorizer.RemoveAllAnsiCodes(sb); } return(sb.ToString()); }
public Trigger(string pattern, string command, string character = "", bool isSilent = false, string identifier = "", TerminalTarget moveTo = TerminalTarget.None, bool gag = false, string group = "", bool disableAfterTriggered = false, bool enabled = true, bool highlightLine = false, bool isLua = false, bool variableReplacement = false, bool systemTrigger = false, int priority = 10000, bool stopProcessing = false) { this.Pattern = pattern; this.Command = command; this.Character = character; this.IsSilent = isSilent; this.Identifier = identifier; this.MoveTo = moveTo; this.Gag = gag; this.Group = group; this.DisableAfterTriggered = disableAfterTriggered; this.Enabled = enabled; this.HighlightLine = highlightLine; this.IsLua = isLua; this.VariableReplacement = variableReplacement; this.SystemTrigger = systemTrigger; this.Priority = priority; this.StopProcessing = stopProcessing; _conveyor = AppServices.GetService <IConveyor>(); }
/// <summary> /// Writes output to the specified terminal window. This procedure writes directly to the /// terminal and does not go through processing as when other data comes in through the OnEcho /// event (that gets processed for triggers). We don't want triggers processed from here. /// </summary> /// <param name="line"></param> /// <param name="target"></param> public void EchoText(Line line, TerminalTarget target) { switch (target) { case TerminalTarget.None: case TerminalTarget.Main: Application.Current.Dispatcher.Invoke(new Action(() => { App.MainWindow.GameTerminal.Append(line); // If the back buffer setting is enabled put the data also in there. if (App.Settings.AvalonSettings.BackBufferEnabled) { line.ScrollToLastLine = false; App.MainWindow.GameBackBufferTerminal.Append(line); } })); break; case TerminalTarget.Communication: Application.Current.Dispatcher.Invoke(new Action(() => { App.MainWindow.CommunicationTerminal.Append(line); })); break; case TerminalTarget.OutOfCharacterCommunication: Application.Current.Dispatcher.Invoke(new Action(() => { App.MainWindow.OocCommunicationTerminal.Append(line); })); break; } }
/// <summary> /// Tells the implementing window or form that it needs to echo some text to it's terminal. /// </summary> /// <param name="text"></param> /// <param name="foregroundColor"></param> /// <param name="reverseColors"></param> /// <param name="terminal">The terminal that the main window should try to echo to.</param> public void EchoText(string text, AnsiColor foregroundColor, bool reverseColors, TerminalTarget terminal) { var e = new EchoEventArgs { Text = $"{text}\r\n", UseDefaultColors = false, ForegroundColor = foregroundColor, ReverseColors = reverseColors, Terminal = terminal }; this.OnEcho(e); }
/// <summary> /// Writes output to the specified terminal window. /// </summary> /// <param name="text"></param> /// <param name="target"></param> public void EchoText(string text, TerminalTarget target) { EchoText(text.ToLine(), target); }
public Trigger(string pattern, string command, string character, bool silent, string identifier, TerminalTarget moveTo, bool gag) { this.Pattern = pattern; this.Command = command; this.Character = character; this.Identifier = identifier; this.IsSilent = silent; this.MoveTo = moveTo; this.Gag = gag; }
/// <summary> /// Writes output to the specified terminal window. This procedure writes directly to the /// terminal and does not go through processing as when other data comes in through the OnEcho /// event (that gets processed for triggers). We don't want triggers processed from here. /// </summary> /// <param name="line"></param> /// <param name="target"></param> public void EchoText(Line line, TerminalTarget target) { // If it doesn't have access then execute the same function on the UI thread, otherwise just run it. if (!Application.Current.Dispatcher.CheckAccess()) { Application.Current.Dispatcher.BeginInvoke(new Action(() => EchoText(line, target))); return; } var sb = Argus.Memory.StringBuilderPool.Take(line.FormattedText); Colorizer.MudToAnsiColorCodes(sb); line.FormattedText = sb.ToString(); Argus.Memory.StringBuilderPool.Return(sb); switch (target) { case TerminalTarget.None: case TerminalTarget.Main: App.MainWindow.GameTerminal.Append(line); // If the back buffer setting is enabled put the data also in there. if (App.Settings.AvalonSettings.BackBufferEnabled) { line.ScrollToLastLine = false; App.MainWindow.GameBackBufferTerminal.Append(line); } break; case TerminalTarget.Terminal1: App.MainWindow.Terminal1.Append(line); if (!App.MainWindow.CustomTab1.IsSelected) { App.MainWindow.CustomTab1Badge.Value += 1; } else if (App.MainWindow.CustomTab1.IsSelected && App.MainWindow.CustomTab1Badge.Value != 0) { // Only setting this if the value isn't 0 so it doesn't trigger UI processing. App.MainWindow.CustomTab1Badge.Value = 0; } break; case TerminalTarget.Terminal2: App.MainWindow.Terminal2.Append(line); if (!App.MainWindow.CustomTab2.IsSelected) { App.MainWindow.CustomTab2Badge.Value += 1; } else if (App.MainWindow.CustomTab2.IsSelected && App.MainWindow.CustomTab2Badge.Value != 0) { // Only setting this if the value isn't 0 so it doesn't trigger UI processing. App.MainWindow.CustomTab2Badge.Value = 0; } break; case TerminalTarget.Terminal3: App.MainWindow.Terminal3.Append(line); if (!App.MainWindow.CustomTab3.IsSelected) { App.MainWindow.CustomTab3Badge.Value += 1; } else if (App.MainWindow.CustomTab3.IsSelected && App.MainWindow.CustomTab3Badge.Value != 0) { // Only setting this if the value isn't 0 so it doesn't trigger UI processing. App.MainWindow.CustomTab3Badge.Value = 0; } break; } }
public Trigger(string pattern, string command, string character, bool isSilent, string identifier, TerminalTarget moveTo, bool gag) { this.Pattern = pattern; this.Command = command; this.Character = character; this.Identifier = identifier; this.IsSilent = isSilent; this.MoveTo = moveTo; this.Gag = gag; _conveyor = AppServices.GetService <IConveyor>(); }
/// <summary> /// Writes output to the main terminal window. /// </summary> /// <param name="text"></param> /// <param name="foregroundColor"></param> /// <param name="terminal"></param> public void EchoText(string text, AnsiColor foregroundColor, TerminalTarget terminal) { EchoText(text.ToLine().ForegroundColor = foregroundColor, terminal); }