|
|
|
|
|
|
Re: Text Editor - Customize word separators [message #449384 is a reply to message #449381] |
Thu, 11 May 2006 17:00 |
Antonio Gurisatti Messages: 109 Registered: July 2009 |
Senior Member |
|
|
Well, my WordDetector looks like this:
public boolean isWordStart(char c) {
for (int i = 0, n = SQLSyntax.KEYWORDS.length; i < n; i++)
if (c == ((String) SQLSyntax.KEYWORDS[i]).charAt(0))
return true;
for (int i = 0, n = SQLSyntax.FUNCTIONS.length; i < n; i++)
if (c == ((String) SQLSyntax.FUNCTIONS[i]).charAt(0))
return true;
for (int i = 0, n = SQLSyntax.DATATYPES.length; i < n; i++)
if (c == ((String) SQLSyntax.DATATYPES[i]).charAt(0))
return true;
for (int i = 0, n = SQLSyntax.CONNECTORS.length; i < n; i++)
if (c == ((String) SQLSyntax.CONNECTORS[i]).charAt(0))
return true;
// for (int i = 0, n = SQLSyntax.PUNCTUATION.length; i < n; i++)
// if (c == ((String) SQLSyntax.PUNCTUATION[i]).charAt(0))
// return true;
return false;
}
/**
* Gets whether the specified character is part of a word
*
* @return boolean
*/
public boolean isWordPart(char c) {
for (int i = 0, n = SQLSyntax.KEYWORDS.length; i < n; i++)
if (((String) SQLSyntax.KEYWORDS[i]).indexOf(c) != -1)
return true;
for (int i = 0, n = SQLSyntax.FUNCTIONS.length; i < n; i++)
if (((String) SQLSyntax.FUNCTIONS[i]).indexOf(c) != -1)
return true;
for (int i = 0, n = SQLSyntax.DATATYPES.length; i < n; i++)
if (((String) SQLSyntax.DATATYPES[i]).indexOf(c) != -1)
return true;
for (int i = 0, n = SQLSyntax.CONNECTORS.length; i < n; i++)
if (((String) SQLSyntax.CONNECTORS[i]).indexOf(c) != -1)
return true;
// for (int i = 0, n = SQLSyntax.PUNCTUATION.length; i < n; i++)
// if (((String) SQLSyntax.PUNCTUATION[i]).indexOf(c) != -1)
// return true;
return false;
}
As far as I understand, this is used to know if what you are typing is the start or part of one of your target words.
What I can smell in the air is that WorldRule somehow is (indirectly) responsable for the typed in word endings.
As I understand, WorldRule uses a buffer to save the characters you are typing and an algorithm to narrow the search for a special word (in combination with WordDetector).
Suppose I'm typyn the special word "select". In the moment I type the "t" the word gets highlighted. If I continue and type, for example an "x" the word is not highlited any more. Why? Because the "x" is part of the word.
But if I type a space, the word continues highlited. Why? Because the space character is considered as a "word separator" and so, somehow and somewhere, the buffers are cleaned, counters and other stuff are restored and starts a new cicle.
The proble here is that, by default, the character"_" is considered as a "word separator", so if I type "select_" the "select" part remains highligted. And I'm trying to change that. I need that caharacters like "_" are considered as part of a typed word and don't cause a word termination.
AG
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.06192 seconds