|
EControl Ltd. VCL libraries and software support forum
|
View previous topic :: View next topic |
Author |
Message |
tranglos
Joined: 12 Dec 2007 Posts: 12 Location: Poland
|
Posted: Mon Jan 14, 2008 11:30 pm Post subject: Bad caret up/down movement when wordwrap is on |
|
|
Hi Michael,
I remember reporting this to you when I first registered TSyntaxMemo (May 2005), you replied that you were going to change this, and I am almost certain that you did fix it at some later version. However, I've just noticed that in v 2.40 the problem still exists:
When wordwrap is on and long lines are wrapped in the editor, pressing up or down arrow key causes the caret to jump to the next physical line (paragraph) instead of the next logical line. That is, if a paragraph is wrapped into 5 lines for example, the caret jumps over those five lines, while it should stop at each of them.
Is there a property to change this behavior, or is it a bug? It's very dificult to edit / navigate text in word wrap mode in this way.
Thanks again for all your help!
marek
Last edited by tranglos on Tue Jan 15, 2008 1:11 am; edited 1 time in total |
|
Back to top |
|
|
tranglos
Joined: 12 Dec 2007 Posts: 12 Location: Poland
|
Posted: Tue Jan 15, 2008 1:01 am Post subject: |
|
|
After some tweaking of options...
I've found soSmartCaret, which does what I need.
However, when soSmartCaret is combined with soKeepCaretInText, the caret behavior becomes quite unpredictable in WordWrap mode. For example, if you start at top of the editor window, and press Down arrow three times, the caret will move correctly. Now press Down arrow again - the caret will not move at all. If you want to move down, you need to press Right arrow first, then Down arrow works again - but again only three times :)
But sometimes Down will only work once, then stop responding.
Or, if you start at the bottom (Ctrl+End), make sure the caret is in the first column (col 0), then press Up arrow, it will still jump over wrapped paragraphs, as if soSmartCaret was not specified. If, however, the caret is in the middle of a line, Up arrow locks after only one keypress. Other times up arrow jumps two wrapped lines, instead of one.
Even stranger things happen when I enable soVirtualCaretPos and soUnlimitedCaretPos in OptionsEx (with or without soKeepCaretInText). Some examples:
Make sure the text in the editor has a single line at the bottom, followed by one or more empty lines. Start at top of text, press Ctrl+End, then Home. Now press Up arrow and see what happens :) The caret goes up until it meets the last line of text, then goes DOWN, and up again, in circles. You will never be able to move the caret above the last line of text using Up arrow.
Then try clicking anywhere in the middle of the text. If you click inside text, the caret will not be placed where you clicked, but on the last line (in the correct column). If you click on an empty line inside the text, the caret will be placed correctly... but when you next press Up arrow, it will jump to the very bottom again.
soFixedColumnMove also introduces problems when used with soSmartCaret. It seems that all these options don't quite work in combination :)
Please let me know if you need a sample project. Just as an example: uncomment ANY of the disabled options, and you will see some of the behaviors I described, if WordWrap is on and lines are being wrapped.
Code: | Options := [soOverwriteBlocks,soEnableBlockSel{,soKeepCaretInText}
,soAutoIndentMode,soUndoAfterSave
,soBackUnindent,soGroupUndo,soDragText,soScrollLastLine
,soSmartCaret{,soFixedColumnMove}
,soHideCursorOnType
,soScrollLastLine
,soDrawCurLineFocus
];
OptionsEx := [soSmartPaste,soCorrectNonPrinted
{,soVirtualCaretPos}
{,soUnlimitedCaretPos}
];
|
Thank you,
marek |
|
Back to top |
|
|
econtrol Site Admin
Joined: 09 Jun 2006 Posts: 202
|
Posted: Tue Jan 15, 2008 10:32 am Post subject: |
|
|
Fix for first problem (ecSyntMemo.pas):
Code: | function FixedColumnPos: TPoint;
var lInfo: TLineInfo;
begin
if (soFixedColumnMove in FOptions) and
(CaretPos.Y = FColPos.Y) and
(CaretPos.X >= FColPos.X) then
Result := FColPos
else
Result := FCaretPos;
if (soKeepCaretInText in Options) then
begin
if FWordWrap then
begin
lInfo := GetLineInfo(Result.Y);
if (lInfo.LineCount > 1) and (Result.X >= lInfo.WordBreaks[0]) then
Exit;
end;
if FKeepedXPos = -1 then
FSvKeepPos := LinesPosToLog(Point(Result.X, FCaretPos.Y)).X
else
begin
Result := LogToLinesPos(Point(FKeepedXPos, Result.Y));
FSvKeepPos := FKeepedXPos;
end;
end;
end; |
Fix of second problem:
http://www.econtrol.ru/mantis/view.php?id=272
Michael. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|