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