Allegro.cc - Online Community

Allegro.cc Forums » Allegro Development » al_draw_multiline_text() return value

This thread is locked; no one can reply to it. rss feed Print
al_draw_multiline_text() return value
Kev Callahan
Member #6,022
July 2005
avatar

I don't think that has been asked before as it didn't show up in my search..

Is there any mileage in al_draw_multiline_text() returning the number of lines it's created/drawn?
It returns a void at the moment which seems wasteful.

I understand I could call al_do_multiline_text() and setup a callback to count them, but this feels I'm doing the same thing twice (I see everything appears to use al_do_multiline_ustr( ) anyway).

Kev

SiegeLord
Member #7,827
October 2006
avatar

That sounds like a good idea, unfortunately we can't change the function's signature due to ABI backwards compatibility.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Chris Katko
Member #1,881
January 2002
avatar

I alway get ABI and API confused. So you're saying, adding a return value would break the BINARY compatibility right so things won't link anymore, right? Because it seems like functionally, turning a void into an int (that people will ignore by default) seems doable.

Also, do we have any plans to allow for breaks ABI in A5? Because if so, I'd definitely put this one on the TODO list when that happens. It seems like an oversight in its current form, and a super simple fix.

For a practical matter for Kev, you could "fork" the function and just call it al_draw_multiline_text2() or al_draw_multiline_text_ex() in your code.

I honestly never realized we had a multi-line text function in A5 (since IIRC A4 never had it) and I always just write my own as it's pretty simple to do a function that works in 90% of cases. (e.g. No auto-wrapping.)

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

SiegeLord
Member #7,827
October 2006
avatar

adding a return value would break the BINARY compatibility right so things won't link anymore, right?

Yes, that's the claim I am making. It's not that it won't link, though... when you break ABI with C functions, you get random segfaults and/or bizzare behavior that's hard to debug.

That said, maybe changing void to int is not ABI incompatible, but we'd need to investigate if it is.

Quote:

Also, do we have any plans to allow for breaks ABI in A5?

In version 5.3/5.4.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Kev Callahan
Member #6,022
July 2005
avatar

Thanks for not shooting the idea down ;)
Didn't know ABI was important and no idea if it would affect it; as was stated it won't really affect API as no-one would be checking return value anyway..

I may create my own 'forked' version, I'm currently using 'do_multiline..()'for now and may just stick with that, but I like code to be optimised.

I've already added a few functions to my allegro build, such as a kc_al_set_opengl_texture() which I created to link a VPU video texture created by eglCreateImageKHR() with Allegro (couldn't figure out a better method, probably quite a bodge.. and very specific to the platform, but it works).. so that's obviously an option.

beoran
Member #12,636
March 2011

Yes, when I made those functions, I didn't consider this. It would be useful, but I agree the ABI of Allegro must remain stable, so perhaps adding a new function that does return the line count could would help?

I'm a bit surprised people still don't know about these function though. Multi line text was a widely demanded feature so I implemented it. But apparently not everyone who wanted the feature was informed of this?

Chris Katko
Member #1,881
January 2002
avatar

Not sure if I'm a representative sample. I wasn't involved much in A5 suggestions, I was midway through my degree so I was a ghost here for a few years.

But yeah, I always rolled my own, so I never even thought to look in the docs for one.

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Polybios
Member #12,293
October 2010

Another interesting value would be the max. width actually used by the longest (widest?) line.

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Kev Callahan
Member #6,022
July 2005
avatar

Go to: