PageRenderTime 42ms CodeModel.GetById 17ms RepoModel.GetById 0ms 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
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
  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. void nextDirtyBuffer(View view)
  11. {
  12. Buffer current = view.getBuffer();
  13. Buffer b = current.getNext();
  14. for(int i=0; i < jEdit.getBufferCount()-1; i++)
  15. {
  16. // Buffer.getNext() returns null on last
  17. if(b == null)
  18. b = jEdit.getFirstBuffer();
  19. if(b.isDirty())
  20. {
  21. view.getEditPane().setBuffer(b);
  22. return;
  23. }
  24. b = b.getNext(); // check next
  25. }
  26. // if we get here, we didn't switch
  27. if(current.isDirty())
  28. view.getStatus().setMessageAndClear("No other buffers are dirty");
  29. else
  30. view.getStatus().setMessageAndClear("No buffers are dirty");
  31. }
  32. nextDirtyBuffer(view);
  33. /*
  34. <listitem>
  35. <para><filename>Next_Dirty_Buffer.bsh</filename></para>
  36. <abstract><para>Switches to the next dirty buffer, if there is one.
  37. </para></abstract>
  38. </listitem>
  39. */