~ubuntu-branches/ubuntu/precise/arduino/precise

« back to all changes in this revision

Viewing changes to src/processing/app/syntax/PdeTextAreaDefaults.java

  • Committer: Bazaar Package Importer
  • Author(s): Scott Howard
  • Date: 2010-04-13 22:32:24 UTC
  • Revision ID: james.westby@ubuntu.com-20100413223224-jduxnd0xxnkkda02
Tags: upstream-0018+dfsg
ImportĀ upstreamĀ versionĀ 0018+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
 
2
 
 
3
/*
 
4
  PdeTextAreaDefaults - grabs font/color settings for the editor
 
5
  Part of the Processing project - http://processing.org
 
6
 
 
7
  Copyright (c) 2004-06 Ben Fry and Casey Reas
 
8
  Copyright (c) 2001-03 Massachusetts Institute of Technology
 
9
 
 
10
  This program is free software; you can redistribute it and/or modify
 
11
  it under the terms of the GNU General Public License as published by
 
12
  the Free Software Foundation; either version 2 of the License, or
 
13
  (at your option) any later version.
 
14
 
 
15
  This program is distributed in the hope that it will be useful,
 
16
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
  GNU General Public License for more details.
 
19
 
 
20
  You should have received a copy of the GNU General Public License
 
21
  along with this program; if not, write to the Free Software Foundation,
 
22
  Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
*/
 
24
 
 
25
package processing.app.syntax;
 
26
 
 
27
import processing.app.*;
 
