goblinfactory / konsole

Home of the simple console library consisting of ProgressBar, Window, Form, Draw & MockConsole (C# console progress bar with support for single or multithreaded progress updates) Window is a 100%-ish console compatible window, supporting all normal console writing to a windowed section of the screen, supporting scrolling and clipping of console output.
718 stars 62 forks source link

Newline / carriage return? #61

Open martinweihrauch opened 4 years ago

martinweihrauch commented 4 years ago

Thank you for writing Konsole, I really dig it! Do you have a newline-character, which I can put into e. g. a Write or Writeline statement? \r\n does not work correctly. Thx

goblinfactory commented 4 years ago

this should be added....

goblinfactory commented 4 years ago

this will definitely be added to the next version. in the meantime you can create an extension method for yourself in the few cases you need it like this //PSUEDO CODE ... You need to write and test something properly yourself

public static class ConsoleHelper {

public static IConsole WriteLineSpecialChars(this IConsole con, string text) { 
   text.split("`\r\n").ToList().ForEach(line=> con.WriteLine(line));
  // edit this code further to add support for other special characters you need to support.
 // remember to test to make sure your implementation works for both \n as well as \n\r
}
}

that should be easy enough.

goblinfactory commented 3 years ago

@martinweihrauch this is now fixed in V7-alpha or later. You can now WriteLine("line1\nLine2\rLine3"); V7-Alpha or later. Packages are now in nuget : https://www.nuget.org/packages/Goblinfactory.Konsole/7.0.0.3-alpha