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