PageRenderTime 3ms CodeModel.GetById 1ms app.highlight 1ms RepoModel.GetById 1ms 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
 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
10import gnu.regexp.*;
11
12void globClose(View view)
13{
14	String glob = Macros.input(view, "Glob Pattern:");
15	if(glob == null || glob.length() == 0)
16		return;
17
18	RE re = null;
19	try
20	{
21		re = new RE(MiscUtilities.globToRE(glob));
22	}
23	catch(Exception e)
24	{
25		Macros.error(view,"Error in glob pattern: " + e.toString());
26		return;
27	}
28
29	Buffer[] buffers = jEdit.getBuffers();
30	for(int i=0; i < buffers.length; i++)
31	{
32		if(re.isMatch(buffers[i].getPath()))
33			jEdit.closeBuffer(view,buffers[i]);
34	}
35}
36
37globClose(view);
38
39/*
40
41<listitem>
42	<para><filename>Glob_Close.bsh</filename></para>
43	<abstract><para>
44		Closes all open buffers matching a given glob pattern.
45	</para></abstract>
46</listitem>
47
48*/