home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 September / PCWorld_2008-09_cd.bin / komunikace / kmeleon / K-Meleon1.1.3en-US.exe / macros / mru.kmm < prev    next >
Text File  |  2007-05-04  |  3KB  |  85 lines

  1. # K-Meleon Macros (http://kmeleon.sourceforge.net/wiki/index.php?id=MacroLanguage)
  2.  
  3. # ---------- Undo Last Closed (MRU) --------------------------------------------------------------------------------
  4. #
  5. # Dependencies    : main.kmm ($_kLayers/$_kLayers_IsDetach, OpenURL)
  6. # Resources    : -
  7. # Preferences    : kmeleon.plugins.macros.MRU.max
  8. #          kmeleon.plugins.macros.MRU.[0,...,max-1]
  9. #
  10. # ------------------------------------------------------------------------------------------------------------------
  11.  
  12. MRU_Clear{
  13. $__m=getpref(INT,$_MRU_Max); $_i=0; while($_i<$__m) &_MRU_Expunge;
  14. }
  15. MRU_OpenLastClosed{
  16. menugrayed=(getpref(STRING,$_MRU_Pref."0")=="");
  17. $OpenURL=getpref(STRING,$_MRU_Pref."0");
  18. index($OpenURL,"\t")>0?pluginmsg(layers,AddLayersToWindow,$OpenURL):&OpenURL_InNew;
  19. $__m=getpref(INT,$_MRU_Max);
  20. delpref($_MRU_Pref."0"); $_i=0; while($_i<$__m) &_MRU_ShiftUp; delpref($_MRU_Pref.$__m-1);
  21. }
  22.  
  23. # ----- PRIVATE
  24.  
  25. $_MRU_Open="";
  26. $_MRU_Pref=$macroPrefBranch."MRU.";
  27. $_MRU_Max=$_MRU_Pref."max";
  28. $_MRU_Cnt=0;
  29.  
  30. _MRU_Expunge{
  31. delpref($_MRU_Pref.$_i); $_i=$_i+1;
  32. }
  33.  
  34. _MRU_SavePage{
  35. $_MRU_Cnt?0:&_MRU_Save; $_MRU_Cnt?($_MRU_Cnt=$_MRU_Cnt==1?0:$_MRU_Cnt-1):0;
  36. }
  37. _MRU_Save{
  38. $_j=index($URL,"about:")+index($URL,"chrome://")+index($URL,"wyciwyg://"); $_j=$_j>-3?-1:getpref(INT,$_MRU_Max)-1;
  39. while($_j>0) &_MRU_ShiftDown; $_j==0?setpref(STRING,$_MRU_Pref."0",$URL):0;
  40. }
  41. _MRU_SaveGroup{
  42. $_j=getpref(INT,$_MRU_Max)-1; while($_j>0) &_MRU_ShiftDown;
  43. setpref(STRING,$_MRU_Pref."0",pluginmsgex(layers,GetLayersInWindow,"",STRING));
  44. }
  45.  
  46. _MRU_ShiftDown{
  47. $__data=getpref(STRING,$_MRU_Pref.$_j-1);
  48. $__data==""?delpref($_MRU_Pref.$_j):setpref(STRING,$_MRU_Pref.$_j,$__data); $_j=$_j-1;
  49. }
  50. _MRU_ShiftUp{
  51. $__data=getpref(STRING,$_MRU_Pref.$_i+1);
  52. $__data==""?delpref($_MRU_Pref.$_i):setpref(STRING,$_MRU_Pref.$_i,$__data); $_i=$_i+1;
  53. }
  54.  
  55. # Menu Integration
  56. _MRU_BuildMenu{
  57. # file menu
  58. setmenu(OpenSave,macro,"&Undo Last Closed",MRU_OpenLastClosed,ID_FILE_SAVE_AS);
  59. # context menus
  60. $kLayers==true?setmenu(LayerButtonPopup,macro,"&Undo Last Closed",MRU_OpenLastClosed,NavLayer):0;
  61. }
  62. _MRU_SetAccels{
  63. setaccel("CTRL ALT Z","macros(MRU_OpenLastClosed)");
  64. }
  65. $OnInit=$OnInit."_MRU_SetAccels;_MRU_BuildMenu;";
  66.  
  67. # Event Handling
  68.  
  69. _MRU_OnCloseGroup{
  70. $_MRU_Cnt=pluginmsgex(layers,NumberOfLayersInWindow,"",INT); &_MRU_SaveGroup;
  71. }
  72. _MRU_OnCloseWindow{
  73. $_kLayers_IsDetach==true?0:&_MRU_SavePage;
  74. }
  75.  
  76. _MRU_SetDefaults{
  77. $__m=getpref(INT,$_MRU_Max); $__m==0?setpref(INT,$_MRU_Max,5):0;
  78. $OnCloseGroup=$OnCloseGroup."_MRU_OnCloseGroup;";
  79. $OnCloseWindow=$OnCloseWindow."_MRU_OnCloseWindow;";
  80. $OnQuit=$OnQuit."MRU_Clear;";
  81. }
  82. $OnStartup=$OnStartup."_MRU_SetDefaults;MRU_Clear;";
  83.  
  84. # ------------------------------------------------------------------------------------------------------------------
  85. $macroModules=$macroModules."MRU;";