/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
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /*
- * 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 5016 2004-04-09 17:10:15Z spestov $
- */
- 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("No other buffers are dirty");
- else
- view.getStatus().setMessageAndClear("No buffers are dirty");
- }
- 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>
- */