예제 #1
0
        public void InsertPart(string text, Client.ContentLine.MessageStyle InputStyle, bool WriteLog = true, long Date = 0, bool SuppressPing = false, bool IgnoreUpdate = false)
        {
            DateTime time = DateTime.Now;

            if (Date != 0)
            {
                time = DateTime.FromBinary(Date);
            }

            if (EndingLine == null)
            {
                EndingLine = new ContentLine(InputStyle, text, time, false);

                if (Thread.CurrentThread == Core._KernelThread && (!Configuration.Scrollback.DynamicReload || WindowVisible()))
                {
                    if (lastDate > time)
                    {
                        Flush();
                        SortNeeded = true;
                        Reload(true);
                    }
                    else
                    {
                        InsertPartToText(EndingLine);
                    }
                }
                else
                {
                    lock (UndrawnTextParts)
                    {
                        UndrawnTextParts.Add(new TextPart(Configuration.Scrollback.format_date.Replace("$1",
                                          time.ToString(Configuration.Scrollback.timestamp_mask)) + text, InputStyle, time));
                    }
                }
            }
            else
            {
                lock (EndingLine)
                {
                    EndingLine.text += text;
                }

                if (Thread.CurrentThread == Core._KernelThread && (!Configuration.Scrollback.DynamicReload || WindowVisible()))
                {
                    InsertPartToText(text);
                }
                else
                {
                    lock (UndrawnTextParts)
                    {
                        UndrawnTextParts.Add(new TextPart(text, InputStyle, time));
                    }
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Insert a text to scrollback list
        /// </summary>
        /// <param name="text">Text</param>
        /// <param name="InputStyle">Style</param>
        /// <param name="WriteLog">Write to a log</param>
        /// <param name="Date">Date</param>
        /// <param name="SuppressPing">Suppress highlight</param>
        /// <param name="IgnoreUpdate"></param>
        /// <returns></returns>
        private bool insertText(string text, Client.ContentLine.MessageStyle InputStyle, bool WriteLog = true, long Date = 0, bool SuppressPing = false, bool IgnoreUpdate = false)
        {
            // we need to finish the previous partial line
            if (!IsEmtpy)
            {
                Flush();
            }
            // in case there are multiple lines we call this function for every line
            if (text.Contains('\n'))
            {
                string[] data = text.Split('\n');
                foreach (string Next in data)
                {
                    InsertText(Next, InputStyle, WriteLog, Date, SuppressPing);
                }
                return true;
            }

            if (owner != null && owner.MicroBox)
            {
                Core.SystemForm.micro.scrollback_mc.InsertText("{" + owner.WindowName + "} " + text, InputStyle, false, Date);
            }

            bool Matched = false;

            if (!SuppressPing)
            {
                Matched = Match(text);
            }

            if (Matched && owner != null && owner.Highlights)
            {
                if (Hooks._Scrollback.NotificationDisplay(text, InputStyle, ref WriteLog, Date, ref SuppressPing))
                {
                    Core.DisplayNote(text, owner.WindowName);
                }
            }

            if (!IgnoreUpdate && owner != null && owner != Core.SystemForm.Chat && owner._Network != null && owner._Network._Protocol != null && !owner._Network._Protocol.SuppressChanges)
            {
                switch (InputStyle)
                {
                    case ContentLine.MessageStyle.Kick:
                    case ContentLine.MessageStyle.System:
                        owner.MenuColor = Configuration.CurrentSkin.HighlightColor;
                        break;
                    case ContentLine.MessageStyle.Message:
                        if (owner.MenuColor != Configuration.CurrentSkin.HighlightColor)
                        {
                            owner.MenuColor = Configuration.CurrentSkin.ColorTalk;
                        }
                        break;
                    case ContentLine.MessageStyle.Action:
                        if (owner.MenuColor != Configuration.CurrentSkin.ColorTalk && owner.MenuColor != Configuration.CurrentSkin.HighlightColor)
                        {
                            owner.MenuColor = Configuration.CurrentSkin.MiscelancsColor;
                        }
                        break;
                    case ContentLine.MessageStyle.Part:
                    case ContentLine.MessageStyle.Channel:
                    case ContentLine.MessageStyle.User:
                    case ContentLine.MessageStyle.Join:
                        if (owner.MenuColor != Configuration.CurrentSkin.HighlightColor && owner.MenuColor != Configuration.CurrentSkin.MiscelancsColor && owner.MenuColor != Configuration.CurrentSkin.ColorTalk)
                        {
                            owner.MenuColor = Configuration.CurrentSkin.JoinColor;
                        }
                        break;
                }

                Graphics.PidgeonList.Updated = true;

                if (Matched)
                {
                    owner.MenuColor = Configuration.CurrentSkin.HighlightColor;
                }
            }

            DateTime time = DateTime.Now;

            if (Date != 0)
            {
                time = DateTime.FromBinary(Date);
            }

            ContentLine line = new ContentLine(InputStyle, text, time, Matched);

            lock (ContentLines)
            {
                ContentLines.Add(line);
                if (Date != 0)
                {
                    SortNeeded = true;
                }
            }

            if (WriteLog == true)
            {
                if (owner != null && owner._Network != null)
                {
                    if (logs.Count > 0)
                    {
                        lock (logs)
                        {
                            foreach (LI item in logs)
                            {
                                LineLogs.Log(item.text, item.style, owner, LogfilePath, item.date);
                            }
                            logs.Clear();
                        }
                    }
                    LineLogs.Log(text, InputStyle, owner, LogfilePath, time);
                }
                else
                {
                    LI item = new LI();
                    item.text = text;
                    item.style = InputStyle;
                    item.date = time;
                    lock (logs)
                    {
                        if (logs.Count > 100)
                        {
                            Core.DebugLog("Buffer overflow: more than 100 items waiting to be written to log: auto flushing");
                            logs.Clear();
                        }
                        logs.Add(item);
                    }
                }
            }

            Changed = true;

            if (Thread.CurrentThread == Core._KernelThread && (!Configuration.Scrollback.DynamicReload || WindowVisible()))
            {
                if (!RequireReload(time))
                {
                    InsertLineToText(line);
                    lastDate = time;
                }
                else
                {
                    SortNeeded = true;
                    Reload(true);
                }
            }
            else
            {
                if (!RequireReload(time))
                {
                    lock (UndrawnLines)
                    {
                        if (!UndrawnLines.Contains(line))
                        {
                            UndrawnLines.Add(line);
                        }
                    }
                    lastDate = time;
                }
                else
                {
                    SortNeeded = true;
                    ReloadWaiting = true;
                }
            }
            return false;
        }
예제 #3
0
        private void InsertPartToText(ContentLine line)
        {
            if (Configuration.Memory.EnableSimpleViewCache && simple)
            {
                if (!ScrollingEnabled)
                {
                    Changed = true;
                    return;
                }
                Gtk.TextIter iter = simpleview.Buffer.EndIter;
                if (!Configuration.Scrollback.KeepSpecialCharsSimple)
                {
                    simpleview.Buffer.Insert(ref iter, Configuration.Scrollback.format_date.Replace("$1",
                                              line.time.ToString(Configuration.Scrollback.timestamp_mask)) +
                                              Core.RemoveSpecial(line.text));
                }
                else
                {
                    simpleview.Buffer.Insert(ref iter, Configuration.Scrollback.format_date.Replace("$1",
                                          line.time.ToString(Configuration.Scrollback.timestamp_mask)) +
                                          line.text);
                }
                if (ScrollingEnabled)
                {
                    simpleview.ScrollToIter(simpleview.Buffer.GetIterAtLine(ContentLines.Count), 0, true, 0, 0);
                }
                Changed = false;
                return;
            }
            RT.InsertPart(CreateLine(line));

            Changed = false;
        }
예제 #4
0
        private Client.RichTBox.Line CreateLine(ContentLine Line)
        {
            Color color = Configuration.CurrentSkin.FontColor;
            switch (Line.style)
            {
                case Client.ContentLine.MessageStyle.Action:
                    color = Configuration.CurrentSkin.MiscelancsColor;
                    break;
                case Client.ContentLine.MessageStyle.Kick:
                    color = Configuration.CurrentSkin.KickColor;
                    break;
                case Client.ContentLine.MessageStyle.System:
                    color = Configuration.CurrentSkin.MiscelancsColor;
                    break;
                case Client.ContentLine.MessageStyle.Channel:
                    color = Configuration.CurrentSkin.ColorTalk;
                    break;
                case Client.ContentLine.MessageStyle.User:
                    color = Configuration.CurrentSkin.changenickcolor;
                    break;
                case Client.ContentLine.MessageStyle.Join:
                case Client.ContentLine.MessageStyle.Part:
                    color = Configuration.CurrentSkin.JoinColor;
                    break;
            }

            if (Line.notice)
            {
                color = Configuration.CurrentSkin.HighlightColor;
            }

            string stamp = "";
            if (Configuration.Scrollback.chat_timestamp)
            {
                stamp = Configuration.Scrollback.format_date.Replace("$1", Line.time.ToString(Configuration.Scrollback.timestamp_mask));
            }

            Client.RichTBox.Line text = Parser.FormatLine(Line.text, RT, color);
            Client.RichTBox.ContentText content = new Client.RichTBox.ContentText(stamp, color);
            Client.RichTBox.Line line = new Client.RichTBox.Line(RT);
            line.insertData(content);
            line.Merge(text);
            return line;
        }
예제 #5
0
        private static Client.RichTBox.ContentText CreateText(ContentLine line, string text)
        {
            Color color = Configuration.CurrentSkin.JoinColor;
            if (line != null)
            {
                switch (line.style)
                {
                    case Client.ContentLine.MessageStyle.Action:
                        color = Configuration.CurrentSkin.MiscelancsColor;
                        break;
                    case Client.ContentLine.MessageStyle.Kick:
                        color = Configuration.CurrentSkin.KickColor;
                        break;
                    case Client.ContentLine.MessageStyle.System:
                        color = Configuration.CurrentSkin.MiscelancsColor;
                        break;
                    case Client.ContentLine.MessageStyle.Channel:
                        color = Configuration.CurrentSkin.ColorTalk;
                        break;
                    case Client.ContentLine.MessageStyle.User:
                        color = Configuration.CurrentSkin.changenickcolor;
                        break;
                    case Client.ContentLine.MessageStyle.Join:
                    case Client.ContentLine.MessageStyle.Part:
                        color = Configuration.CurrentSkin.JoinColor;
                        break;
                }

                if (line.notice)
                {
                    color = Configuration.CurrentSkin.HighlightColor;
                }
            }

            return new Client.RichTBox.ContentText(text, color);
        }
예제 #6
0
 /// <summary>
 /// Creates a new instance of text part
 /// </summary>
 /// <param name="Text"></param>
 /// <param name="ms"></param>
 /// <param name="time"></param>
 public TextPart(string Text, ContentLine.MessageStyle ms, DateTime time)
 {
     date = time;
     text = Text;
     style = ms;
 }
예제 #7
0
파일: Class1.cs 프로젝트: JGunning/OpenAIM
 public override bool Hook_NotificationDisplay(string text, ContentLine.MessageStyle InputStyle, ref bool WriteLog, long Date, ref bool SuppressPing)
 {
     collector.scrollback.InsertText(text, InputStyle, false, Date, true);
     return true;
 }