anchor.diff:  function TKMEdit.KeyDown(Key: Word; Shift: TShiftState): Boolean;
   begin
     Result := KeyEventHandled(Key, Shift);
  -  if inherited KeyDown(Key, Shift) or ReadOnly then exit;
  +  if inherited KeyDown(Key, Shift) or ReadOnly then Exit;
   
     //Clipboard operations
     if (Shift = [ssCtrl]) and (Key <> VK_CONTROL) then
     begin
       case Key of
  -      Ord('C'):    Clipboard.AsText := fText;
  -      Ord('X'):    begin Clipboard.AsText := fText; Text := ''; end;
  -      Ord('V'):
  -      begin
  -          Insert(Clipboard.AsText, fText, CursorPos + 1);
  -          CursorPos := CursorPos + Length(Clipboard.AsText);
  -          ValidateText();
  -        end;
  -      end;
  +      Ord('C'): Clipboard.AsText := fText;
  +      Ord('X'): begin
  +                  Clipboard.AsText := fText;
  +                  Text := '';
  +                end;
  +      Ord('V'): begin
  +                  Insert(Clipboard.AsText, fText, CursorPos + 1);
  +                  CursorPos := CursorPos + Length(Clipboard.AsText);
  +                  ValidateText;
  +                end;
  +    end;
     end;
   
     case Key of
  
positive.code: begin
    if ReadOnly then Exit;
    inherited;
    CursorPos := length(fText);
  end;
  
  
  
negative.code: procedure TKMEdit.SetText(aText: string);
  begin
    fText := aText;
    CursorPos := Math.Min(CursorPos, Length(fText));
    //Setting the text should place cursor to the end
    fLeftIndex := 0;
    SetCursorPos(Length(Text));
    ValidateText;
  end;
  
  
  //Validates fText basing on predefined sets of allowed or disallowed chars
  //It iterates from end to start of a string - deletes chars and moves cursor appropriately
  procedure TKMEdit.ValidateText;
  var
    I: Integer;
  const
    DigitChars: set of Char = ['1' .. '9', '0'];
    NonFileChars: set of Char = [#0 .. #31, '<', '>', '|', '"', '\', '/', ':', '*', '?'];
    NonTextChars: set of Char = [#0 .. #31, '|'];
  begin
    for I := Length(fText) downto 1 do
    if (fAllowedChars = acDigits) and not(fText[i] in DigitChars) or
       (fAllowedChars = acFileName) and (fText[i] in NonFileChars) or
       (fAllowedChars = acText) and (fText[i] in NonTextChars) then
    begin
      Delete(fText, I, 1);
      if CursorPos >= I then //Keep cursor in place
        CursorPos := CursorPos - 1;
    end;
  end;
  
  
  