PageRenderTime 41ms CodeModel.GetById 37ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

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

#
Unknown | 44 lines | 39 code | 5 blank | 0 comment | 0 complexity | ea676d33725ccf4344d012eb43bfb161 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 5016 2004-04-09 17:10:15Z spestov $
 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*/