Page 1 of 1

Ctrl+Del in RVE

Posted: Fri Nov 14, 2014 7:04 pm
by Martian
Ctrl+Backspace removes word at left but why Ctrl+Del doesn't work (should delete word at right)?

Any easy implementation?

Posted: Sat Nov 15, 2014 8:08 am
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.

Posted: Sat Nov 15, 2014 8:59 am
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.

Posted: Sat Nov 15, 2014 9:21 am
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.

Posted: Mon Nov 17, 2014 10:25 pm
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;

Posted: Fri Nov 21, 2014 8:35 pm
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)

Posted: Tue Nov 25, 2014 7:45 am
by Martian
Thanks!

Posted: Tue Nov 25, 2014 8:50 am
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.