View Javadoc

1   /*
2    * TextAreaDefaults.java - Encapsulates default values for various settings
3    * Copyright (C) 1999 Slava Pestov
4    *
5    * You may use and modify this package for any purpose. Redistribution is
6    * permitted, in both source and binary form, provided that this notice
7    * remains intact in all source distributions of this package.
8    */
9   
10  package org.syntax.jedit;
11  
12  import java.awt.Color;
13  
14  import javax.swing.JPopupMenu;
15  
16  /***
17   * Encapsulates default settings for a text area. This can be passed to the
18   * constructor once the necessary fields have been filled out. The advantage of
19   * doing this over calling lots of set() methods after creating the text area is
20   * that this method is faster.
21   */
22  public class TextAreaDefaults
23  {
24  	// private static TextAreaDefaults DEFAULTS;
25  
26  	public InputHandler inputHandler;
27  	public SyntaxDocument document;
28  	public boolean editable;
29  
30  	public boolean caretVisible;
31  	public boolean caretBlinks;
32  	public boolean blockCaret;
33  	public int electricScroll;
34  
35  	public int cols;
36  	public int rows;
37  	public SyntaxStyle[] styles;
38  	public Color caretColor;
39  	public Color selectionColor;
40  	public Color lineHighlightColor;
41  	public boolean lineHighlight;
42  	public Color bracketHighlightColor;
43  	public boolean bracketHighlight;
44  	public Color eolMarkerColor;
45  	public boolean eolMarkers;
46  	public boolean paintInvalid;
47  
48  	public JPopupMenu popup;
49  
50  	/***
51  	 * Returns a new TextAreaDefaults object with the default values filled in.
52  	 */
53  	public static TextAreaDefaults getDefaults()
54  	{
55  		// if(DEFAULTS == null)
56  		// {
57  		TextAreaDefaults DEFAULTS = new TextAreaDefaults();
58  
59  		DEFAULTS.inputHandler = new DefaultInputHandler();
60  		DEFAULTS.inputHandler.addDefaultKeyBindings();
61  		DEFAULTS.document = new SyntaxDocument();
62  		DEFAULTS.editable = true;
63  
64  		DEFAULTS.blockCaret = false;
65  		DEFAULTS.caretVisible = true;
66  		DEFAULTS.caretBlinks = true;
67  		DEFAULTS.electricScroll = 3;
68  
69  		DEFAULTS.cols = 80;
70  		DEFAULTS.rows = 25;
71  		DEFAULTS.styles = SyntaxUtilities.getDefaultSyntaxStyles();
72  		DEFAULTS.caretColor = Color.black; // Color.red;
73  		DEFAULTS.selectionColor = new Color( 0xccccff );
74  		DEFAULTS.lineHighlightColor = new Color( 0xe0e0e0 );
75  		DEFAULTS.lineHighlight = true;
76  		DEFAULTS.bracketHighlightColor = Color.black;
77  		DEFAULTS.bracketHighlight = true;
78  		DEFAULTS.eolMarkerColor = new Color( 0x009999 );
79  		DEFAULTS.eolMarkers = false; // true;
80  		DEFAULTS.paintInvalid = false; // true;
81  		// }
82  
83  		return DEFAULTS;
84  	}
85  }