Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

Convert to Email Style Quoted Text

Description
Takes a block of text, adds a line break every ~73 characters (depends on word length), and adds a "greater than" symbol at the start of each line.
Language
C#.net
Minimum Version
Created By
Thomas Malloch (BFS)
Contributors
-
Date Created
Aug 19, 2014
Date Last Modified
Aug 19, 2014

Macro Code

using System;
using System.Text;

public static class ClipboardFusionHelper
{
        public static string ProcessText(string text)

        {
            string output = "> ";
            int charCount = 0;

            foreach (string word in text.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries))
            {
                if ((word.Contains("\n")) || (word.Contains("\r")) || (word.Contains("\0")))
                {
                    string newWord = word.Replace(Environment.NewLine, "\n");
                    newWord = newWord.Replace("\r", "\n");
                    newWord = newWord.Replace("\0", "\n");
                    output += newWord.Replace("\n", Environment.NewLine + "> ") + " ";
                    charCount = newWord.Length + 1;
                }
                else if (charCount > 72 - word.Length)
                {
                    output = output.TrimEnd() + Environment.NewLine + "> " + word + " ";

                    charCount = word.Length + 1;
                }
                else
                {
                    output += word + " ";
                    charCount += word.Length + 1;
                }
            }

            return output;
        }
}