Skip to content

Commit

Permalink
Allow more tags in ttk (when compiled against Tcl 9.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
jan.nijtmans committed Mar 23, 2024
1 parent 4a635a2 commit 90ab1c4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions generic/ttk/ttkTagSet.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* +++ Internal data structures.
*/
struct TtkTag {
int priority; /* 1=>highest */
Tcl_Size priority; /* 1=>highest */
const char *tagName; /* Back-pointer to hash table entry */
void *tagRecord; /* User data */
};
Expand All @@ -21,8 +21,8 @@ struct TtkTagTable {
Tk_Window tkwin; /* owner window */
const Tk_OptionSpec *optionSpecs; /* ... */
Tk_OptionTable optionTable; /* ... */
int recordSize; /* size of tag record */
int nTags; /* #tags defined so far */
Tcl_Size recordSize; /* size of tag record */
Tcl_Size nTags; /* #tags defined so far */
Tcl_HashTable tags; /* defined tags */
};

Expand Down Expand Up @@ -155,7 +155,7 @@ Ttk_TagSet Ttk_GetTagSetFromObj(
Tcl_Obj *Ttk_NewTagSetObj(Ttk_TagSet tagset)
{
Tcl_Obj *result = Tcl_NewListObj(0,0);
int i;
Tcl_Size i;

for (i = 0; i < tagset->nTags; ++i) {
Tcl_ListObjAppendElement(
Expand All @@ -174,7 +174,7 @@ void Ttk_FreeTagSet(Ttk_TagSet tagset)
*/
int Ttk_TagSetContains(Ttk_TagSet tagset, Ttk_Tag tag)
{
int i;
Tcl_Size i;
for (i = 0; i < tagset->nTags; ++i) {
if (tagset->tags[i] == tag) {
return 1;
Expand All @@ -190,7 +190,7 @@ int Ttk_TagSetContains(Ttk_TagSet tagset, Ttk_Tag tag)
*/
int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag)
{
int i;
Tcl_Size i;
for (i = 0; i < tagset->nTags; ++i) {
if (tagset->tags[i] == tag) {
return 0;
Expand All @@ -209,7 +209,8 @@ int Ttk_TagSetAdd(Ttk_TagSet tagset, Ttk_Tag tag)
*/
int Ttk_TagSetAddSet(Ttk_TagSet tagset, Ttk_TagSet tagsetFrom)
{
int i, j, result = 0, found, total, nTags = tagset->nTags;
Tcl_Size i, j, total, nTags = tagset->nTags;
int result = 0, found;
Ttk_Tag tag;

total = tagsetFrom->nTags + tagset->nTags;
Expand Down Expand Up @@ -238,7 +239,7 @@ int Ttk_TagSetAddSet(Ttk_TagSet tagset, Ttk_TagSet tagsetFrom)
*/
int Ttk_TagSetRemove(Ttk_TagSet tagset, Ttk_Tag tag)
{
int i = 0, j = 0;
Tcl_Size i = 0, j = 0;
while (i < tagset->nTags) {
if ((tagset->tags[j] = tagset->tags[i]) != tag) {
++j;
Expand Down Expand Up @@ -317,7 +318,7 @@ void Ttk_TagSetDefaults(Ttk_TagTable tagTable, Ttk_Style style, void *record)
void Ttk_TagSetValues(Ttk_TagTable tagTable, Ttk_TagSet tagSet, void *record)
{
const int LOWEST_PRIORITY = 0x7FFFFFFF;
int i, j;
Tcl_Size i, j;

for (i = 0; tagTable->optionSpecs[i].type != TK_OPTION_END; ++i) {
const Tk_OptionSpec *optionSpec = tagTable->optionSpecs + i;
Expand Down
2 changes: 1 addition & 1 deletion generic/ttk/ttkWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ typedef struct TtkTag *Ttk_Tag;
typedef struct TtkTagTable *Ttk_TagTable;
typedef struct TtkTagSet { /* TODO: make opaque */
Ttk_Tag *tags;
int nTags;
Tcl_Size nTags;
} *Ttk_TagSet;

MODULE_SCOPE Ttk_TagTable Ttk_CreateTagTable(
Expand Down

0 comments on commit 90ab1c4

Please sign in to comment.