|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
EOL control in scintillaHi 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 |
|
|
Re: EOL control in scintillaOn Tue, 01 May 2007 04:39:09 -0600, mikemc <mike.j.mcmahon@...>
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 Perl-Win32-GUI-Users@... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ |
|
|
Re: EOL control in scintillaThanks 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
|
|
|
Re: EOL control in scintillaOn Wed, 02 May 2007 05:31:24 -0600, mikemc <mike.j.mcmahon@...>
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 Perl-Win32-GUI-Users@... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ |
|
|
Re: EOL control in scintillaSorry 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
|
|
|
Re: EOL control in scintillaI 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 Perl-Win32-GUI-Users@... https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users http://perl-win32-gui.sourceforge.net/ |
|
|
Re: EOL control in scintillaThanks Sean
I see what you mean. I have done as you said and all is good now. Thanks Mike
|
|
|
|
| Free embeddable forum powered by Nabble | Forum Help |