Модераторы: Vitalik

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> [ENG] SynEdit2.0.3stable + CodeFolding(MyStix0.31), For english users 
:(
    Опции темы
Sep.
Дата 18.8.2006, 09:51 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Цитата(DavidCl0nel @  18.8.2006,  03:45 Найти цитируемый пост)
Sure it cause problems, but only in the case if you have //comment at the end of line.

Here is screenshot with endings in CF-rule
user posted image
and without endings
user posted image

Цитата(DavidCl0nel @  18.8.2006,  03:45 Найти цитируемый пост)
 i stay at my version, cause i didnt want this ending.
 Of course, you told this in first posts in this thread. I only want to say that there no bug for me =)

Цитата(DavidCl0nel @  18.8.2006,  03:45 Найти цитируемый пост)
Send it back to me with all your changes you made since now.

No problems =) But changes aren't major. I don't have so much time to improve component, there only small fixes.
Цитата(DavidCl0nel @  18.8.2006,  03:45 Найти цитируемый пост)
What? Compile error or what you mean?

Yes, it is compile error =(
Цитата(DavidCl0nel @  18.8.2006,  03:45 Найти цитируемый пост)
I couldnt see such bugs, it works on all cases, he copy and cut the right things and so on.

I can send compiled version, if it helps... =)
--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
DavidCl0nel
Дата 20.8.2006, 01:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



>>Here is screenshot with endings in CF-rule
I show you on Monday a screenshot with the error smile

Do you have sent the source code of 11.08. with your changes? I havent got something till now.
PM MAIL   Вверх
Sep.
Дата 20.8.2006, 08:15 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Цитата(DavidCl0nel @  20.8.2006,  01:18 Найти цитируемый пост)
Do you have sent the source code of 11.08. with your changes? I havent got something till now.

Yes, of course. Now i send once more. May be try to other your mail? Or you can download SynMix, there was very little changes in it since upload.

OFF:
best prog i've seen to compare sources - WinMerge, and it is free.

Это сообщение отредактировал(а) Sep. - 20.8.2006, 08:21
--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
DavidCl0nel
Дата 21.8.2006, 11:40 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



Your mail was catched by spam filter, i saw the second one moving in the spam-folder and could move it back. Your first mail was deleted I think, because the spam box was deleted to early (one day i think).

I had to change the workarounds a little bit
Код
  procedure SetSelectedTextEmpty;
..
    for i := fBlockBegin.Line to fBlockEnd.Line-1 do
      vSelText := vSelText + Lines[i-1] + #13#10;
    if fBlockBegin.Line = fBlockEnd.Line then //Only one Line <-->
      vSelText := TrimRight(Lines[fBlockBegin.Line-1]);
..

The other workaround in the Redo-case like this one. Check your mail with the complete source.

I hope you have now no errors like me.

PS: I merge it with TotalCommander Compare. ;)
PM MAIL   Вверх
DavidCl0nel
Дата 21.8.2006, 14:03 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



Some other changes, please test it with these little changes.

After Pasting I had to call RescanForFoldRanges, to get the new FoldRange work. Please test it with and without this change. Maybe your control update it correctly like on destroying fold-marker (for -> f or). The OnChange-issue...
Код
procedure TCustomSynEdit.PasteFromClipboard;
...
  DoOnPaintTransient(ttAfter);                                                
  RescanForFoldRanges;
end;


Код
function TCustomSynEdit.CanExecuteInLine(aLine: Integer; aKey: Word): Boolean;
...
      if aKey = VK_RETURN then begin
        if CaretX = 1 then begin
          Result := True;
          if (FoldRange1 <> nil) and FoldRange1.Collapsed and not FoldRange1.ParentCollapsed then begin
            Uncollapse(FoldRange1);
          end;
          if FoldRange2 <> nil then CaretY := CaretY + 1;
        end else if CaretX >= Length(TrimRight(Lines[CaretY - 1])) + 1 then begin     //###mod caret beyond EOL
          Result := True;
          if (FoldRange1 <> nil) and FoldRange1.Collapsed and not FoldRange1.ParentCollapsed then begin
            Uncollapse(FoldRange1); //Uncollapse this Block
            CaretY := CaretY + FoldRange1.LinesCollapsed + 1; //Put Cursor to the correct line after uncollapse
            CaretX := Length(Lines[CaretY-1]) + 1;
          end else begin
            CaretX := Length(TrimRight(Lines[CaretY - 1])) + 1;
          end;

        end else if (FoldRange1 = nil) or (not FoldRange1.Collapsed) then begin
          Result := True;
        end;


Delete had to changed. In older version i cant delete the line between two blocks (If-block, free-line, other-if-block. Put cursor at begin of free line and press delete - it will be ignored). So this change:
Код

      end else if (aKey = VK_DELETE) and (CaretX >= Length(TrimRight(Lines[CaretY-1])) + 1) then begin
        Result := True;
        FoldRange2 := FoldRangeForLine(CaretY+1);


        if (FoldRange2 <> nil) and FoldRange2.Collapsed and not FoldRange2.ParentCollapsed then begin
          Uncollapse(FoldRange2); //Uncollapse Block below
        end;
        if (FoldRange1 <> nil) and FoldRange1.Collapsed and not FoldRange1.ParentCollapsed then begin
          Uncollapse(FoldRange1); //Uncollapse this Block
          CaretY := CaretY + FoldRange1.LinesCollapsed + 1; //Put Cursor to the correct line after uncollapse
        end;





