001: /*
002: * DefaultTheme.java
003: *
004: * Copyright (C) 2000-2002 Peter Graves
005: * $Id: DefaultTheme.java,v 1.3 2002/12/29 16:53:22 piso Exp $
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License
009: * as published by the Free Software Foundation; either version 2
010: * of the License, or (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
020: */
021:
022: package org.armedbear.j;
023:
024: import java.awt.Color;
025: import java.awt.Font;
026:
027: public final class DefaultTheme {
028: public static final Color getColor(String thing) {
029: return getColor(null, thing);
030: }
031:
032: // Returns null if mode/thing not found.
033: public static final Color getColor(String mode, String thing) {
034: if (thing == null)
035: return null;
036: thing = thing.intern();
037: if (mode != null) {
038: mode = mode.intern();
039: if (mode == "CSSMode") {
040: if (thing == "selector")
041: return new Color(0, 0, 0);
042: if (thing == "property")
043: return new Color(0, 0, 204);
044: } else if (mode == "DiffMode") {
045: if (thing == "file")
046: return new Color(0, 0, 0);
047: if (thing == "header")
048: return new Color(0, 102, 0);
049: if (thing == "context")
050: return new Color(0, 0, 0);
051: if (thing == "inserted")
052: return new Color(153, 0, 0);
053: if (thing == "deleted")
054: return new Color(0, 0, 153);
055: } else if (mode == "DirectoryMode") {
056: if (thing == "directory")
057: return new Color(0, 0, 0);
058: if (thing == "symlink")
059: return new Color(0, 0, 255);
060: if (thing == "marked")
061: return new Color(153, 0, 0);
062: } else if (mode == "HtmlMode") {
063: if (thing == "tag")
064: return new Color(0, 0, 153);
065: if (thing == "anchor")
066: return new Color(51, 153, 51);
067: if (thing == "image")
068: return new Color(204, 102, 0);
069: if (thing == "table")
070: return new Color(204, 0, 0);
071: if (thing == "tableRow")
072: return new Color(153, 0, 0);
073: if (thing == "tableData")
074: return new Color(153, 51, 0);
075: if (thing == "comment")
076: return new Color(128, 128, 128);
077: if (thing == "script")
078: return new Color(0, 0, 255);
079: } else if (mode == "ListOccurrencesMode") {
080: if (thing == "headerName")
081: return new Color(0, 0, 153);
082: if (thing == "headerValue")
083: return new Color(0, 0, 255);
084: } else if (mode == "MailboxMode") {
085: if (thing == "to")
086: return new Color(0, 0, 0);
087: if (thing == "flags")
088: return new Color(0, 0, 0);
089: if (thing == "date")
090: return new Color(51, 51, 51);
091: if (thing == "from")
092: return new Color(0, 0, 0);
093: if (thing == "size")
094: return new Color(51, 51, 51);
095: if (thing == "subject")
096: return new Color(51, 102, 102);
097: if (thing == "flaggedTo")
098: return new Color(204, 51, 0);
099: if (thing == "flaggedFlags")
100: return new Color(0, 0, 0);
101: if (thing == "flaggedDate")
102: return new Color(0, 0, 0);
103: if (thing == "flaggedFrom")
104: return new Color(204, 51, 0);
105: if (thing == "flaggedSize")
106: return new Color(0, 0, 0);
107: if (thing == "flaggedSubject")
108: return new Color(204, 51, 0);
109: if (thing == "marked")
110: return new Color(153, 0, 0);
111: if (thing == "deleted")
112: return new Color(153, 153, 153);
113: } else if (mode == "MessageMode") {
114: if (thing == "headerName")
115: return new Color(0, 0, 153);
116: if (thing == "headerValue")
117: return new Color(51, 102, 102);
118: if (thing == "signature")
119: return new Color(102, 102, 102);
120: if (thing == "string")
121: return new Color(0, 102, 0);
122: if (thing == "comment")
123: return new Color(102, 102, 102);
124: } else if (mode == "WebMode") {
125: if (thing == "headerValue")
126: return new Color(51, 102, 102);
127: } else if (mode == "LispMode") {
128: if (thing == "substitution")
129: return new Color(153, 0, 153);
130: if (thing == "punctuation")
131: return new Color(102, 102, 102);
132: if (thing == "parenthesis")
133: return new Color(102, 102, 102);
134: if (thing == "secondaryKeyword")
135: return new Color(0, 102, 153);
136: } else if (mode == "PerlMode") {
137: if (thing == "scalar")
138: return new Color(51, 51, 0);
139: if (thing == "list")
140: return new Color(0, 51, 51);
141: } else if (mode == "PHPMode") {
142: if (thing == "var")
143: return new Color(51, 51, 0);
144: if (thing == "tag")
145: return new Color(0, 0, 0);
146: if (thing == "attribute")
147: return new Color(0, 0, 128);
148: if (thing == "equals")
149: return new Color(0, 153, 153);
150: } else if (mode == "TclMode") {
151: if (thing == "brace")
152: return new Color(153, 0, 51);
153: if (thing == "bracket")
154: return new Color(204, 102, 0);
155: } else if (mode == "VHDLMode") {
156: if (thing == "type")
157: return new Color(0, 0, 255);
158: } else if (mode == "PropertiesMode") {
159: if (thing == "section")
160: return new Color(0, 0, 153);
161: } else if (mode == "XmlMode") {
162: if (thing == "attribute")
163: return new Color(0, 0, 128);
164: if (thing == "equals")
165: return new Color(0, 153, 153);
166: if (thing == "namespace")
167: return new Color(0, 0, 0);
168: if (thing == "tag")
169: return new Color(0, 0, 0);
170: }
171: }
172:
173: if (thing == "text")
174: return new Color(0, 0, 0);
175: if (thing == "background")
176: return new Color(255, 255, 224);
177: if (thing == "caret")
178: return new Color(255, 0, 0);
179: if (thing == "verticalRule")
180: return new Color(204, 204, 204);
181: if (thing == "selectionBackground")
182: return new Color(153, 204, 255);
183: if (thing == "matchingBracketBackground")
184: return new Color(153, 204, 255);
185: if (thing == "preprocessor")
186: return new Color(255, 0, 0);
187: if (thing == "comment")
188: return new Color(0, 102, 0);
189: if (thing == "keyword")
190: return new Color(0, 0, 153);
191: if (thing == "brace")
192: return new Color(0, 128, 128);
193: if (thing == "number")
194: return new Color(153, 102, 51);
195: if (thing == "currentLineBackground")
196: return new Color(235, 235, 204);
197: if (thing == "function")
198: return new Color(0, 0, 0);
199: if (thing == "string")
200: return new Color(153, 51, 0);
201: if (thing == "operator")
202: return new Color(0, 0, 255);
203: if (thing == "disabled")
204: return new Color(153, 153, 153);
205: if (thing == "change")
206: return new Color(255, 164, 0);
207: if (thing == "savedChange")
208: return new Color(180, 180, 180);
209: if (thing == "lineNumber")
210: return new Color(153, 153, 153);
211: if (thing == "gutterBorder")
212: return new Color(153, 153, 153);
213: if (thing == "prompt")
214: return new Color(0, 0, 0);
215: if (thing == "input")
216: return new Color(0, 0, 255);
217: if (thing == "matchingText")
218: return new Color(204, 102, 0);
219: if (thing == "status")
220: return new Color(0, 0, 153);
221: if (thing == "key")
222: return new Color(0, 0, 153);
223: if (thing == "value")
224: return new Color(128, 0, 0);
225: if (thing == "delimiter")
226: return new Color(0, 153, 153);
227:
228: // Makefile mode.
229: if (thing == "target")
230: return new Color(0, 0, 0);
231:
232: // Web mode.
233: if (thing == "link")
234: return new Color(0, 0, 255);
235:
236: // List Registers mode.
237: if (thing == "registerPrefix")
238: return new Color(0, 0, 153);
239: if (thing == "registerName")
240: return new Color(204, 102, 0);
241:
242: // Not found.
243: return null;
244: }
245:
246: // Font.PLAIN is 0, Font.BOLD is 1, Font.ITALIC is 2.
247: // Returns -1 if mode/thing not found.
248: public static final int getStyle(String mode, String thing) {
249: if (thing == null)
250: return -1;
251: thing = thing.intern();
252: if (mode != null) {
253: mode = mode.intern();
254: if (mode == "CSSMode") {
255: if (thing == "selector")
256: return Font.BOLD;
257: if (thing == "property")
258: return Font.PLAIN;
259: } else if (mode == "DiffMode") {
260: if (thing == "file")
261: return Font.BOLD;
262: if (thing == "header")
263: return Font.ITALIC;
264: } else if (mode == "MailboxMode") {
265: if (thing == "to")
266: return Font.BOLD;
267: if (thing == "date")
268: return Font.PLAIN;
269: if (thing == "from")
270: return Font.BOLD;
271: if (thing == "subject")
272: return Font.BOLD;
273: if (thing == "flaggedTo")
274: return Font.BOLD;
275: if (thing == "flaggedFrom")
276: return Font.BOLD;
277: if (thing == "flaggedSubject")
278: return Font.BOLD;
279: if (thing == "marked")
280: return Font.BOLD;
281: } else if (mode == "MessageMode") {
282: if (thing == "headerName")
283: return Font.BOLD;
284: if (thing == "headerValue")
285: return Font.BOLD;
286: if (thing == "comment")
287: return Font.PLAIN;
288: } else if (mode == "WebMode") {
289: if (thing == "headerValue")
290: return Font.BOLD;
291: } else if (mode == "ListOccurrencesMode") {
292: if (thing == "headerName")
293: return Font.BOLD;
294: } else if (mode == "PropertiesMode") {
295: if (thing == "section")
296: return Font.BOLD;
297: else if (thing == "comment")
298: return Font.ITALIC;
299: else
300: return Font.PLAIN;
301: } else if (mode == "DirectoryMode") {
302: if (thing == "directory")
303: return Font.BOLD;
304: if (thing == "marked")
305: return Font.BOLD;
306: } else if (mode == "TclMode") {
307: if (thing == "brace")
308: return Font.BOLD;
309: if (thing == "bracket")
310: return Font.BOLD;
311: } else if (mode == "XmlMode" || mode == "PHPMode") {
312: if (thing == "tag")
313: return Font.BOLD;
314: } else if (mode == "MakefileMode") {
315: if (thing == "target")
316: return Font.BOLD;
317: }
318: }
319:
320: if (thing == "keyword")
321: return Font.BOLD;
322: if (thing == "function")
323: return Font.BOLD;
324: if (thing == "prompt")
325: return Font.BOLD;
326: if (thing == "comment")
327: return Font.ITALIC;
328: if (thing == "matchingText")
329: return Font.BOLD;
330: if (thing == "status")
331: return Font.ITALIC;
332: if (thing == "key")
333: return Font.PLAIN;
334: if (thing == "delimiter")
335: return Font.BOLD;
336:
337: // List Registers mode.
338: if (thing == "registerPrefix")
339: return Font.BOLD;
340: if (thing == "registerName")
341: return Font.BOLD;
342:
343: // Not found.
344: return -1;
345: }
346: }
|