Source Code Cross Referenced for SwtBuffer.java in  » Scripting » Kawa » gnu » jemacs » swt » 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 » Scripting » Kawa » gnu.jemacs.swt 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //This is free software;  for terms and warranty disclaimer see ./COPYING.
002:
003:        package gnu.jemacs.swt;
004:
005:        import gnu.jemacs.buffer.Buffer;
006:        import gnu.jemacs.buffer.Marker;
007:        import gnu.lists.CharSeq;
008:        import gnu.lists.FString;
009:        import gnu.mapping.InPort;
010:
011:        import java.io.Reader;
012:        import java.io.Writer;
013:        import java.util.HashSet;
014:        import java.util.Iterator;
015:        import java.util.Set;
016:
017:        import org.eclipse.swt.custom.StyledTextContent;
018:
019:        /**
020:         * @author Christian Surlykke
021:         *         11-07-2004
022:         */
023:        public class SwtBuffer extends Buffer {
024:
025:            private BufferContent bufferContent = null;
026:
027:            public SwtBuffer(String name) {
028:                this (name, new BufferContent());
029:            }
030:
031:            public SwtBuffer(String name, BufferContent content) {
032:                super (name);
033:                this .bufferContent = content;
034:
035:                pointMarker = new Marker(this , 0, true);
036:                markMarker = new Marker();
037:                redrawModeline();
038:            }
039:
040:            /** 
041:             * @see gnu.jemacs.buffer.Buffer#redrawModeline()
042:             */
043:            public void redrawModeline() {
044:                modeline = new FString("-----JEmacs: " + getName() + " ---");
045:            }
046:
047:            private FString modeline = new FString("");
048:
049:            public FString getModelineFormat() {
050:                return modeline;
051:            }
052:
053:            /**
054:             * @see gnu.jemacs.buffer.Buffer#getLength()
055:             */
056:            public int getLength() {
057:                return bufferContent.getCharCount();
058:            }
059:
060:            // ---------------------- The Dot ------------------------------
061:            private int dot = 0;
062:
063:            /**
064:             * @see gnu.jemacs.buffer.Buffer#getDot()
065:             */
066:            public int getDot() {
067:                return dot;
068:            }
069:
070:            /**
071:             * @see gnu.jemacs.buffer.Buffer#setDot(int)
072:             */
073:            public void setDot(int dot) {
074:                this .dot = dot;
075:            }
076:
077:            /**
078:             * @see gnu.jemacs.buffer.Buffer#maxDot()
079:             */
080:            public int maxDot() {
081:                return length();
082:            }
083:
084:            // ---------------------- Insertion --------------------------
085:
086:            /**
087:             * @see gnu.jemacs.buffer.Buffer#insert(java.lang.String, java.lang.Object, int)
088:             */
089:            public void insert(String string, Object style, int ipos) {
090:                // TODO Auto-generated method stub
091:            }
092:
093:            /**
094:             * @see gnu.jemacs.buffer.Buffer#insert(char, int, java.lang.Object)
095:             */
096:            public void insert(char ch, int count, Object style) {
097:                // TODO: Handle styles !
098:                char[] charr = new char[count];
099:
100:                for (int i = 0; i < charr.length; i++) {
101:                    charr[i] = ch;
102:                }
103:
104:                bufferContent.replaceTextRange(getDot(), 0, new String(charr));
105:                setDot(getDot() + 1);
106:            }
107:
108:            /**
109:             * @see gnu.jemacs.buffer.Buffer#insert(char, int)
110:             */
111:            public void insert(char ch, int count) {
112:                insert(ch, count, null);
113:            }
114:
115:            /**
116:             * @see gnu.jemacs.buffer.Buffer#removeAll()
117:             */
118:            public void removeAll() {
119:                bufferContent.setText("");
120:            }
121:
122:            /**
123:             * @see gnu.jemacs.buffer.Buffer#insertFile(java.io.Reader)
124:             */
125:            public void insertFile(Reader in) throws Exception {
126:                bufferContent.insertFile(in, getDot());
127:            }
128:
129:            /**
130:             * @see gnu.jemacs.buffer.Buffer#save(java.io.Writer)
131:             */
132:            public void save(Writer out) throws Exception {
133:                bufferContent.save(out);
134:            }
135:
136:            /**
137:             * @see gnu.jemacs.buffer.Buffer#removeChar(int)
138:             */
139:            public void removeChar(int count) {
140:                int start = Math.min(getDot(), getDot() + count);
141:                int end = Math.max(getDot(), getDot() + count);
142:
143:                // Confine interval to be within [0; size()]
144:                start = Math.max(0, Math.min(start, size()));
145:                end = Math.max(0, Math.min(end, size()));
146:
147:                if (start != end) {
148:                    count = Math.abs(end - start);
149:                    start = Math.min(start, end);
150:                    bufferContent.replaceTextRange(start, count, null);
151:                    setDot(start);
152:                }
153:            }
154:
155:            /**
156:             * @see gnu.jemacs.buffer.Buffer#lineStartOffset(int)
157:             */
158:            public int lineStartOffset(int offset) {
159:                return bufferContent.lineStartPos(offset);
160:            }
161:
162:            /**
163:             * @see gnu.jemacs.buffer.Buffer#scan(char, int, int, int, boolean)
164:             */
165:            public long scan(char target, int start, int end, int count,
166:                    boolean allowQuit) {
167:                // TODO Auto-generated method stub
168:                return 0;
169:            }
170:
171:            public CharSeq getStringContent() {
172:                return bufferContent;
173:            }
174:
175:            /**
176:             * @see gnu.jemacs.buffer.Buffer#openReader(int, int)
177:             */
178:            public InPort openReader(int start, int count) {
179:                return new InPort(new BufferContentReader(bufferContent, start,
180:                        count));
181:            }
182:
183:            /**
184:             * @see gnu.jemacs.buffer.Buffer#savePointMark()
185:             */
186:            public long savePointMark() {
187:                // TODO Auto-generated method stub
188:                return 0;
189:            }
190:
191:            /**
192:             * @see gnu.jemacs.buffer.Buffer#restorePointMark(long)
193:             */
194:            public void restorePointMark(long pointMark) {
195:                // TODO Auto-generated method stub
196:
197:            }
198:
199:            /**
200:             * @see gnu.jemacs.buffer.Buffer#invoke(java.lang.Runnable)
201:             */
202:            public void invoke(Runnable doRun) {
203:                // TODO Auto-generated method stub
204:
205:            }
206:
207:            /**
208:             * @see gnu.lists.AbstractSequence#size()
209:             */
210:            public int size() {
211:                return bufferContent.getCharCount();
212:            }
213:
214:            /**
215:             * @see gnu.lists.AbstractSequence#get(int)
216:             */
217:            public Object get(int index) {
218:                throw new UnsupportedOperationException();
219:            }
220:
221:            /**
222:             * @see gnu.lists.AbstractSequence#createPos(int, boolean)
223:             */
224:            public int createPos(int index, boolean isAfter) {
225:                // TODO Auto-generated method stub
226:                return 0;
227:            }
228:
229:            public StyledTextContent getBufferContent() {
230:                return bufferContent;
231:            }
232:
233:            /**
234:             * @see gnu.jemacs.buffer.Buffer#forwardLine(int)
235:             */
236:            public int forwardLine(int lines) {
237:                int currentLine = bufferContent.getLineAtOffset(getDot());
238:                int newLine = currentLine + lines;
239:                if (newLine < 0) {
240:                    setDot(bufferContent.getOffsetAtLine(0));
241:                    return newLine;
242:                } else if (newLine > bufferContent.getLineCount()) {
243:                    setDot(bufferContent.getOffsetAtLine(bufferContent
244:                            .getLineCount()));
245:                    return newLine - bufferContent.getLineCount();
246:                } else {
247:                    setDot(bufferContent.getOffsetAtLine(newLine));
248:                    return 0;
249:                }
250:            }
251:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.