And the Plugin-functions changed once again. I decided to rewrite the LinesInserted for the Return-At-Begin-On-Line-Case.
Код
procedure TSynEditCodeFoldingPlugin.LinesDeleted(FirstLine, Count: integer);

var
  i: Integer;
  StartBC, EndBC: TBufferCoord;
begin
  if Count > 0 then
  begin
    //###mod CF bugs
    for i := fOwner.fAllFoldRanges.AllCount - 1 downto 0 do
      if ( (Count = 1) and (fOwner.fAllFoldRanges[i].FromLine-1 = FirstLine) ) or
         ( (Count > 1) and (fOwner.fAllFoldRanges[i].FromLine >= FirstLine) and (fOwner.fAllFoldRanges[i].FromLine <= Pred(FirstLine+Count))) then
      begin
        fOwner.fUndoList.AddChange(crDeleteCollapsedFold, StartBC, EndBC,
          '', fOwner.SelectionMode, fOwner.fAllFoldRanges[i], i);
        fOwner.fAllFoldRanges.Delete(i);
      end;

    fOwner.UpdateFoldRanges(FirstLine-1, -Count);
    fOwner.GutterChanged(fOwner);
    //###mod CF bugs
  end;
{$IFNDEF VER130} //###mod delphi5
  inherited;
{$ENDIF}
end;
      
procedure TSynEditCodeFoldingPlugin.LinesInserted(FirstLine, Count: integer);
var
  i: Integer;
begin
  //fOwner.UpdateFoldRanges(FirstLine, Count);    
  for i := fOwner.fAllFoldRanges.AllCount - 1 downto 0 do begin //###mod Update all Foldranges, if Lines inserted
    if (fOwner.fAllFoldRanges[i].FromLine >= FirstLine) or (fOwner.fAllFoldRanges[i].ToLine >= FirstLine) then begin
      fOwner.fAllFoldRanges[i].MoveBy(Count);
    end;
  end;
{$IFNDEF VER130} //###mod delphi5
  inherited;
{$ENDIF}
end;




Edit:

And very important. The OnChange-issue:
Код

function TCustomSynEdit.IsKeywordAtCursorPos(OpenKeyWord: PBoolean): Boolean;
...
begin
  Result := False;
    
  //<-->
  if CodeFolding.HighlighterFoldRegions then begin
    if (fHighlighter <> nil) and (fHighlighter.FoldRegions.Count = 0) then
    begin
      Result := False;
      Exit;
    end
    else if (fHighlighter <> nil) then
      Result := IsKeywordAtCursorPosForFoldRegions(OpenKeyWord,
        fHighlighter.FoldRegions);
  end else begin
    if (CodeFolding.FoldRegions.Count > 0) then 
      Result := IsKeywordAtCursorPosForFoldRegions(OpenKeyWord,
        CodeFolding.FoldRegions);
  end;
end;


I have my FoldRegion-Infos in the Control, not in the Highlighter. (i set it if i create a form in my source code with all keywords for folds). And in my highlighter I dont have this information, so he dont do something and exit the function. With my change he looks also in the Control, if the Flag is set. Now it works (for -> f or). Great. smile





Last Bug I found:
 - Copy something in LineSelect-Mode. If you insert it somewhere, it overwrite the text. If you paste it in an simple text editor and recopy it and paste it in Syn it works. Something is wrong in the SpecialClipboardFormat.

Это сообщение отредактировал(а) DavidCl0nel - 21.8.2006, 14:53
PM MAIL   Вверх
Sep.
Дата 22.8.2006, 10:23 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Цитата

Please test it with and without this change

I cant test it because of bug in delphi highlighter with drop of foldranges. But i see that func is called and other foldranges don't crush =) (In php HL there one char foldranges.)
Цитата

And very important. The OnChange-issue

Viva!
Цитата

Last Bug I found:

