|
Модераторы: Vitalik |
|
DavidCl0nel |
|
||||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
Hello,
first of all, please speak english with me, i cant speak any word russian. i've found this little summary SynMix (http://sepa.spb.ru/d.php?syn/SynMix.rar) because i fail with compile of the mystix-source code. Your code works, but with a little changes, because i use an old Delphi version (5). In "TSynEditCodeFoldingPlugin.AfterPaint", "TSynEditCodeFoldingPlugin.LinesDeleted" and "TSynEditCodeFoldingPlugin.LinesInserted" you call inherited. These methods are override of the upper class TSynEditPlugin. In this class these 3 methods are virtual; abstract. - What should the compiler do? It crashs hard... I comment it out of the code and it works good. You apparently dont have this problems with a newer delphi version. Second Change is in "TCustomSynEdit.ReScanForFoldRanges". I changed it to:
Now i can compile it with Delphi 5 and it works.... but it crashs. In my little test program I set in the main.formcreate:
In the SynMemo.OnChange-Method i call "ReScanForFoldRanges". If I start my test program and edit the text (i.e. change a endif to other things, that he dont fold this code), it works good. But if I fold a block (only then!) and add lines after it and delete it, the lines and [+] are painted wrong and later it crashs with an Access Violation in "TSynEditFoldRanges.GetCount". What I do wrong or do you have the same problems? Help me. PS: I have also changed "CanExecuteInLine". There were some errors too, if you backspace a Line to a folded block above and such things. And another thing, that I can copy folded blocks (that he dont copy only the first line).. But if I paste it, it crashs also, because he called OnChange->RescanforFoldRanges.... Это сообщение отредактировал(а) DavidCl0nel - 31.7.2006, 11:23 |
||||
|
|||||
Sep. |
|
|||
Шустрый Профиль Группа: Участник Сообщений: 109 Регистрация: 22.7.2004 Репутация: нет Всего: 6 |
Yes, we have same problems and work on them. There are sometimes drop of all foldranges when you have some line collapsed and delete text somwhere. But it depends on highlughter you are using. Now i can't say more =( Copying & deleting of collapsed lines can be done. It needs to write codefolded version of TCustomSynEdit.GetSelText so undo/redo will work with deleting collapsed lines. I've write it but take many strange bugs in other parts of code. If anyone can properly implement it, please post it here. --------------------
Syn - TotalCommander lister plugin | SynTree - coders sourcebook |
|||
|
||||
DavidCl0nel |
|
||||||||||||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
After further investigation I found the problem for the crash.
In "ReScanForFoldRanges"
This free (I commented it) called the destructor (see below) and destroys in his loop TemporaryAllFoldRanges.
In the part above "Now we need to combine collapsed items with new one's" you add (AddFold) the FoldRanges to Temp. AddFold does TList.Add and this TList work with the Pointer, so you dont copy the fold, you only put a pointer to it. And later you free the items and the pointer points to somewhere. These Informations you copy from Temp to fAllFoldRanges. In my debug session all was right, only one FromLine-Attribute was set to a very high line number, that doesnt exists. I have commented the free now, and it works. Another bug occur, if you edit, and all folds are collapsed. Then you get an EListError. In "TCustomSynEdit.UpdateFoldRangeParents" I changed the loop to:
Another change (i sayed it in last post), that I changed the function, that controls, what key you are allowed to press at/near collapsed folds, that you dont destroy the lines. In your version you can Backspace a line to a collapsed block above and the line is add to the collapsed-headerline. If you uncollapse the block the added line is in your folded block.... Some more cases I've catched, but maybe I miss something. Try it. I changed "TCustomSynEdit.CanExecuteInLine" to
I changed GetSelText to, that he copy all lines.
Please cross-check my changes, that I dont do any evil things. More eyes see more errors. ;) Now it works stable with my tests, but one time I get a weird error while editing (he destroys the folds again), but i cant see it again. Edit: Another little change: Uncollapsing all folds, before you disable CodeFolding.
Question: For what using is "procedure TCustomSynEdit.UpdateBmps", it isnt used yet? Это сообщение отредактировал(а) DavidCl0nel - 1.8.2006, 14:31 |
||||||||||||
|
|||||||||||||
Sep. |
|
|||
Шустрый Профиль Группа: Участник Сообщений: 109 Регистрация: 22.7.2004 Репутация: нет Всего: 6 |
Great work man!
But why do you use
Isn't it automatically moves caret to next line by ENTER? I make all changes you post here but still have some bugs: 1. i have collapsed line begin [...] end i place cursor to start of line below it and press BkSpace = drop all foldranges 2. i have collapsed line i try to paste a block of text above it, and again take drop of foldranges 3. collapsed line in selected text. Pressing Del deletes colapsed range. But pressing Ctrl-Z = drop again Do you have same bugs? May be we have some changes in other parts of code, because i have some edits after last upload of SynMix. Can you mail me your SynEdit.pas? (sepich()rambler.ru) I wanna look to it thru WinDiff. Let's sinchronize our work and take this bugs down =) --------------------
Syn - TotalCommander lister plugin | SynTree - coders sourcebook |
|||
|
||||
DavidCl0nel |
|
||||||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
I use folded blocks without ending, maybe you use it in another way. And I have a other language syntax highlighting, but i translate it to delphi code blocks:
Maybe you use it on the other Way and get such weird things? If you have two folded lines now without a free line between them:
And put the cursor with Key END to the end of first line (There are two endings, if you press END more than one. One after the line, and another 5 spaces behind the [...] - why?! Can you explain it?). I have add this case, that he goes to the next line and insert the new line.
. = Cursor Position If i dont have this case, i have no opportunity to devide such folded blocks. Tomorrow I will test your 3 cases again (today no free time for it) and send you both pas files (I have another little changed in SynEditCodeFolding.pas i think...) |
||||||
|
|||||||
Sep. |
|
||||
Шустрый Профиль Группа: Участник Сообщений: 109 Регистрация: 22.7.2004 Репутация: нет Всего: 6 |
Yes i use endings. There are mod named "//###mod pos of [...] to left" which makes from begin end [...] to begin [...] end This 5 spaces are needed to provide space for [...] sign.
i have this working normal without manually move caret =) --------------------
Syn - TotalCommander lister plugin | SynTree - coders sourcebook |
||||
|
|||||
DavidCl0nel |
|
|||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
Ok, I have tested your 3 cases and I have the same errors. Number1 I solved yet and now I check the complete behaviour of CanExecuteInLine with SelText. For pasting I have no idea where i should search at the moment.
I have send a email with both pas files to you. Edit: If I don't move Cursor, it destroys the fold, if I press return at the end of Line1 of 2 collapsed lines. Это сообщение отредактировал(а) DavidCl0nel - 3.8.2006, 10:39 |
|||
|
||||
DavidCl0nel |
|
||||||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
Changes in "TCustomSynEdit.CanExecuteInLine" for Selecting Text:
I have changed it for case3, he delete the block now correctly, but he keep the wrong part in UndoBuffer. So, if you do undo, there are some lines missing. I don't found the real place for the problem. In my quoted part he calls "fCodeFoldingPlugin.LinesDeleted" with the correct ranges, but later (Step Step Step through the programm) he comes through "TCustomSynEdit.ExecuteCommand". This command calls SelText to get the selected Strings, to put this info into the UndoBuffer, but there he copy only the marked line count, not with the uncollapsed. But the same function is called, if I copy selected text to clipboard. For both cases he takes the BlockBegin and BlockEnd positions, but for the Delete-Case it are wrong. Snip of "TCustomSynEdit.GetSelText":
If I change the -2 to 0 then he fill the UndoBuffer correctly, but crashs, if i copy the SelText to Clipboard. I hope you can understand me. Help! I don't find the correct place to change this behavior at the moment. For this problem I try to copy a space line, a folded block and another space line (so 3 visible lines with 3 collapsed lines in the folded block). I mark this 3 lines in NormalMode. In LineMode for Selection he destroys something with Delete this Block, but it seems to work correct with Undo. Graaarr! The paste-problem (case-2) is also unsolved. Edit: I have forgotten this method. I had to reimplement the Delete-Instruction (why you commented it?!):
And another Edit: Whats with the commented fAllFoldRanges.Free (it destroys TemporaryFoldRanges) in "ReScanForFoldRanges"? Is it really necessary (then we had to think about it, how to implement it correctly that it don't destroy Temp) or is it ok so now? I don't test it with a profiler yet, that I can see the memleaks. Это сообщение отредактировал(а) DavidCl0nel - 3.8.2006, 16:12 |
||||||
|
|||||||
Sep. |
|
||||||
Шустрый Профиль Группа: Участник Сообщений: 109 Регистрация: 22.7.2004 Репутация: нет Всего: 6 |
Hi!
Sorry for late answer, i was left city for a day. I add all your changes to SynMix. Your problem with move cursor in 2 collapsed lines is fixed. It will be good if you download new pack and make all patches from it. So we will speak about same things. I also fixed wrong indent of all text (from 2 to 4 spaces) There was also some memory leaks fixed by Vitalik, after last upload SynMix. This changes are also here. So what bugs we have now: 1. deleting and editing near collapsed line all works ok, but here is drop of foldranges when place cursor on line after it and press BkSpace 2. paste of block text above collapsed line 3. copy collapsed line and paste it somewhere = drop 4. delete collapsed line in selection and press Ctrl-Z 5. if collapsed line was selected in normal mode - there no copy contents to buffer. if select it in line mode - all ok (but bug when paste it) 6. pressing Del key on line above collapsed. This line must be non empty. Collapsed text destroys.
i have such: undo buffer is store right text, but drop of foldranges
it was bug with pressing Del on empty line above collapsed. Now it fixed my method slightly differ from standart.
How do you test memleaks? Do you use FastMM4? PS I not very professional programmer. Those codefolding implementation is very dislike me and this almost at top of my programming level. So my methods may be not wonderfull. Feel free to change them and post here. Also this forum has [ code] tag, try to use it instead of [ quote], so code will look more like in SynEdit =) --------------------
Syn - TotalCommander lister plugin | SynTree - coders sourcebook |
||||||
|
|||||||
DavidCl0nel |
|
|||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
I look at your merged code on Monday. 1. and 6. sounds like to fix it in the CanExecute-Method.
For pasting i dont have a idea, where i start to search for the bug. I dont look for memleaks at the moment, if you (or Vitalik) check it, its ok. ;) But if so, then i use FastMM, yes. But not at the moment with my little testbench. The codefolding code is a good start, but all this little things, that destroy the folds, seeming not checked at the moment. I cant compile the mystix cause some missing other controls, but if i test it with a compiled binary, it has the same hazardous behaviour - so we must go on to fix it. ;) |
|||
|
||||
DavidCl0nel |
|
||||||||||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
I show you my last changes
Problem 1 with pasting above collapsed blocks:
It is done here (there it was in comments):
Problem 2 with Undo and Redo after Delete a Block... It wasnt implemented! The type has a new element "crDeleteCollapsedFold", but it isnt used in both functions. I implement it and add a case else with an message box. Maybe there are on some cases also missed instructions.
And the structure fUndoList had to fill correctly if you delete lines. The function is now:
There are some changes with "fOwner.BlockEnd.Char>3" and such things. What should it do there? I commented it like in my older version and change the filling of fUndoList correctly. ! At this time Delete a Block and undo it works correctly, but Redo (delete again) the block destroys the fold. There are a error in it, but i don't know where at the moment. |
||||||||||
|
|||||||||||
DavidCl0nel |
|
|||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
And the biggest change is in CanExecuteInLine... complete function:
It works a little bit different now. In older version it didnt look at folded lines and allow editing. Now it deny all changes, except the cases that are allowed in the code. Maybe there are some problems even at the moment. A known error is, if you add lines near a collapsed block. Sometimes he change the position of the foldstart wrong. Another error, that I didn't can re-adjust always, is, that it destroys the fold, if select something in normal select mode and then switch to line select mode. So my new error list is: 1. Return near collapsed line may destroy fold 2. Redo after Undo ater delete collapsed Line 3. Sometimes it drops folding if select something in normal mode and then switch to line select mode Maybe you find other errors (I dont hope it should be sometime all correctly ). I send the file by email, maybe i miss to say a change here. PS: I had to split the post in 2 parts, because it was to big for one. Be sure, to see both. ;) Это сообщение отредактировал(а) DavidCl0nel - 8.8.2006, 14:45 |
|||
|
||||
Sep. |
|
|||
Шустрый Профиль Группа: Участник Сообщений: 109 Регистрация: 22.7.2004 Репутация: нет Всего: 6 |
Finally forum start work for me!
Here is some fixed part of CanExecuteInLine, that i sent to you yesterday:
There was some bugs when using collapsed line endings, and try to press enter, del, bkSpace at start/end of non collapsed lines. --------------------
Syn - TotalCommander lister plugin | SynTree - coders sourcebook |
|||
|
||||
DavidCl0nel |
|
||||||||||
Новичок Профиль Группа: Участник Сообщений: 44 Регистрация: 31.7.2006 Где: Berlin/Germany Репутация: 1 Всего: 1 |
And again some changes..
Complete CanExecute is now. It based on yours, but i renamed your tmp-vars:
It now modificate your case, if you press return on collapsed line. It set the cursor (quick and dirty) to another line and it works now. All other cases should be also ok. LinesDeleted had to fill correctly the UndoBuffer and is now:
LinesInserted isnt changed i think:
Redo is now:
Undo is now:
Undo and Redo of deleting collapsed blocks works well now. Remaining Error is now, if you delete 2 collapsed blocks... it crashs complete. I search.... Это сообщение отредактировал(а) DavidCl0nel - 9.8.2006, 13:01 |
||||||||||
|
|||||||||||
Sep. |
|
|||
Шустрый Профиль Группа: Участник Сообщений: 109 Регистрация: 22.7.2004 Репутация: нет Всего: 6 |
My two cents: =)
There was bug when you try to Ctrl-A, Ctrl-C file greater than 120kb with foldranges. Memory leak and performance improve in TCustomSynEdit.GetSelText:
GetUncollapsedStrings returns not pointer but copy of strings. You allways need to free it. Same as you can't use GetUncollapsedStrings.Count because there will be memory leak, need to assign first. I have drops of foldranges again, when highlighter is delphi =(. php highlighter works good. Simple open SynEdit.pas(400kb) in test programm, collapse line, place cursor to start of collapsed line and press Enter. --------------------
Syn - TotalCommander lister plugin | SynTree - coders sourcebook |
|||
|
||||
Rules and hints for the forum "SynUniHighlighter" | |
|
Hello, dear user! This is official forum for SynUniHighlighter component and unofficial forum for SynEdit, Codefolding and all related projects. Some rules for the forum: 1. Do not create new topic if exactly the same already exists. 2. Don't ask several questions in the same topic. One topic - one question. 3. If discussion changes to far from original topic context, then create a separate thread for new discussion subject. If you already registered then click here to log in. If you havent't registered yet then click here and register. You need to type username, password (twice), email (twice) and security code. Next you need go here and choose English language instead of Russian and press Enter. Some hints for enghlish-speaking users: - create new topic; - create new vote; - answer to the topic. |
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей) | |
0 Пользователей: | |
« Предыдущая тема | SynUniHighlighter and SynEdit (English Language) | Следующая тема » |
|
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности Powered by Invision Power Board(R) 1.3 © 2003 IPS, Inc. |