Στις 31/12/2011 02:33, ο/η Joe English έγραψε:
> Georgios Petasis wrote:
>>
>> I am missing some functionality regarding tags from the text widget, and
>> I would like to propose a TIP about this. [...]
>
> A couple suggestions:
>
>> In addition, the following configuration tag options are proposed:
>>
>> -ipadl(eft): how much internal padding to leave to the left of the tag
>> -ipadr(ight): how much internal padding to leave to the right of the tag
>> -ipadt(op): how much internal padding to leave to the top of the tag
>> -ipadb(ottom): how much internal padding to leave to the bottom of the tag
>
> I'd suggest folding these into a single "-padding" option as per
> Ttk_GetPaddingFromObj(). (That is: a list of up to four elements
> specifying the left, top, right, and bottom padding; right and bottom
> default to left and top; top defaults to left.) That makes it convenient
> to specify uniform padding (one element), separate horizontal and vertical
> padding (two elements), or completely asymmetric padding (four elements).
This is a good proposal, and Ttk_GetPaddingFromObj is now in the core...
>
> Similarly for -opad{l(eft)/r(ight)/t(op)/b(ottom)}; suggest
> calling this "-margins" (that's what Tile and CSS call it).
Also a good idea.
(To say the truth it cross my mind what would be required to draw tags
using the Ttk engine, but I have postponed it at a latter stage).
>
>> The first data structure is Tk_TextTagType (similar to Tk_ItemType):
>>
>> typedef struct Tk_TextTagType {
>> const char *name;
>> int itemSize;
>> Tk_TextTagCreateProc *createProc;
>> const Tk_ConfigSpec *configSpecs;
>> Tk_TextTagConfigureProc *configProc;
>> Tk_TextTagDeleteProc *deleteProc;
>>
>> Tk_TextTagDisplayBackgroundProc *displayBackgroundProc;
>> Tk_TextTagDisplay3DVerticalBevelProc *display3DVerticalBevelProc;
>> Tk_TextTagDisplay3DHorizontalBevelProc *display3DHorizontalBevelProc;
>> Tk_TextTagType *nextPtr;
>> } Tk_TextTagType;
>
>
> What is the proposed signature of Tk_TextTagDisplayXXXProc()?
>
> What is the meaning of the 'itemSize' member?
It is an idea taken from the canvas implementation. It allows the
specification of a larger structure, whose first element is the
Tk_TextTagType structure, like the BitmapItem example:
http://docs.activestate.com/activetcl/8.6/tcl/TkLib/CrtItemType.htm
>
> I'd suggest replacing the three displayXXXProc callbacks
> with a single displayProc. The motivating use case for
> this proposal (spell-check undersquiggles) doesn't even
> have 3D bevels, so the callbacks are misleadingly named
> at best, and most likely unnecessary.
This was my initial thought (all drawing by a single routine),
but I gave up on the idea because of performance considerations.
The text widget draws areas of the same tag characteristics as a uniform
area, with borders drawn only at the edges.
Moving all this logic to the drawing routine, may not be a good idea.
But I am not so sure about all these, of course.
>
> Do you have a rough idea of how feasible this would be
> to implement? (I haven't looked; the text widget internals
> have gotten really scary.)
Yes, it is going to be quite difficult. I have tried to implement the
-ipad options (not that difficult). But the real problem is that the
current code examines all tags for an index, and merges them into a
single visual presentation, based on their priority.
This has to change :-)
George