strange =( and when i copy text in LineSelect and try to paste in NormalSelect it paste nothing

I added code from last your post to code from your mail and have now this bugs =(:
1. when select all collapsed line in NormalSelect and delete - there left [+] on gutter. And undo don't return collapsed text.
2. if select this line by click on gutter and delete - text of line deletes, but foldrange dont deletes and moves one string above
Код

procedure TSynEditCodeFoldingPlugin.LinesDeleted
...
      if ( (Count = 1) and (fOwner.fAllFoldRanges[i].FromLine{-1} = FirstLine) ) or

It because of -1 here. For what it needed?
And i still search for FreeMem(IndentGuides); error. May be i need to write freeing of array of array manually. 
Nobody to ask for, because Vitalik have no internet connection for 3 weeks =(
--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
DavidCl0nel
Дата 22.8.2006, 11:28 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



My last bug is still exists. If I use NormalInsert instead of LinesInsert (there are a Case that decide this) I can insert it "correct", but LineInsert should insert it on another way. But I have some errors if i Undo this block-paste.
Edit: It occurs because Undo want to delete the pasted block and this called LinesDeleted. And LinesDeleted fill the Undo-Buffer again with the collapsed fold. After LinesDeleted he also undo this element and restore the collapsed text again. Not really what i want. ;) Dont know at the moment, how to prevent this.

One other error was with selecting a complete line next to a collapses line. There he start at wrong position and copy also the collapsed lines. I have corrected it and I send you later a mail with the corrected. Another little fix is needed in LinesInserted too.

Your problems:
1. Yes smile If I select and delete only 4 of 5 folds he can undo it correct... Hmm. I will look at it.
Solution in UndoItem: If nothing is in, he cant go through the array and cant add. Fixed.
Код
      //### Code Folding ###
      crDeleteCollapsedFold:
        begin
          if fAllFoldRanges.AllCount > 0 then begin
            //Insert at right place, not add to end
            for i := 0 to fAllFoldRanges.AllCount - 1 do begin
              if TSynEditFoldRange(Item.ChangeData).FromLine <= fAllFoldRanges[i].FromLine then begin
                fAllFoldRanges.AllRanges.Insert(i, Item.ChangeData); 
                fRedoList.AddChange(Item.ChangeReason, Item.ChangeStartPos,
                  Item.ChangeEndPos, '', Item.ChangeSelMode, fAllFoldRanges[i], i);
                Break;
              end;
            
              if i = fAllFoldRanges.AllCount - 1 then begin //add to end
                fAllFoldRanges.AddFold(Item.ChangeData);
                fRedoList.AddChange(Item.ChangeReason, Item.ChangeStartPos,
                  Item.ChangeEndPos, '', Item.ChangeSelMode, fAllFoldRanges[fAllFoldRanges.AllCount-1], fAllFoldRanges.AllCount-1);
              end;
            end;
          end else begin
            //Add
            fAllFoldRanges.AddFold(Item.ChangeData);
            fRedoList.AddChange(Item.ChangeReason, Item.ChangeStartPos,
              Item.ChangeEndPos, '', Item.ChangeSelMode, fAllFoldRanges[fAllFoldRanges.AllCount-1], fAllFoldRanges.AllCount-1);
          end;
        end;
      //### End Code Folding ###  


2. -1 was needed sometimes. There are so much cases, and for some I test it with and without -1. I cant remember for what -1 was good.
Now I dont have this -1.
PS: Click on Gutter select the line? Dont have this feature. He collapse and uncollapse the block.
Edit: If you put cursor one line above a block (collapsed or not collapsed, no matter) - its a free line - and press DEL-Key, he deletes the foldrange in this function because of no -1. This case had to catched on some way.
Solution:
Код
procedure TCustomSynEdit.ExecuteCommand(Command: TSynEditorCommand; AChar: char;
...
      ecDeleteChar:
...
              // join line with the line after
              if CaretY < Lines.Count then
              begin
                Helper := StringOfChar(#32, CaretX - 1 - Len);
                ProperSetLine(CaretY - 1, Temp + Helper + Lines[CaretY]);
                Caret.Char := 1;
                Caret.Line := CaretY + 1;
                Helper := #13#10;
                Lines.Delete(CaretY);
                DoLinesDeleted(CaretY, 1); //<-->
              end;
...

There was a CaretY+1, but i dont know, why it should added 1.

3. FreeMem compiles good. But in whole function the IndentGuides only is filled and needed in commented lines. Nobody use it and you can delete the variable.

Это сообщение отредактировал(а) DavidCl0nel - 22.8.2006, 12:30
PM MAIL   Вверх
DavidCl0nel
Дата 22.8.2006, 15:11 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



Цитата
My last bug is still exists. If I use NormalInsert instead of LinesInsert (there are a Case that decide this) I can insert it "correct", but LineInsert should insert it on another way. But I have some errors if i Undo this block-paste.
Edit: It occurs because Undo want to delete the pasted block and this called LinesDeleted. And LinesDeleted fill the Undo-Buffer again with the collapsed fold. After LinesDeleted he also undo this element and restore the collapsed text again. Not really what i want. ;) Dont know at the moment, how to prevent this.

This I could only solve with an interface change. smile I dont like it, but it is needed. This function should decide, if add to undo list or not.
Also an other -1 was wrong in this function (UpdateFoldRanges). Now it looks like:
Код
procedure TSynEditCodeFoldingPlugin.LinesDeleted(FirstLine, Count: integer; AddToUndoList: Boolean);
var
  i: Integer;
  StartBC, EndBC: TBufferCoord;
begin
  if Count > 0 then
  begin
    //###mod CF bugs
    for i := fOwner.fAllFoldRanges.AllCount - 1 downto 0 do
      if ( (Count = 1) and (fOwner.fAllFoldRanges[i].FromLine = FirstLine) ) or
         ( (Count > 1) and (fOwner.fAllFoldRanges[i].FromLine >= FirstLine) and (fOwner.fAllFoldRanges[i].FromLine <= Pred(FirstLine+Count))) then
      begin
        if AddToUndoList then
          fOwner.fUndoList.AddChange(crDeleteCollapsedFold, StartBC, EndBC,
            '', fOwner.SelectionMode, fOwner.fAllFoldRanges[i], i);
        
        fOwner.fAllFoldRanges.Delete(i);
      end;

    fOwner.UpdateFoldRanges(FirstLine, -Count);
    fOwner.GutterChanged(fOwner);
    //###mod CF bugs
  end;
{$IFNDEF VER130} //###mod delphi5
  inherited;
{$ENDIF}
end;

Following functions had to change. The "upper" functions dont need it, but had to pipe it to the last function, where it is needed.
TCustomSynEdit.DoLinesDeleted(FirstLine, Count: integer; AddToUndoList: Boolean);
TSynEditPlugin.LinesDeleted(FirstLine, Count: integer; AddToUndoList: Boolean); virtual; abstract;
TSynEditCodeFoldingPlugin.LinesDeleted(FirstLine, Count: integer; AddToUndoList: Boolean); override;


LinesInserted was changed a little bit. New is the Collapsed-Check.
Код
procedure TSynEditCodeFoldingPlugin.LinesInserted(FirstLine, Count: integer);
var
  i: Integer;
begin
  //fOwner.UpdateFoldRanges(FirstLine, Count);    
  for i := fOwner.fAllFoldRanges.AllCount - 1 downto 0 do begin //###mod Update all Foldranges, if Lines inserted
    if (fOwner.fAllFoldRanges[i].FromLine >= FirstLine) or (not fOwner.fAllFoldRanges[i].Collapsed and (fOwner.fAllFoldRanges[i].ToLine >= FirstLine)) then begin
      fOwner.fAllFoldRanges[i].MoveBy(Count);
    end;
  end;
{$IFNDEF VER130} //###mod delphi5
  inherited;
{$ENDIF}
end;


GetSelText copy a line to early. Fix is in For-loop with First+1:
Код
    case fActiveSelectionMode of
      smNormal:

        //###mod copy collapsed line
        if (First = Last) then                                       
          Result := Copy(Lines[First], ColFrom, ColTo - ColFrom)
        else begin
          ts:=GetUncollapsedStrings;
          // step1: calculate total length of result string
          iLineCount := 0;
          //first line
          Inc(TotalLen, Length(TrimRight(ts[GetRealLineNumber(First+1)-1])));
          Inc(iLineCount);
          //middle lines
          for i := GetRealLineNumber(First+1) to GetRealLineNumber(Last+1)-2 do begin
            Inc(TotalLen, Length(TrimRight(ts[i])));
            Inc(iLineCount);
          end;
          //last line
          Inc(TotalLen, ColTo - 1);
          Inc(TotalLen, Length(sLineBreak) * iLineCount);

          // step2: build up result string
          SetLength(Result, TotalLen);
          P := PChar(Result);
          //first line
          CopyAndForward(TrimRight(ts[GetRealLineNumber(First+1)-1]), ColFrom, MaxInt, P);
          CopyAndForward(sLineBreak, 1, MaxInt, P);
          //middle lines
          for i := GetRealLineNumber(First+1) to GetRealLineNumber(Last+1)-2 do begin
            CopyAndForward(TrimRight(ts[i]), 1, MaxInt, P);
            CopyAndForward(sLineBreak, 1, MaxInt, P);
          end;
          //last line
          CopyAndForward(TrimRight(ts[GetRealLineNumber(Last+1)-1]), 1, ColTo-1, P);
          ts.Free;
        end;
        //###mod copy collapsed line
      smColumn:
...
      smLine:
        //###mod copy collapsed line
        begin
          ts:=GetUncollapsedStrings;
          // If block selection includes LastLine,
          // line break code(s) of the last line will not be added.
          // step1: calculate total length of result string
          for i := GetRealLineNumber(First+1)-1 to GetRealLineNumber(Last+2)-2 do begin
            Inc(TotalLen, Length(TrimRight(ts[i])) + Length(sLineBreak));
          end;
          if Last = Lines.Count then Dec(TotalLen, Length(sLineBreak));

          // step2: build up result string
          SetLength(Result, TotalLen);
          P := PChar(Result);
          for i := GetRealLineNumber(First+1)-1 to GetRealLineNumber(Last+2)-2 do begin
            CopyAndForward(TrimRight(ts[i]), 1, MaxInt, P);
            CopyAndForward(sLineBreak, 1, MaxInt, P);
          end;
          ts.Free;
        end;
        //###mod copy collapsed line
    end;




Another bug is in the workaround for GetSelText. This workaround should copy the right parts of course. So it had to make different things in all 3 selection modes.

In ExecuteCommand it is now much more difficult:
Код
    //Copy only the lines around the collapsed line (the "real" lines), SelText give also the collapsed lines back
    vSelText := '';
    Case fActiveSelectionMode of
      smNormal:
        begin
          if fBlockBegin.Line = fBlockBegin.Line then begin // One in Line
            vSelText := Copy(Lines[fBlockBegin.Line-1], fBlockBegin.Char, fBlockEnd.Char-fBlockBegin.Char);
          end else begin
            vSelText := Copy(Lines[fBlockBegin.Line-1], fBlockBegin.Char, MaxInt) + #13#10;
            for i := fBlockBegin.Line+1 to fBlockEnd.Line-1 do
              vSelText := vSelText + Lines[i-1] + #13#10;
            vSelText := vSelText + Copy(Lines[fBlockEnd.Line-1], 1, fBlockEnd.Char-1);
          end;
        end;
      smColumn:
        begin
          for i := fBlockBegin.Line to fBlockEnd.Line do
            vSelText := vSelText + Copy(Lines[i-1], fBlockBegin.Char, fBlockEnd.Char-fBlockBegin.Char) + #13#10;
        end;
      smLine:
        begin
          for i := fBlockBegin.Line to fBlockEnd.Line do
            vSelText := vSelText + Lines[i-1] + #13#10;
        end;
    end;


In SetSelTextExternal it is the same. (Copy this block and rename the variable from sText to it)



That is why i original think of SetCompleteText..... So it is a little bit difficult, but it works now. But i dont like it.


I send a mail with complete source.


I think I now have found and fix the most common problems. I hope it... It must have an end sometime....

Это сообщение отредактировал(а) DavidCl0nel - 22.8.2006, 15:12
PM MAIL   Вверх
Sep.
Дата 23.8.2006, 11:13 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Цитата
PS: Click on Gutter select the line? Dont have this feature. He collapse and uncollapse the block.

You need click and drag mouse down or up to select lines
Цитата
If you put cursor one line above a block (collapsed or not collapsed, no matter) - its a free line - and press DEL-Key, he deletes the foldrange in this function because of no -1. This case had to catched on some way.
Solution:

It's need to edit another DoLinesDeleted(CaretY{+1}, 1); too in ecDeleteLastChar: to prevent drop of foldrange when press BkSpace on start of line with foldrange.
[quote]IndentGuides. Nobody use it and you can delete the variable.[/qoute]
Heh=) And you may comment out 'SynRegExpr' in uses clause, it not used too.
Цитата
I send a mail with complete source.

Ok, but mail differs from your last post =). I added code in last post and test it.
Цитата
I think I now have found and fix the most common problems. I hope it... It must have an end sometime....

Great! Bug with column select , delete and undo deleteion fixed! I found small bugs:
1. Bug when cursor at end of line with foldrange and press BkSpace - drop of current foldrange
2. When delete line before last string of foldrange then start of foldrange moves one line down

There are bug with keystrokes. If i assign to any of it shortcut:=0 (none) Then it thinks that key=0 toggles it. But in onKeyDown assigment of key=0 (i cant assign to it -1) is stops processing key. Need to edit SynKeyCmds.pas
Код
function TSynEditKeyStrokes.FindKeycode(Code: word; SS: TShiftState): integer;
var
  x: integer;
begin
  Result := -1;
  if (Code=0)and(SS=[]) then exit; //###mod key(0)=ecNone

and
Код
function TSynEditKeyStrokes.FindKeycode2(Code1: word; SS1: TShiftState;
  Code2: word; SS2: TShiftState): integer;
var
  x: integer;
begin
  Result := -1;
  if (Code1=0)and(Code2=0)and(SS1=[])and(SS2=[]) then exit;  //###mod key(0)=ecNone

--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
Sep.
Дата 23.8.2006, 11:57 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Цитата

In ExecuteCommand it is now much more difficult:

Heh, some error =): you write 
Код

