1 22 23 29 30 package org.netbeans.lib.terminalemulator; 31 32 33 class InterpDtTerm extends InterpANSI { 34 35 protected static class InterpTypeDtTerm extends InterpTypeANSI { 36 protected final State st_esc_rb = new State("esc_rb"); protected final State st_esc_lb_q = new State("esc_lb_q"); protected final State st_esc_lb_b = new State("esc_lb_b"); protected final State st_wait = new State("wait"); 41 protected final Actor act_DEC_private = new ACT_DEC_PRIVATE(); 42 protected final Actor act_M = new ACT_M(); 43 protected final Actor act_D = new ACT_D(); 44 protected final Actor act_done_collect = new ACT_DONE_COLLECT(); 45 protected final Actor act_collect = new ACT_COLLECT(); 46 protected final Actor act_start_collect = new ACT_START_COLLECT(); 47 48 49 protected InterpTypeDtTerm() { 50 st_esc.setAction(']', st_esc_rb, act_start_collect); 51 52 st_esc.setAction('D', st_base, act_D); 54 st_esc.setAction('M', st_base, act_M); 55 56 for (char c = 0; c < 128; c++) 57 st_esc_rb.setAction(c, st_esc_rb, act_collect); 58 st_esc_rb.setAction((char) 27, st_wait, act_nop); 59 60 st_wait.setAction('\\', st_base, act_done_collect); 61 62 st_esc_lb.setAction('?', st_esc_lb_q, act_reset_number); 63 64 for (char c = '0'; c <= '9'; c++) 65 st_esc_lb_q.setAction(c, st_esc_lb_q, act_remember_digit); 66 st_esc_lb_q.setAction('h', st_base, act_DEC_private); 67 st_esc_lb_q.setAction('l', st_base, act_DEC_private); 68 st_esc_lb_q.setAction('r', st_base, act_DEC_private); 69 st_esc_lb_q.setAction('s', st_base, act_DEC_private); 70 71 st_esc_lb.setAction('!', st_esc_lb_b, act_reset_number); 72 st_esc_lb_b.setAction('p', st_base, new ACT_DEC_STR()); 73 } 74 75 protected static final class ACT_START_COLLECT implements Actor { 76 public String action(AbstractInterp ai, char c) { 77 InterpDtTerm i = (InterpDtTerm) ai; 78 i.text = ""; return null; 80 } 81 } 82 83 protected static final class ACT_COLLECT implements Actor { 84 public String action(AbstractInterp ai, char c) { 85 InterpDtTerm i = (InterpDtTerm) ai; 87 i.text = i.text + c; 88 return null; 89 } 90 } 91 92 protected static final class ACT_DONE_COLLECT implements Actor { 93 public String action(AbstractInterp ai, char c) { 94 97 return null; 98 } 99 } 100 101 protected static final class ACT_D implements Actor { 102 public String action(AbstractInterp ai, char c) { 103 ai.ops.op_do(1); 104 return null; 105 } 106 }; 107 108 protected static final class ACT_M implements Actor { 109 public String action(AbstractInterp ai, char c) { 110 ai.ops.op_up(1); 111 return null; 112 } 113 } 114 115 protected static final class ACT_DEC_PRIVATE implements Actor { 116 public String action(AbstractInterp ai, char c) { 117 if (ai.noNumber()) 118 return "act_DEC_private: no number"; int n = ai.numberAt(0); 120 switch(c) { 121 case 'h': 122 if (n == 5) 123 ai.ops.op_reverse(true); 124 else if (n == 25) 125 ai.ops.op_cursor_visible(true); 126 else 127 return "act_DEC_private: unrecognized cmd " + c; break; 129 case 'l': 130 if (n == 5) 131 ai.ops.op_reverse(false); 132 else if (n == 25) 133 ai.ops.op_cursor_visible(false); 134 else 135 return "act_DEC_private: unrecognized cmd " + c; break; 137 case 'r': 138 case 's': 139 143 break; 144 default: 145 return "act_DEC_private: unrecognized cmd " + c; } 147 return null; 148 } 149 } 150 151 protected static final class ACT_DEC_STR implements Actor { 152 public String action(AbstractInterp ai, char c) { 153 ai.ops.op_soft_reset(); 154 return null; 155 } 156 } 157 } 158 159 private String text = null; 160 161 private InterpTypeDtTerm type; 162 163 public static final InterpTypeDtTerm type_singleton = new InterpTypeDtTerm(); 164 165 public InterpDtTerm(Ops ops) { 166 super(ops, type_singleton); 167 this.type = type_singleton; 168 setup(); 169 } 170 171 protected InterpDtTerm(Ops ops, InterpTypeDtTerm type) { 172 super(ops, type); 173 this.type = type; 174 setup(); 175 } 176 177 public String name() { 178 return "dtterm"; } 180 181 public void reset() { 182 super.reset(); 183 text = null; 184 } 185 186 187 private void setup() { 188 state = type.st_base; 189 } 190 191 } 192 | Popular Tags |