too long string to show in one line ?

For general discussion related FlowStone
Post Reply
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

too long string to show in one line ?

Post by Nubeat7 »

hallo, iwant to do a label, for the presetmanager, which dont write 2 lines when the string is too long, i would prefer that it shortens the string and keep it in one line i.e.

"dark arp syn..."
and not
"dark arp
synthecizer"

is there a way to do this?
and a maximum lenght of the string would be fancy too...

Thanks
User avatar
trogluddite
Posts: 1730
Joined: Fri Oct 22, 2010 12:46 am
Location: Yorkshire, UK

Re: too long string to show in one line ?

Post by trogluddite »

Yes, both the Ruby and primitive texts let you do this; you need to turn off word wrapping.

For priimitives, you use the format option "nowrap". For example, on the Text primitive, connect a string to the 'SF' input, and write "nowrap, left, centre" for one line text, left aligned, in the middle of the height.

For Ruby - you need to use the setFlags method for the formatString object - there's a list of the codes in the user guide (4096 is the right one for "nowrap" IIRC), e.g.

Code: Select all

@my_format = formatString.new
@my_format = setAlighment("left")
@my_format = setLineAlignment("top")
@my_format = setFlags(4096)


In Ruby there's load of extra flags that the Text prim' doesn't have - don't quite understand them all yet, but a quick experiment setting the number from an input value should soon find the most useful ones. Then you just add together the numbers of the ones you want to use.
All schematics/modules I post are free for all to use - but a credit is always polite!
Don't stagnate, mutate to create!
User avatar
Nubeat7
Posts: 1347
Joined: Sat Apr 14, 2012 9:59 am
Location: Vienna
Contact:

Re: too long string to show in one line ?

Post by Nubeat7 »

thanks trog, great it stays in one line now with the flag (4096) also when the label is higher... to shorten the string with "..." for the last characters i used this lines inside the code:

Code: Select all

s = @label[0...90]
   l = @length   
   if l <= 3 then l = 3 end
   if s.length >= l then s = @label[0,l-3] + "..." end


it shortens the link now like this when its longer the 14 character

"dark arp syn..."

i also found out that the max length for preset names are limited to 24 characters by the presetmanager anyway..

get this little gimmick for toolbox here: viewtopic.php?f=3&t=953
RJHollins
Posts: 1573
Joined: Thu Mar 08, 2012 7:58 pm

Re: too long string to show in one line ?

Post by RJHollins »

Thanks NuBeat !

Very handy. Thanks Guys for a bit of the RUBY lesson :)
Post Reply