if fBlockBegin.Line = fBlockBegin.Line then begin // One in Line
may be you mean
if fBlockBegin.Line = fBlockEnd.Line then begin // One in Line

There another error
3.  Press Ctrl-A and then any letter - will get AV. If there not full text selected - then all ok. Looks like bug in SetSelTextPrimitiveEx but i cant find it =(
--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
DavidCl0nel
Дата 23.8.2006, 12:24 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



>>It's need to edit another DoLinesDeleted(CaretY{+1}, 1); too in ecDeleteLastChar: to prevent drop of foldrange when press BkSpace on start of line with foldrange.

Ok



>>There are bug with keystrokes

I dont know, what you do with keystrokes, but ok. ;)

>>1. Bug when cursor at end of line with foldrange and press BkSpace - drop of current foldrange
I cant press BkSpace there. It is ignored.

>>2. When delete line before last string of foldrange then start of foldrange moves one line down
Yes. It was CanExecuteInline.
Код
      if aKey = VK_RETURN then begin
        if CaretX = 1 then begin
          Result := True;
          if (FoldRange1 <> nil) and FoldRange1.Collapsed and not FoldRange1.ParentCollapsed then begin
            Uncollapse(FoldRange1);
          end;

There was a CaretY+1.

>>Heh, some error =): you write 
Yes i found it today. It should be on both BlockEnd.

