public ColorMessage DispatchPromptEvent(ColorMessage colorPrompt) { if (PromptEvent == null) { return(colorPrompt); } foreach (PromptEventDelegate del in PromptEvent.GetInvocationList()) { try { colorPrompt = del(colorPrompt); } catch (Exception e) { ChiConsole.WriteError("Error calling prompt handler", e); } if (colorPrompt == null) { break; } } return(colorPrompt); }
public ColorMessage DispatchOutputMessage(ColorMessage colorMessage) { if (OutputEvent == null) { return(colorMessage); } foreach (OutputEventDelegate del in OutputEvent.GetInvocationList()) { try { colorMessage = del(colorMessage); } catch (Exception e) { ChiConsole.WriteError("Error calling output handler", e); } if (colorMessage == null) { break; } } return(colorMessage); }
public void Insert(int index, ColorMessage msg) { m_text.Insert(index, msg.m_text); int i = 0; while (i < m_metaData.Count && m_metaData[i].m_index < index) { i++; } m_metaData.InsertRange(i, msg.m_metaData); int t = 0; while (t < msg.m_metaData.Count) { m_metaData[i + t].m_index += index; t++; } i += t; while (i < m_metaData.Count) { m_metaData[i].m_index += msg.m_text.Length; i++; } Validate(); }
bool ReplaceCallback(ColorMessage msg, Match match, object userdata) { if (m_subst == null) { m_subst = new TriggerManager.TriggerSubst(m_script); } List <object[]> inserts = new List <object[]>(); while (match.Success) { string str = m_subst.Replace(msg.Text, match); inserts.Add(new object[] { match.Index, match.Length, str }); match = match.NextMatch(); } inserts.Reverse(); foreach (object[] insert in inserts) { int idx = (int)insert[0]; int len = (int)insert[1]; string str = (string)insert[2]; msg.Remove(idx, len); msg.Insert(idx, str); } return(false); }
bool ScriptCallback(ColorMessage msg, Match match, object userdata) { if (m_scriptAction == null) { string parsedScript = TriggerManager.TriggerSubst.ReplaceScript(m_script); m_scriptAction = PythonInterface.PythonEngine.CreateMethod <TriggerAction>(parsedScript); } return(m_scriptAction(msg, match, userdata)); }
bool SendCallback(ColorMessage msg, Match match, object userdata) { if (m_subst == null) { m_subst = new TriggerManager.TriggerSubst(m_script); } string str = m_subst.Replace(msg.Text, match); if (PythonInterface.Network.IsConnected) { PythonInterface.Network.SendLine(str); } return(false); }
bool HiliteCallback(ColorMessage msg, Match match, object userdata) { if (m_hiliteLine) { msg.Colorize(0, msg.Length, m_style); //msg.SetText(ControlCodes.ColorizeString(msg.Text, m_fgColor, m_bgColor)); } else { while (match.Success) { msg.Colorize(match.Index, match.Length, m_style); match = match.NextMatch(); } } return(false); }
public ColorMessage HandleColorMessage(ColorMessage colorMessage) { foreach (Trigger trigger in m_triggerList) { if (trigger.Regex == null) { continue; } Match match = trigger.Regex.Match(colorMessage.Text); if (match.Success == false) { continue; } bool gag = false; try { gag = trigger.Action(colorMessage, match, trigger.UserData); } catch (Exception e) { ChiConsole.WriteError("Failed to run trigger action for trigger ID " + trigger.TriggerID.ToString(), e); } if (trigger.IsGag || gag) { colorMessage = null; break; } if (trigger.IsFallThrough == false) { break; } } return(colorMessage); }
public static ColorMessage CreateFromAnsi(string str, AnsiTextStyle lastStyle) { ColorMessage colorMsg = Ansi.ParseAnsi(str, ref lastStyle); return(colorMsg); }
public static void WriteLine(ColorMessage msg) { s_console.WriteLine(msg); }
public void WriteLine(ColorMessage msg) { Console.WriteLine(msg.Text); }