[Gambas-user] Draw.Text problem with control chars
Doriano Blengino
doriano.blengino at ...1909...
Sun Jan 31 10:59:47 CET 2010
Benoît Minisini ha scritto:
>> Am Samstag, den 30.01.2010, 00:35 +0100 schrieb Benoît Minisini:
>>
>>>> Salut,
>>>>
>>>> I' using gambas2 2.19.
>>>> For printing text, I use Draw.Text that works well.
>>>> But when I print Text out of a TextArea, where are sometimes control
>>>> chars ("\n" and "\t") in the text, I found a problem.
>>>>
>>>> The LF (\n) is handled, but not the Tab (\t) it is show as a rectangle.
>>>>
>>>> Do I miss something ? Nothing found about!
>>>>
>>>> Does anybody have a hint/workaround ?
>>>>
>>> Tabs are not handled automatically, you must handle them yourself.
>>>
>>> Regards,
>>>
>> Salut Benoît,
>>
>> where does gambas get the "tab width" in controls like TextArea,
>> is there a set parameter somewhere ?
>>
>>
>
> This is managed by the underlying toolkit. I don't see it.
>
>
A tab width is normally eight spaces, meaning with that, that by doing a
"tabulation" you go to the next position multiple of eight (counting
from 0).
By pressing TAB in any of the first 7 columns, from 0 to 6, you go to
column 7. Some prefer 4 places, others 3, and so on.
Note that the gambas editor does not use this concept exactly - instead
of inserting a TAB character, the tab keys make indentation. Anyway,
(suggestion), even the gambas editor has a preference to set the
indentation width.
In every terminal (both true ones and emulators), tab width defaults to
eight, but it is possible to program them differently, not necessarily
even-spaced. So when printing a TAB character, the cursor should go to
the "next tab position" which, if not defined, is the next position
evenly divisible by eight.
In a graphic context things are very similar, except that the columns
are much smaller and a character occupies more columns (at least 5 or
6). A good starting point is to take, for a tabulator width, eight times
the width of a space, or even more for proportional fonts (they tend to
have spaces narrower than other characters). But then depends on the
application.
Regards,
--
Doriano Blengino
"Listen twice before you speak.
This is why we have two ears, but only one mouth."
More information about the User
mailing list