Advertisement
Guest User

Untitled

a guest
Jun 27th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. (* To preserve the current stylesheet information it has to be
  2. plucked out of the StyleDefinitions; 1st time this is OK as the
  3. StyleDefinitions = just a notebook name, but after adding items it
  4. gets messy and we need to extract the stylesheet notebook name to reapply it.
  5. *)
  6. sdef = CurrentValue[EvaluationNotebook[], StyleDefinitions];
  7. If[! StringQ[sdef], (*
  8. this is typically just the filename of a stylesheet notebook,
  9. but if it isn't... *)
  10. sdef = ToString[sdef];
  11. sdef = StringCases[sdef, "StyleDefinitions -> " ~~ __ ~~ ".nb]]",
  12. 1];
  13. sdef = StringReplace[
  14. sdef[[1]], {"StyleDefinitions -> " -> "", "]]" -> ""}]
  15. ];
  16. SetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{
  17. Cell[StyleData[StyleDefinitions -> sdef]],
  18. Cell[StyleData["MessageMenuLabel"], Bold,
  19. FontColor -> RGBColor[N[174/255], 0.1, 0],
  20. FontSize ->
  21. CurrentValue[{StyleDefinitions, "Output", "FontSize"}]],
  22. Cell[StyleData["MessageText"],
  23. FontColor -> RGBColor[0.1, 0.1, 0.1]]
  24. }
  25. ]
  26. (* last line needed per Kuba's Programming scripts to create and modify stylesheets answer*)
  27. /. s_Symbol /; Context[s] === "Global`" :>
  28. Symbol["FrontEnd`" <> SymbolName[s]]]
  29. (* Do something illegal to check the message appearance... *)
  30. 1/0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement