digitalmars.D.learn - text wrap
- Joel (11/11) Sep 19 2015 What is simple way to wrap a string into strings?
- Doxin (7/18) Sep 19 2015 a common method works as follows. first you split your string
- Doxin (7/8) Sep 19 2015 here you go: http://dpaste.dzfl.pl/e6e715c54c1b
- Joel (3/11) Sep 19 2015 Thanks Doxin. I going with the Phobos one, though. I've added
- Vladimir Panteleev (2/13) Sep 19 2015 http://dlang.org/phobos/std_string.html#.wrap
- Joel (2/13) Sep 19 2015 Actually, I did a search and found this. import std.string.wrap;
What is simple way to wrap a string into strings? Eg from: I went for a walk and fell down a hole. To (6 max width): I went for a walk and fell down a hole.
Sep 19 2015
On Sunday, 20 September 2015 at 00:22:17 UTC, Joel wrote:What is simple way to wrap a string into strings? Eg from: I went for a walk and fell down a hole. To (6 max width): I went for a walk and fell down a hole.a common method works as follows. first you split your string into chunks where newlines might appear. e.g. after every space. then you keep track of a "line buffer", you keep adding chunks to the line buffer until it's too wide, then you remove one chunk and output the buffer as a line. rinse and repeat. I'll get to work on some example code.
Sep 19 2015
On Sunday, 20 September 2015 at 00:28:23 UTC, Doxin wrote:I'll get to work on some example code.here you go: http://dpaste.dzfl.pl/e6e715c54c1b do mind that this code has a couple issues, for example handing it a word longer than the break width will make it loop infinitely. word wrap is a surprisingly hard problem, but I hope I gave you a good enough starting point.
Sep 19 2015
On Sunday, 20 September 2015 at 00:48:39 UTC, Doxin wrote:On Sunday, 20 September 2015 at 00:28:23 UTC, Doxin wrote:Thanks Doxin. I going with the Phobos one, though. I've added your code to my large amount to of small programs.I'll get to work on some example code.here you go: http://dpaste.dzfl.pl/e6e715c54c1b do mind that this code has a couple issues, for example handing it a word longer than the break width will make it loop infinitely. word wrap is a surprisingly hard problem, but I hope I gave you a good enough starting point.
Sep 19 2015
On Sunday, 20 September 2015 at 00:22:17 UTC, Joel wrote:What is simple way to wrap a string into strings? Eg from: I went for a walk and fell down a hole. To (6 max width): I went for a walk and fell down a hole.
Sep 19 2015
On Sunday, 20 September 2015 at 00:22:17 UTC, Joel wrote:What is simple way to wrap a string into strings? Eg from: I went for a walk and fell down a hole. To (6 max width): I went for a walk and fell down a hole.Actually, I did a search and found this. import std.string.wrap;
Sep 19 2015