fix for jEdit 4.3pre3

cvs
Slava Pestov 2005-07-04 21:35:22 +00:00
parent 930ac75dbd
commit 06e0804b5b
6 changed files with 20 additions and 19 deletions

View File

@ -17,6 +17,8 @@
debug="true"
optimize="true"
classpathref="jedit-classpath"
source="1.4"
target="1.4"
>
<include name="**/*.java"/>
</javac>

View File

@ -609,7 +609,7 @@ public class FactorPlugin extends EditPlugin
public static void extractWord(View view)
{
JEditTextArea textArea = view.getTextArea();
Buffer buffer = textArea.getBuffer();
Buffer buffer = view.getBuffer();
String selection = textArea.getSelectedText();
if(selection == null)
selection = "";
@ -670,12 +670,14 @@ public class FactorPlugin extends EditPlugin
} //}}}
//{{{ getRulesetAtOffset() method
public static String getRulesetAtOffset(JEditTextArea textArea, int caret)
public static String getRulesetAtOffset(EditPane editPane, int caret)
{
JEditTextArea textArea = editPane.getTextArea();
int line = textArea.getLineOfOffset(caret);
DefaultTokenHandler h = new DefaultTokenHandler();
textArea.getBuffer().markTokens(line,h);
editPane.getBuffer().markTokens(line,h);
Token tokens = h.getTokens();
int offset = caret - textArea.getLineStartOffset(line);

View File

@ -64,8 +64,7 @@ public class FactorSideKickParser extends SideKickParser
public void activate(EditPane editPane)
{
super.activate(editPane);
WordPreview preview = new WordPreview(this,
editPane.getTextArea());
WordPreview preview = new WordPreview(this,editPane);
previewMap.put(editPane,preview);
editPane.getTextArea().addCaretListener(preview);
} //}}}
@ -271,8 +270,7 @@ public class FactorSideKickParser extends SideKickParser
if(data == null)
return null;
String ruleset = FactorPlugin.getRulesetAtOffset(
editPane.getTextArea(),caret);
String ruleset = FactorPlugin.getRulesetAtOffset(editPane,caret);
if(ruleset == null)
return null;

View File

@ -45,7 +45,7 @@ public class WordPreview implements ActionListener, CaretListener
{
private FactorSideKickParser parser;
private Timer timer;
private JEditTextArea textArea;
private EditPane editPane;
private static String[] IGNORED_RULESETS = {
"factor::LITERAL",
@ -54,11 +54,10 @@ public class WordPreview implements ActionListener, CaretListener
};
//{{{ WordPreview constructor
public WordPreview(FactorSideKickParser parser,
JEditTextArea textArea)
public WordPreview(FactorSideKickParser parser, EditPane editPane)
{
this.parser = parser;
this.textArea = textArea;
this.editPane = editPane;
this.timer = new Timer(0,this);
timer.setRepeats(false);
} //}}}
@ -91,7 +90,9 @@ public class WordPreview implements ActionListener, CaretListener
private FactorWord getWordAtCaret(FactorParsedData fdata)
throws IOException
{
String name = FactorPlugin.getRulesetAtOffset(textArea,
JEditTextArea textArea = editPane.getTextArea();
String name = FactorPlugin.getRulesetAtOffset(editPane,
textArea.getCaretPosition());
if(name == null)
return null;
@ -114,7 +115,7 @@ public class WordPreview implements ActionListener, CaretListener
private void showPreview()
throws IOException
{
View view = textArea.getView();
View view = editPane.getView();
if(SideKickPlugin.isParsingBuffer(view.getBuffer()))
return;

View File

@ -30,7 +30,7 @@ GENERIC: orientation
zip >r orientation r> [ uncons rot set-axis ] map-with ;
: packed-dim-2 ( gadget sizes -- list )
[ over shape-dim over v- rot filling v*n v+ ] map-with ;
[ over shape-dim { 1 1 1 } vmax over v- rot filling v*n v+ ] map-with ;
: (packed-dims) ( gadget sizes -- list )
2dup packed-dim-2 swap orient ;
@ -43,8 +43,8 @@ GENERIC: orientation
{ 0 0 0 } [ v+ ] accumulate ;
: packed-loc-2 ( gadget sizes -- list )
>r dup shape-dim over r> packed-dim-2 [ v- ] map-with
>r dup alignment swap shape-dim r>
>r dup shape-dim { 1 1 1 } vmax over r> packed-dim-2 [ v- ] map-with
>r dup alignment swap shape-dim { 1 1 1 } vmax r>
[ >r 2dup r> v- n*v ] map 2nip ;
: (packed-locs) ( gadget sizes -- list )

View File

@ -17,9 +17,7 @@ strings styles io ;
] when drop ;
: filter-nulls ( str -- str )
0 over contains? [
[ dup 0 = [ drop CHAR: \s ] when ] map
] when ;
[ dup 0 = [ drop CHAR: \s ] when ] map ;
: size-string ( font text -- w h )
filter-nulls dup empty? [