trichview.com

trichview.support




Re: Tabbing on selected text and image


Return to index


Author

Message

Sergey Tkachenko

Posted: 01/09/2005 17:53:20


Well, I can explain how to implement something like that.

This example uses a global variable SAI: Boolean (add it to the form)

If the caret at the beginning of paragraph, or several paragraphs are

selected completely, this code calls

rvActionsResource.rvActionIndentInc1.Execute instead of insertion of

tabulator.

Actually, it should indent not by default value (like TrvActionIndentInc

does), but to the closest tab position...



function ShouldAutoIndent(rve: TCustomRichViewEdit): Boolean;

var StartNo, StartOffs, EndNo, EndOffs: Integer;

begin

  rve := rve.TopLevelEditor;

  rve.RVData.GetSelectionBoundsEx(StartNo, StartOffs, EndNo, EndOffs, True);

  // is (StartNo,StartOffs) a beginning of paragraph?

  Result := (rve.IsParaStart(StartNo) or ((StartNo>0) and

(rve.GetItemStyle(StartNo-1)=rvsListMarker))) and

    (StartOffs<=rve.GetOffsBeforeItem(StartNo));

  if not Result or ((StartNo=EndNo) and (StartOffs=EndOffs)) then

    exit;

  // is (EndNo,EndOffs) a end of paragraph?

  Result := (EndNo=rve.ItemCount-1) or rve.IsParaStart(EndNo+1);

end;


procedure TForm3.RichViewEdit1KeyDown(Sender: TObject; var Key: Word;

  Shift: TShiftState);

begin

  if Key = VK_TAB then begin

    SAI := ShouldAutoIndent(RichViewEdit1);

    if SAI then begin

      rvActionsResource.rvActionIndentInc1.Execute;

      Key := 0;

      exit;

    end;

  end;

  ...

end;


procedure TForm3.RichViewEdit1KeyPress(Sender: TObject; var Key: Char);

begin

  if (Key=#9) and SAI then begin

    Key := #0;

  end;

  ...

end;


> if I exclude rvoWantTabs from RichViewEdit.EditorOptions, tabbing on rve

> will no longer work. I want the tab working, but the when I highlighted a

> paragraph of text, I want all the selected text to be tabbed but not

> deleted.

>

> If you do not understand what I mean, you can test it using MS Word.

Select

> a paragraph of text then press tab,  all the selected text will be move

> behind.

>

> Hope you can understand what I mean. Thanx!! :)

>





Powered by ABC Amber Outlook Express Converter