Insert a letter at the end of a line destroyed the CRLF

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Insert a letter at the end of a line destroyed the CRLF

Postby vanessa » Fri Nov 15, 2013 4:22 am

Hi Robert,

I met an issue while insert a letter at the end of one line using the RSyntaxTextArea.
For example I have lines like this in document:
"I have a cute dog
and I like it"

I view the hex code of this content, it's like:
00000000h: 49 20 68 61 76 65 20 61 20 63 75 74 65 20 64 6F ; I have a cute do
00000010h: 67 0D 0A 61 6E 64 20 49 20 6C 69 6B 65 20 69 74 ; g..and I like it

The 'OD OA' indicates my document use CRLF as the line break.
But if I edit the content in RSyntaxTextArea, the letters I append at end of a line will be inserted between the CR and LF. I think it is because the RSyntaxTextArea use the LF as the line break mark. But I need the CRLF sticks together. Is there any possibility to fix this ?

Waiting for your great help! Thanks!

/vanessa
vanessa
 
Posts: 2
Joined: Mon Aug 06, 2012 8:18 am

Re: Insert a letter at the end of a line destroyed the CRLF

Postby robert » Fri Nov 15, 2013 6:23 pm

Hi Vanessa,

Yes, RSTA, like all Swing JTextComponents, only use a LF char internally to denote the end of a line. But that shouldn't matter as long as you load the text via a java.io.Reader. Newlines will be automatically handled correctly.

The simplest way to load data into a text component is via the read() method:

java code:

Reader r = ...;
textArea.read(r, null);
User avatar
robert
 
Posts: 801
Joined: Sat May 10, 2008 5:16 pm


Return to Help

Who is online

Users browsing this forum: No registered users and 3 guests