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

# · Unknown · 52 lines · 44 code · 8 blank · 0 comment · 0 complexity · a7af75ef9c67c1191a4ee26d805ee0bb 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 3866 2001-11-06 15:04:21Z jgellene $
  21. *
  22. *
  23. * Checked for jEdit 4.0 API
  24. *
  25. */
  26. selection = textArea.getSelectedText();
  27. if (selection != null)
  28. color = GUIUtilities.parseColor(selection);
  29. else
  30. color = null;
  31. color = JColorChooser.showDialog(view, "Color Picker", color);
  32. if (color != null)
  33. textArea.setSelectedText(GUIUtilities.getColorHexString(color));
  34. /*
  35. Macro index data (in DocBook format)
  36. <listitem>
  37. <para><filename>Color_Picker.bsh</filename></para>
  38. <abstract><para>
  39. Displays a color picker and inserts the selected color in
  40. hexadecimal format, prefixed with a <quote>#</quote>.
  41. </para></abstract>
  42. </listitem>
  43. */
  44. // end Color_Picker.bsh