Another change with Undo for Clipboard:
Код
procedure TCustomSynEdit.CutToClipboard;
begin
  if not ReadOnly and SelAvail then
  begin
    BeginUndoBlock;
    try
      DoCopyToClipboard(SelText);
      SetSelTextExternal('');
    finally
      EndUndoBlock;
    end;
  end;
end;


And in SetSelTextExternal..
Код
    //<--> Undo the delete of "real" lines after the collapsed Block
    if vSelText <> '' then
      fUndoList.AddChange(crDelete, StartOfBlock, EndOfBlock, vSelText, fActiveSelectionMode);
 The StartOfBlock and EndOfBlock.


In RedoItem is the third place for the case (i dont like it - really)
Код
      crDelete, crSilentDelete:
        begin
          SetCaretAndSelection(Item.ChangeStartPos, Item.ChangeStartPos,
            Item.ChangeEndPos);

          //Copy only the lines around the collapsed line (the "real" lines), SelText give also the collapsed lines back
          Case Item.ChangeSelMode of
            smNormal:
              begin
                if Item.ChangeStartPos.Line = Item.ChangeEndPos.Line then begin // One in Line
                  TempString := Copy(Lines[Item.ChangeStartPos.Line-1], Item.ChangeStartPos.Char, Item.ChangeEndPos.Char-Item.ChangeStartPos.Char);
                end else begin
                  TempString := Copy(Lines[Item.ChangeStartPos.Line-1], Item.ChangeStartPos.Char, MaxInt) + #13#10;
                  for i := Item.ChangeStartPos.Line+1 to Item.ChangeEndPos.Line-1 do
                    TempString := TempString + Lines[i-1] + #13#10;
                  TempString := TempString + Copy(Lines[Item.ChangeEndPos.Line-1], 1, Item.ChangeEndPos.Char-1);
                end;
              end;
            smColumn:
              begin
                for i := Item.ChangeStartPos.Line to Item.ChangeEndPos.Line do
                  TempString := TempString + Copy(Lines[i-1], Item.ChangeStartPos.Char, Item.ChangeEndPos.Char-Item.ChangeStartPos.Char) + #13#10;
              end;
            smLine:
              begin
                for i := Item.ChangeStartPos.Line to Item.ChangeEndPos.Line do
                  TempString := TempString + Lines[i-1] + #13#10;
              end;
          end;

          fUndoList.AddChange(Item.ChangeReason, Item.ChangeStartPos,
            Item.ChangeEndPos, TempString, Item.ChangeSelMode);
          SetSelTextPrimitiveEx( Item.ChangeSelMode, PChar(Item.ChangeStr),
            False );
          InternalCaretXY := Item.ChangeStartPos;
        end;

