void AddChatState(MessageModel msg) { DeleteOldChatState(); var buffer = OutputMessageTextView.Buffer; buffer.AddMark(ChatStateStartPosition, buffer.EndIter); OutputMessageTextView.AddMessage(msg, false, false); ChatStatePositionValid = true; }
void DeleteOldChatState() { if (!ChatStatePositionValid) { return; } var buffer = OutputMessageTextView.Buffer; var start = buffer.GetIterAtMark(ChatStateStartPosition); var end = buffer.EndIter; buffer.Delete(ref start, ref end); buffer.DeleteMark(ChatStateStartPosition); if (buffer.EndIter.Offset < OutputMessageTextView.MarkerlineBufferPosition) { // in the rare case that the markeline is below the dots, move it to the correct position OutputMessageTextView.UpdateMarkerline(); } ChatStatePositionValid = false; }
void UpdateChatState() { DeleteOldChatState(); if (LastPresenceMessage == null && TypingDots == null) { // nothing to display return; } var buffer = OutputMessageTextView.Buffer; buffer.AddMark(ChatStateStartPosition, buffer.EndIter); if (TypingDots != null) { OutputMessageTextView.AddMessage(TypingDots, true, false); } if (LastPresenceMessage != null) { OutputMessageTextView.AddMessage(LastPresenceMessage, false); } ChatStatePositionValid = true; }