1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-30 16:24:09 +03:00

Merging r327:r331 of the branches/processing-sync into the trunk. This adds the Processing core, and some new features including printing, copy for discourse, better auto-format, improved keyboard shortcuts, etc.

This commit is contained in:
David A. Mellis
2007-09-25 14:04:01 +00:00
parent 413b439974
commit 616d65d32a
40 changed files with 31946 additions and 779 deletions

View File

@ -888,22 +888,20 @@ public class JEditTextArea extends JComponent
*/
public void setText(String text)
{
try
{
try {
document.beginCompoundEdit();
document.remove(0,document.getLength());
document.insertString(0,text,null);
}
catch(BadLocationException bl)
{
} catch (BadLocationException bl) {
bl.printStackTrace();
}
finally
{
} finally {
document.endCompoundEdit();
}
}
/**
* Returns the specified substring of the document.
* @param start The start offset
@ -1502,7 +1500,7 @@ public class JEditTextArea extends JComponent
/**
* Sets if the selection should be rectangular.
* @param overwrite True if the selection should be rectangular,
* @param rectSelect True if the selection should be rectangular,
* false otherwise.
*/
public final void setSelectionRectangular(boolean rectSelect)
@ -1644,6 +1642,7 @@ public class JEditTextArea extends JComponent
switch(evt.getID()) {
case KeyEvent.KEY_TYPED:
//if ((editorListener != null) && !editorListener.keyTyped(evt)) {
inputHandler.keyTyped(evt);
break;
case KeyEvent.KEY_PRESSED:
@ -2145,21 +2144,52 @@ public class JEditTextArea extends JComponent
bl.printStackTrace();
}
// Ok, it's not a bracket... select the word
String lineText = getLineText(line);
char ch = lineText.charAt(Math.max(0,offset - 1));
String noWordSep = (String)document.getProperty("noWordSep");
if(noWordSep == null)
noWordSep = "";
// If the user clicked on a non-letter char,
// we select the surrounding non-letters
boolean selectNoLetter = (!Character
.isLetterOrDigit(ch)
&& noWordSep.indexOf(ch) == -1);
// Ok, it's not a bracket... select the word
String lineText = getLineText(line);
int wordStart = 0;
int wordEnd = lineText.length();
char ch = lineText.charAt(Math.max(0,offset - 1));
// special case for whitespace (fry 0122, bug #348)
// this is really nasty.. turns out that double-clicking any non-letter
// or digit char gets lumped together.. sooo, this quickly gets messy,
// because really it needs to check whether the chars are of the same
// type.. so a double space or double - might be grouped together,
// but what about a +=1? do + and - get grouped but not the 1? blech,
// coming back to this later. it's not a difficult fix, just a
// time-consuming one to track down all the proper cases.
/*
if (ch == ' ') {
//System.out.println("yeehaa");
for(int i = offset - 1; i >= 0; i--) {
if (lineText.charAt(i) == ' ') {
wordStart = i;
} else {
break;
}
}
for(int i = offset; i < lineText.length(); i++) {
if (lineText.charAt(i) == ' ') {
wordEnd = i + 1;
} else {
break;
}
}
} else {
*/
// If the user clicked on a non-letter char,
// we select the surrounding non-letters
boolean selectNoLetter = (!Character.isLetterOrDigit(ch)
&& noWordSep.indexOf(ch) == -1);
for(int i = offset - 1; i >= 0; i--) {
ch = lineText.charAt(i);
@ -2170,18 +2200,15 @@ public class JEditTextArea extends JComponent
}
}
int wordEnd = lineText.length();
for(int i = offset; i < lineText.length(); i++)
{
for(int i = offset; i < lineText.length(); i++) {
ch = lineText.charAt(i);
if(selectNoLetter ^ (!Character
.isLetterOrDigit(ch) &&
noWordSep.indexOf(ch) == -1))
{
if(selectNoLetter ^ (!Character.isLetterOrDigit(ch) &&
noWordSep.indexOf(ch) == -1)) {
wordEnd = i;
break;
}
}
//}
int lineStart = getLineStartOffset(line);
select(lineStart + wordStart,lineStart + wordEnd);