trichview.com

trichview.support




Re: Auto Correct


Return to index


Author

Message

Sergey Tkachenko

Posted: 01/07/2005 15:55:20


You can see how it's implemented in RichViewActions:


unction RVA_Addict3AutoCorrect(rve: TCustomRichViewEdit): Boolean;

var ItemNo, WordEnd, WordStart: Integer;

    s,s2: String;

begin

  Result := RVA_Addict3<>nil;

  if not Result then

    exit;

  rve := rve.TopLevelEditor;

  ItemNo := rve.CurItemNo;

  WordEnd := rve.OffsetInCurItem;

  if (rve.GetItemStyle(ItemNo)<0) or

    (rve.Style.TextStyles[rve.GetItemStyle(ItemNo)].Charset=SYMBOL_CHARSET)

then

    exit;

  s := rve.GetItemTextA(ItemNo);

  WordStart := WordEnd;

  if WordStart<1 then

    exit;

  while (WordStart-1>0) and not rve.RVData.IsDelimiterA(s[WordStart-1]) do

    dec(WordStart);

  s := Copy(s, WordStart, WordEnd-WordStart);

  Result := RVA_Addict3.WordHasCorrection(s,s2);

  if Result then begin

    rve.SetSelectionBounds(ItemNo, WordStart, ItemNo, WordEnd);

    rve.InsertText(s2);

  end;

end;




>I am implementing an auto correct function.

>

>When a space is being pressed, how can I get the word? For example, after

>typing "testing" then press space, I would like to get the word testing

so

>that I can check from addict spell whether it is already added to auto

>correct list or not then I can do my stuff.

>

>After checking, if the word is in the auto correct list, I would like to

>replace word with the preset auto correct word. How?

>

>I have no prblem with the process of checking the auto correct list to get

>the correction, the only problem I am facing is how to get the typed word

>after space is pressed and how to replace it with the correction I get.

>

>





Powered by ABC Amber Outlook Express Converter