PageRenderTime 63ms CodeModel.GetById 57ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/macros/Files/Next_Dirty_Buffer.bsh

#
Unknown | 44 lines | 39 code | 5 blank | 0 comment | 0 complexity | 7c2c94ff15f39f8e5393bdbdf0c6a100 MD5 | raw file
 1/*
 2 * Next_Dirty_Buffer.bsh - Changes the buffer in
 3 * the current EditPane to the next dirty buffer, if 
 4 * there is one.
 5 *
 6 * Copyright (C) 2002-2004 Ollie Rutherfurd <oliver@rutherfurd.net>
 7 *
 8 * $Id: Next_Dirty_Buffer.bsh 5450 2006-06-20 09:08:13Z vampire0 $
 9 */
10
11void nextDirtyBuffer(View view)
12{
13	Buffer current = view.getBuffer();
14	Buffer b = current.getNext();
15	for(int i=0; i < jEdit.getBufferCount()-1; i++)
16	{
17		// Buffer.getNext() returns null on last
18		if(b == null)
19			b = jEdit.getFirstBuffer();
20		if(b.isDirty())
21		{
22			view.getEditPane().setBuffer(b);
23			return;
24		}
25		b = b.getNext();	// check next
26	}
27	// if we get here, we didn't switch
28	if(current.isDirty())
29		view.getStatus().setMessageAndClear("No other buffers are dirty");
30	else
31		view.getStatus().setMessageAndClear("No buffers are dirty");
32}
33
34nextDirtyBuffer(view);
35
36/*
37
38<listitem>
39	<para><filename>Next_Dirty_Buffer.bsh</filename></para>
40	<abstract><para>Switches to the next dirty buffer, if there is one.
41	</para></abstract>
42</listitem>
43
44*/