1 21 22 package org.armedbear.j; 23 24 import java.awt.event.KeyEvent ; 25 26 public final class PythonMode extends AbstractMode implements Constants, Mode 27 { 28 private static final PythonMode mode = new PythonMode(); 29 30 private PythonMode() 31 { 32 super(PYTHON_MODE, PYTHON_MODE_NAME); 33 keywords = new Keywords(this); 34 } 35 36 public static final PythonMode getMode() 37 { 38 return mode; 39 } 40 41 public boolean canIndent() 42 { 43 return true; 44 } 45 46 public boolean canIndentPaste() 47 { 48 return false; 49 } 50 51 public final SyntaxIterator getSyntaxIterator(Position pos) 52 { 53 return new PythonSyntaxIterator(pos); 54 } 55 56 public final String getCommentStart() 57 { 58 return "#"; 59 } 60 61 public final Formatter getFormatter(Buffer buffer) 62 { 63 return new PythonFormatter(buffer); 64 } 65 66 protected void setKeyMapDefaults(KeyMap km) 67 { 68 km.mapKey(KeyEvent.VK_TAB, 0, "tab"); 69 km.mapKey(KeyEvent.VK_TAB, SHIFT_MASK, "slideOut"); 70 km.mapKey(KeyEvent.VK_TAB, CTRL_MASK, "insertTab"); 71 km.mapKey(KeyEvent.VK_ENTER, 0, "newlineAndIndent"); 72 km.mapKey(KeyEvent.VK_I, ALT_MASK, "cycleIndentSize"); 73 } 74 75 public final boolean isTaggable() 76 { 77 return true; 78 } 79 80 public final Tagger getTagger(SystemBuffer buffer) 81 { 82 return new PythonTagger(buffer); 83 } 84 85 public int getCorrectIndentation(Line line, Buffer buffer) 86 { 87 return new PythonIndenter(line, buffer).getCorrectIndentation(); 88 } 89 90 public final boolean isIdentifierStart(char c) 91 { 92 if (c > 127) 93 return false; 94 return values[c] == 1; 95 } 96 97 public final boolean isIdentifierPart(char c) 98 { 99 if (c > 127) 100 return false; 101 return values[c] != 0; 102 } 103 104 private static final byte values[] = 105 { 106 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 }; 123 } 124 | Popular Tags |