/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. selection = textArea.getSelectedText();
  23. if (selection != null)
  24. color = GUIUtilities.parseColor(selection);
  25. else
  26. color = null;
  27. color = JColorChooser.showDialog(view, "Color Picker", color);
  28. if (color != null){
  29. if(buffer.isReadOnly())
  30. Macros.error(view, "Buffer is read-only.");
  31. else
  32. textArea.setSelectedText(GUIUtilities.getColorHexString(color));
  33. }
  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