public Example() { RSyntaxTextArea editor = new RSyntaxTextArea(); ((AbstractTokenMakerFactory) TokenMakerFactory.getDefaultInstance()).putMapping(WikiTokenMaker.StyleName, WikiTokenMaker.class.getName()); editor.setSyntaxEditingStyle(WikiTokenMaker.StyleName); editor.setSyntaxScheme(getWikiSyntaxScheme(editor)); editor.setWrapStyleWord(true); editor.setLineWrap(true); try { editor.read(new StringReader("*: ''She was a fast machine She kept her motor clean She was the best damn woman I had ever seen She had the sightless eyes Telling me no lies Knockin' me out with those American thighs Taking more than her share Had me fighting for air She told me to come but I was already there 'Cause the walls start shaking The earth was quaking My mind was aching And we were making it and you - Shook me all night long''"), null); } catch (Exception e) { e.printStackTrace(); } editor.setCaretPosition(0); RTextScrollPane sp = new RTextScrollPane(editor); getContentPane().setLayout(new BorderLayout(0, 0)); getContentPane().add(new JLabel("Remove one of the leading single quotes (tick) to properly word wrap."), BorderLayout.NORTH); getContentPane().add(sp, BorderLayout.CENTER); }

/** * Returns the text to place at the beginning and end of a * line to "comment" it in a this programming language. * * @return The start and end strings to add to a line to "comment" * it out. */ public String[] getLineCommentStartAndEnd() { return new String[] { null, null }; }

/** * Returns a list of tokens representing the given text. * * @param text The text to break into tokens. * @param startTokenType The token with which to start tokenizing. * @param startOffset The offset at which the line of tokens begins. * @return A linked list of tokens representing <code>text</code>. */ public Token getTokenList(Segment text, int startTokenType, final int startOffset) {

// See, when we find a token, its starting position is always of the form: // 'startOffset + (currentTokenStart-offset)'; but since startOffset and // offset are constant, tokens' starting positions become: // 'newStartOffset+currentTokenStart' for one less subraction operation. int newStartOffset = startOffset - offset;

You've just discovered a long-standing issue with RSTA. When word wrapping, it will do it on word boundaries as long as each Token returned by the scanner is a single "word" (i.e. no whitespace). For tokens that can contain embedded whitespace, such as comments, wrapping is done on at char boundaries

I've added a bug entry for this so it gets tracked, but I consider it lower priority since the text is still being wrapped, just not as nicely as it could be.

If you're seeing a different issue than this one, let me know and I'll look a little deeper!