Source Code Cross Referenced for InterpANSI.java in  » IDE-Netbeans » cvsclient » org » netbeans » lib » terminalemulator » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » cvsclient » org.netbeans.lib.terminalemulator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         *
041:         * Contributor(s): Ivan Soleimanipour.
042:         */
043:
044:        /*
045:         * "InterpANSI.java"
046:         * InterpANSI.java 1.6 01/07/30
047:         * Input stream interpreter
048:         * Decodes incoming characters into cursor motion etc.
049:         */
050:
051:        package org.netbeans.lib.terminalemulator;
052:
053:        public class InterpANSI extends InterpDumb {
054:
055:            protected static class InterpTypeANSI extends InterpTypeDumb {
056:                protected final State st_esc = new State("esc"); // NOI18N
057:                protected final State st_esc_lb = new State("esc_lb"); // NOI18N
058:
059:                protected final Actor act_reset_number = new ACT_RESET_NUMBER();
060:                protected final Actor act_remember_digit = new ACT_REMEMBER_DIGIT();
061:
062:                protected InterpTypeANSI() {
063:                    st_base.setAction((char) 27, st_esc, new ACT_TO_ESC());
064:
065:                    st_esc.setRegular(st_esc, act_regular);
066:                    st_esc.setAction('7', st_base, new ACT_SC());
067:                    st_esc.setAction('8', st_base, new ACT_RC());
068:                    st_esc.setAction('c', st_base, new ACT_FULL_RESET());
069:                    st_esc.setAction('[', st_esc_lb, act_reset_number);
070:
071:                    st_esc_lb.setRegular(st_esc_lb, act_regular);
072:                    for (char c = '0'; c <= '9'; c++)
073:                        st_esc_lb.setAction(c, st_esc_lb, act_remember_digit);
074:                    st_esc_lb.setAction(';', st_esc_lb, new ACT_PUSH_NUMBER());
075:                    st_esc_lb.setAction('A', st_base, new ACT_UP());
076:                    st_esc_lb.setAction('B', st_base, new ACT_DO());
077:                    st_esc_lb.setAction('C', st_base, new ACT_ND());
078:                    st_esc_lb.setAction('D', st_base, new ACT_BC());
079:                    st_esc_lb.setAction('H', st_base, new ACT_HO());
080:                    st_esc_lb.setAction('i', st_base, new ACT_PRINT());
081:                    st_esc_lb.setAction('J', st_base, new ACT_J());
082:                    st_esc_lb.setAction('K', st_base, new ACT_K());
083:                    st_esc_lb.setAction('L', st_base, new ACT_AL());
084:                    st_esc_lb.setAction('M', st_base, new ACT_DL());
085:                    st_esc_lb.setAction('m', st_base, new ACT_ATTR());
086:                    st_esc_lb.setAction('n', st_base, new ACT_DSR());
087:                    st_esc_lb.setAction('P', st_base, new ACT_DC());
088:                    st_esc_lb.setAction('h', st_base, new ACT_SM());
089:                    st_esc_lb.setAction('l', st_base, new ACT_RM());
090:                    st_esc_lb.setAction('r', st_base, new ACT_MARGIN());
091:                    st_esc_lb.setAction('t', st_base, new ACT_GLYPH());
092:                    st_esc_lb.setAction('@', st_base, new ACT_IC());
093:                }
094:
095:                protected static final class ACT_TO_ESC implements  Actor {
096:                    public String action(AbstractInterp ai, char c) {
097:                        InterpDumb i = (InterpDumb) ai;
098:                        i.ctl_sequence = ""; // NOI18N
099:                        return null;
100:                    }
101:                }
102:
103:                protected static final class ACT_SC implements  Actor {
104:                    public String action(AbstractInterp ai, char c) {
105:                        ai.ops.op_sc();
106:                        return null;
107:                    }
108:                }
109:
110:                protected static final class ACT_RC implements  Actor {
111:                    public String action(AbstractInterp ai, char c) {
112:                        ai.ops.op_rc();
113:                        return null;
114:                    }
115:                }
116:
117:                protected static final class ACT_FULL_RESET implements  Actor {
118:                    public String action(AbstractInterp ai, char c) {
119:                        ai.ops.op_full_reset();
120:                        return null;
121:                    }
122:                }
123:
124:                protected static class ACT_RESET_NUMBER implements  Actor {
125:                    public String action(AbstractInterp ai, char c) {
126:                        ai.resetNumber();
127:                        return null;
128:                    }
129:                };
130:
131:                protected static class ACT_REMEMBER_DIGIT implements  Actor {
132:                    public String action(AbstractInterp ai, char c) {
133:                        ai.remember_digit(c);
134:                        return null;
135:                    }
136:                };
137:
138:                protected static final class ACT_PUSH_NUMBER implements  Actor {
139:                    public String action(AbstractInterp ai, char c) {
140:                        if (!ai.pushNumber())
141:                            return "ACT PUSH_NUMBER"; // NOI18N
142:                        return null;
143:                    }
144:                }
145:
146:                protected static final class ACT_UP implements  Actor {
147:                    public String action(AbstractInterp ai, char c) {
148:                        if (ai.noNumber())
149:                            ai.ops.op_up(1);
150:                        else
151:                            ai.ops.op_up(ai.numberAt(0));
152:                        return null;
153:                    }
154:                }
155:
156:                protected static final class ACT_DO implements  Actor {
157:                    public String action(AbstractInterp ai, char c) {
158:                        if (ai.noNumber())
159:                            ai.ops.op_do(1);
160:                        else
161:                            ai.ops.op_do(ai.numberAt(0));
162:                        return null;
163:                    }
164:                }
165:
166:                protected static final class ACT_ND implements  Actor {
167:                    public String action(AbstractInterp ai, char c) {
168:                        if (ai.noNumber())
169:                            ai.ops.op_nd(1);
170:                        else
171:                            ai.ops.op_nd(ai.numberAt(0));
172:                        return null;
173:                    }
174:                }
175:
176:                protected static final class ACT_BC implements  Actor {
177:                    public String action(AbstractInterp ai, char c) {
178:                        if (ai.noNumber())
179:                            ai.ops.op_bc(1);
180:                        else
181:                            ai.ops.op_bc(ai.numberAt(0));
182:                        return null;
183:                    }
184:                }
185:
186:                protected static final class ACT_MARGIN implements  Actor {
187:                    public String action(AbstractInterp ai, char c) {
188:                        if (ai.noNumber())
189:                            ai.ops.op_margin(0, 0);
190:                        else
191:                            ai.ops.op_margin(ai.numberAt(0), ai.numberAt(1));
192:                        return null;
193:                    }
194:                }
195:
196:                protected static final class ACT_DC implements  Actor {
197:                    public String action(AbstractInterp ai, char c) {
198:                        if (ai.noNumber())
199:                            ai.ops.op_dc(1);
200:                        else
201:                            ai.ops.op_dc(ai.numberAt(0));
202:                        return null;
203:                    }
204:                }
205:
206:                protected static final class ACT_SM implements  Actor {
207:                    public String action(AbstractInterp ai, char c) {
208:                        if (ai.noNumber())
209:                            ai.ops.op_set_mode(1);
210:                        else
211:                            ai.ops.op_set_mode(ai.numberAt(0));
212:                        return null;
213:                    }
214:                }
215:
216:                protected static final class ACT_RM implements  Actor {
217:                    public String action(AbstractInterp ai, char c) {
218:                        if (ai.noNumber())
219:                            ai.ops.op_reset_mode(1);
220:                        else
221:                            ai.ops.op_reset_mode(ai.numberAt(0));
222:                        return null;
223:                    }
224:                }
225:
226:                protected static final class ACT_IC implements  Actor {
227:                    public String action(AbstractInterp ai, char c) {
228:                        if (ai.noNumber())
229:                            ai.ops.op_ic(1);
230:                        else
231:                            ai.ops.op_ic(ai.numberAt(0));
232:                        return null;
233:                    }
234:                }
235:
236:                protected static final class ACT_DL implements  Actor {
237:                    public String action(AbstractInterp ai, char c) {
238:                        if (ai.noNumber()) {
239:                            ai.ops.op_dl(1);
240:                        } else {
241:                            ai.ops.op_dl(ai.numberAt(0));
242:                        }
243:                        return null;
244:                    }
245:                }
246:
247:                protected static final class ACT_HO implements  Actor {
248:                    public String action(AbstractInterp ai, char c) {
249:                        if (ai.noNumber()) {
250:                            ai.ops.op_ho();
251:                        } else {
252:                            ai.ops.op_cm(ai.numberAt(0), ai.numberAt(1));// row, col
253:                        }
254:                        return null;
255:                    }
256:                }
257:
258:                protected static final class ACT_PRINT implements  Actor {
259:                    public String action(AbstractInterp ai, char c) {
260:                        // Ignored for now, except for 'dump time'
261:                        if (ai.noNumber()) {
262:                            // Print screen
263:                        } else {
264:                            switch (ai.numberAt(0)) {
265:                            case 1: // Print Line
266:                            case 4: // Stop Print Log
267:                            case 5: // Start Print Log
268:                                break;
269:                            case 10:
270:                                ai.ops.op_time(true);
271:                                break;
272:                            case 11:
273:                                ai.ops.op_time(false);
274:                                break;
275:                            }
276:                        }
277:                        return null;
278:                    }
279:                }
280:
281:                protected static final class ACT_J implements  Actor {
282:                    public String action(AbstractInterp ai, char c) {
283:                        if (ai.noNumber()) {
284:                            ai.ops.op_cd();
285:                        } else {
286:                            int count = ai.numberAt(0);
287:                            if (count == 1) {
288:                                return "ACT J: count of 1 not supported"; // NOI18N
289:                            } else if (count == 2) {
290:                                ai.ops.op_cl();
291:                            }
292:                        }
293:                        return null;
294:                    }
295:                }
296:
297:                protected static final class ACT_K implements  Actor {
298:                    public String action(AbstractInterp ai, char c) {
299:                        if (ai.noNumber()) {
300:                            ai.ops.op_ce();
301:                        } else {
302:                            int count = ai.numberAt(0);
303:                            if (count == 1) {
304:                                return "ACT K: count of 1 not supported"; // NOI18N
305:                            } else if (count == 2) {
306:                                return "ACT K: count of 2 not supported"; // NOI18N
307:                            }
308:                        }
309:                        return null;
310:                    }
311:                }
312:
313:                protected static final class ACT_AL implements  Actor {
314:                    public String action(AbstractInterp ai, char c) {
315:                        if (ai.noNumber()) {
316:                            ai.ops.op_al(1);
317:                        } else {
318:                            ai.ops.op_al(ai.numberAt(0));
319:                        }
320:                        return null;
321:                    }
322:                }
323:
324:                protected static final class ACT_ATTR implements  Actor {
325:                    public String action(AbstractInterp ai, char c) {
326:                        // set graphics modes (bold, reverse video etc)
327:                        if (ai.noNumber()) {
328:                            ai.ops.op_attr(0); // reset everything
329:                        } else {
330:                            for (int n = 0; n <= ai.nNumbers(); n++)
331:                                ai.ops.op_attr(ai.numberAt(n));
332:                        }
333:                        return null;
334:                    }
335:                }
336:
337:                protected static final class ACT_DSR implements  Actor {
338:                    // Device Status Report
339:                    public String action(AbstractInterp ai, char c) {
340:                        if (ai.noNumber()) {
341:                            ai.ops.op_status_report(5); // reset everything
342:                        } else {
343:                            ai.ops.op_status_report(ai.numberAt(0));
344:                        }
345:                        return null;
346:                    }
347:                }
348:
349:                protected static final class ACT_GLYPH implements  Actor {
350:                    public String action(AbstractInterp ai, char c) {
351:                        if (ai.noNumber()) {
352:                            return "ACT GLYPH: missing number"; // NOI18N
353:                        } else {
354:                            int p1 = ai.numberAt(0);
355:                            int p2 = ai.numberAt(1);
356:                            int p3 = ai.numberAt(2);
357:                            if (p1 == 22) {
358:                                ai.ops.op_glyph(p2, p3);
359:                            } else {
360:                                return "ACT GLYPH: op othger than 22 not supported"; // NOI18N
361:                            }
362:                        }
363:                        return null;
364:                    }
365:                }
366:            }
367:
368:            private InterpTypeANSI type;
369:
370:            public static final InterpTypeANSI type_singleton = new InterpTypeANSI();
371:
372:            public InterpANSI(Ops ops) {
373:                super (ops, type_singleton);
374:                this .type = type_singleton;
375:                setup();
376:            }
377:
378:            protected InterpANSI(Ops ops, InterpTypeANSI type) {
379:                super (ops, type);
380:                this .type = type;
381:                setup();
382:            }
383:
384:            public String name() {
385:                return "ansi"; // NOI18N
386:            }
387:
388:            public void reset() {
389:                super .reset();
390:            }
391:
392:            private void setup() {
393:                state = type.st_base;
394:            }
395:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.