OriginalBugID: 6016 RFE
Version: 8.4a1
SubmitDate: '2000-07-17'
LastModified:
Severity: SER
Status: UnAssn
Submitter: techsupp
OS: All
Name:
Don Porter
CVS:
2000-07-16 state of CVS repository
Comments:
Please note that this patch does not move
any of Tk's *public* commands into ::tk as
I've been advocating recently in comp.lang.tcl.
It moves only private commands and variables,
which should be harmless to those who've
resisted the temptation to directly access
Tk's privates.
I expect to submit another patch offering
a compatibility interface to support those
who have their code broken by this patch
because they relied on undocumented private
interfaces. Stay tuned.
DesiredBehavior:
In addition to the commands and variables which
comprise Tk's public interface, Tk defines many
other commands and variables intended for its
own private use only. It is a legacy from
Tk 4 that many of these private commands and
variables are defined in the global namespace.
I request that Tk's privates be placed in
the ::tk namespace or its child namespaces.
I include a patch which I think does the job,
but this is a big task, so it would be good
to have others check my work -- especially
on other platforms.
On my Linux/x86 box, the Tk test suite shows
no failed tests both before and after this
patch is applied.
Patch:
The patch is too large (584kB) to inflict on
the web form / newsgroup. Instead, download
it from:
http://math.nist.gov/~DPorter/tcltk/patches/tk84a1private.txt
PatchFiles:
File: tkvars.n Status: Locally Modified
File: tkBind.c Status: Locally Modified
File: tkMenu.c Status: Locally Modified
File: tkTextDisp.c Status: Locally Modified
File: bgerror.tcl Status: Locally Modified
File: button.tcl Status: Locally Modified
File: choosedir.tcl Status: Locally Modified
File: clrpick.tcl Status: Locally Modified
File: comdlg.tcl Status: Locally Modified
File: console.tcl Status: Locally Modified
File: dialog.tcl Status: Locally Modified
File: entry.tcl Status: Locally Modified
File: focus.tcl Status: Locally Modified
File: listbox.tcl Status: Locally Modified
File: menu.tcl Status: Locally Modified
File: msgbox.tcl Status: Locally Modified
File: optMenu.tcl Status: Locally Modified
File: palette.tcl Status: Locally Modified
File: scale.tcl Status: Locally Modified
File: scrlbar.tcl Status: Locally Modified
File: spinbox.tcl Status: Locally Modified
File: tclIndex Status: Locally Modified
File: tearoff.tcl Status: Locally Modified
File: text.tcl Status: Locally Modified
File: tk.tcl Status: Locally Modified
File: tkfbox.tcl Status: Locally Modified
File: xmfbox.tcl Status: Locally Modified
File: tkMacMenu.c Status: Locally Modified
File: all.tcl Status: Locally Modified
File: clrpick.test Status: Locally Modified
File: filebox.test Status: Locally Modified
File: macMenu.test Status: Locally Modified
File: menu.test Status: Locally Modified
File: menuDraw.test Status: Locally Modified
File: msgbox.test Status: Locally Modified
File: text.test Status: Locally Modified
File: textDisp.test Status: Locally Modified
File: unixMenu.test Status: Locally Modified
File: winMenu.test Status: Locally Modified
File: xmfbox.test Status: Locally Modified
File: tkUnixDialog.c Status: Locally Modified
We should do this; it may be a whopper change, but since it should only ever affect code that was grubbing around where it shouldn't have been (we always said that the functions were private) so doing it without loads of prior warnings will be OK from a process PoV. It would also help a lot with cleaning up the command-load of Tk, which is rather heavy right now. (I find it difficult to find out what commands I've created when debugging due to the sheer quantity of Tk internal procs lying around in the global namespace.)
We might wish to do this in an alpha and see what code it breaks in practise so we can figure out which procedures that are currently private really ought to be documented and put into the public API...
Note also the following additional patch that
was submitted to the Ajuba bug DB, but apparently
did not make the move to SourceForge. (I can no
longer find it at Ajuba either. Good thing I
was e-mailed a copy!):
Tk 8.4a1 Feature
Name: Don Porter
email: dgp@cam.nist.gov
Support: None
Severity: 2
OperatingSystem: All
CustomShell: I've already applied my
"conceal Tk's privates" patch.
It does not yet appear in the bug
DB, so sorry, no ticket reference.
Synopsis: compatibility interface for Tk privates
DesiredBehavior:
As proposed on c.l.t., this patch adds two
commands, [::tk::unsupported::ExposePrivateCommand]
and [::tk::unsupported::ExposePrivateVariable] to
allow those who need access to Tk's privates to
support their old scripts to gain that access when
using a Tk patched to conceal those privates.
There may be better ways to support this
compatibility, but at least this is an
existence proof.
Patch:
*** tk.tcl.old Wed Aug 2 10:51:25 2000
--- tk.tcl Wed Aug 2 10:44:59 2000
***************
*** 359,361 ****
--- 359,601 ----
focus $w
}
+ # ----------------------------------------------------------------------
+ # Unsupported compatibility interface for folks accessing Tk's private
+ # commands and variable against recommended usage.
+ # ----------------------------------------------------------------------
+
+ namespace eval ::tk::unsupported {
+ variable PrivateCommands
+ array set PrivateCommands {
+ tkButtonAutoInvoke ::tk::ButtonAutoInvoke
+ tkButtonDown ::tk::ButtonDown
+ tkButtonEnter ::tk::ButtonEnter
+ tkButtonInvoke ::tk::ButtonInvoke
+ tkButtonLeave ::tk::ButtonLeave
+ tkButtonUp ::tk::ButtonUp
+ tkCancelRepeat ::tk::CancelRepeat
+ tkCheckRadioDown ::tk::CheckRadioDown
+ tkCheckRadioEnter ::tk::CheckRadioEnter
+ tkCheckRadioInvoke ::tk::CheckRadioInvoke
+ tkColorDialog ::tk::dialog::color::
+ tkColorDialog_BuildDialog ::tk::dialog::color::BuildDialog
+ tkColorDialog_CancelCmd ::tk::dialog::color::CancelCmd
+ tkColorDialog_Config ::tk::dialog::color::Config
+ tkColorDialog_CreateSelector ::tk::dialog::color::CreateSelector
+ tkColorDialog_DrawColorScale ::tk::dialog::color::DrawColorScale
+ tkColorDialog_EnterColorBar ::tk::dialog::color::EnterColorBar
+ tkColorDialog_InitValues ::tk::dialog::color::InitValues
+ tkColorDialog_HandleRGBEntry ::tk::dialog::color::HandleRGBEntry
+ tkColorDialog_HandleSelEntry ::tk::dialog::color::HandleSelEntry
+ tkColorDialog_LeaveColorBar ::tk::dialog::color::LeaveColorBar
+ tkColorDialog_MoveSelector ::tk::dialog::color::MoveSelector
+ tkColorDialog_OkCmd ::tk::dialog::color::OkCmd
+ tkColorDialog_RedrawColorBars ::tk::dialog::color::RedrawColorBars
+ tkColorDialog_RedrawFinalColor ::tk::dialog::color::RedrawFinalColor
+ tkColorDialog_ReleaseMouse ::tk::dialog::color::ReleaseMouse
+ tkColorDialog_ResizeColorBars ::tk::dialog::color::ResizeColorBars
+ tkColorDialog_RgbToX ::tk::dialog::color::RgbToX
+ tkColorDialog_SetRGBValue ::tk::dialog::color::SetRGBValue
+ tkColorDialog_StartMove ::tk::dialog::color::StartMove
+ tkColorDialog_XToRgb ::tk::dialog::color::XToRGB
+ tkConsoleAbout ::tk::ConsoleAbout
+ tkConsoleBind ::tk::ConsoleBind
+ tkConsoleExit ::tk::ConsoleExit
+ tkConsoleHistory ::tk::ConsoleHistory
+ tkConsoleInit ::tk::ConsoleInit
+ tkConsoleInsert ::tk::ConsoleInsert
+ tkConsoleInvoke ::tk::ConsoleInvoke
+ tkConsoleOutput ::tk::ConsoleOutput
+ tkConsolePrompt ::tk::ConsolePrompt
+ tkConsoleSource ::tk::ConsoleSource
+ tkDarken ::tk::Darken
+ tkEntryAutoScan ::tk::EntryAutoScan
+ tkEntryBackspace ::tk::EntryBackspace
+ tkEntryButton1 ::tk::EntryButton1
+ tkEntryClosestGap ::tk::EntryClosestGap
+ tkEntryGetSelection ::tk::EntryGetSelection
+ tkEntryInsert ::tk::EntryInsert
+ tkEntryKeySelect ::tk::EntryKeySelect
+ tkEntryMouseSelect ::tk::EntryMouseSelect
+ tkEntryNextWord ::tk::EntryNextWord
+ tkEntryPaste ::tk::EntryPaste
+ tkEntryPreviousWord ::tk::EntryPreviousWord
+ tkEntrySeeInsert ::tk::EntrySeeInsert
+ tkEntrySetCursor ::tk::EntrySetCursor
+ tkEntryTranspose ::tk::EntryTranspose
+ tkEventMotifBindings ::tk::EventMotifBindings
+ tkFDGetFileTypes ::tk::FDGetFileTypes
+ tkFirstMenu ::tk::FirstMenu
+ tkFocusGroup_BindIn ::tk::FocusGroup_BindIn
+ tkFocusGroup_BindOut ::tk::FocusGroup_BindOut
+ tkFocusGroup_Create ::tk::FocusGroup_Create
+ tkFocusGroup_Destroy ::tk::FocusGroup_Destroy
+ tkFocusGroup_In ::tk::FocusGroup_In
+ tkFocusGroup_Out ::tk::FocusGroup_Out
+ tkFocusOK ::tk::FocusOK
+ tkGenerateMenuSelect ::tk::GenerateMenuSelect
+ tkIconList ::tk::IconList
+ tkIconList_Add ::tk::IconList_Add
+ tkIconList_Arrange ::tk::IconList_Arrange
+ tkIconList_AutoScan ::tk::IconList_AutoScan
+ tkIconList_Btn1 ::tk::IconList_Btn1
+ tkIconList_Config ::tk::IconList_Config
+ tkIconList_Create ::tk::IconList_Create
+ tkIconList_CtrlBtn1 ::tk::IconList_CtrlBtn1
+ tkIconList_Curselection ::tk::IconList_Curselection
+ tkIconList_DeleteAll ::tk::IconList_DeleteAll
+ tkIconList_Double1 ::tk::IconList_Double1
+ tkIconList_DrawSelection ::tk::IconList_DrawSelection
+ tkIconList_FocusIn ::tk::IconList_FocusIn
+ tkIconList_FocusOut ::tk::IconList_FocusOut
+ tkIconList_Get ::tk::IconList_Get
+ tkIconList_Goto ::tk::IconList_Goto
+ tkIconList_Index ::tk::IconList_Index
+ tkIconList_Invoke ::tk::IconList_Invoke
+ tkIconList_KeyPress ::tk::IconList_KeyPress
+ tkIconList_Leave1 ::tk::IconList_Leave1
+ tkIconList_LeftRight ::tk::IconList_LeftRight
+ tkIconList_Motion1 ::tk::IconList_Motion1
+ tkIconList_Reset ::tk::IconList_Reset
+ tkIconList_ReturnKey ::tk::IconList_ReturnKey
+ tkIconList_See ::tk::IconList_See
+ tkIconList_Select ::tk::IconList_Select
+ tkIconList_Selection ::tk::IconList_Selection
+ tkIconList_ShiftBtn1 ::tk::IconList_ShiftBtn1
+ tkIconList_UpDown ::tk::IconList_UpDown
+ tkListbox ::tk::Listbox
+ tkListboxAutoScan ::tk::ListboxAutoScan
+ tkListboxBeginExtend ::tk::ListboxBeginExtend
+ tkListboxBeginSelect ::tk::ListboxBeginSelect
+ tkListboxBeginToggle ::tk::ListboxBeginToggle
+ tkListboxCancel ::tk::ListboxCancel
+ tkListboxDataExtend ::tk::ListboxDataExtend
+ tkListboxExtendUpDown ::tk::ListboxExtendUpDown
+ tkListboxKeyAccel_Goto ::tk::ListboxKeyAccel_Goto
+ tkListboxKeyAccel_Key ::tk::ListboxKeyAccel_Key
+ tkListboxKeyAccel_Reset ::tk::ListboxKeyAccel_Reset
+ tkListboxKeyAccel_Set ::tk::ListboxKeyAccel_Set
+ tkListboxKeyAccel_Unset ::tk::ListboxKeyAccel_Unxet
+ tkListboxMotion ::tk::ListboxMotion
+ tkListboxSelectAll ::tk::ListboxSelectAll
+ tkListboxUpDown ::tk::ListboxUpDown
+ tkListboxBeginToggle ::tk::ListboxBeginToggle
+ tkMbButtonUp ::tk::MbButtonUp
+ tkMbEnter ::tk::MbEnter
+ tkMbLeave ::tk::MbLeave
+ tkMbMotion ::tk::MbMotion
+ tkMbPost ::tk::MbPost
+ tkMenuButtonDown ::tk::MenuButtonDown
+ tkMenuDownArrow ::tk::MenuDownArrow
+ tkMenuDup ::tk::MenuDup
+ tkMenuEscape ::tk::MenuEscape
+ tkMenuFind ::tk::MenuFind
+ tkMenuFindName ::tk::MenuFindName
+ tkMenuFirstEntry ::tk::MenuFirstEntry
+ tkMenuInvoke ::tk::MenuInvoke
+ tkMenuLeave ::tk::MenuLeave
+ tkMenuLeftArrow ::tk::MenuLeftArrow
+ tkMenuMotion ::tk::MenuMotion
+ tkMenuNextEntry ::tk::MenuNextEntry
+ tkMenuNextMenu ::tk::MenuNextMenu
+ tkMenuRightArrow ::tk::MenuRightArrow
+ tkMenuUnpost ::tk::MenuUnpost
+ tkMenuUpArrow ::tk::MenuUpArrow
+ tkMessageBox ::tk::MessageBox
+ tkMotifFDialog ::tk::MotifFDialog
+ tkMotifFDialog_ActivateDList ::tk::MotifFDialog_ActivateDList
+ tkMotifFDialog_ActivateFList ::tk::MotifFDialog_ActivateFList
+ tkMotifFDialog_ActivateFEnt ::tk::MotifFDialog_ActivateFEnt
+ tkMotifFDialog_ActivateSEnt ::tk::MotifFDialog_ActivateSEnt
+ tkMotifFDialog ::tk::MotifFDialog
+ tkMotifFDialog_BrowseDList ::tk::MotifFDialog_BrowseDList
+ tkMotifFDialog_BrowseFList ::tk::MotifFDialog_BrowseFList
+ tkMotifFDialog_BuildUI ::tk::MotifFDialog_BuildUI
+ tkMotifFDialog_CancelCmd ::tk::MotifFDialog_CancelCmd
+ tkMotifFDialog_Config ::tk::MotifFDialog_Config
+ tkMotifFDialog_Create ::tk::MotifFDialog_Create
+ tkMotifFDialog_FileTypes ::tk::MotifFDialog_FileTypes
+ tkMotifFDialog_FilterCmd ::tk::MotifFDialog_FilterCmd
+ tkMotifFDialog_InterpFilter ::tk::MotifFDialog_InterpFilter
+ tkMotifFDialog_LoadFiles ::tk::MotifFDialog_LoadFiles
+ tkMotifFDialog_MakeSList ::tk::MotifFDialog_MakeSList
+ tkMotifFDialog_OkCmd ::tk::MotifFDialog_OkCmd
+ tkMotifFDialog_SetFilter ::tk::MotifFDialog_SetFilter
+ tkMotifFDialog_SetListMode ::tk::MotifFDialog_SetListMode
+ tkMotifFDialog_Update ::tk::MotifFDialog_Update
+ tkPostOverPoint ::tk::PostOverPoint
+ tkRecolorTree ::tk::RecolorTree
+ tkRestoreOldGrab ::tk::RestoreOldGrab
+ tkSaveGrabInfo ::tk::SaveGrabInfo
+ tkScaleActivate ::tk::ScaleActivate
+ tkScaleButtonDown ::tk::ScaleButtonDown
+ tkScaleButton2Down ::tk::ScaleButton2Down
+ tkScaleControlPress ::tk::ScaleControlPress
+ tkScaleDrag ::tk::ScaleDrag
+ tkScaleEndDrag ::tk::ScaleEndDrag
+ tkScaleIncrement ::tk::ScaleIncrement
+ tkScreenChanged ::tk::ScreenChanged
+ tkScrollButtonDown ::tk::ScrollButtonDown
+ tkScrollButton2Down ::tk::ScrollButton2Down
+ tkScrollButtonDrag ::tk::ScrollButtonDrag
+ tkScrollButtonUp ::tk::ScrollButtonUp
+ tkScrollByPages ::tk::ScrollByPages
+ tkScrollByUnits ::tk::ScrollByUnits
+ tkScrollEndDrag ::tk::ScrollEndDrag
+ tkScrollSelect ::tk::ScrollSelect
+ tkScrollStartDrag ::tk::ScrollStartDrag
+ tkScrollTopBottom ::tk::ScrollTopBottom
+ tkScrollToPos ::tk::ScrollToPos
+ tkTabToWindow ::tk::TabToWindow
+ tkTearOffMenu ::tk::TearOffMenu
+ tkTextAutoScan ::tk::TextAutoScan
+ tkTextButton1 ::tk::TextButton1
+ tkTextClosestGap ::tk::TextClosestGap
+ tkTextInsert ::tk::TextInsert
+ tkTextKeyExtend ::tk::TextKeyExtend
+ tkTextKeySelect ::tk::TextKeySelect
+ tkTextNextPara ::tk::TextNextPara
+ tkTextNextPos ::tk::TextNextPos
+ tkTextNextWord ::tk::TextNextWord
+ tkTextPaste ::tk::TextPaste
+ tkTextPrevPara ::tk::TextPrevPara
+ tkTextPrevPos ::tk::TextPrevPos
+ tkTextPrevWord ::tk::TextPrevWord
+ tkTextResetAnchor ::tk::TextResetAnchor
+ tkTextScrollPages ::tk::TextScrollPages
+ tkTextSelectTo ::tk::TextSelectTo
+ tkTextSetCursor ::tk::TextSetCursor
+ tkTextTranspose ::tk::TextTranspose
+ tkTextUpDownLine ::tk::TextUpDownLine
+ tkTraverseToMenu ::tk::TraverseToMenu
+ tkTraverseWithinMenu ::tk::TraverseWithinMenu
+ }
+ variable PrivateVariables
+ array set PrivateVariables {
+ histNum ::tk::histNum
+ tk_textRedraw ::tk::textRedraw
+ tk_textRelayout ::tk::textRelayout
+ tkFocusIn ::tk::FocusIn
+ tkFocusOut ::tk::FocusOut
+ tkPalette ::tk::Palette
+ tkPriv ::tk::Priv
+ tkPrivMsgBox ::tk::PrivMsgBox
+ }
+ }
+
+ proc ::tk::unsupported::ExposePrivateCommand {cmd} {
+ variable PrivateCommands
+ if {![info exists PrivateCommands($cmd)]} {
+ return -code error "No compatibility support for \[$cmd]"
+ }
+ namespace eval :: [list interp alias {} $cmd {}] $PrivateCommands($cmd)
+ }
+
+ proc ::tk::unsupported::ExposePrivateVariable {var} {
+ variable PrivateVariables
+ if {![info exists PrivateVariables($var)]} {
+ return -code error "No compatibility support for \$$var"
+ }
+ namespace eval :: [list upvar #0 $PrivateVariables($var) $var]
+ }
+
PatchFiles:
library/tk.tcl
Comments:
This patch adds the compatibility
interface to the file tk.tcl. It
might be better to add a completely
new file, unsupported.tcl, to
tk/library/ for things like this,
but it did not seem appropriate to
do that in a patch.
Logged In: YES
user_id=80530
A first cut at this project has been committed to the
feature branch labeled by branch tag
dgp-privates-into-namespace in the Tk repository.
All Tk users are encouraged to try it out and post
feedback on problems that arise due to the changes.
Logged In: YES
user_id=80530
See TIP 44:
http://purl.org/tcl/tip/44.html
Logged In: YES
user_id=80530
The changes on branch dgp-privates-into-namespace
affect the following maintainer areas:
[console] JH, CM
Generic Menus JH, TH
[text] JH
Events JH
Error Handling JH
[*button] and [label] AF, JH, DAS
[tk_chooseDirectory] DKF, JH
[tk_chooseColor] DKF, JH
Generic Dialog Support DKF, JH
[tk_dialog] DKF, JH, DAS
[entry] AF, JH
[tk_focus*] JH
[listbox] AF, JH
[tk_messageBox] DKF, JH
[tk_optionMenu] JH
[tk_setPalette] JH
[scale] JH, DAS
[scrollbar] JH, DAS
[spinbox] JH
Bindings JH
[tk_get*File] DKF, JH
Mac Menus GBS, DAS
Unix Menus JH, TH
Win Menus JH, TH
Logged In: YES
user_id=80530
Here are the changes as a unidiff patch against the
current (2001-07-19) HEAD.
TIP 44 implementation (gzipped)
Logged In: YES
user_id=80530
I think this is ready for commit. There are
lots of changes, but they're all pretty mechanical.
The test suite indicates no new failures.
I'll commit to HEAD on Wednesday unless I hear
from a maintainer that wants more time to review
over the changes.
Logged In: YES
user_id=80530
Committed implementation for release in Tk 8.4.
Logged In: YES
user_id=80530
Now the reports are starting to come in about
packages that relied on the Tk internals.
Especially widespread is use of [tkCancelRepeat].
Here's a list I received in e-mail:
following a list of all related packages produced by
grepping for "tkCancelRepeat" in my local archives:
"C-Extensions":
BrowsX brx.linux.bin-1.5.0 et.al.
ClassyTcl ClassyTk-1.0.0.src.tar.bz2
Gepetto gepetto-0.12.tar.gz
Memchan memchan2.1p2.tar.gz
Tcl-Plugin tclplug20-x86-linux2.tar.gz
Sybase wisql5.1.tar.gz
Tix tix8.2.0b1.tar.bz2
VU vu_cvs
[incr]tcl itcl3.2.0.tar.bz2
MASH mash-src-5.1.4.tar.bz2
impress-1.1-b6 imp1.1b.tar.gz
tkgraph tkgraph-2.0.4.tar.gz
Nebula Device nebula09Jan01.tar.bz2
MicroLinux muTCL.tar.bz2
TkDesk tkdesk-1.2.tar.bz2
wrap wrap0.3.tar.bz2
TclPro (ofcourse)
Ruby tcltk-ext04.tar.gz
"Code-Extensions":
TSIPP Workbench TSIPPwb1.4.tar.bz2
Xtask Xtask.tar.gz
<http://www.ucolick.org/~de/Tcl>
Agentk Widgets agentk1.0b4.tar.gz
ASED ased208.tar.gz
Cbrowser cbrowser-0.8.tar.gz
Combobox (Oakley) combobox-2.0.tar.gz
tkCVS tkcvs-7.0.tar.gz
TkDiff tkdiff_3_09.zip
Tuba tuba-2.5.b1.tar.gz
Widgets(Hobbs) widget-20010630.tar.gz
Getleft Getleft-0.10.0.tar.gz
AlphaTk alphatk050301.tar.gz
Vtcl vtcl-1.5.2.tar.gz
Vtcl vtcl-combobox-2.0.tar.gz
Any assistance tracking down the authors of these
packages, alerting them to the issue and offering
them workaround patches like:
if {![llength [info commands tkCancelRepeat]]} {
::tk::unsupported::ExposePrivateCommand tkCancelRepeat
}
would be appreciated.
A TIP for a properly public form of tkCancelRepeat is
probably also in order.