Ctrl+Del in RVE

General TRichView support forum. Please post your questions here
Post Reply
Martian
Posts: 95
Joined: Sun Apr 03, 2011 7:32 pm

Ctrl+Del in RVE

Post by Martian »

Ctrl+Backspace removes word at left but why Ctrl+Del doesn't work (should delete word at right)?

Any easy implementation?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

It's not that simple, otherwise it would be implemented long ago.
It is because "Delete" is implemented as a reverted "Backspace", but Ctrl+Del cannot be implemented in this way.
Nothing overcomplicated, but this work has a low priority, sorry.
Martian
Posts: 95
Joined: Sun Apr 03, 2011 7:32 pm

Post by Martian »

A lot of word processors has this feature...for example MS Word, Notepad++
People asks me to implement it. I don't understand why it's so hard?
It's hard to detect a word after cursor? I don't think so.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

If you look in the code, you will see that OnBackSpacePress_ and OnDeletePress_ are the most complicated editing procedures.
But ok, I'll see if we can implement Ctrl+Delete in one of next updates.
Splinter
Posts: 41
Joined: Mon Aug 29, 2005 6:08 pm

Post by Splinter »

Here you go, call the function DeleteToEndOfWord from your rve:

Code: Select all

Function TfmMain.DeleteToEndOfWord:boolean;
var ItemNo, WordEnd, WordStart: Integer;
    s,s2: String;
    CodePage: TRVCodePage;
    rve1: TCustomRichViewEdit;
begin
  rve1 := rve.TopLevelEditor;

  ItemNo := rve1.CurItemNo;
  WordEnd := rve1.OffsetInCurItem;
  CodePage := rve1.RVData.GetItemCodePage(ItemNo);

  if (rve1.GetItemStyle(ItemNo)<0) then exit;
  s := rve1.GetItemTextW(ItemNo);
  WordStart := WordEnd;

  if WordStart<1 then
    exit;
  if s='' then exit;

  //calc from cursor to end of word
  while ((WordEnd<length(s)) and (not rve1.RVData.IsDelimiterA(s[WordEnd+1],codepage))) do
    inc(WordEnd);

  //add extra 1 to delete trailing space
  if WordEnd<length(s) then inc(WordEnd);

  s := Copy(s, WordStart, WordEnd-WordStart);
  if s<>'' then
  begin
      Result:=true;
      rve1.SetSelectionBounds(ItemNo, WordStart, ItemNo, WordEnd);
      rve1.InsertTextW('');
  end
  else
  Result:=false;

end;

procedure TfmMain.rveKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
Begin

if (ssCtrl in Shift) and (key=vk_delete) then
begin
      DeleteToEndOfWord;
end;

end;
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

We have implemented Ctrl+Delete in TRichView 15.3, available for registered users.
It's not based on your code (but for implementation in an event, your method (selecting and deleting selection) is a right approach)
Martian
Posts: 95
Joined: Sun Apr 03, 2011 7:32 pm

Post by Martian »

Thanks!
jonjon
Posts: 467
Joined: Sat Aug 27, 2005 4:19 pm

Post by jonjon »

Sergey Tkachenko wrote:We have implemented Ctrl+Delete in TRichView 15.3, available for registered users.
Great! While you are at it, a long-time missing feature is double-click -> select word -> hold mouse button and drag -> continue selection!
The only other application missing this feature I know of, is the Delphi IDE itself. And this is often requested by end-users.
I hope you'll consider it.
Post Reply