Skip to content

Autocomplete #3484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 46 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
0063898
refactoring of Sketck class and creation of BaseSketck class allowing
ricardojlrufino Jan 21, 2015
11f6eb0
State of the buttons (UNDO / REDO) is now in
ricardojlrufino Jan 23, 2015
4c83280
Trying to fix (unsuccessfully) support for the Japanese Input
ricardojlrufino Jan 23, 2015
83891fd
Removed old Japanese support files (perhaps the new java already support
ricardojlrufino Jan 23, 2015
13269a9
[Linux] Installation Script that creates shortcuts on the menu and
ricardojlrufino Jan 23, 2015
b07d636
Syntax highlighting Styles
ricardojlrufino Jan 23, 2015
0c466b0
New Editor based on RSyntaxTextArea (for autocomplete and syntax errors)
ricardojlrufino Jan 23, 2015
5834681
Improved rendering of the name of the tabs
ricardojlrufino Jan 23, 2015
0a2839e
Arduino IDE Launcher class
ricardojlrufino Jan 23, 2015
a181828
arduino-autocomplete module project
ricardojlrufino Jan 23, 2015
12c6b14
Refactoring sketche to support listeners, integration with autocomplete
ricardojlrufino Jan 23, 2015
9b64e70
Listeners to monitor changes in sketches and in the active libraries
ricardojlrufino Jan 23, 2015
00fc88a
Classes for the Log control and some utility classes
ricardojlrufino Jan 23, 2015
3cc9157
Correction in REGEX doing parser of compilation errors (in LINUX)
ricardojlrufino Jan 23, 2015
403133e
small refactoring on PdePreprocessor
ricardojlrufino Jan 23, 2015
3b8007a
[Important] Added line in the beginning, to the autocomplete detect
ricardojlrufino Jan 23, 2015
3a67523
Base - logs configuration and fix the icon on Linux
ricardojlrufino Jan 23, 2015
a7f6c51
Linux - improvements in the script to display icons correctly and spash
ricardojlrufino Jan 23, 2015
9e196f1
Fixes in the build scripts for autocomplete module
ricardojlrufino Jan 23, 2015
0f0ba70
improvement when adding items in autocomplete
ricardojlrufino Mar 8, 2015
aaf4273
Rename class PdeTokenMarker to SketchTokenMaker
ricardojlrufino Mar 8, 2015
2bc6da2
update lib cplus-libparser
ricardojlrufino Mar 8, 2015
f5cc40f
update arduino.desktop link
ricardojlrufino Mar 8, 2015
4f72737
update build .classpath
ricardojlrufino Mar 9, 2015
d5aa45e
remove unused imports
ricardojlrufino Mar 9, 2015
3641374
Merge branch 'ide-1.5.x' into 1.6.x-autocomplete-neweditor
ricardojlrufino Mar 9, 2015
5d8c1f7
fix CTRL+'/' not working on Linux (with new Editor)
ricardojlrufino Mar 10, 2015
9818577
clean syntax errors before upload
ricardojlrufino Mar 10, 2015
2c9072e
completion shortcuts: dw,dr,aw,ar (digitalWrite, digitalRead,
ricardojlrufino Mar 10, 2015
481e7ab
openUrl - show message if file not exist
ricardojlrufino Mar 10, 2015
6cbf93b
Open reference documentation using CONTROL + CLICK
ricardojlrufino Mar 10, 2015
73a647d
update lib cplus-libparser
ricardojlrufino Mar 10, 2015
bcdd420
add LED_BUILTIN to autocomplete
ricardojlrufino Mar 10, 2015
0358bb6
Merge remote-tracking branch 'upstream/master' into 1.6.x-autocomplet…
ricardojlrufino Mar 10, 2015
a4d48be
remove java7 generic JList<?>
ricardojlrufino Mar 10, 2015
fb31607
maintaining compatibility with Java 1.6
ricardojlrufino Mar 10, 2015
22b6e4d
Merge remote-tracking branch 'origin/1.6.x-autocomplete-neweditor' in…
ricardojlrufino Mar 10, 2015
0e85891
fix launcher depencencies for windows
ricardojlrufino Mar 11, 2015
839c609
fix launcher depencencies for macosx - fixes #2
ricardojlrufino Mar 15, 2015
e53d775
fix launcher depencencies for macosx - fixes #2
ricardojlrufino Mar 15, 2015
1551eb4
Autocomplete re-integration
ricardojlrufino Jul 5, 2015
97088be
Compiler/SyntaxError - show multiple compiler erros at same time
ricardojlrufino Jul 8, 2015
7b92cf0
fixed - autocomplete cache/listeners problem on 'saveAs' sketch (It is
ricardojlrufino Jul 8, 2015
a52a909
fix eclipse classpath (add cplus-libparser-0.0.1)
ricardojlrufino Jul 8, 2015
79eb524
update Arduino.h, add param names and cplus-libparser jar
ricardojlrufino Jul 8, 2015
cdca07c
refactoring - move ConsoleLogger to arduino-core
ricardojlrufino Jul 8, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Trying to fix (unsuccessfully) support for the Japanese Input
  • Loading branch information
ricardojlrufino committed Jan 23, 2015
commit 4c83280da61ba56a9a041c134f9ff1dc9b17380a
35 changes: 16 additions & 19 deletions app/src/processing/app/syntax/im/CompositionTextManager.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
package processing.app.syntax.im;

import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.font.TextAttribute;
import java.awt.font.TextLayout;
Expand All @@ -13,8 +9,7 @@

import javax.swing.text.BadLocationException;

import processing.app.syntax.JEditTextArea;
import processing.app.syntax.TextAreaPainter;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

/**
* This class Manage texts from input method
Expand All @@ -30,7 +25,7 @@
*/

public class CompositionTextManager {
private JEditTextArea textArea;
private RSyntaxTextArea textArea;
private String prevComposeString;
private int prevCommittedCount;
private boolean isInputProcess;
Expand All @@ -41,7 +36,7 @@ public class CompositionTextManager {
* Create text manager class with a textarea.
* @param textArea texarea component for PDE.
*/
public CompositionTextManager(JEditTextArea textArea) {
public CompositionTextManager(RSyntaxTextArea textArea) {
this.textArea = textArea;
prevComposeString = "";
isInputProcess = false;
Expand Down Expand Up @@ -90,7 +85,7 @@ public void beginCompositionText(AttributedCharacterIterator text, int committed
*/
public void processCompositionText(AttributedCharacterIterator text, int committed_count) {
int layoutCaretPosition = initialCaretPosition + committed_count;
CompositionTextPainter compositionPainter = textArea.getPainter().getCompositionTextpainter();
CompositionTextPainter compositionPainter = textArea.getGraphics().getCompositionTextpainter();
compositionPainter.setComposedTextLayout(getTextLayout(text, committed_count), layoutCaretPosition);
int textLength = text.getEndIndex() - text.getBeginIndex() - committed_count;
StringBuffer unCommitedStringBuf = new StringBuffer(textLength);
Expand Down Expand Up @@ -154,19 +149,18 @@ private void removeNotCommittedText(AttributedCharacterIterator text){

private TextLayout getTextLayout(AttributedCharacterIterator text, int committed_count) {
AttributedString composed = new AttributedString(text, committed_count, text.getEndIndex());
Font font = textArea.getPainter().getFont();
FontRenderContext context = ((Graphics2D) (textArea.getPainter().getGraphics())).getFontRenderContext();
Font font = textArea.getFont();
FontRenderContext context = ((Graphics2D) (textArea.getGraphics())).getFontRenderContext();
composed.addAttribute(TextAttribute.FONT, font);
TextLayout layout = new TextLayout(composed.getIterator(), context);
return layout;
}

private Point getCaretLocation() {
Point loc = new Point();
TextAreaPainter painter = textArea.getPainter();
FontMetrics fm = painter.getFontMetrics();
FontMetrics fm = textArea.getGraphics().getFontMetrics();
int offsetY = fm.getHeight() - COMPOSING_UNDERBAR_HEIGHT;
int lineIndex = textArea.getCaretLine();
int lineIndex = textArea.getCaretLineNumber();
loc.y = lineIndex * fm.getHeight() + offsetY;
int offsetX = textArea.getCaretPosition()
- textArea.getLineStartOffset(lineIndex);
Expand All @@ -180,15 +174,18 @@ public Rectangle getTextLocation() {
}

private Rectangle getCaretRectangle(int x, int y) {
TextAreaPainter painter = textArea.getPainter();
Point origin = painter.getLocationOnScreen();
int height = painter.getFontMetrics().getHeight();
Point origin = textArea.getLocationOnScreen();
int height = textArea.getGraphics().getFontMetrics().getHeight();
return new Rectangle(origin.x + x, origin.y + y, 0, height);
}

public AttributedCharacterIterator getCommittedText(int beginIndex, int endIndex) {
int length = endIndex - beginIndex;
String textAreaString = textArea.getText(beginIndex, length);
String textAreaString = null;
try {
textAreaString = textArea.getText(beginIndex, length);
} catch (BadLocationException e) {
}
return new AttributedString(textAreaString).getIterator();
}

Expand Down
22 changes: 8 additions & 14 deletions app/src/processing/app/syntax/im/CompositionTextPainter.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
package processing.app.syntax.im;

import java.awt.Color;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.*;
import java.awt.font.TextLayout;

import processing.app.syntax.JEditTextArea;
import processing.app.syntax.TextAreaPainter;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

/**
* Paint texts from input method. Text via input method are transmitted by
Expand All @@ -24,13 +19,13 @@
public class CompositionTextPainter {
private TextLayout composedTextLayout;
private int composedBeginCaretPosition = 0;
private JEditTextArea textArea;
private RSyntaxTextArea textArea;

/**
* Constructor for painter.
* @param textarea textarea used by PDE.
*/
public CompositionTextPainter(JEditTextArea textArea) {
public CompositionTextPainter(RSyntaxTextArea textArea) {
this.textArea = textArea;
composedTextLayout = null;
}
Expand Down Expand Up @@ -101,9 +96,9 @@ public void draw(Graphics gfx, Color fillBackGroundColor) {
* @param y y-coordinate where to fill.
*/
private void refillComposedArea(Color fillColor, int x, int y) {
Graphics gfx = textArea.getPainter().getGraphics();
Graphics gfx = textArea.getGraphics();
gfx.setColor(fillColor);
FontMetrics fm = textArea.getPainter().getFontMetrics();
FontMetrics fm = textArea.getGraphics().getFontMetrics();
int newY = y - (fm.getHeight() - CompositionTextManager.COMPOSING_UNDERBAR_HEIGHT);
int paintHeight = fm.getHeight();
int paintWidth = (int) composedTextLayout.getBounds().getWidth();
Expand All @@ -112,10 +107,9 @@ private void refillComposedArea(Color fillColor, int x, int y) {

private Point getCaretLocation() {
Point loc = new Point();
TextAreaPainter painter = textArea.getPainter();
FontMetrics fm = painter.getFontMetrics();
FontMetrics fm = textArea.getGraphics().getFontMetrics();
int offsetY = fm.getHeight() - CompositionTextManager.COMPOSING_UNDERBAR_HEIGHT;
int lineIndex = textArea.getCaretLine();
int lineIndex = textArea.getCaretLineNumber();
loc.y = lineIndex * fm.getHeight() + offsetY;
int offsetX = composedBeginCaretPosition - textArea.getLineStartOffset(lineIndex);
loc.x = textArea.offsetToX(lineIndex, offsetX);
Expand Down
4 changes: 2 additions & 2 deletions app/src/processing/app/syntax/im/InputMethodSupport.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import java.awt.im.InputMethodRequests;
import java.text.AttributedCharacterIterator;

import processing.app.syntax.JEditTextArea;
import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea;

/**
* Support in-line Japanese input for PDE. (Maybe Chinese, Korean and more)
Expand All @@ -26,7 +26,7 @@ public class InputMethodSupport implements InputMethodRequests,
private int committed_count = 0;
private CompositionTextManager textManager;

public InputMethodSupport(JEditTextArea textArea) {
public InputMethodSupport(RSyntaxTextArea textArea) {
textManager = new CompositionTextManager(textArea);
textArea.enableInputMethods(true);
textArea.addInputMethodListener(this);
Expand Down