File: Next_Dirty_Buffer.bsh

package info (click to toggle)
jedit 5.3.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 14,252 kB
  • ctags: 11,190
  • sloc: java: 98,480; xml: 94,070; makefile: 52; sh: 42; cpp: 6; python: 6
file content (49 lines) | stat: -rw-r--r-- 1,336 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * Next_Dirty_Buffer.bsh - Changes the buffer in
 * the current EditPane to the next dirty buffer, if 
 * there is one.
 *
 * Copyright (C) 2002-2004 Ollie Rutherfurd <oliver@rutherfurd.net>
 *
 * $Id: Next_Dirty_Buffer.bsh 21353 2012-03-14 09:46:51Z jojaba_67 $
 */

// Localization
final static String NoOtherBufferDirtyMessage = jEdit.getProperty("macro.rs.NextDirtyBuffer.NoOtherBufferDirty.message", "No other buffers are dirty");
final static String NoBufferDirtyMessage = jEdit.getProperty("macro.rs.NextDirtyBuffer.NoBufferDirty.message", "No buffers are dirty");

// Process
void nextDirtyBuffer(View view)
{
	Buffer current = view.getBuffer();
	Buffer b = current.getNext();
	for(int i=0; i < jEdit.getBufferCount()-1; i++)
	{
		// Buffer.getNext() returns null on last
		if(b == null)
			b = jEdit.getFirstBuffer();
		if(b.isDirty())
		{
			view.getEditPane().setBuffer(b);
			return;
		}
		b = b.getNext();	// check next
	}
	// if we get here, we didn't switch
	if(current.isDirty())
		view.getStatus().setMessageAndClear(NoOtherBufferDirtyMessage);
	else
		view.getStatus().setMessageAndClear(NoBufferDirtyMessage);
}

nextDirtyBuffer(view);

/*

<listitem>
	<para><filename>Next_Dirty_Buffer.bsh</filename></para>
	<abstract><para>Switches to the next dirty buffer, if there is one.
	</para></abstract>
</listitem>

*/