1 21 22 package org.armedbear.j; 23 24 import java.awt.event.KeyEvent ; 25 26 public final class SchemeMode extends AbstractMode implements Constants, Mode 27 { 28 private static final SchemeMode mode = new SchemeMode(); 29 30 private SchemeMode() 31 { 32 super(SCHEME_MODE, SCHEME_MODE_NAME); 33 keywords = new Keywords(this); 34 } 35 36 public static final SchemeMode getMode() 37 { 38 return mode; 39 } 40 41 public final String getCommentStart() 42 { 43 return "; "; 44 } 45 46 public final Formatter getFormatter(Buffer buffer) 47 { 48 return new SchemeFormatter(buffer); 49 } 50 51 protected void setKeyMapDefaults(KeyMap km) 52 { 53 km.mapKey(KeyEvent.VK_ENTER, 0, "newlineAndIndent"); 54 km.mapKey(KeyEvent.VK_T, CTRL_MASK, "findTag"); 55 km.mapKey(KeyEvent.VK_PERIOD, ALT_MASK, "findTagAtDot"); 56 km.mapKey(KeyEvent.VK_L, CTRL_MASK | SHIFT_MASK, "listTags"); 57 km.mapKey(')', "closeParen"); 58 } 59 60 public boolean isTaggable() 61 { 62 return true; 63 } 64 65 public Tagger getTagger(SystemBuffer buffer) 66 { 67 return new SchemeTagger(buffer); 68 } 69 70 private static final String validChars = 71 "!$%&*+-./0123456789:<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_abcdefghijklmnopqrstuvwxyz{}~"; 72 73 public final boolean isIdentifierStart(char c) 74 { 75 return validChars.indexOf(c) >= 0; 76 } 77 78 public final boolean isIdentifierPart(char c) 79 { 80 return validChars.indexOf(c) >= 0; 81 } 82 83 public boolean isInQuote(Buffer buffer, Position pos) 84 { 85 Line line = pos.getLine(); 87 int offset = pos.getOffset(); 88 boolean inQuote = false; 89 for (int i = 0; i < offset; i++) { 90 char c = line.charAt(i); 91 if (c == '\\') { 92 ++i; 94 } else if (inQuote) { 95 if (c == '"') 96 inQuote = false; 97 } else { 98 if (c == '"') 99 inQuote = true; 100 } 101 } 102 return inQuote; 103 } 104 } 105 | Popular Tags |