Factor plugin updates, other stuff
parent
32764e8029
commit
200caca9d5
|
@ -1,3 +1,4 @@
|
|||
- extra chars in completion!
|
||||
- set 'end' of artifacts/assets accurately
|
||||
- faster layout
|
||||
- faster repaint
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
/* :folding=explicit:collapseFolds=1: */
|
||||
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* Copyright (C) 2004, 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 factor.*;
|
||||
import java.util.*;
|
||||
import javax.swing.ListCellRenderer;
|
||||
import org.gjt.sp.jedit.textarea.*;
|
||||
import org.gjt.sp.jedit.*;
|
||||
import sidekick.*;
|
||||
|
||||
public abstract class AbstractCompletion extends SideKickCompletion
|
||||
{
|
||||
protected View view;
|
||||
protected JEditTextArea textArea;
|
||||
protected FactorParsedData data;
|
||||
|
||||
//{{{ AbstractCompletion constructor
|
||||
public AbstractCompletion(View view, FactorParsedData data)
|
||||
{
|
||||
this.view = view;
|
||||
textArea = view.getTextArea();
|
||||
this.data = data;
|
||||
} //}}}
|
||||
|
||||
//{{{ getLongestPrefix() method
|
||||
public String getLongestPrefix()
|
||||
{
|
||||
return MiscUtilities.getLongestPrefix(items,false);
|
||||
} //}}}
|
||||
|
||||
//{{{ updateInPlace() method
|
||||
/**
|
||||
* @return If this returns false, then we create a new completion
|
||||
* object after user input.
|
||||
*/
|
||||
public boolean updateInPlace(EditPane editPane, int caret)
|
||||
{
|
||||
return false;
|
||||
} //}}}
|
||||
|
||||
//{{{ handleKeystroke() method
|
||||
public boolean handleKeystroke(int selectedIndex, char keyChar)
|
||||
{
|
||||
if(keyChar == '\t' || keyChar == '\n')
|
||||
{
|
||||
insert(selectedIndex);
|
||||
return false;
|
||||
}
|
||||
else if(keyChar == ' ')
|
||||
{
|
||||
insert(selectedIndex);
|
||||
textArea.userInput(' ');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
textArea.userInput(keyChar);
|
||||
return true;
|
||||
}
|
||||
} //}}}
|
||||
}
|
|
@ -36,57 +36,15 @@ import org.gjt.sp.jedit.textarea.*;
|
|||
import org.gjt.sp.jedit.*;
|
||||
import sidekick.*;
|
||||
|
||||
public class FactorVocabCompletion extends AbstractCompletion
|
||||
public class FactorVocabCompletion extends SideKickCompletion
|
||||
{
|
||||
private String vocab;
|
||||
protected FactorParsedData data;
|
||||
|
||||
//{{{ FactorVocabCompletion constructor
|
||||
public FactorVocabCompletion(View view, String vocab, FactorParsedData data)
|
||||
{
|
||||
super(view,data);
|
||||
String[] completions = FactorPlugin.getVocabCompletions(
|
||||
vocab,false);
|
||||
this.items = Arrays.asList(completions);
|
||||
this.vocab = vocab;
|
||||
super(view,vocab,Arrays.asList(FactorPlugin.getVocabCompletions(
|
||||
vocab,false)));
|
||||
this.data = data;
|
||||
} //}}}
|
||||
|
||||
public String getLongestPrefix()
|
||||
{
|
||||
return MiscUtilities.getLongestPrefix(items,false);
|
||||
}
|
||||
|
||||
public void insert(int index)
|
||||
{
|
||||
String selected = ((String)get(index));
|
||||
String insert = selected.substring(vocab.length());
|
||||
|
||||
Buffer buffer = textArea.getBuffer();
|
||||
|
||||
textArea.setSelectedText(insert);
|
||||
}
|
||||
|
||||
public int getTokenLength()
|
||||
{
|
||||
return vocab.length();
|
||||
}
|
||||
|
||||
public boolean handleKeystroke(int selectedIndex, char keyChar)
|
||||
{
|
||||
if(keyChar == '\t' || keyChar == '\n')
|
||||
{
|
||||
insert(selectedIndex);
|
||||
return false;
|
||||
}
|
||||
else if(keyChar == ' ')
|
||||
{
|
||||
insert(selectedIndex);
|
||||
textArea.userInput(' ');
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
textArea.userInput(keyChar);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,20 +36,16 @@ import org.gjt.sp.jedit.textarea.*;
|
|||
import org.gjt.sp.jedit.*;
|
||||
import sidekick.*;
|
||||
|
||||
public class FactorWordCompletion extends AbstractCompletion
|
||||
public class FactorWordCompletion extends SideKickCompletion
|
||||
{
|
||||
private String word;
|
||||
protected FactorParsedData data;
|
||||
|
||||
//{{{ FactorWordCompletion constructor
|
||||
public FactorWordCompletion(View view, String word, FactorParsedData data)
|
||||
{
|
||||
super(view,data);
|
||||
|
||||
FactorWord[] completions = FactorPlugin.toWordArray(
|
||||
FactorPlugin.getWordCompletions(word,false));
|
||||
|
||||
this.items = Arrays.asList(completions);
|
||||
this.word = word;
|
||||
super(view,word,FactorPlugin.toWordArray(
|
||||
FactorPlugin.getWordCompletions(word,false)));
|
||||
this.data = data;
|
||||
} //}}}
|
||||
|
||||
/**
|
||||
|
@ -58,14 +54,14 @@ public class FactorWordCompletion extends AbstractCompletion
|
|||
*/
|
||||
public boolean updateInPlace(EditPane editPane, int caret)
|
||||
{
|
||||
String word = FactorSideKickParser.getCompletionWord(editPane,caret);
|
||||
text = FactorSideKickParser.getCompletionWord(editPane,caret);
|
||||
|
||||
List newItems = new ArrayList();
|
||||
Iterator iter = items.iterator();
|
||||
while(iter.hasNext())
|
||||
{
|
||||
FactorWord w = (FactorWord)iter.next();
|
||||
if(w.name.startsWith(word))
|
||||
if(w.name.startsWith(text))
|
||||
newItems.add(w);
|
||||
}
|
||||
|
||||
|
@ -76,27 +72,10 @@ public class FactorWordCompletion extends AbstractCompletion
|
|||
|
||||
public void insert(int index)
|
||||
{
|
||||
super.insert(index);
|
||||
FactorWord selected = ((FactorWord)get(index));
|
||||
String insert = selected.name.substring(word.length());
|
||||
|
||||
Buffer buffer = textArea.getBuffer();
|
||||
|
||||
try
|
||||
{
|
||||
buffer.beginCompoundEdit();
|
||||
textArea.setSelectedText(insert);
|
||||
if(!FactorPlugin.isUsed(view,selected.vocabulary))
|
||||
FactorPlugin.insertUse(view,selected.vocabulary);
|
||||
}
|
||||
finally
|
||||
{
|
||||
buffer.endCompoundEdit();
|
||||
}
|
||||
}
|
||||
|
||||
public int getTokenLength()
|
||||
{
|
||||
return word.length();
|
||||
if(!FactorPlugin.isUsed(view,selected.vocabulary))
|
||||
FactorPlugin.insertUse(view,selected.vocabulary);
|
||||
}
|
||||
|
||||
public ListCellRenderer getRenderer()
|
||||
|
|
|
@ -58,6 +58,7 @@ BUILTIN: f 9 ; : f f swons ; parsing
|
|||
! Do not execute parsing word
|
||||
: POSTPONE: ( -- ) scan-word swons ; parsing
|
||||
|
||||
! Word definitions
|
||||
: :
|
||||
#! Begin a word definition. Word name follows.
|
||||
CREATE [ define-compound ] [ ] "in-definition" on ; parsing
|
||||
|
|
|
@ -9,7 +9,8 @@ IN: words
|
|||
USING: interpreter kernel lists stdio strings test ;
|
||||
|
||||
: annotate ( word quot -- ) #! Quotation: ( word def -- def )
|
||||
>r dup dup word-def r> call (define-compound) ; inline
|
||||
over >r >r dup word-def r> call r> swap (define-compound) ;
|
||||
inline
|
||||
|
||||
: (watch) >r "==> " swap word-name cat2 \ print r> cons cons ;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2005 Slava Pestov.
|
||||
! See http://factor.sf.net/license.txt for BSD license.
|
||||
IN: files
|
||||
USING: alien kernel math namespaces ;
|
||||
USING: alien io-internals kernel math namespaces ;
|
||||
|
||||
: cd ( dir -- )
|
||||
"void" "libc" "chdir" [ "char*" ] alien-invoke ;
|
||||
|
|
|
@ -13,3 +13,6 @@ USING: errors kernel math ;
|
|||
: open-write ( path -- fd )
|
||||
O_WRONLY O_CREAT bitor O_TRUNC bitor file-mode sys-open
|
||||
dup io-error ;
|
||||
|
||||
: read-step ( fd buffer -- )
|
||||
;
|
||||
|
|
|
@ -1,3 +1 @@
|
|||
#include "factor.h"
|
||||
|
||||
void primitive_arithmetic_type(void);
|
||||
|
|
Loading…
Reference in New Issue