PageRenderTime 45ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/startup/startup.bsh

#
Unknown | 134 lines | 106 code | 28 blank | 0 comment | 0 complexity | 073ffe457941b5162c5abcea046a4523 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. // Slava Pestov's startup script. Doesn't have much in it yet.
  2. // :folding=explicit:expandFolds=1:
  3. //Most of the file is commented out. Note that the hacks here are
  4. //not guaranteed to work, might break various features in odd ways,
  5. //etc.
  6. // Print something useful...
  7. Log.log(Log.DEBUG,scriptPath,"BeanShell interpreter version "
  8. + this.interpreter.VERSION);
  9. /*{{{ Some useful scripting aids */
  10. /* If you are a plugin developer you will like this. After calling
  11. * ac(), you can access private variables and methods in BeanShell.
  12. */
  13. ac()
  14. {
  15. setAccessibility(true);
  16. }
  17. /* For the mathematicians among us. */
  18. e = Math.E;
  19. pi = Math.PI;
  20. /* I use this for scripting various search and replace operations. */
  21. s(search,replace,flags)
  22. {
  23. SearchAndReplace.setSearchString(search);
  24. SearchAndReplace.setReplaceString(replace);
  25. SearchAndReplace.setBeanShellReplace(flags.indexOf('b') != -1);
  26. SearchAndReplace.setIgnoreCase(flags.indexOf('i') != -1);
  27. SearchAndReplace.setRegexp(flags.indexOf('r') != -1);
  28. SearchAndReplace.setSearchFileSet(new CurrentBufferSet());
  29. SearchAndReplace.replaceAll(view);
  30. } /*}}}*/
  31. /*{{{ Setting environment variables on Console plugin */
  32. /* If you use the Console plugin, and want to set some environment
  33. * variables for programs you run in the Console, without having to
  34. * change operating system specific-scripts (as if the below method is
  35. * any easier...)
  36. */
  37. /* if(jEdit.getPlugin("console.ConsolePlugin") != null)
  38. {
  39. setenv("CVS_RSH","ssh");
  40. // setenv("PATH",getenv("PATH") + ":" + getenv("HOME") + "/bin");
  41. } */
  42. /*}}}*/
  43. /*{{{ Hang on copy/paste workaround */
  44. /* If your Java version has shitty clipboard support you can have jEdit
  45. * use an internal storage area for the clipboard.
  46. *
  47. * A rare bug in Sun's Java virtual machine on Linux, for example, can
  48. * make the JVM (or the AWT thread at least) hang while trying to copy
  49. * or paste.
  50. */
  51. //Registers.setRegister('$',new Registers.StringRegister());
  52. //Registers.setRegister('%',new Registers.StringRegister());
  53. /*}}}*/
  54. /*{{{ Remapping modifier keys part I */
  55. /* The below is the default, swap the items around to
  56. * change meaning of C+, A+, M+, S+.
  57. */
  58. //KeyEventTranslator.setModifierMapping(InputEvent.CTRL_MASK,
  59. // InputEvent.ALT_MASK, InputEvent.META_MASK,
  60. // InputEvent.SHIFT_MASK);
  61. /* ... and this the MacOS default: */
  62. //KeyEventTranslator.setModifierMapping(InputEvent.META_MASK, /* == C+ */
  63. // InputEvent.CTRL_MASK, /* == A+ */
  64. // InputEvent.ALT_MASK, /* == M+ */
  65. // InputEvent.SHIFT_MASK /* == S+ */);
  66. /*}}}*/
  67. /*{{{ Remapping modifier keys part II */
  68. /* Note if you chose to make use of the M+ (option key) prefix on MacOS, you
  69. * will need to disable a little piece of code: */
  70. //Debug.ALT_KEY_PRESSED_DISABLED = false;
  71. /* Otherwise M+ will be ignored for the purposes of keyboard shortcuts. */
  72. /* But if you enable this, you might find that Option+8 for example invokes your
  73. * macro but also inserts a bulletpoint, as per standard Macintosh keyboard
  74. * behavior. To disable the Option key for inserting special high ASCII
  75. * characters, uncomment this. Note that it has wider implications, notably
  76. * DROVAK keyboard shortcuts will be mapped as if the keyboard was QWERTY. */
  77. //Debug.ALTERNATIVE_DISPATCHER = false;
  78. /*}}}*/
  79. /*{{{ Workaround for buggy international key handling */
  80. /* If international keys do not work in the text area, sometimes it is possible
  81. * to workaround the problem by adding translation mappings: */
  82. // KeyEventTranslator.translateKey(
  83. // new KeyEventTranslator.Key("CS",KeyEvent.VK_COMMA,'\0'),
  84. // new KeyEventTranslator.Key("C",KeyEvent.VK_SEMICOLON,'\0')
  85. // );
  86. // KeyEventTranslator.translateKey(
  87. // new KeyEventTranslator.Key(null,KeyEvent.VK_CLOSE_BRACKET,'\0'),
  88. // new KeyEventTranslator.Key(null,0,'"')
  89. // );
  90. // KeyEventTranslator.translateKey(
  91. // new KeyEventTranslator.Key("S",KeyEvent.VK_CLOSE_BRACKET,'\0'),
  92. // new KeyEventTranslator.Key(null,0,(char)0x5e)
  93. // );
  94. // KeyEventTranslator.translateKey(
  95. // new KeyEventTranslator.Key("C",KeyEvent.VK_CLOSE_BRACKET,'\0'),
  96. // new KeyEventTranslator.Key(null,0,'~')
  97. // );
  98. // KeyEventTranslator.translateKey(
  99. // new KeyEventTranslator.Key(null,KeyEvent.VK_EQUALS,'\0'),
  100. // new KeyEventTranslator.Key(null,0,'\'')
  101. // );
  102. // KeyEventTranslator.translateKey(
  103. // new KeyEventTranslator.Key("S",KeyEvent.VK_EQUALS,'\0'),
  104. // new KeyEventTranslator.Key(null,0,'`')
  105. // );
  106. /*}}}*/