PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.21k stars 463 forks source link

Can I use "FastColoredTextBox" to transfer formatted code to RTF? #175

Closed it19862 closed 4 years ago

it19862 commented 4 years ago

There is: the file "Code.cs", which contains the code;

Logics:

  1. Get the code from the file "Code.cs";
  2. Format the syntax;
  3. Insert the code into the file "* .rtf";
  4. User. Opens the file "* .rtf", sees the formatted code (with syntax highlighting);

Objectives: Minimum: do at least some formatting of the code. Maximum: make code formatting as in VisualStruio.

Questions. How to apply your library to my task?

Code (preliminary)

public List<string> GetContetn()
        {
            string[] lines = File.ReadAllLines(@"c:\test\visualStudio\01\Code.cs");

            List<string> list = new List<string>(); // Результат
            for (int i = 1; i < lines.Length; i++)
            {
                if (lines[i] == "")
                    continue;
                // string[] lineParts = lines[i].Split(' ');
                list.Add(lines[i]);
            }

            return list;
        }
WrongBit commented 4 years ago

@it19862: I think you loose understanding what is EDITOR and what is IDE. FCTB has nothing common with CSharp, XML or any other language. It's editor with ability to colorize characters. Period. Everything else is just "extra" addons/helpers/utilities. If you want to make VisualStudio - go ahead and do it, but don't ask us to convert editor into IDE.

PavelTorgashov commented 4 years ago

@it19862 You can open file in FTCB and then read property public string Rtf. This property returns text formatted as RTF. Also you can use class ExportToRTF to make export to RTF more flexibility.