PageRenderTime 37ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-3-pre5/org/gjt/sp/jedit/textarea/Anchor.java

#
Java | 94 lines | 57 code | 8 blank | 29 comment | 8 complexity | 07e17acfadaf4e03dec61f1933d7bbf6 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. * Anchor.java - A base point for physical line <-> screen line conversion
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2005 Slava Pestov
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21. */
  22. package org.gjt.sp.jedit.textarea;
  23. /**
  24. * A base point for physical line/screen line conversion.
  25. */
  26. abstract class Anchor
  27. {
  28. DisplayManager displayManager;
  29. JEditTextArea textArea;
  30. int physicalLine;
  31. int scrollLine;
  32. boolean callChanged;
  33. boolean callReset;
  34. //{{{ Anchor constructor
  35. Anchor(DisplayManager displayManager,
  36. JEditTextArea textArea)
  37. {
  38. this.displayManager = displayManager;
  39. this.textArea = textArea;
  40. } //}}}
  41. abstract void reset();
  42. abstract void changed();
  43. //{{{ toString() method
  44. public String toString()
  45. {
  46. return getClass().getName() + "[" + physicalLine + ","
  47. + scrollLine + "]";
  48. } //}}}
  49. //{{{ contentInserted() method
  50. void contentInserted(int startLine, int numLines)
  51. {
  52. if(this.physicalLine >= startLine)
  53. {
  54. if(this.physicalLine != startLine)
  55. this.physicalLine += numLines;
  56. this.callChanged = true;
  57. }
  58. } //}}}
  59. //{{{ preContentRemoved() method
  60. void preContentRemoved(int startLine, int numLines)
  61. {
  62. if(this.physicalLine >= startLine)
  63. {
  64. if(this.physicalLine == startLine)
  65. this.callChanged = true;
  66. else
  67. {
  68. int end = Math.min(startLine + numLines,
  69. this.physicalLine);
  70. for(int i = startLine + 1; i <= end; i++)
  71. {
  72. //XXX
  73. if(displayManager.isLineVisible(i - 1))
  74. {
  75. this.scrollLine -=
  76. displayManager
  77. .screenLineMgr
  78. .getScreenLineCount(i);
  79. }
  80. }
  81. this.physicalLine -= (end - startLine);
  82. this.callChanged = true;
  83. }
  84. }
  85. } //}}}
  86. }