PageRenderTime 43ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/org/gjt/sp/jedit/textarea/FoldVisibilityManager.java

#
Java | 904 lines | 604 code | 113 blank | 187 comment | 167 complexity | 874bedbae18c01f1a89f529ac7dcf688 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. * FoldVisibilityManager.java - Controls fold visiblity
  3. * :tabSize=8:indentSize=8:noTabs=false:
  4. * :folding=explicit:collapseFolds=1:
  5. *
  6. * Copyright (C) 2001, 2002 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. //{{{ Imports
  24. import java.awt.Toolkit;
  25. import org.gjt.sp.jedit.buffer.OffsetManager;
  26. import org.gjt.sp.jedit.*;
  27. //}}}
  28. /**
  29. * Manages fold visibility.
  30. *
  31. * This class defines methods for translating between physical and virtual
  32. * line numbers, for determining which lines are visible and which aren't,
  33. * and for expanding and collapsing folds.<p>
  34. *
  35. * Note that a "physical" line number is a line index, numbered from the
  36. * start of the buffer. A "virtual" line number is a visible line index;
  37. * lines after a collapsed fold have a virtual line number that is less
  38. * than their physical line number, for example.<p>
  39. *
  40. * You can use the <code>physicalToVirtual()</code> and
  41. * <code>virtualToPhysical()</code> methods to convert one type of line
  42. * number to another.
  43. *
  44. * @author Slava Pestov
  45. * @version $Id: FoldVisibilityManager.java 3987 2002-01-21 11:36:47Z spestov $
  46. * @since jEdit 4.0pre1
  47. */
  48. public class FoldVisibilityManager
  49. {
  50. //{{{ FoldVisibilityManager constructor
  51. public FoldVisibilityManager(Buffer buffer, OffsetManager offsetMgr,
  52. JEditTextArea textArea)
  53. {
  54. this.buffer = buffer;
  55. this.offsetMgr = offsetMgr;
  56. this.textArea = textArea;
  57. } //}}}
  58. //{{{ isNarrowed() method
  59. /**
  60. * Returns if the buffer has been narrowed.
  61. * @since jEdit 4.0pre2
  62. */
  63. public boolean isNarrowed()
  64. {
  65. return narrowed;
  66. } //}}}
  67. //{{{ getVirtualLineCount() method
  68. /**
  69. * Returns the number of virtual lines in the buffer.
  70. * @since jEdit 4.0pre1
  71. */
  72. public int getVirtualLineCount()
  73. {
  74. return offsetMgr.getVirtualLineCount(index);
  75. } //}}}
  76. //{{{ isLineVisible() method
  77. /**
  78. * Returns if the specified line is visible.
  79. * @param line A physical line index
  80. * @since jEdit 4.0pre1
  81. */
  82. public final boolean isLineVisible(int line)
  83. {
  84. if(line < 0 || line >= offsetMgr.getLineCount())
  85. throw new ArrayIndexOutOfBoundsException(line);
  86. try
  87. {
  88. buffer.readLock();
  89. return offsetMgr.isLineVisible(line,index);
  90. }
  91. finally
  92. {
  93. buffer.readUnlock();
  94. }
  95. } //}}}
  96. //{{{ getFirstVisibleLine() method
  97. /**
  98. * Returns the physical line number of the first visible line.
  99. * @since jEdit 4.0pre3
  100. */
  101. public int getFirstVisibleLine()
  102. {
  103. try
  104. {
  105. buffer.readLock();
  106. for(int i = 0; i < buffer.getLineCount(); i++)
  107. {
  108. if(offsetMgr.isLineVisible(i,index))
  109. return i;
  110. }
  111. }
  112. finally
  113. {
  114. buffer.readUnlock();
  115. }
  116. // can't happen?
  117. return -1;
  118. } //}}}
  119. //{{{ getLastVisibleLine() method
  120. /**
  121. * Returns the physical line number of the last visible line.
  122. * @since jEdit 4.0pre3
  123. */
  124. public int getLastVisibleLine()
  125. {
  126. try
  127. {
  128. buffer.readLock();
  129. for(int i = buffer.getLineCount() - 1; i >= 0; i--)
  130. {
  131. if(offsetMgr.isLineVisible(i,index))
  132. return i;
  133. }
  134. }
  135. finally
  136. {
  137. buffer.readUnlock();
  138. }
  139. // can't happen?
  140. return -1;
  141. } //}}}
  142. //{{{ getNextVisibleLine() method
  143. /**
  144. * Returns the next visible line after the specified line index.
  145. * @param line A physical line index
  146. * @since jEdit 4.0pre1
  147. */
  148. public int getNextVisibleLine(int line)
  149. {
  150. if(line < 0 || line >= offsetMgr.getLineCount())
  151. throw new ArrayIndexOutOfBoundsException(line);
  152. try
  153. {
  154. buffer.readLock();
  155. if(line == buffer.getLineCount() - 1)
  156. return -1;
  157. for(int i = line + 1; i < buffer.getLineCount(); i++)
  158. {
  159. if(offsetMgr.isLineVisible(i,index))
  160. return i;
  161. }
  162. return -1;
  163. }
  164. finally
  165. {
  166. buffer.readUnlock();
  167. }
  168. } //}}}
  169. //{{{ getPrevVisibleLine() method
  170. /**
  171. * Returns the previous visible line before the specified line index.
  172. * @param line A physical line index
  173. * @since jEdit 4.0pre1
  174. */
  175. public int getPrevVisibleLine(int line)
  176. {
  177. if(line < 0 || line >= offsetMgr.getLineCount())
  178. throw new ArrayIndexOutOfBoundsException(line);
  179. try
  180. {
  181. buffer.readLock();
  182. if(line == 0)
  183. return -1;
  184. for(int i = line - 1; i >= 0; i--)
  185. {
  186. if(offsetMgr.isLineVisible(i,index))
  187. return i;
  188. }
  189. return -1;
  190. }
  191. finally
  192. {
  193. buffer.readUnlock();
  194. }
  195. } //}}}
  196. //{{{ physicalToVirtual() method
  197. /**
  198. * Converts a physical line number to a virtual line number.
  199. * @param line A physical line index
  200. * @since jEdit 4.0pre1
  201. */
  202. public int physicalToVirtual(int line)
  203. {
  204. try
  205. {
  206. buffer.readLock();
  207. if(line < 0)
  208. throw new ArrayIndexOutOfBoundsException(line + " < 0");
  209. else if(line >= offsetMgr.getLineCount())
  210. {
  211. throw new ArrayIndexOutOfBoundsException(line + " > "
  212. + buffer.getLineCount());
  213. }
  214. while(!offsetMgr.isLineVisible(line,index) && line > 0)
  215. line--;
  216. if(line == 0 && !offsetMgr.isLineVisible(line,index))
  217. {
  218. // inside the top narrow.
  219. return 0;
  220. }
  221. if(lastPhysical == line)
  222. {
  223. if(lastVirtual < 0 || lastVirtual >= offsetMgr.getVirtualLineCount(index))
  224. {
  225. throw new ArrayIndexOutOfBoundsException(
  226. "cached: " + lastVirtual);
  227. }
  228. }
  229. else if(line > lastPhysical && lastPhysical != -1)
  230. {
  231. for(;;)
  232. {
  233. if(lastPhysical == line)
  234. break;
  235. if(offsetMgr.isLineVisible(lastPhysical,index))
  236. lastVirtual++;
  237. if(lastPhysical == buffer.getLineCount() - 1)
  238. break;
  239. else
  240. lastPhysical++;
  241. }
  242. if(lastVirtual < 0 || lastVirtual >= offsetMgr.getVirtualLineCount(index))
  243. {
  244. throw new ArrayIndexOutOfBoundsException(
  245. "fwd scan: " + lastVirtual);
  246. }
  247. }
  248. else if(line < lastPhysical && lastPhysical - line > line)
  249. {
  250. for(;;)
  251. {
  252. if(lastPhysical == line)
  253. break;
  254. if(offsetMgr.isLineVisible(lastPhysical,index))
  255. lastVirtual--;
  256. if(lastPhysical == 0)
  257. break;
  258. else
  259. lastPhysical--;
  260. }
  261. if(lastVirtual < 0 || lastVirtual >= offsetMgr.getVirtualLineCount(index))
  262. {
  263. throw new ArrayIndexOutOfBoundsException(
  264. "back scan: " + lastVirtual);
  265. }
  266. }
  267. else
  268. {
  269. lastPhysical = 0;
  270. // find first visible line
  271. while(!offsetMgr.isLineVisible(lastPhysical,index))
  272. lastPhysical++;
  273. lastVirtual = 0;
  274. for(;;)
  275. {
  276. if(lastPhysical == line)
  277. break;
  278. if(offsetMgr.isLineVisible(lastPhysical,index))
  279. lastVirtual++;
  280. if(lastPhysical == buffer.getLineCount() - 1)
  281. break;
  282. else
  283. lastPhysical++;
  284. }
  285. if(lastVirtual < 0 || lastVirtual >= offsetMgr.getVirtualLineCount(index))
  286. {
  287. throw new ArrayIndexOutOfBoundsException(
  288. "zero scan: " + lastVirtual);
  289. }
  290. }
  291. return lastVirtual;
  292. }
  293. finally
  294. {
  295. buffer.readUnlock();
  296. }
  297. } //}}}
  298. //{{{ virtualToPhysical() method
  299. /**
  300. * Converts a virtual line number to a physical line number.
  301. * @param line A virtual line index
  302. * @since jEdit 4.0pre1
  303. */
  304. public int virtualToPhysical(int line)
  305. {
  306. try
  307. {
  308. buffer.readLock();
  309. if(line < 0)
  310. throw new ArrayIndexOutOfBoundsException(line + " < 0");
  311. else if(line >= offsetMgr.getVirtualLineCount(index))
  312. {
  313. throw new ArrayIndexOutOfBoundsException(line + " > "
  314. + offsetMgr.getVirtualLineCount(index));
  315. }
  316. if(lastVirtual == line)
  317. {
  318. if(lastPhysical < 0 || lastPhysical >= buffer.getLineCount())
  319. {
  320. throw new ArrayIndexOutOfBoundsException(
  321. "cached: " + lastPhysical);
  322. }
  323. }
  324. else if(line > lastVirtual && lastVirtual != -1)
  325. {
  326. for(;;)
  327. {
  328. if(offsetMgr.isLineVisible(lastPhysical,index))
  329. {
  330. if(lastVirtual == line)
  331. break;
  332. else
  333. lastVirtual++;
  334. }
  335. if(lastPhysical == buffer.getLineCount() - 1)
  336. break;
  337. else
  338. lastPhysical++;
  339. }
  340. if(lastPhysical < 0 || lastPhysical >= buffer.getLineCount())
  341. {
  342. throw new ArrayIndexOutOfBoundsException(
  343. "fwd scan: " + lastPhysical);
  344. }
  345. }
  346. else if(line < lastVirtual && lastVirtual - line > line)
  347. {
  348. for(;;)
  349. {
  350. if(offsetMgr.isLineVisible(lastPhysical,index))
  351. {
  352. if(lastVirtual == line)
  353. break;
  354. else
  355. lastVirtual--;
  356. }
  357. if(lastPhysical == 0)
  358. break;
  359. else
  360. lastPhysical--;
  361. }
  362. if(lastPhysical < 0 || lastPhysical >= buffer.getLineCount())
  363. {
  364. throw new ArrayIndexOutOfBoundsException(
  365. "back scan: " + lastPhysical);
  366. }
  367. }
  368. else
  369. {
  370. lastPhysical = 0;
  371. // find first visible line
  372. while(!offsetMgr.isLineVisible(lastPhysical,index))
  373. lastPhysical++;
  374. lastVirtual = 0;
  375. for(;;)
  376. {
  377. if(offsetMgr.isLineVisible(lastPhysical,index))
  378. {
  379. if(lastVirtual == line)
  380. break;
  381. else
  382. lastVirtual++;
  383. }
  384. if(lastPhysical == buffer.getLineCount() - 1)
  385. break;
  386. else
  387. lastPhysical++;
  388. }
  389. if(lastPhysical < 0 || lastPhysical >= buffer.getLineCount())
  390. {
  391. throw new ArrayIndexOutOfBoundsException(
  392. "zero scan: " + lastPhysical);
  393. }
  394. }
  395. return lastPhysical;
  396. }
  397. finally
  398. {
  399. buffer.readUnlock();
  400. }
  401. } //}}}
  402. //{{{ collapseFold() method
  403. /**
  404. * Collapses the fold at the specified physical line index.
  405. * @param line A physical line index
  406. * @since jEdit 4.0pre1
  407. */
  408. public void collapseFold(int line)
  409. {
  410. int lineCount = buffer.getLineCount();
  411. int start = 0;
  412. int end = lineCount - 1;
  413. try
  414. {
  415. buffer.writeLock();
  416. // if the caret is on a collapsed fold, collapse the
  417. // parent fold
  418. if(line != 0
  419. && line != buffer.getLineCount() - 1
  420. && buffer.isFoldStart(line)
  421. && !offsetMgr.isLineVisible(line + 1,index))
  422. {
  423. line--;
  424. }
  425. int initialFoldLevel = buffer.getFoldLevel(line);
  426. //{{{ Find fold start and end...
  427. if(line != lineCount - 1
  428. && buffer.getFoldLevel(line + 1) > initialFoldLevel)
  429. {
  430. // this line is the start of a fold
  431. start = line + 1;
  432. for(int i = line + 1; i < lineCount; i++)
  433. {
  434. if(buffer.getFoldLevel(i) <= initialFoldLevel)
  435. {
  436. end = i - 1;
  437. break;
  438. }
  439. }
  440. }
  441. else
  442. {
  443. boolean ok = false;
  444. // scan backwards looking for the start
  445. for(int i = line - 1; i >= 0; i--)
  446. {
  447. if(buffer.getFoldLevel(i) < initialFoldLevel)
  448. {
  449. start = i + 1;
  450. ok = true;
  451. break;
  452. }
  453. }
  454. if(!ok)
  455. {
  456. // no folds in buffer
  457. return;
  458. }
  459. for(int i = line + 1; i < lineCount; i++)
  460. {
  461. if(buffer.getFoldLevel(i) < initialFoldLevel)
  462. {
  463. end = i - 1;
  464. break;
  465. }
  466. }
  467. } //}}}
  468. //{{{ Collapse the fold...
  469. int delta = (end - start + 1);
  470. for(int i = start; i <= end; i++)
  471. {
  472. if(offsetMgr.isLineVisible(i,index))
  473. offsetMgr.setLineVisible(i,index,false);
  474. else
  475. delta--;
  476. }
  477. if(delta == 0)
  478. {
  479. // user probably pressed A+BACK_SPACE twice
  480. return;
  481. }
  482. offsetMgr.setVirtualLineCount(index,
  483. offsetMgr.getVirtualLineCount(index)
  484. - delta);
  485. //}}}
  486. }
  487. finally
  488. {
  489. buffer.writeUnlock();
  490. }
  491. foldStructureChanged();
  492. int virtualLine = physicalToVirtual(start);
  493. if(textArea.getFirstLine() > virtualLine)
  494. textArea.setFirstLine(virtualLine - textArea.getElectricScroll());
  495. } //}}}
  496. //{{{ expandFold() method
  497. /**
  498. * Expands the fold at the specified physical line index.
  499. * @param line A physical line index
  500. * @param fully If true, all subfolds will also be expanded
  501. * @since jEdit 4.0pre3
  502. */
  503. public int expandFold(int line, boolean fully)
  504. {
  505. // the first sub-fold. used by JEditTextArea.expandFold().
  506. int returnValue = -1;
  507. int lineCount = buffer.getLineCount();
  508. int start = 0;
  509. int end = lineCount - 1;
  510. int delta = 0;
  511. try
  512. {
  513. buffer.writeLock();
  514. int initialFoldLevel = buffer.getFoldLevel(line);
  515. //{{{ Find fold start and fold end...
  516. if(line != lineCount - 1
  517. && offsetMgr.isLineVisible(line,index)
  518. && !offsetMgr.isLineVisible(line + 1,index)
  519. && buffer.getFoldLevel(line + 1) > initialFoldLevel)
  520. {
  521. // this line is the start of a fold
  522. start = line + 1;
  523. for(int i = line + 1; i < lineCount; i++)
  524. {
  525. if(/* offsetMgr.isLineVisible(i,index) && */
  526. buffer.getFoldLevel(i) <= initialFoldLevel)
  527. {
  528. end = i - 1;
  529. break;
  530. }
  531. }
  532. }
  533. else
  534. {
  535. boolean ok = false;
  536. // scan backwards looking for the start
  537. for(int i = line - 1; i >= 0; i--)
  538. {
  539. if(offsetMgr.isLineVisible(i,index) && buffer.getFoldLevel(i) < initialFoldLevel)
  540. {
  541. start = i + 1;
  542. ok = true;
  543. break;
  544. }
  545. }
  546. if(!ok)
  547. {
  548. // no folds in buffer
  549. return -1;
  550. }
  551. for(int i = line + 1; i < lineCount; i++)
  552. {
  553. if((offsetMgr.isLineVisible(i,index) &&
  554. buffer.getFoldLevel(i) < initialFoldLevel)
  555. || i == getLastVisibleLine())
  556. {
  557. end = i - 1;
  558. break;
  559. }
  560. }
  561. } //}}}
  562. //{{{ Expand the fold...
  563. // we need a different value of initialFoldLevel here!
  564. initialFoldLevel = buffer.getFoldLevel(start);
  565. for(int i = start; i <= end; i++)
  566. {
  567. buffer.getFoldLevel(i);
  568. }
  569. for(int i = start; i <= end; i++)
  570. {
  571. if(buffer.getFoldLevel(i) > initialFoldLevel)
  572. {
  573. if(returnValue == -1
  574. && i != 0
  575. && buffer.isFoldStart(i - 1))
  576. {
  577. returnValue = i - 1;
  578. }
  579. if(!offsetMgr.isLineVisible(i,index) && fully)
  580. {
  581. delta++;
  582. offsetMgr.setLineVisible(i,index,true);
  583. }
  584. }
  585. else if(!offsetMgr.isLineVisible(i,index))
  586. {
  587. delta++;
  588. offsetMgr.setLineVisible(i,index,true);
  589. }
  590. }
  591. offsetMgr.setVirtualLineCount(index,
  592. offsetMgr.getVirtualLineCount(index)
  593. + delta);
  594. //}}}
  595. if(!fully && !offsetMgr.isLineVisible(line,index))
  596. {
  597. // this is a hack, and really needs to be done better.
  598. expandFold(line,false);
  599. return returnValue;
  600. }
  601. }
  602. finally
  603. {
  604. buffer.writeUnlock();
  605. }
  606. foldStructureChanged();
  607. int virtualLine = physicalToVirtual(start);
  608. int firstLine = textArea.getFirstLine();
  609. int visibleLines = textArea.getVisibleLines();
  610. if(virtualLine + delta >= firstLine + visibleLines
  611. && delta < visibleLines - 1)
  612. {
  613. textArea.setFirstLine(virtualLine + delta - visibleLines + 1);
  614. }
  615. return returnValue;
  616. } //}}}
  617. //{{{ expandAllFolds() method
  618. /**
  619. * Expands all folds.
  620. * @since jEdit 4.0pre1
  621. */
  622. public void expandAllFolds()
  623. {
  624. try
  625. {
  626. buffer.writeLock();
  627. narrowed = false;
  628. offsetMgr.setVirtualLineCount(index,buffer.getLineCount());
  629. for(int i = 0; i < buffer.getLineCount(); i++)
  630. {
  631. offsetMgr.setLineVisible(i,index,true);
  632. }
  633. foldStructureChanged();
  634. }
  635. finally
  636. {
  637. buffer.writeUnlock();
  638. }
  639. } //}}}
  640. //{{{ expandFolds() method
  641. /**
  642. * This method should only be called from <code>actions.xml</code>.
  643. * @since jEdit 4.0pre1
  644. */
  645. public void expandFolds(char digit)
  646. {
  647. if(digit < '1' || digit > '9')
  648. {
  649. Toolkit.getDefaultToolkit().beep();
  650. return;
  651. }
  652. else
  653. expandFolds((int)(digit - '1') + 1);
  654. } //}}}
  655. //{{{ expandFolds() method
  656. /**
  657. * Expands all folds with the specified fold level.
  658. * @param foldLevel The fold level
  659. * @since jEdit 4.0pre1
  660. */
  661. public void expandFolds(int foldLevel)
  662. {
  663. try
  664. {
  665. buffer.writeLock();
  666. narrowed = false;
  667. // so that getFoldLevel() calling fireFoldLevelsChanged()
  668. // won't break
  669. offsetMgr.setVirtualLineCount(index,buffer.getLineCount());
  670. int newVirtualLineCount = 0;
  671. foldLevel = (foldLevel - 1) * buffer.getIndentSize() + 1;
  672. /* this ensures that the first line is always visible */
  673. boolean seenVisibleLine = false;
  674. for(int i = 0; i < buffer.getLineCount(); i++)
  675. {
  676. if(!seenVisibleLine || buffer.getFoldLevel(i) < foldLevel)
  677. {
  678. seenVisibleLine = true;
  679. offsetMgr.setLineVisible(i,index,true);
  680. newVirtualLineCount++;
  681. }
  682. else
  683. offsetMgr.setLineVisible(i,index,false);
  684. }
  685. offsetMgr.setVirtualLineCount(index,newVirtualLineCount);
  686. }
  687. finally
  688. {
  689. buffer.writeUnlock();
  690. }
  691. foldStructureChanged();
  692. } //}}}
  693. //{{{ narrow() method
  694. /**
  695. * Narrows the visible portion of the buffer to the specified
  696. * line range.
  697. * @param start The first line
  698. * @param end The last line
  699. * @since jEdit 4.0pre1
  700. */
  701. public void narrow(int start, int end)
  702. {
  703. if(start > end || start < 0 || end >= offsetMgr.getLineCount())
  704. throw new ArrayIndexOutOfBoundsException(start + ", " + end);
  705. // ideally, this should somehow be rolled into the below loop.
  706. if(start != offsetMgr.getLineCount() - 1
  707. && !offsetMgr.isLineVisible(start + 1,index))
  708. expandFold(start,false);
  709. int virtualLineCount = offsetMgr.getVirtualLineCount(index);
  710. for(int i = 0; i < start; i++)
  711. {
  712. if(offsetMgr.isLineVisible(i,index))
  713. {
  714. virtualLineCount--;
  715. offsetMgr.setLineVisible(i,index,false);
  716. }
  717. }
  718. for(int i = end + 1; i < buffer.getLineCount(); i++)
  719. {
  720. if(offsetMgr.isLineVisible(i,index))
  721. {
  722. virtualLineCount--;
  723. offsetMgr.setLineVisible(i,index,false);
  724. }
  725. }
  726. offsetMgr.setVirtualLineCount(index,virtualLineCount);
  727. narrowed = true;
  728. foldStructureChanged();
  729. // Hack... need a more direct way of obtaining a view?
  730. // JEditTextArea.getView() method?
  731. GUIUtilities.getView(textArea).getStatus().setMessageAndClear(
  732. jEdit.getProperty("view.status.narrow"));
  733. } //}}}
  734. //{{{ Methods for Buffer class to call
  735. //{{{ _grab() method
  736. /**
  737. * Do not call this method. The only reason it is public is so
  738. * that the <code>Buffer</code> class can call it.
  739. */
  740. public final void _grab(int index)
  741. {
  742. this.index = index;
  743. lastPhysical = lastVirtual = -1;
  744. } //}}}
  745. //{{{ _release() method
  746. /**
  747. * Do not call this method. The only reason it is public is so
  748. * that the <code>Buffer</code> class can call it.
  749. */
  750. public final void _release()
  751. {
  752. index = -1;
  753. } //}}}
  754. //{{{ _getIndex() method
  755. /**
  756. * Do not call this method. The only reason it is public is so
  757. * that the <code>Buffer</code> class can call it.
  758. */
  759. public final int _getIndex()
  760. {
  761. return index;
  762. } //}}}
  763. //{{{ _invalidate() method
  764. /**
  765. * Do not call this method. The only reason it is public is so
  766. * that the <code>Buffer</code> class can call it.
  767. */
  768. public void _invalidate(int startLine)
  769. {
  770. if(lastPhysical >= startLine)
  771. lastPhysical = lastVirtual = 0;
  772. } //}}}
  773. //}}}
  774. //{{{ Private members
  775. //{{{ Instance variables
  776. private Buffer buffer;
  777. private OffsetManager offsetMgr;
  778. private JEditTextArea textArea;
  779. private int index;
  780. private int lastPhysical;
  781. private int lastVirtual;
  782. private boolean narrowed;
  783. //}}}
  784. //{{{ foldStructureChanged() method
  785. private void foldStructureChanged()
  786. {
  787. lastPhysical = lastVirtual = -1;
  788. textArea.foldStructureChanged();
  789. } //}}}
  790. //}}}
  791. }