fix 'extract word' putting stuff in the wrong place
parent
21ce71c4a4
commit
4154b4a2ac
|
@ -98,4 +98,12 @@
|
||||||
FactorPlugin.getExternalInstance());
|
FactorPlugin.getExternalInstance());
|
||||||
</CODE>
|
</CODE>
|
||||||
</ACTION>
|
</ACTION>
|
||||||
|
<ACTION NAME="factor-compile-all">
|
||||||
|
<CODE>
|
||||||
|
wm.showDockableWindow("console");
|
||||||
|
CompileBufferProcessor.compileWordsInBuffer(view,buffer,
|
||||||
|
FactorPlugin.getExternalInstance(),
|
||||||
|
wm.getDockableWindow("console"));
|
||||||
|
</CODE>
|
||||||
|
</ACTION>
|
||||||
</ACTIONS>
|
</ACTIONS>
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
!
|
!
|
||||||
! ./f boot.image.le32
|
! ./f boot.image.le32
|
||||||
! -libraries:sdl:name=libSDL.so
|
! -libraries:sdl:name=libSDL.so
|
||||||
! -libraries:sdl-gfx:name=libSDL_gfx.
|
! -libraries:sdl-gfx:name=libSDL_gfx.so
|
||||||
!
|
!
|
||||||
! (But all on one line)
|
! (But all on one line)
|
||||||
!
|
!
|
||||||
|
@ -36,9 +36,6 @@ SYMBOL: d
|
||||||
: next-x ( x y -- x ) a get * sin swap b get * cos - ;
|
: next-x ( x y -- x ) a get * sin swap b get * cos - ;
|
||||||
: next-y ( x y -- y ) swap c get * sin swap d get * cos - ;
|
: next-y ( x y -- y ) swap c get * sin swap d get * cos - ;
|
||||||
|
|
||||||
: white ( -- rgb )
|
|
||||||
HEX: ffffffff ;
|
|
||||||
|
|
||||||
: pixel ( #{ x y }# color -- )
|
: pixel ( #{ x y }# color -- )
|
||||||
>r >r surface get r> >rect r> pixelColor ;
|
>r >r surface get r> >rect r> pixelColor ;
|
||||||
|
|
||||||
|
@ -52,20 +49,20 @@ SYMBOL: d
|
||||||
: draw-dejong ( x0 y0 iterations -- )
|
: draw-dejong ( x0 y0 iterations -- )
|
||||||
[
|
[
|
||||||
iterate-dejong 2dup scale-dejong rect> white pixel
|
iterate-dejong 2dup scale-dejong rect> white pixel
|
||||||
] times 2drop ;
|
] times 2drop ; compiled
|
||||||
|
|
||||||
: dejong ( -- )
|
: dejong ( -- )
|
||||||
! Fiddle with these four values!
|
! Fiddle with these four values!
|
||||||
1.4 a set
|
1.0 a set
|
||||||
-2.3 b set
|
-1.3 b set
|
||||||
2.4 c set
|
0.8 c set
|
||||||
-2.1 d set
|
-2.1 d set
|
||||||
|
|
||||||
640 480 32 SDL_HWSURFACE [
|
1024 768 0 SDL_HWSURFACE [
|
||||||
[ 0 0 100000 draw-dejong ] with-surface
|
[ 0 0 200000 [ draw-dejong ] time ] with-surface
|
||||||
|
|
||||||
<event> event-loop
|
<event> event-loop
|
||||||
SDL_Quit
|
SDL_Quit
|
||||||
] with-screen ; compiled
|
] with-screen ;
|
||||||
|
|
||||||
[ dejong ] time
|
dejong
|
||||||
|
|
|
@ -241,10 +241,7 @@ public class FactorReader
|
||||||
FactorWord word;
|
FactorWord word;
|
||||||
|
|
||||||
if(define)
|
if(define)
|
||||||
{
|
|
||||||
word = lookup.define(getIn(),name);
|
word = lookup.define(getIn(),name);
|
||||||
definedWords = new Cons(word,definedWords);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
word = searchVocabulary(getUse(),name);
|
word = searchVocabulary(getUse(),name);
|
||||||
|
@ -283,6 +280,7 @@ public class FactorReader
|
||||||
FactorWord w = intern((String)next,define);
|
FactorWord w = intern((String)next,define);
|
||||||
if(define && w != null)
|
if(define && w != null)
|
||||||
{
|
{
|
||||||
|
definedWords = new Cons(w,definedWords);
|
||||||
w.line = line;
|
w.line = line;
|
||||||
w.col = col;
|
w.col = col;
|
||||||
w.file = scanner.getFileName();
|
w.file = scanner.getFileName();
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/* :folding=explicit:collapseFolds=1: */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Id$
|
||||||
|
*
|
||||||
|
* Copyright (C) 2005 Slava Pestov.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||||
|
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* DEVELOPERS AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||||
|
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||||
|
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||||
|
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package factor.jedit;
|
||||||
|
|
||||||
|
import console.Output;
|
||||||
|
import factor.*;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.*;
|
||||||
|
import org.gjt.sp.jedit.*;
|
||||||
|
import org.gjt.sp.util.*;
|
||||||
|
|
||||||
|
public class CompileBufferProcessor extends FactorBufferProcessor
|
||||||
|
{
|
||||||
|
//{{{ compileWordsInBuffer() method
|
||||||
|
public static void compileWordsInBuffer(View view,
|
||||||
|
Buffer buffer,
|
||||||
|
ExternalFactor factor,
|
||||||
|
Output output) throws Exception
|
||||||
|
{
|
||||||
|
String results = new CompileBufferProcessor(
|
||||||
|
buffer,factor).getResults();
|
||||||
|
output.print(null,results);
|
||||||
|
} //}}}
|
||||||
|
|
||||||
|
//{{{ CompileBufferProcessor constructor
|
||||||
|
public CompileBufferProcessor(Buffer buffer, ExternalFactor factor)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super(buffer,factor);
|
||||||
|
} //}}}
|
||||||
|
|
||||||
|
//{{{ processWord() method
|
||||||
|
/**
|
||||||
|
* @return Code to process the word.
|
||||||
|
*/
|
||||||
|
public String processWord(FactorWord word)
|
||||||
|
{
|
||||||
|
StringBuffer expression = new StringBuffer();
|
||||||
|
expression.append(FactorPlugin.factorWord(word));
|
||||||
|
expression.append(" try-compile");
|
||||||
|
return expression.toString();
|
||||||
|
} //}}}
|
||||||
|
}
|
|
@ -30,8 +30,6 @@
|
||||||
package factor.jedit;
|
package factor.jedit;
|
||||||
|
|
||||||
import factor.*;
|
import factor.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.*;
|
|
||||||
import org.gjt.sp.jedit.Buffer;
|
import org.gjt.sp.jedit.Buffer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,13 +38,13 @@ import org.gjt.sp.jedit.Buffer;
|
||||||
*/
|
*/
|
||||||
public abstract class FactorBufferProcessor
|
public abstract class FactorBufferProcessor
|
||||||
{
|
{
|
||||||
private LinkedHashMap results;
|
private String results;
|
||||||
|
|
||||||
//{{{ FactorBufferProcessor constructor
|
//{{{ FactorBufferProcessor constructor
|
||||||
public FactorBufferProcessor(Buffer buffer, ExternalFactor factor)
|
public FactorBufferProcessor(Buffer buffer, ExternalFactor factor)
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
results = new LinkedHashMap();
|
StringBuffer buf = new StringBuffer();
|
||||||
|
|
||||||
Cons words = (Cons)buffer.getProperty(
|
Cons words = (Cons)buffer.getProperty(
|
||||||
FactorSideKickParser.WORDS_PROPERTY);
|
FactorSideKickParser.WORDS_PROPERTY);
|
||||||
|
@ -55,10 +53,14 @@ public abstract class FactorBufferProcessor
|
||||||
{
|
{
|
||||||
FactorWord word = (FactorWord)words.car;
|
FactorWord word = (FactorWord)words.car;
|
||||||
String expr = processWord(word);
|
String expr = processWord(word);
|
||||||
System.err.println(expr);
|
buf.append("! ");
|
||||||
results.put(word,factor.eval(expr));
|
buf.append(expr);
|
||||||
|
buf.append('\n');
|
||||||
|
buf.append(factor.eval(expr));
|
||||||
words = words.next();
|
words = words.next();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
results = buf.toString();
|
||||||
} //}}}
|
} //}}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,14 +68,9 @@ public abstract class FactorBufferProcessor
|
||||||
*/
|
*/
|
||||||
public abstract String processWord(FactorWord word);
|
public abstract String processWord(FactorWord word);
|
||||||
|
|
||||||
//{{{ insertResults() method
|
//{{{ getResults() method
|
||||||
public void insertResults(Buffer buffer, int offset)
|
public String getResults()
|
||||||
throws Exception
|
|
||||||
{
|
{
|
||||||
StringBuffer result = new StringBuffer();
|
return results;
|
||||||
Iterator iter = results.values().iterator();
|
|
||||||
while(iter.hasNext())
|
|
||||||
result.append(iter.next());
|
|
||||||
buffer.insert(offset,result.toString().trim());
|
|
||||||
} //}}}
|
} //}}}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,6 +154,7 @@ public class FactorPlugin extends EditPlugin
|
||||||
*/
|
*/
|
||||||
public static void stopExternalInstance()
|
public static void stopExternalInstance()
|
||||||
{
|
{
|
||||||
|
if(getFactorShell() != null)
|
||||||
getFactorShell().closeStreams();
|
getFactorShell().closeStreams();
|
||||||
|
|
||||||
if(external != null)
|
if(external != null)
|
||||||
|
|
|
@ -30,10 +30,11 @@ plugin.factor.jedit.FactorPlugin.menu=factor-listener \
|
||||||
factor-extract-word \
|
factor-extract-word \
|
||||||
- \
|
- \
|
||||||
factor-infer-effect \
|
factor-infer-effect \
|
||||||
factor-compile \
|
|
||||||
- \
|
|
||||||
factor-infer-effects \
|
factor-infer-effects \
|
||||||
- \
|
- \
|
||||||
|
factor-compile \
|
||||||
|
factor-compile-all \
|
||||||
|
- \
|
||||||
factor-restart
|
factor-restart
|
||||||
|
|
||||||
factor-listener.label=Listener
|
factor-listener.label=Listener
|
||||||
|
@ -47,8 +48,9 @@ factor-edit-dialog.label=Edit word...
|
||||||
factor-usages.label=Word usages at caret
|
factor-usages.label=Word usages at caret
|
||||||
factor-extract-word.label=Extract word...
|
factor-extract-word.label=Extract word...
|
||||||
factor-infer-effect.label=Infer word at caret
|
factor-infer-effect.label=Infer word at caret
|
||||||
factor-compile.label=Compile word at caret
|
|
||||||
factor-infer-effects.label=Infer all words in buffer
|
factor-infer-effects.label=Infer all words in buffer
|
||||||
|
factor-compile.label=Compile word at caret
|
||||||
|
factor-compile-all.label=Compile all words in buffer
|
||||||
factor-restart.label=Restart Factor
|
factor-restart.label=Restart Factor
|
||||||
|
|
||||||
# SideKick stuff
|
# SideKick stuff
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/*
|
/*
|
||||||
* $Id$
|
* $Id$
|
||||||
*
|
*
|
||||||
* Copyright (C) 2004 Slava Pestov.
|
* Copyright (C) 2004, 2005 Slava Pestov.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions are met:
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
|
|
@ -46,7 +46,11 @@ public class InferBufferProcessor extends FactorBufferProcessor
|
||||||
public static void createInferUnitTests(View view,
|
public static void createInferUnitTests(View view,
|
||||||
final Buffer buffer,
|
final Buffer buffer,
|
||||||
final ExternalFactor factor)
|
final ExternalFactor factor)
|
||||||
|
throws Exception
|
||||||
{
|
{
|
||||||
|
final String results = new InferBufferProcessor(buffer,factor)
|
||||||
|
.getResults();
|
||||||
|
|
||||||
final Buffer newBuffer = jEdit.newFile(view);
|
final Buffer newBuffer = jEdit.newFile(view);
|
||||||
VFSManager.runInAWTThread(new Runnable()
|
VFSManager.runInAWTThread(new Runnable()
|
||||||
{
|
{
|
||||||
|
@ -55,8 +59,7 @@ public class InferBufferProcessor extends FactorBufferProcessor
|
||||||
newBuffer.setMode("factor");
|
newBuffer.setMode("factor");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
new InferBufferProcessor(buffer,factor)
|
newBuffer.insert(0,results);
|
||||||
.insertResults(newBuffer,0);
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
! :folding=indent:collapseFolds=1:sidekick.parser=none:
|
! :folding=indent:collapseFolds=1:
|
||||||
|
|
||||||
! $Id$
|
! $Id$
|
||||||
!
|
!
|
||||||
|
@ -78,8 +78,8 @@ USE: alien
|
||||||
: TTF_FontFaceStyleName ( font -- n )
|
: TTF_FontFaceStyleName ( font -- n )
|
||||||
"char*" "sdl-ttf" "TTF_FontFaceStyleName" [ "void*" ] alien-invoke ;
|
"char*" "sdl-ttf" "TTF_FontFaceStyleName" [ "void*" ] alien-invoke ;
|
||||||
|
|
||||||
: TTF_RenderText_Solid ( font text fg bg -- surface )
|
: TTF_RenderText_Solid ( font text fg -- surface )
|
||||||
"surface*" "sdl-ttf" "TTF_RenderText_Solid" [ "void*" "char*" "int" "int" ] alien-invoke ;
|
"surface*" "sdl-ttf" "TTF_RenderText_Solid" [ "void*" "char*" "int" ] alien-invoke ;
|
||||||
|
|
||||||
: TTF_RenderGlyph_Shaded ( font text fg bg -- surface )
|
: TTF_RenderGlyph_Shaded ( font text fg bg -- surface )
|
||||||
"surface*" "sdl-ttf" "TTF_RenderGlyph_Shaded" [ "void*" "ushort" "int" "int" ] alien-invoke ;
|
"surface*" "sdl-ttf" "TTF_RenderGlyph_Shaded" [ "void*" "ushort" "int" "int" ] alien-invoke ;
|
||||||
|
|
|
@ -83,9 +83,6 @@ USE: words
|
||||||
"newPlainView" off
|
"newPlainView" off
|
||||||
] extend make-jedit-request send-jedit-request ;
|
] extend make-jedit-request send-jedit-request ;
|
||||||
|
|
||||||
: resource-path ( -- path )
|
|
||||||
global [ "resource-path" get ] bind [ "." ] unless* ;
|
|
||||||
|
|
||||||
: word-file ( path -- dir file )
|
: word-file ( path -- dir file )
|
||||||
dup [
|
dup [
|
||||||
"resource:/" ?str-head [
|
"resource:/" ?str-head [
|
||||||
|
|
Loading…
Reference in New Issue