28
 
 
29
 
 
30
public class PdeTextAreaDefaults extends TextAreaDefaults {
 
31
 
 
32
  public PdeTextAreaDefaults() {
 
33
 
 
34
    inputHandler = new DefaultInputHandler();
 
35
    //inputHandler.addDefaultKeyBindings();  // 0122
 
36
 
 
37
    // use option on mac for things that are ctrl on windows/linux
 
38
    String mod = Base.isMacOS() ? "A" : "C";
 
39
 
 
40
    // right now, ctrl-up/down is select up/down, but mod should be
 
41
    // used instead, because the mac expects it to be option(alt)
 
42
 
 
43
    inputHandler.addKeyBinding("BACK_SPACE", InputHandler.BACKSPACE);
 
44
    inputHandler.addKeyBinding("DELETE", InputHandler.DELETE);
 
45
 
 
46
    //inputHandler.addKeyBinding("S+BACK_SPACE", InputHandler.BACKSPACE);
 
47
    // for 0122, shift-backspace is delete
 
48
    inputHandler.addKeyBinding("S+BACK_SPACE", InputHandler.DELETE);
 
49
    inputHandler.addKeyBinding("S+DELETE", InputHandler.DELETE);
 
50
 
 
51
    // the following two were changing for 0122 for better mac/pc compatability
 
52
    inputHandler.addKeyBinding(mod+"+BACK_SPACE", InputHandler.BACKSPACE_WORD);
 
53
    inputHandler.addKeyBinding(mod+"+DELETE", InputHandler.DELETE_WORD);
 
54
 
 
55
    // handled by listener, don't bother here
 
56
    //inputHandler.addKeyBinding("ENTER", InputHandler.INSERT_BREAK);
 
57
    //inputHandler.addKeyBinding("TAB", InputHandler.INSERT_TAB);
 
58
 
 
59
    inputHandler.addKeyBinding("INSERT", InputHandler.OVERWRITE);
 
60
    // disabling for 0122, not sure what this does
 
61
    //inputHandler.addKeyBinding("C+\\", InputHandler.TOGGLE_RECT);
 
62
 
 
63
    // for 0122, these have been changed for better compatability
 
64
    // HOME and END now mean the beginning/end of the document
 
65
    if (Base.isMacOS()) {
 
66
      inputHandler.addKeyBinding("HOME", InputHandler.DOCUMENT_HOME);
 
67
      inputHandler.addKeyBinding("END", InputHandler.DOCUMENT_END);
 
68
      inputHandler.addKeyBinding("S+HOME", InputHandler.SELECT_DOC_HOME);
 
69
      inputHandler.addKeyBinding("S+END", InputHandler.SELECT_DOC_END);
 
70
    } else {
 
71
      // for 0123 added the proper windows defaults
 
72
      inputHandler.addKeyBinding("HOME", InputHandler.HOME);
 
73
      inputHandler.addKeyBinding("END", InputHandler.END);
 
74
      inputHandler.addKeyBinding("S+HOME", InputHandler.SELECT_HOME);
 
75
      inputHandler.addKeyBinding("S+END", InputHandler.SELECT_END);
 
76
      inputHandler.addKeyBinding("C+HOME", InputHandler.DOCUMENT_HOME);
 
77
      inputHandler.addKeyBinding("C+END", InputHandler.DOCUMENT_END);
 
78
      inputHandler.addKeyBinding("CS+HOME", InputHandler.SELECT_DOC_HOME);
 
79
      inputHandler.addKeyBinding("CS+END", InputHandler.SELECT_DOC_END);
 
80
    }
 
81
 
 
82
    if (Base.isMacOS()) {
 
83
      inputHandler.addKeyBinding("M+LEFT", InputHandler.HOME);
 
84
      inputHandler.addKeyBinding("M+RIGHT", InputHandler.END);
 
85
      inputHandler.addKeyBinding("MS+LEFT", InputHandler.SELECT_HOME); // 0122
 
86
      inputHandler.addKeyBinding("MS+RIGHT", InputHandler.SELECT_END);  // 0122
 
87
    } else {
 
88
      inputHandler.addKeyBinding("C+LEFT", InputHandler.HOME);  // 0122
 
89
      inputHandler.addKeyBinding("C+RIGHT", InputHandler.END);  // 0122
 
90
      inputHandler.addKeyBinding("CS+HOME", InputHandler.SELECT_HOME); // 0122
 
91
      inputHandler.addKeyBinding("CS+END", InputHandler.SELECT_END);  // 0122
 
92
    }
 
93
 
 
94
    inputHandler.addKeyBinding("PAGE_UP", InputHandler.PREV_PAGE);
 
95
    inputHandler.addKeyBinding("PAGE_DOWN", InputHandler.NEXT_PAGE);
 
96
    inputHandler.addKeyBinding("S+PAGE_UP", InputHandler.SELECT_PREV_PAGE);
 
97
    inputHandler.addKeyBinding("S+PAGE_DOWN", InputHandler.SELECT_NEXT_PAGE);
 
98
 
 
99
    inputHandler.addKeyBinding("LEFT", InputHandler.PREV_CHAR);
 
100
    inputHandler.addKeyBinding("S+LEFT", InputHandler.SELECT_PREV_CHAR);
 
101
    inputHandler.addKeyBinding(mod + "+LEFT", InputHandler.PREV_WORD);
 
102
    inputHandler.addKeyBinding(mod + "S+LEFT", InputHandler.SELECT_PREV_WORD);
 
103
    inputHandler.addKeyBinding("RIGHT", InputHandler.NEXT_CHAR);
 
104
    inputHandler.addKeyBinding("S+RIGHT", InputHandler.SELECT_NEXT_CHAR);
 
105
    inputHandler.addKeyBinding(mod + "+RIGHT", InputHandler.NEXT_WORD);
 
106
    inputHandler.addKeyBinding(mod + "S+RIGHT", InputHandler.SELECT_NEXT_WORD);
 
107
 
 
108
    inputHandler.addKeyBinding("UP", InputHandler.PREV_LINE);
 
109
    inputHandler.addKeyBinding(mod + "+UP", InputHandler.PREV_LINE);  // p5
 
110
    inputHandler.addKeyBinding("S+UP", InputHandler.SELECT_PREV_LINE);
 
111
    inputHandler.addKeyBinding("DOWN", InputHandler.NEXT_LINE);
 
112
    inputHandler.addKeyBinding(mod + "+DOWN", InputHandler.NEXT_LINE);  // p5
 
113
    inputHandler.addKeyBinding("S+DOWN", InputHandler.SELECT_NEXT_LINE);
 
114
 
 
115
    inputHandler.addKeyBinding("MS+UP", InputHandler.SELECT_DOC_HOME);
 
116
    inputHandler.addKeyBinding("CS+UP", InputHandler.SELECT_DOC_HOME);
 
117
    inputHandler.addKeyBinding("MS+DOWN", InputHandler.SELECT_DOC_END);
 
118
    inputHandler.addKeyBinding("CS+DOWN", InputHandler.SELECT_DOC_END);
 
119
 
 
120
    inputHandler.addKeyBinding(mod + "+ENTER", InputHandler.REPEAT);
 
121
 
 
122
    document = new SyntaxDocument();
 
123
    editable = true;
 
124
    electricScroll = 3;
 
125
 
 
126
    cols = 80;
 
127
    rows = 15;
 
128
 
 
129
 
 
130
    // moved from SyntaxUtilities
 
131
    //DEFAULTS.styles = SyntaxUtilities.getDefaultSyntaxStyles();
 
132
 
 
133
    styles = new SyntaxStyle[Token.ID_COUNT];
 
134
 
 
135
    // comments
 
136
    styles[Token.COMMENT1] = Theme.getStyle("comment1");
 
137
    styles[Token.COMMENT2] = Theme.getStyle("comment2");
 
138
 
 
139
    // abstract, final, private
 
140
    styles[Token.KEYWORD1] = Theme.getStyle("keyword1");
 
141
 
 
142
    // beginShape, point, line
 
143
    styles[Token.KEYWORD2] = Theme.getStyle("keyword2");
 
144
 
 
145
    // byte, char, short, color
 
146
    styles[Token.KEYWORD3] = Theme.getStyle("keyword3");
 
147
 
 
148
    // constants: null, true, this, RGB, TWO_PI
 
149
    styles[Token.LITERAL1] = Theme.getStyle("literal1");
 
150
 
 
151
    // p5 built in variables: mouseX, width, pixels
 
152
    styles[Token.LITERAL2] = Theme.getStyle("literal2");
 
153
 
 
154
    // ??
 
155
    styles[Token.LABEL] = Theme.getStyle("label");
 
156
 
 
157
    // + - = /
 
158
    styles[Token.OPERATOR] = Theme.getStyle("operator");
 
159
 
 
160
    // area that's not in use by the text (replaced with tildes)
 
161
    styles[Token.INVALID] = Theme.getStyle("invalid");
 
162
 
 
163
 
 
164
    // moved from TextAreaPainter
 
165
 
 
166
    font = Preferences.getFont("editor.font");
 
167
 
 
168
    fgcolor = Theme.getColor("editor.fgcolor");
 
169
    bgcolor = Theme.getColor("editor.bgcolor");
 
170
 
 
171
    caretVisible = true;
 
172
    caretBlinks = Preferences.getBoolean("editor.caret.blink");
 
173
    caretColor = Theme.getColor("editor.caret.color");
 
174
 
 
175
    selectionColor = Theme.getColor("editor.selection.color");
 
176
 
 
177
    lineHighlight =
 
178
      Theme.getBoolean("editor.linehighlight");
 
179
    lineHighlightColor =
 
180
      Theme.getColor("editor.linehighlight.color");
 
181
 
 
182
    bracketHighlight =
 
183
      Theme.getBoolean("editor.brackethighlight");
 
184
    bracketHighlightColor =
 
185
      Theme.getColor("editor.brackethighlight.color");
 
186
 
 
187
    eolMarkers = Theme.getBoolean("editor.eolmarkers");
 
188
    eolMarkerColor = Theme.getColor("editor.eolmarkers.color");
 
189
 
 
190
    paintInvalid = Theme.getBoolean("editor.invalid");
 
191
  }
 
192
}