From: <kp...@us...> - 2008-02-22 08:08:07
|
Revision: 11846 http://jedit.svn.sourceforge.net/jedit/?rev=11846&view=rev Author: kpouer Date: 2008-02-22 00:08:06 -0800 (Fri, 22 Feb 2008) Log Message: ----------- fixed plugin loading and square drawing was too high Modified Paths: -------------- plugins/Highlight/trunk/src/gatchan/highlight/HighlightManagerTableModel.java plugins/Highlight/trunk/src/gatchan/highlight/HighlightPlugin.java plugins/Highlight/trunk/src/gatchan/highlight/Highlighter.java Modified: plugins/Highlight/trunk/src/gatchan/highlight/HighlightManagerTableModel.java =================================================================== --- plugins/Highlight/trunk/src/gatchan/highlight/HighlightManagerTableModel.java 2008-02-22 06:37:45 UTC (rev 11845) +++ plugins/Highlight/trunk/src/gatchan/highlight/HighlightManagerTableModel.java 2008-02-22 08:08:06 UTC (rev 11846) @@ -710,6 +710,9 @@ changed = true; } //}}} + Highlighter.square = jEdit.getBooleanProperty(HighlightOptionPane.PROP_SQUARE); + Highlighter.squareColor = jEdit.getColorProperty(HighlightOptionPane.PROP_SQUARE_COLOR); + if (changed) { currentWordHighlight.init(currentWordHighlight.getStringToHighlight(), entireWord, ignoreCase, newColor); Modified: plugins/Highlight/trunk/src/gatchan/highlight/HighlightPlugin.java =================================================================== --- plugins/Highlight/trunk/src/gatchan/highlight/HighlightPlugin.java 2008-02-22 06:37:45 UTC (rev 11845) +++ plugins/Highlight/trunk/src/gatchan/highlight/HighlightPlugin.java 2008-02-22 08:08:06 UTC (rev 11846) @@ -21,7 +21,7 @@ */ package gatchan.highlight; -//{{{ imports +//{{{ Imports import org.gjt.sp.jedit.*; import org.gjt.sp.jedit.search.SearchAndReplace; import org.gjt.sp.jedit.msg.EditPaneUpdate; @@ -64,17 +64,7 @@ File highlightFile = dataMigration(); highlightManager = HighlightManagerTableModel.createInstance(highlightFile); highlightManager.propertiesChanged(); - View view = jEdit.getFirstView(); - while (view != null) - { - EditPane[] panes = view.getEditPanes(); - for (int i = 0; i < panes.length; i++) - { - JEditTextArea textArea = panes[i].getTextArea(); - initTextArea(textArea); - } - view = view.getNext(); - } + jEdit.visit(new TextAreaInitializer()); } //}}} //{{{ stop() method @@ -94,18 +84,8 @@ { buffers[i].unsetProperty("highlights"); } - - View view = jEdit.getFirstView(); - while (view != null) - { - EditPane[] panes = view.getEditPanes(); - for (int i = 0; i < panes.length; i++) - { - JEditTextArea textArea = panes[i].getTextArea(); - uninitTextArea(textArea); - } - view = view.getNext(); - } + + jEdit.visit(new TextAreaUninitializer()); highlightManager = null; } //}}} @@ -167,30 +147,21 @@ { int layer = jEdit.getIntegerProperty(HighlightOptionPane.PROP_LAYER_PROPERTY, TextAreaPainter.HIGHEST_LAYER); float alpha = ((float)jEdit.getIntegerProperty(HighlightOptionPane.PROP_ALPHA, 50)) / 100f; - Highlighter.square = jEdit.getBooleanProperty(HighlightOptionPane.PROP_SQUARE); - Highlighter.squareColor = jEdit.getColorProperty(HighlightOptionPane.PROP_SQUARE_COLOR); if (this.layer != layer || this.alpha != alpha) { this.layer = layer; this.alpha = alpha; - View view = jEdit.getFirstView(); - while (view != null) - { - EditPane[] panes = view.getEditPanes(); - for (int i = 0; i < panes.length; i++) - { - JEditTextArea textArea = panes[i].getTextArea(); - TextAreaPainter painter = textArea.getPainter(); - Highlighter highlighter = (Highlighter) textArea.getClientProperty(Highlighter.class); - highlighter.setAlphaComposite(alpha); - if (highlighter != null) - { - painter.removeExtension(highlighter); - painter.addExtension(highlighter); - } - } - view = view.getNext(); - } + jEdit.visit(new JEditVisitorAdapter() + { + public void visit(JEditTextArea textArea) + { + TextAreaPainter painter = textArea.getPainter(); + Highlighter highlighter = (Highlighter) textArea.getClientProperty(Highlighter.class); + highlighter.setAlphaComposite(HighlightPlugin.this.alpha); + painter.removeExtension(highlighter); + painter.addExtension(HighlightPlugin.this.layer, highlighter); + } + }); } highlightManager.propertiesChanged(); } @@ -421,4 +392,22 @@ } return newFile; } //}}} + + //{{{ TextAreaInitializer class + private class TextAreaInitializer extends JEditVisitorAdapter + { + public void visit(JEditTextArea textArea) + { + initTextArea(textArea); + } + } //}}} + + //{{{ TextAreaUninitializer class + private class TextAreaUninitializer extends JEditVisitorAdapter + { + public void visit(JEditTextArea textArea) + { + uninitTextArea(textArea); + } + } //}}} } Modified: plugins/Highlight/trunk/src/gatchan/highlight/Highlighter.java =================================================================== --- plugins/Highlight/trunk/src/gatchan/highlight/Highlighter.java 2008-02-22 06:37:45 UTC (rev 11845) +++ plugins/Highlight/trunk/src/gatchan/highlight/Highlighter.java 2008-02-22 08:08:06 UTC (rev 11846) @@ -3,7 +3,7 @@ * :tabSize=8:indentSize=8:noTabs=false: * :folding=explicit:collapseFolds=1: * -* Copyright (C) 2004, 2007 Matthieu Casanova +* Copyright (C) 2004, 2008 Matthieu Casanova * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -21,7 +21,7 @@ */ package gatchan.highlight; -//{{{ imports +//{{{ Imports import org.gjt.sp.jedit.jEdit; import org.gjt.sp.jedit.buffer.JEditBuffer; import org.gjt.sp.jedit.search.SearchMatcher; @@ -235,12 +235,12 @@ Composite oldComposite = gfx.getComposite(); gfx.setColor(highlightColor); gfx.setComposite(blend); - gfx.fillRect(startX, y, endX - startX, fm.getHeight()); + gfx.fillRect(startX, y, endX - startX, fm.getHeight() - 1); if (square) { gfx.setColor(squareColor); - gfx.drawRect(startX, y, endX - startX, fm.getHeight()); + gfx.drawRect(startX, y, endX - startX, fm.getHeight() - 1); } gfx.setColor(oldColor); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |