shortcuts for xpad
[scilab.git] / scilab / modules / xpad / src / java / org / scilab / modules / xpad / actions / IndentAction.java
1 /*
2  * Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3  * Copyright (C) 2009 - DIGITEO - Bruno JOFRET
4  *
5  * This file must be used under the terms of the CeCILL.
6  * This source file is licensed as described in the file COPYING, which
7  * you should have received as part of this distribution.  The terms
8  * are also available at
9  * http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
10  *
11  */
12
13 package org.scilab.modules.xpad.actions;
14
15 import java.awt.event.ActionEvent;
16 import java.awt.event.KeyEvent;
17
18 import javax.swing.KeyStroke;
19
20 import org.scilab.modules.xpad.Xpad;
21 import org.scilab.modules.xpad.style.ScilabStyleDocument;
22
23 public class IndentAction extends DefaultAction {
24         
25         public IndentAction(Xpad editor) {
26                 super("Indent", editor);
27                 setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_I, ActionEvent.CTRL_MASK));
28
29         }
30         
31         public void doAction() {
32                 
33                 //int start = getEditor().getTextPane().getSelectionStart();
34                 //int end = getEditor().getTextPane().getSelectionEnd();
35                 ((ScilabStyleDocument) getEditor().getTextPane().getStyledDocument()).indent(/*start, end*/);
36                 //getEditor().getTextPane().setSelectionStart(/*start*/);
37                 getEditor().getTextPane().setSelectionEnd(getEditor().getTextPane().getCaretPosition());
38                 //((ScilabStyleDocument) _editor.getStyledDocument()).indent();
39         }
40
41 }