Then Undo-Redo-Undo works for Cut and Delete a fold.


>>3.  Press Ctrl-A and then any letter - will get AV. If there not full text selected - then all ok. Looks like bug in SetSelTextPrimitiveEx but i cant find it =( 

No. But maybe it is solved with upper changes.




Other question:
On PaintLines for Drawing the indentGuides for non collapsed folds, why you have this:
Код
                if Canvas.Pen.Color<>clGray then begin                      //###mod IndentGiudes change highlight
                  Canvas.Pen.Color := clGray;                               //
                  Canvas.MoveTo(X, Y);                                      //
                  Canvas.LineTo(X, rcLine.Bottom);                          //
                  Canvas.Pen.Color := clBlack;                              //
                end;                                                        //###mod IndentGiudes change highlight

I like it, if it is the current fold of cursor, that he draw the line in Red. Why you set it here to other things and draw it gray?






Edit: I found a very tiny bug with the IndentGuides on one situation. If you have a Keyword for FoldEnd similar to FoldStart (for example IF-ENDIF) he found after END (if you set the cursor there) the new IF and think he found a new Fold and dont draw the IndentGuides correctly in red.

Fix is:
Код
function TCustomSynEdit.IsKeywordAtCursorPos(OpenKeyWord: PBoolean): Boolean;
...
      Keyword := FoldRegions[i].Open;
  
      repeat
        P := Pos(Keyword, Line);
        if Pos(FoldRegions[i].Close, Line) <> 0 then P := 0; //If KeyWordClose
  
        if (P > 0) and ((CaretX >= P)
        and (CaretX <= P + Integer( StrLen(Keyword) ))) then // Cast to Integer type to shut up the compiler

With this new if Pos he dont make this little failure and draw the IndentGuides in whole keyword.



Last Edit:
LinesInserted was wrong, if you insert a line in a block. Then he moves the complete foldrange, with start... Not right. It is now:
Код
procedure TSynEditCodeFoldingPlugin.LinesInserted(FirstLine, Count: integer);
var
  i: Integer;
begin
  //fOwner.UpdateFoldRanges(FirstLine, Count);    
  for i := fOwner.fAllFoldRanges.AllCount - 1 downto 0 do begin //###mod Update all Foldranges, if Lines inserted
    if (fOwner.fAllFoldRanges[i].FromLine >= FirstLine) then 
      fOwner.fAllFoldRanges[i].FromLine := fOwner.fAllFoldRanges[i].FromLine + Count;

    if (not fOwner.fAllFoldRanges[i].Collapsed and (fOwner.fAllFoldRanges[i].ToLine >= FirstLine)) then 
      fOwner.fAllFoldRanges[i].ToLine := fOwner.fAllFoldRanges[i].ToLine + Count;
  end;
{$IFNDEF VER130} //###mod delphi5
  inherited;
{$ENDIF}
end;



And now I send a email.

Это сообщение отредактировал(а) DavidCl0nel - 23.8.2006, 15:16
PM MAIL   Вверх
DavidCl0nel
Дата 24.8.2006, 11:55 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



Today fixes: 

Код
function TCustomSynEdit.CanExecuteInLine(aLine: Integer; aKey: Word): Boolean;
    if SelAvail then
    begin // if selection is available
      if (aKey in [VK_SHIFT, VK_CONTROL, VK_MENU {Alt}, VK_ESCAPE, VK_F1..VK_F12, VK_PRIOR, VK_NEXT, VK_END, VK_HOME, VK_LEFT, VK_UP, VK_RIGHT, VK_DOWN, VK_SELECT, VK_PRINT, VK_EXECUTE, VK_SNAPSHOT, VK_INSERT]) then begin
        Result := True;
      end else begin
        FoldRange1 := CollapsableFoldRangeForLine(BlockBegin.Line);
        if BlockBegin.Line = BlockEnd.Line then begin
          //One Line selected
          if (FoldRange1 <> nil) and (FoldRange1.Collapsed) and (not FoldRange1.ParentCollapsed) then begin
            Result := False;
            //Direction
            if fBlockBegin.Char > fBlockEnd.Char then begin //swap it
              StartBC := fBlockBegin;
              fBlockBegin := fBlockEnd;
              fBlockEnd := StartBC;
            end;
            
            //Allow only delete complete line, if collapsed
            if ((fBlockBegin.Char = 1) and (fBlockEnd.Char >= Length(TrimRight(Lines[fBlockEnd.Line - 1])) + 1)) then begin
              //Search and delete complete fold range
              for iFold := fAllFoldRanges.AllCount - 1 downto 0 do
                if fAllFoldRanges[iFold].FromLine = fBlockBegin.Line then begin
                  fUndoList.AddChange(crDeleteCollapsedFold, StartBC, EndBC, '', SelectionMode, fAllFoldRanges[iFold], iFold);
                  fAllFoldRanges.Delete(iFold);
                end;
              Result := True;
            end;
          end else begin
            Result := True;
          end;
        end else begin
          //More lines selected
          //Direction
          if fBlockBegin.Line > fBlockEnd.Line then begin //swap it
            StartBC := fBlockBegin;
            fBlockBegin := fBlockEnd;
            fBlockEnd := StartBC;
          end;
          Result := True;
        end;
      end; // if aKey-else

If you select from back to end a word or more lines and delete it, the UndoBuffer (in one of this workarounds) isnt filled correctly, because of the wrong "direction". This fix always set BlockEnd after BlockBegin.





Maybe I edit some other changes in this post later, but it looks good yet. smile
PM MAIL   Вверх
Sep.
Дата 24.8.2006, 21:09 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Looks more stable than ever!
 Now we can update SynMix. Next step to excelence =)
 
 SynMix update 24/08/06 great thanx to DavidCl0nel
 download 400kb
 
 
