A number of special definitions are loaded from .tr
files on Front End initialization and are accessible via FrontEndResource
. These are used among other things for various menus and toolsbars, e.g.:
FrontEndResource["FEBitmaps", "HomeIconHot"] // ToExpression
FrontEndResource["FEExpressions", "HelpViewerToolbar"] // CellPrint
FrontEndResource["ContextMenus", "GraphicsBox"]
FrontEndResource["ColorSchemeSelector"] // CellPrint
The .tr
resource files can be edited to change these as I proposed for Can you make the new "Choose color scheme" helper larger? and Is it possible to insert new colour schemes into ColorData? It would be much nicer to be able to edit these after they are loaded from within Mathematica. One can Unprotect
FrontEndResource
and modify the definition but this does not actually change what is displayed in the Front End.
As a simple example I would like to make the Color Scheme Selector a little wider so that it does not have a pointless horizontal scroll bar on my system. I attempt:
Unprotect[FrontEndResource];
With[{FER := FrontEndResource["ColorSchemeSelector"]},
FER = FER /. {180, Automatic} -> {195, Automatic};
]
The manually called resource is now wider:
FrontEndResource["ColorSchemeSelector"] // CellPrint
However the auto-complete popup for Color is not:
On examination this is not too surprising since the actual definition of FrontEndResource
is:
FrontEndResource[name_] :=
MathLink`CallFrontEnd[FrontEnd`Value[FEPrivate`FrontEndResource[name]]];
FrontEndResource[name_, sub_] :=
MathLink`CallFrontEnd[FrontEnd`Value[FEPrivate`FrontEndResource[name, sub]]];
It seems logical that the Front End would make this lower level call directly, bypassing System`FrontEndResource
. My problem is that I don't know how to redefine this FrontEnd`Value
. Names
finds a FrontEnd`SetValue
which sounds promising but I haven't figured out how to use it.
How can I change this Front End Resource in a way that affects all appearances of the menu?
FrontEndExecute@FrontEnd`FlushTextResourceCaches[]
for expressions' caches. $\endgroup$.tr
file rather than directly editing things in memory. Perhaps these definitions are simply read only but I am hoping for authoritative confirmation of that before coming to a conclusion. $\endgroup$FrontEnd`SetValue[FEPrivate`Set[CurrentValue[spec],val]]
. That works fine, but doesn't really help us here. Once I figure out how to make the packets work I'll post a solution editing at theDownValues
level onFrontEnd`Value
, but I have no experience with these WTSP packets so it's all very confusing. $\endgroup${PrivatePaths, "TextResources"}
then by callingFrontEnd`FlushTextResourceCaches[]
. It reloads everything as one would hope--as long as one uses a resource name already known to the system. $\endgroup$KeyEventTranslations.tr
although I'm gonna keep playing with it. Reloading the menus works fine if you callResetMenusPacket[{Automatic,Automatic}]
(found in the PacletManager code) so I'm working on editing theMenuSetup.tr
right now. $\endgroup$