Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Auto WordWrap ToolTip?


  • Please log in to reply
10 replies to this topic
adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
I'm sure this has been documented before, but I can't find anything on it... How can I break up a long variable say very 100 characters and append a line feed, then display the new variable in a tooltip?

LongMessage=This is long ... 100+ characters ... This is long

WrappedMessage:=LongMessage     ; Help here! StringTrim? StringLeft/Right? RexEg?

Tooltip, %LongMessage%  ; bad
Sleep,5000
Tooltip, %WrappedMessage% ; hmm
Sleep,5000

Thaaaaaaaanks!

Adam

IVG
  • Members
  • 20 posts
  • Last active: Mar 02 2009 12:58 AM
  • Joined: 21 Mar 2007
You could make some function that could insert `r`n after a certain number of words, that might be the easiest way I think, but not very reliable


...

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
what about making it append a `r`n after it finds say 10 spaces

IVG
  • Members
  • 20 posts
  • Last active: Mar 02 2009 12:58 AM
  • Joined: 21 Mar 2007

what about making it append a `r`n after it finds say 10 spaces

Try 8)
[Just Do It]


...

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
i am trying :p I cant figure it out, I think regexreplace is the way to go though

adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
LongMessage=Look-ahead and look-behind assertions: The groups (?=...), (?!...), (?<=...), and (?<!...) are called assertions because they demand a condition to be met but don't consume any characters. For example, abc(?=.*xyz) is a look-ahead assertion that requires the string xyz to exist somewhere to the right of the string abc (if it doesn't, the entire pattern is not considered a match). (?=...) is called a positive look-ahead because it requires that the specified pattern exist. Conversely, (?!...) is a negative look-ahead because it requires that the specified pattern not exist. Similarly, (?<=...) and (?<!...) are positive and negative look-behinds (respectively) because they look to the left of the current position rather than the right. Look-behinds are more limited than look-aheads because they do not support quantifiers of varying size such as *, ?, and +.


WrappedMessage := RegExReplace(LongMessage,"(.{50}\s)","$1`n")


Tooltip, %LongMessage% 
Sleep,500
Tooltip, %WrappedMessage%
Sleep,500

Seems to work

polyethene
  • Members
  • 5519 posts
  • Last active: May 17 2015 06:39 AM
  • Joined: 26 Oct 2012
That's a useful regex adam, I'd tried (.{10,}?\s+) but yours works fine.

autohotkey.com/net Site Manager

 

Contact me by email (polyethene at autohotkey.net) or message tidbit


adamrgolf
  • Members
  • 442 posts
  • Last active: May 22 2017 09:16 PM
  • Joined: 28 Dec 2006
Thanks Titan!

I'm getting better at RegEx, which is exciting. :D

soggos
  • Members
  • 129 posts
  • Last active: Nov 30 2012 10:35 AM
  • Joined: 27 Mar 2008
:D A Great Thank's for un Little Line!

POur les français qui cherchent comment couper une ligne a x caractères c'est içi :!:
with ahk, all is different!...

Demokos
  • Members
  • 105 posts
  • Last active: Jan 20 2011 06:28 PM
  • Joined: 28 Dec 2005
C'est où ?

soggos
  • Members
  • 129 posts
  • Last active: Nov 30 2012 10:35 AM
  • Joined: 27 Mar 2008
Hello Demokos
Juste au dessus! (par adamrgolf)

et maintenant en solitaire juste au-dessous!
WrappedMessage := RegExReplace(LongMessage,"(.{50}\s)","$1`n")   ; oubien  ; WrappedMessage := RegExReplace(LongMessage,"(.{50})","$1`n")

(le \s si tu veux le dernier "mot" en entier, ici x=50).
with ahk, all is different!...