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>
*/
|