TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

#FORMAT %w? Word wrap clarification

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
Robbo76



Joined: 08 Jul 2016
Posts: 3

PostPosted: Sun Jul 10, 2016 12:16 pm    Post subject: #FORMAT %w? Word wrap clarification Reply with quote

Looking for some clarification, as it isn't well documented: If I use a #format command with %w to word wrap, at what width is it choosing to wrap? My terminal width? 80 chars? Is it configurable? If not, is there a better option?

I have a script that needs to generate formatted notes to a player, and lines must be wrapped to an 80 character or less width prior to sending.

Thoughts?
Back to top
View user's profile Send private message
Robbo76



Joined: 08 Jul 2016
Posts: 3

PostPosted: Sun Jul 10, 2016 10:07 pm    Post subject: Further notes... Reply with quote

Thought I should use an example, as it sounds like this is supposed to split things into 80-char wraps.

Code:
#FORMAT {formattedheader} {%w} {$crossheader[$i]};
#FOREACH {$formattedheader[%*]} {line} {#SHOWME $line;#FORMAT length {%L} {$line};#SHOWME {Length is $length};};


Input ($crossheader[i$]) is a 242 char string, several sentences. Output gives me 1 line, with length of 242. Perhaps I am misusing the list in the FOREACH statement.

-Rob
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Wed Jul 13, 2016 12:27 pm    Post subject: Reply with quote

I think that #format uses the entire length of the terminal, and I don't see a parameter to set it...

Anyway, you can use the #foreach code, just add a counter, and every time it reaches 80, #send all those chars and reset the counter
Back to top
View user's profile Send private message
Robbo76



Joined: 08 Jul 2016
Posts: 3

PostPosted: Wed Aug 03, 2016 2:53 pm    Post subject: Reply with quote

PowerGod wrote:
I think that #format uses the entire length of the terminal, and I don't see a parameter to set it...

Anyway, you can use the #foreach code, just add a counter, and every time it reaches 80, #send all those chars and reset the counter


This certainly doesn't do the trick, as it doesn't take into account whitespace vs. words - at least not without extra trickery.
Back to top
View user's profile Send private message
PowerGod



Joined: 04 Aug 2014
Posts: 339

PostPosted: Tue Aug 16, 2016 4:10 pm    Post subject: Reply with quote

then add the extra trickery Coffee

I have no other ideas in mind, that cycle is the only thing I can think about
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Thu Aug 25, 2016 6:38 pm    Post subject: Reply with quote

I might add support for this, will add it to my todo list.
Back to top
View user's profile Send private message Send e-mail
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3770

PostPosted: Fri Aug 26, 2016 11:46 pm    Post subject: Reply with quote

Think I got this working in the beta. Try:

#format {test} {%w} {{aaaaaaaabbbbbbbcccccccddddddeeee}{10}}

Will wrap the text to a width of 10. Also added UTF-8 support, which requires #config CHARSET UTF-8 to be set.

http://tintin.sf.net/download/tintin-beta.tar.gz
Back to top
View user's profile Send private message Send e-mail
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Thu Sep 01, 2016 9:47 pm    Post subject: Reply with quote

All I can say is - BEWARE OF Unicode (Utf-8) - counting bytes/characters is not going to work if you are not confined to pure ASCII characters. Just because you are using a monospaced font it does not mean all the characters are the same width! Talk to the Hand

For an example, consider the following which all occupy one "space" on the screen:

  • å = {LATIN SMALL LETTER A}+{COMBINING RING ABOVE} display with #ECHO \x61\xCC\x8A
  • = {LATIN SMALL LETTER A WITH RING ABOVE} display with #ECHO \xC3\xA5
  • ḁ = {LATIN SMALL LETTER A WITH RING BELOW} display with #ECHO \xE1\xB8\x81
  • ḁ = {LATIN SMALL LETTER B}+{COMBINING RING BELOW} display with #ECHO \x61\xCC\xA5
How does the above sample look if those sequences are used instead for b,c,d and e?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group