Text Editor - Customize word separators [message #449047] |
Tue, 09 May 2006 10:23  |
Eclipse User |
|
|
|
Hi everybody
I'm building a highlighted Text Editor for SQL and it works well with a few exceptions.
1. I can't find which class is in charge of detecting where a word finishes (word separator). By default, the text editor is considering the underscore (_) character as a word separator and I need to change this so that a word like "select_column" is not displayed with "select" highlighted.
2. I'd like to highlight some punctuation characters. If I do so, the word separating behavior changes and strings like "count('x')" stops showing "count" highlighted.
So both issues depend on the behavior of the word separators.
Any help would be very much appreciated.
Thanks a heap to everybody.
|
|
|
|
|
|
|
|
Re: Text Editor - Customize word separators [message #449384 is a reply to message #449381] |
Thu, 11 May 2006 13:00   |
Eclipse User |
|
|
|
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
|
|
|
|
|
Re: Text Editor - Customize word separators [message #1408255 is a reply to message #449391] |
Thu, 14 August 2014 11:54  |
Eclipse User |
|
|
|
Could someone help me make the edits necessary to alter the word rules outlined above? I'm a long-time Eclipse user, but don't know much Java and have no idea where to dig in and make changes.
I'd like to change the underscore to be considered a word character, not a separator, for all languages.
Thanks for any help you can offer.
|
|
|
Powered by
FUDForum. Page generated in 0.10674 seconds