Цитата
On PaintLines for Drawing the indentGuides for non collapsed folds, why you have this:

 I have this only for more bolder visual appearance of highlighted indent guide. It draws only even dots in normal state. I did that it first draw line under these even dots - so looks more bolder.
 
 
Цитата
>>3.  Press Ctrl-A and then any letter - will get AV. If there not full text selected - then all ok. Looks like bug in SetSelTextPrimitiveEx but i cant find it =( 
 No. But maybe it is solved with upper changes.

 Seems like it is bug of Syn, because work good in LeakTest =( Strange...
 
 Some non-common bug of original CF left. May be now its time for it? =)
 1. Select collapsed line from start to end by mouse in NormalSelect. Then paste above collapsed line - it'll paste without colapsed text and drop of foldrange of collapsed line.
--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
DavidCl0nel
Дата 28.8.2006, 10:42 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Новичок



Профиль
Группа: Участник
Сообщений: 44
Регистрация: 31.7.2006
Где: Berlin/Germany

Репутация: 1
Всего: 1



>>I have this only for more bolder visual appearance of highlighted indent guide. It draws only even dots in normal state. I did that it first draw line under these even dots - so looks more bolder

Ok, but then you have to reset the color to the original (in this case red), not in all cases back to black. You should buffer the color in a variable or make the decision after your extra bold line.


>>1. Select collapsed line from start to end by mouse in NormalSelect. Then paste above collapsed line - it'll paste without colapsed text and drop of foldrange of collapsed line. 

Hmm, a little bit yes. Paste without collapsed text is true, but he don't drop the fold. I had to catch this case in CopyToClipboard (CutToClipboard the same). But I don't know, if I have time for it today.
PM MAIL   Вверх
Sep.
Дата 3.9.2006, 14:52 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 109
Регистрация: 22.7.2004

Репутация: нет
Всего: 6



Цитата
Ok, but then you have to reset the color to the original (in this case red), not in all cases back to black. You should buffer the color in a variable or make the decision after your extra bold line.

But color already backuped above:
OldColor := Canvas.Brush.Color;
and restored after.
Цитата
Hmm, a little bit yes. Paste without collapsed text is true, but he don't drop the fold. I had to catch this case in CopyToClipboard (CutToClipboard the same). But I don't know, if I have time for it today.

It will be great, if there willn't be workaround in CopyToClipboard. Because it don't called when Ctrl-V / Ctrl-C. It only called by program. Strange that i have drop of foldrange. May be again Delphi5 =)

