PageRenderTime 76ms CodeModel.GetById 30ms app.highlight 1ms RepoModel.GetById 21ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/macros/Text/Color_Picker.bsh

#
Unknown | 52 lines | 44 code | 8 blank | 0 comment | 0 complexity | 1053bea92177c65524d40627a08c9547 MD5 | raw file
 1/*
 2 * Color_Picker.bsh - a BeanShell macro script for the
 3 * jEdit text editor - displays color picker, inserts selected color
 4 * Copyright (C) 2001 Slava Pestov
 5 *
 6 * This program is free software; you can redistribute it and/or
 7 * modify it under the terms of the GNU General Public License
 8 * as published by the Free Software Foundation; either version 2
 9 * of the License, or any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with the jEdit application; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
19 *
20 * $Id: Color_Picker.bsh 4988 2004-03-08 04:29:12Z spestov $
21 */
22
23selection = textArea.getSelectedText();
24if (selection != null)
25    color = GUIUtilities.parseColor(selection);
26else
27    color = null;
28
29color = JColorChooser.showDialog(view, "Color Picker", color);
30
31if (color != null){
32	if(buffer.isReadOnly())
33		Macros.error(view, "Buffer is read-only.");
34	else
35		textArea.setSelectedText(GUIUtilities.getColorHexString(color));
36}
37
38/*
39	Macro index data (in DocBook format)
40
41<listitem>
42    <para><filename>Color_Picker.bsh</filename></para>
43    <abstract><para>
44        Displays a color picker and inserts the selected color in
45        hexadecimal format, prefixed with a <quote>#</quote>.
46    </para></abstract>
47</listitem>
48
49*/
50
51// end Color_Picker.bsh
52