[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/actions PyAction.java,1.12,1.13 PyBackspace
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-04-13 13:02:52
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14483/src/org/python/pydev/editor/actions Modified Files: PyAction.java PyBackspace.java Log Message: Refactoring content assistants Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyAction.java 12 Apr 2005 16:29:42 -0000 1.12 --- PyAction.java 13 Apr 2005 13:02:39 -0000 1.13 *************** *** 23,26 **** --- 23,27 ---- import org.python.pydev.editor.PyEdit; import org.python.pydev.plugin.PydevPlugin; + import org.python.pydev.plugin.PydevPrefs; /** *************** *** 348,352 **** */ public static String getInsideParentesisTok(PySelection ps) { ! return getInsideParentesisTok(ps.getSelection()); } --- 349,356 ---- */ public static String getInsideParentesisTok(PySelection ps) { ! if(ps.getSelection().indexOf("(") != -1 && ps.getSelection().indexOf(")") != -1) ! return getInsideParentesisTok(ps.getSelection()); ! else ! return ""; } *************** *** 541,543 **** --- 545,577 ---- return c != '\n' && c != '\r' && c != ' ' && c != '.' && c != '(' && c != ')' && c != ',' && c != ']' && c != '[' && c != '#'; } + + /** + * + * @return indentation string (always recreated) + */ + public static String getStaticIndentationString() { + try { + int tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); + boolean useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); + boolean forceTabs = false; + String identString; + + if (useSpaces && !forceTabs) + identString = PyAction.createStaticSpaceString(tabWidth, tabWidth); + else + identString = "\t"; + return identString; + } catch (Exception e) { + + PydevPlugin.log(e); + return " "; //default + } + } + + public static String createStaticSpaceString(int width, int tabWidth) { + StringBuffer b = new StringBuffer(width); + while (tabWidth-- > 0) + b.append(" "); + return b.toString(); + } } Index: PyBackspace.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyBackspace.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyBackspace.java 12 Apr 2005 16:29:42 -0000 1.4 --- PyBackspace.java 13 Apr 2005 13:02:39 -0000 1.5 *************** *** 285,312 **** } //END TODO. - - - private static String createStaticSpaceString(int width, int tabWidth) { - StringBuffer b = new StringBuffer(width); - while (tabWidth-- > 0) - b.append(" "); - return b.toString(); - } - - /** - * - * @return indentation string (always recreated) - */ - public static String getStaticIndentationString() { - int tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); - boolean useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); - boolean forceTabs = false; - String identString; - - if (useSpaces && !forceTabs) - identString = createStaticSpaceString(tabWidth, tabWidth); - else - identString = "\t"; - return identString; - } } \ No newline at end of file --- 285,287 ---- |