Ok, there some small fixes.
Wrong working if you select text by mouse from right to left (BlockBegin greater than BlockEnd)
Код

  procedure SetSelectedTextEmpty;
  var
    vSelText: string;
    vUndoBegin, vUndoEnd, BB, BE: TBufferCoord;
    i: Integer;
  begin
    vUndoBegin := fBlockBegin;
    vUndoEnd := fBlockEnd;
    //vSelText := SelText;
    //###mod copy CF  
    //Copy only the lines around the collapsed line (the "real" lines), SelText give also the collapsed lines back
    vSelText := '';
    BB:=GetBlockBegin;
    BE:=GetBlockEnd;
    Case fActiveSelectionMode of
      smNormal:
        begin
          if BB.Line = BE.Line then begin // One in Line
            vSelText := Copy(Lines[BB.Line-1], BB.Char, BE.Char-BB.Char);
          end else begin
            vSelText := Copy(Lines[BB.Line-1], BB.Char, MaxInt) + #13#10;
            for i := BB.Line+1 to BE.Line-1 do
              vSelText := vSelText + Lines[i-1] + #13#10;
            vSelText := vSelText + Copy(Lines[BE.Line-1], 1, BE.Char-1);
          end;
        end;
      smColumn:
        begin
          for i := BB.Line to BE.Line do
            vSelText := vSelText + Copy(Lines[i-1], BB.Char, BE.Char-BB.Char) + #13#10;
        end;
      smLine:
        begin
          for i := BB.Line to BE.Line do
            vSelText := vSelText + Lines[i-1] + #13#10;
        end;
    end;
    //###mod copy CF 
    SetSelTextPrimitive('');
...

and
Код

procedure TCustomSynEdit.SetSelTextExternal(const Value: string);
var
  StartOfBlock, EndOfBlock, BB, BE: TBufferCoord;
  i: Integer;
  sText: String;
begin
  BeginUndoBlock;
  try
    if SelAvail then
    begin
      //fUndoList.AddChange(crDelete, fBlockBegin, fBlockEnd,SelText, fActiveSelectionMode);
      //###mod
      BB:=GetBlockBegin;
      BE:=GetBlockEnd;
      Case fActiveSelectionMode of
        smNormal:
          begin
            if BB.Line = BE.Line then begin // One in Line
              sText := Copy(Lines[BB.Line-1], BB.Char, BE.Char-BB.Char);
            end else begin
              sText := Copy(Lines[BB.Line-1], BB.Char, MaxInt) + #13#10;
              for i := BB.Line+1 to BE.Line-1 do
                sText := sText + Lines[i-1] + #13#10;
              sText := sText + Copy(Lines[BE.Line-1], 1, BE.Char-1);
            end;
          end;
        smColumn:
          begin
            for i := BB.Line to BE.Line do
              sText := sText + Copy(Lines[i-1], BB.Char, BE.Char-BB.Char) + #13#10;
          end;
        smLine:
          begin
            for i := BB.Line to BE.Line do
              sText := sText + Lines[i-1] + #13#10;
          end;
      end;
      //###mod
...

Sometimes dont called OnGutterClick method when WordWrap enabled. Need to edit TCustomSynEdit.DoOnGutterClick
Код

...
  if Assigned(fOnGutterClick) then
  begin
    line := PixelsToRowColumn(X,Y).Row;
    line:=RowToLine(line); //###mod bug with onGutterClick
    if line <= Lines.Count then
    begin
...

and allways copy to clipboard in unicode if possible. It usefull only for russian locale i think.
Код

procedure TCustomSynEdit.DoCopyToClipboard(const SText: string);
{$IFDEF SYN_CLX}
begin
  Clipboard.AsText := SText;
end;
{$ELSE}
var
  Mem: HGLOBAL;
  P: PChar;
  SLen: integer;
  Failed: boolean;
  //###mod Copy to Clipboard as unicode
  Ptr: Pointer;
  W: WideString;
begin
  if SText <> '' then begin
    Failed := TRUE; // assume the worst.
    // Open and Close are the only TClipboard methods we use because TClipboard
    // is very hard (impossible) to work with if you want to put more than one
    // format on it at a time.
    Clipboard.Open;
    try
      // Clear anything already on the clipboard.
      EmptyClipboard;
      //###mod Copy to Clipboard as unicode
      // Put it on the clipboard as normal text format so it can be pasted into
      // things like notepad or Delphi.
      if Win32Platform = VER_PLATFORM_WIN32_NT then begin
        W:=SText;
        SLen := (Length(W) + 1) * 2;
        Mem := GlobalAlloc(GMEM_MOVEABLE+GMEM_DDESHARE, SLen);
        Ptr := GlobalLock(Mem);
        Move(PWideChar(W)^, Ptr^, SLen);
        GlobalUnlock(Mem);
        Failed :=  SetClipboardData(CF_UNICODETEXT, Mem) = 0;
      end
      else begin
        SLen := Length(SText);
        Mem := GlobalAlloc(GMEM_MOVEABLE or GMEM_DDESHARE, SLen + 1);
        if Mem <> 0 then begin
          P := GlobalLock(Mem);
          try
            if P <> nil then begin
              Move(PChar(SText)^, P^, SLen + 1);
              // Put it on the clipboard in text format
              Failed := SetClipboardData(CF_TEXT, Mem) = 0;
            end;
          finally
            GlobalUnlock(Mem);
          end;
        end;
      end;
      //###mod Copy to Clipboard as unicode
      // Don't free Mem!  It belongs to the clipboard now, and it will free it
      // when it is done with it.
      if not Failed then begin
...

--------------------
Syn - TotalCommander lister plugin |  SynTree - coders sourcebook  
PM MAIL   Вверх
Ответ в темуСоздание новой темы Создание опроса
Rules and hints for the forum "SynUniHighlighter"
Vit
Vitalik

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.


With regards, Vit, Vitalik.

 
0 Пользователей читают эту тему (0 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | SynUniHighlighter and SynEdit (English Language) | Следующая тема »


 




[ Время генерации скрипта: 0.1787 ]   [ Использовано запросов: 22 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.