PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-2-pre14/macros/Files/Glob_Close.bsh

#
Unknown | 48 lines | 40 code | 8 blank | 0 comment | 0 complexity | df9e3769026b95162abb05e66c191b91 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
  1. /*
  2. * Glob_Close.bsh - a BeanShell macro for jEdit that closes
  3. * all open buffers matching a given glob pattern.
  4. *
  5. * Copyright (C) 2003-2004 Ollie Rutherfurd <oliver@rutherfurd.net>
  6. *
  7. * $Id: Glob_Close.bsh 4995 2004-03-19 15:58:00Z spestov $
  8. */
  9. import gnu.regexp.*;
  10. void globClose(View view)
  11. {
  12. String glob = Macros.input(view, "Glob Pattern:");
  13. if(glob == null || glob.length() == 0)
  14. return;
  15. RE re = null;
  16. try
  17. {
  18. re = new RE(MiscUtilities.globToRE(glob));
  19. }
  20. catch(Exception e)
  21. {
  22. Macros.error(view,"Error in glob pattern: " + e.toString());
  23. return;
  24. }
  25. Buffer[] buffers = jEdit.getBuffers();
  26. for(int i=0; i < buffers.length; i++)
  27. {
  28. if(re.isMatch(buffers[i].getPath()))
  29. jEdit.closeBuffer(view,buffers[i]);
  30. }
  31. }
  32. globClose(view);
  33. /*
  34. <listitem>
  35. <para><filename>Glob_Close.bsh</filename></para>
  36. <abstract><para>
  37. Closes all open buffers matching a given glob pattern.
  38. </para></abstract>
  39. </listitem>
  40. */