PageRenderTime 66ms CodeModel.GetById 50ms app.highlight 4ms RepoModel.GetById 8ms app.codeStats 0ms

/bundles/plugins-trunk/SideKick/sidekick/SideKickBindings.java

#
Java | 64 lines | 32 code | 7 blank | 25 comment | 17 complexity | e695436af57f2e3ff33bfbe8f45ae88e MD5 | raw file
 1/*
 2 * SideKickBindings.java
 3 * :tabSize=8:indentSize=8:noTabs=false:
 4 * :folding=explicit:collapseFolds=1:
 5 *
 6 * Copyright (C) 2003 Slava Pestov
 7 *
 8 * This program is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 */
22
23package sidekick;
24
25import java.awt.event.KeyAdapter;
26import java.awt.event.KeyEvent;
27import java.awt.Component;
28import org.gjt.sp.jedit.gui.KeyEventWorkaround;
29import org.gjt.sp.jedit.GUIUtilities;
30import org.gjt.sp.jedit.View;
31
32/**
33 * Manages our key bindings.
34 */
35class SideKickBindings extends KeyAdapter
36{
37	//{{{ keyTyped() method
38	public void keyTyped(KeyEvent evt)
39	{
40		evt = KeyEventWorkaround.processKeyEvent(evt);
41		if(evt == null)
42			return;
43
44		char ch = evt.getKeyChar();
45		if(ch == '\b')
46			return;
47
48		View view = GUIUtilities.getView((Component)evt.getSource());
49		SideKickParser parser = SideKickPlugin.getParserForView(view);
50
51		if(parser != null && parser.supportsCompletion())
52		{
53			String parseKeys = parser.getParseTriggers();
54			if(parseKeys != null && parseKeys.indexOf(ch) != -1)
55				SideKickPlugin.parse(view,false);
56
57			String instantKeys = parser.getInstantCompletionTriggers();
58			if(instantKeys != null && instantKeys.indexOf(ch) != -1)
59				SideKickActions.keyComplete(view);
60			else if(parser.canCompleteAnywhere())
61				SideKickActions.keyCompleteWithDelay(view);
62		}
63	} //}}}
64}