-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from BalduinLandolt/wip/code-completion
Wip/code completion
- Loading branch information
Showing
5 changed files
with
130 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/java/ch/blandolt/turboTranscriber/util/rsyntax/TTCompletionProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ch.blandolt.turboTranscriber.util.rsyntax; | ||
|
||
import org.fife.ui.autocomplete.DefaultCompletionProvider; | ||
|
||
public class TTCompletionProvider extends DefaultCompletionProvider { | ||
|
||
@Override | ||
protected boolean isValidChar(char ch) { | ||
return super.isValidChar(ch) || ch=='{' || ch== '(' || ch=='[' || ch==';'; | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
src/main/java/ch/blandolt/turboTranscriber/util/rsyntax/WeightedCompletion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package ch.blandolt.turboTranscriber.util.rsyntax; | ||
|
||
import org.fife.ui.autocomplete.BasicCompletion; | ||
import org.fife.ui.autocomplete.Completion; | ||
import org.fife.ui.autocomplete.CompletionProvider; | ||
|
||
public class WeightedCompletion extends BasicCompletion { | ||
|
||
private int weight = 1; | ||
|
||
public WeightedCompletion(CompletionProvider provider, String replacementText) { | ||
this(provider, replacementText, 1); | ||
} | ||
|
||
public WeightedCompletion(CompletionProvider provider, String replacementText, int weight) { | ||
super(provider, replacementText, "("+weight+") "); | ||
this.weight = weight; | ||
} | ||
|
||
public WeightedCompletion(CompletionProvider provider, String replacementText, String shortDesc) { | ||
this(provider, replacementText, shortDesc, 1); | ||
} | ||
|
||
public WeightedCompletion(CompletionProvider provider, String replacementText, String shortDesc, int weight) { | ||
super(provider, replacementText, "("+weight+") "+shortDesc); | ||
this.weight = weight; | ||
} | ||
|
||
public WeightedCompletion(CompletionProvider provider, String replacementText, String shortDesc, String summary) { | ||
this(provider, replacementText, shortDesc, summary, 1); | ||
} | ||
|
||
public WeightedCompletion(CompletionProvider provider, String replacementText, String shortDesc, String summary, int weight) { | ||
super(provider, replacementText, "("+weight+") "+shortDesc, summary); | ||
this.weight = weight; | ||
} | ||
|
||
public int getWeight() { | ||
return weight; | ||
} | ||
|
||
@Override | ||
public int compareTo(Completion other){ | ||
if (other instanceof WeightedCompletion){ | ||
WeightedCompletion wc = (WeightedCompletion)other; | ||
return -1*Integer.valueOf(getWeight()).compareTo(Integer.valueOf(wc.getWeight())); | ||
} else { | ||
return super.compareTo(other); | ||
} | ||
|
||
} | ||
} |