WindowText can't display newlines

Posted by Fiendish on Wed 30 Mar 2011 10:17 AM — 3 posts, 9,762 views.

USA Global Moderator #0
If you use WindowText to display a string that has newlines in it, they show as boxes. This doesn't seem appropriate. If we can't have them actually work, then it'd at least be better to just not show those box characters.
Amended on Wed 30 Mar 2011 11:37 AM by Fiendish
Australia Forum Administrator #1
Well for one thing I can't reproduce that after trying a couple of fonts:


win = "test_" .. GetPluginID ()  
WindowCreate (win, 0, 0, 180, 80, miniwin.pos_center_all, 0, 0xFFFFFF)
WindowFont (win, "f", "Helvetica", 10, true) -- define font
WindowText ( win, "f" , "Hello, world\n", 10, 10, 0, 0, 0, 0)
WindowShow (win,  true)  -- show it 


Result:



No doubt it does it for some of them, otherwise you wouldn't have reported it.

For another thing, some fonts actually take the opportunity to use those "non-printable" positions to slip in some graphical characters, which might be useful. For example:


win = "test_" .. GetPluginID ()  
WindowCreate (win, 0, 0, 380, 80, miniwin.pos_center_all, 0, 0xFFFFFF)
WindowFont (win, "f", "Helvetica", 10, true) -- define font

x = 10
for i = 0, 32 do
  x = x + WindowText ( win, "f" , string.char (i), x, 10, 0, 0, 0, 0)
end
WindowShow (win,  true)  -- show it 


Result:



So if I suppress character 10 just because it makes a box you don't like, then that will drop one of those graphic characters from your ability to display them. Why do that?

WindowText is an interface to the low-level character drawing routines. It doesn't claim to handle newlines or to suppress them. However I'll update the documentation to make that clearer.
USA Global Moderator #2
Quote:
Well for one thing I can't reproduce that after trying a couple of fonts:

Odd. Well, it's not a huge deal anyway. As ever, I just reconsidered what I was trying to do and worked around my misunderstanding of the function. It turns out that just keeping the newlines in place would have broken what I was trying to do anyway (more updates to the Aardwolf chat capture window).