ID:159198
 
I need some help creating a proc that will align the text. Like so

Punch           1
Kick 1
Jumping Kick 1
If you wanted the output to be like that, just tab it.

Punch *TAB**TAB* 1
Kick *TAB**TAB* 1
Jumping Kick *TAB**TAB* 1
In response to Gizhy
I mean when using for()
In response to Lundex
A few tabs should still work.

Don't press the tab key, though, just put '\t' in the string. Like so:

for(var/client/c)
src << "[c.key]\t\t[c.gender]"
For arbitrary text, I'd suggest using a grid control in your skin to line up the data. The grid control will maintain the column widths for you so you won't have to be concerned with spaces and tabs.
In response to Jp
Maybe I should've of been clearer.

Example you have

T1
&
T2

Now, T1 is a random word, so it can be any size, which will change the location of T2 since I'm using "\t".

Example:
T1      T2
T1 T2
T1 T2


So I'm thinking to figure out no matter what T1 is, T2 will always match up with the others.
In response to Lundex
What do you think the tab character does? It's not just eight spaces. It's 'skip to the next multiple of 8 spaces'.

That will be an issue if the things on the left are longer than one tabstop, though. And the richedit control used by Dream Seeker probably uses 4 as the tab-stop. So maybe ACWraith's suggestion.

Or if it has to be in the output control:
//assume 'words' is a list of all the t1
var/maxlen = 0
for(var/k in words) if(strlen(k) > maxlen) maxlen = strlen(k)
maxlen++

var/out = ""
var/numspaces = 0
for(var/k in words)
out = k
numspaces = maxlen - strlen(k)
for(var/i = 0, i < numspaces, i++) out+=" "
out+="whatever" //The second column
src << out


Probably better ways of doing it though.