From: mikemc <mik...@bt...> - 2007-05-01 10:39:08
|
Hi I have just started work on a project. It is based around a text editor so i decided to look at the scintilla control in win32 gui ver 1.05 I am struggling to get to grips with the EOL command. As standard I seem to output a file which when i read back in i see what appears to be double line spacing. If i open the file in vi i see ^M chars at the end of each line. How do i get rid of this to give me a regular file? Also i notice that the first line starts off at char 1 then the next line is indented one char in, all the rest follow this. Again how do i control it so all chars that should be at position 1 stay there? Thanks in advance Mike -- View this message in context: http://www.nabble.com/EOL-control-in-scintilla-tf3674386.html#a10267219 Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: Sean H. <jal...@ho...> - 2007-05-01 22:56:10
|
On Tue, 01 May 2007 04:39:09 -0600, mikemc <mik...@bt...= m> = wrote: > I am struggling to get to grips with the EOL command. > > As standard I seem to output a file which when i read back in i see wh= at > appears to be double line spacing. If i open the file in vi i see ^M = > chars > at the end of each line. > > How do i get rid of this to give me a regular file? You are getting a regular file; it's just that vi reads in Unix format = (EOL =3D LF). So you need to set your EOL mode. EOL constant SC_EOL_CRLF, SC_EOL_CR, SC_EOL_LF. ConvertEOLs (eolMode) Convert all line endings in the document to one mode. GetEOLMode Retrieve the current end of line mode - one of CRLF, CR, or LF. SetEOLMode (eolMode) Set the current end of line mode. This might also solve your other problem; if not send a small amount of = = code that reproduces the problem. |
From: mikemc <mik...@bt...> - 2007-05-02 11:31:23
|
Thanks Sean I needed $Editor->SetEOLMode (2); or $Editor->SetEOLMode (1); depending upon final file destination I still get the indent see below one two three If you use editor.pl from the example files you get the same result, my code is based on this one anyway. I have tried $Editor->SetIndent (0); But no joy Thanks Mike Sean Healy wrote: > > On Tue, 01 May 2007 04:39:09 -0600, mikemc <mik...@bt...> > wrote: > >> I am struggling to get to grips with the EOL command. >> >> As standard I seem to output a file which when i read back in i see what >> appears to be double line spacing. If i open the file in vi i see ^M >> chars >> at the end of each line. >> >> How do i get rid of this to give me a regular file? > > You are getting a regular file; it's just that vi reads in Unix format > (EOL = LF). So you need to set your EOL mode. > > EOL constant > SC_EOL_CRLF, SC_EOL_CR, SC_EOL_LF. > > ConvertEOLs (eolMode) > Convert all line endings in the document to one mode. > > GetEOLMode > Retrieve the current end of line mode - one of CRLF, CR, or LF. > > SetEOLMode (eolMode) > Set the current end of line mode. > > This might also solve your other problem; if not send a small amount of > code that reproduces the problem. > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/EOL-control-in-scintilla-tf3674386.html#a10284218 Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: Sean H. <jal...@ho...> - 2007-05-03 03:39:17
|
On Wed, 02 May 2007 05:31:24 -0600, mikemc <mik...@bt...> wrote: > I still get the indent see below > one > two > three > > If you use editor.pl from the example files you get the same result, my > code > is based on this one anyway. > > I have tried > $Editor->SetIndent (0); > > But no joy Try $Editor->SetWrapStartIndent(0) |
From: mikemc <mik...@bt...> - 2007-05-03 07:47:30
|
Sorry no joy. The getwrap indent reports 0 as well. Set the wrap indent to 5 to see what it did but still had the one indent second line and so on Will start trawing through the docs trying each command in turn Sean Healy wrote: > > On Wed, 02 May 2007 05:31:24 -0600, mikemc <mik...@bt...> > wrote: > >> I still get the indent see below >> one >> two >> three >> >> If you use editor.pl from the example files you get the same result, my >> code >> is based on this one anyway. >> >> I have tried >> $Editor->SetIndent (0); >> >> But no joy > > Try $Editor->SetWrapStartIndent(0) > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/EOL-control-in-scintilla-tf3674386.html#a10300428 Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |
From: Sean H. <jal...@ho...> - 2007-05-04 00:24:57
|
I tracked down the extra spaces problem. It turned out to be a space at = = the end of the line (after the EOL character(s)), not at the beginning, = = which is why it doesn't show up on the first line. Here's the cause of the problem: # How many characters are on a line, not including end of line character= s? sub LineLength { my ($self, $line) =3D @_; return $self->SendMessage (2350, $line, 0); } Scintilla's documentation says: SCI_LINELENGTH(int line) This returns the length of the line, including any line end characters. = If = line is negative or beyond the last line in the document, the result is = 0. = If you want the length of the line not including any end of line = characters, use SCI_GETLINEENDPOSITION(line) - SCI_POSITIONFROMLINE(line= ). Laurent's code makes an incorrect assumption about EOL markers and = SCI_LINELENGTH. (Although it may have been correct when it was coded, an= d = Scintilla later changed.) Everywhere Laurent has used LineLength to get = = the text at a line, he has done the following: my $lenght =3D $self->LineLength($line); my $text =3D " " x ($lenght + 1); $self->SendMessageNP (2153, $line, $text); He has to create the buffer first, because SendMessage requires the memo= ry = to be already allocated, so he creates a buffer of spaces. But he create= s = it one byte too long, so there's a trailing space in the returned text. (SendMessageNP is an alias for SendMessage with the second parameter as = a = pointer. There is also SendMessage PN for the first parameter as a point= er = and SendMessagePP for both parameters as pointers. It would probably be = = better to have a single SendMessage function, and use references when yo= u = want a parameter to be a pointer, but I don't currently have a compiler,= = so I can't mess with the C code. We'd have to leave the extra methods in= = for a couple versions anyway, to prevent older code from breaking.) The intermediate solution is to go to line 196 in Scintilla.pm (in the = GetLine() sub) and take out the '+1'. Then when SaveFile calls GetLine, = = you won't get a trailing space. The long-term solution is to find every place Laurent has used LineLengt= h, = and fix it. I am willing to do this and email the fixed file to someone = = with CVS access, so it will be correct in the next version. I'll test it= = via SaveFile, with differrent combinations of EOL markers in source and = = destination files, to make sure it really works. (I'll also fix that = annoying little misspelling in the local variable while I'm at it.) |
From: Robert M. <rob...@us...> - 2007-05-06 21:17:04
|
Sean Healy wrote: > I tracked down the extra spaces problem. It turned out to be a space at > the end of the line (after the EOL character(s)), not at the beginning, > which is why it doesn't show up on the first line. > > Here's the cause of the problem: > # How many characters are on a line, not including end of line characters? > sub LineLength { > my ($self, $line) = @_; > return $self->SendMessage (2350, $line, 0); > } > > Scintilla's documentation says: > SCI_LINELENGTH(int line) > This returns the length of the line, including any line end characters. If > line is negative or beyond the last line in the document, the result is 0. > If you want the length of the line not including any end of line > characters, use SCI_GETLINEENDPOSITION(line) - SCI_POSITIONFROMLINE(line). This confusion actually comes from the scintilla scintilla.iface document, from which the comment in the code is extracted. > Laurent's code makes an incorrect assumption about EOL markers and > SCI_LINELENGTH. (Although it may have been correct when it was coded, and > Scintilla later changed.) Everywhere Laurent has used LineLength to get > the text at a line, he has done the following: > my $lenght = $self->LineLength($line); > my $text = " " x ($lenght + 1); > $self->SendMessageNP (2153, $line, $text); Having had a look, I don't think it's an incorrect assumption about line lenghts, but an incorrect assumption about terminating NUL's. Often when calling SnedMessage to get a string it will be NUL terminated, and so you need to make the buffer large enough toinclude this NUL, but in this case SCI_GETLINE does not NUL terminate the string. > He has to create the buffer first, because SendMessage requires the memory > to be already allocated, so he creates a buffer of spaces. But he creates > it one byte too long, so there's a trailing space in the returned text. I agree that the buffer is allocated one byte too long, and this is the cause of the problems being seen. > The intermediate solution is to go to line 196 in Scintilla.pm (in the > GetLine() sub) and take out the '+1'. Then when SaveFile calls GetLine, > you won't get a trailing space. Fine short term fix for those who want a solution before the next release. > The long-term solution is to find every place Laurent has used LineLength, > and fix it. I am willing to do this and email the fixed file to someone > with CVS access, so it will be correct in the next version. I'll test it > via SaveFile, with differrent combinations of EOL markers in source and > destination files, to make sure it really works. (I'll also fix that > annoying little misspelling in the local variable while I'm at it.) Scintilla.pm is actually (mostly) autogenerated from scintilla.iface by a script called Scintilla.PL, which you'll find in the source distribution. I've patched up my local copy (there were 2 places that this was a problem), and while doing so found a couple of other buffer 'over allocation' problems. I'll make sure these fixes get into the next release. Many thanks for taking the time to track down the problem and letting us know. Regards, |
From: mikemc <mik...@bt...> - 2007-05-04 08:09:50
|
Thanks Sean I see what you mean. I have done as you said and all is good now. Thanks Mike Sean Healy wrote: > > I tracked down the extra spaces problem. It turned out to be a space at > the end of the line (after the EOL character(s)), not at the beginning, > which is why it doesn't show up on the first line. > > Here's the cause of the problem: > # How many characters are on a line, not including end of line characters? > sub LineLength { > my ($self, $line) = @_; > return $self->SendMessage (2350, $line, 0); > } > > Scintilla's documentation says: > SCI_LINELENGTH(int line) > This returns the length of the line, including any line end characters. If > line is negative or beyond the last line in the document, the result is 0. > If you want the length of the line not including any end of line > characters, use SCI_GETLINEENDPOSITION(line) - SCI_POSITIONFROMLINE(line). > > Laurent's code makes an incorrect assumption about EOL markers and > SCI_LINELENGTH. (Although it may have been correct when it was coded, and > Scintilla later changed.) Everywhere Laurent has used LineLength to get > the text at a line, he has done the following: > my $lenght = $self->LineLength($line); > my $text = " " x ($lenght + 1); > $self->SendMessageNP (2153, $line, $text); > > He has to create the buffer first, because SendMessage requires the memory > to be already allocated, so he creates a buffer of spaces. But he creates > it one byte too long, so there's a trailing space in the returned text. > > (SendMessageNP is an alias for SendMessage with the second parameter as a > pointer. There is also SendMessage PN for the first parameter as a pointer > and SendMessagePP for both parameters as pointers. It would probably be > better to have a single SendMessage function, and use references when you > want a parameter to be a pointer, but I don't currently have a compiler, > so I can't mess with the C code. We'd have to leave the extra methods in > for a couple versions anyway, to prevent older code from breaking.) > > The intermediate solution is to go to line 196 in Scintilla.pm (in the > GetLine() sub) and take out the '+1'. Then when SaveFile calls GetLine, > you won't get a trailing space. > > The long-term solution is to find every place Laurent has used LineLength, > and fix it. I am willing to do this and email the fixed file to someone > with CVS access, so it will be correct in the next version. I'll test it > via SaveFile, with differrent combinations of EOL markers in source and > destination files, to make sure it really works. (I'll also fix that > annoying little misspelling in the local variable while I'm at it.) > > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Perl-Win32-GUI-Users mailing list > Per...@li... > https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users > http://perl-win32-gui.sourceforge.net/ > > -- View this message in context: http://www.nabble.com/EOL-control-in-scintilla-tf3674386.html#a10318581 Sent from the perl-win32-gui-users mailing list archive at Nabble.com. |