trichview.support
Re: Autocompletion ? |
Author |
Message |
Stef Mientki |
Posted: 11/15/2003 15:38:07 Thanks very much Sergey. This is exactly what I had in mind. What you said about the undo order, I think it still works very acceptable, so no problem. So thanks again for your excellent and fast respons ! Stef Mientki Sergey Tkachenko wrote: > Here is the simplest example. It changes 'ms$' to 'one of Bills products' > when you type 'ms$' and press one of characters listed in the Delimiters > property (more exactly, when you press this character to the right of > 'ms$'). > > There is only one problem: wrong order of undo. Autocompletion occurs before > inserting the delimiter character, so this character is undone before the > autocompletion. > Is it acceptable for you? > > procedure TForm3.RichViewEdit1KeyPress(Sender: TObject; var Key: Char); > var rve: TCustomRichViewEdit; > ItemNo, WordEnd, WordStart: Integer; > s: String; > {..................................} > function IsDelimiter(ch: Char): Boolean; > begin > Result := Pos(ch, RichViewEdit1.Delimiters)<>0; > end; > {..................................} > begin > if not IsDelimiter(Key) then > exit; > rve := RichViewEdit1.TopLevelEditor; > ItemNo := rve.CurItemNo; > WordEnd := rve.OffsetInCurItem; > if rve.GetItemStyle(ItemNo)<0 then > exit; > s := rve.GetItemTextA(ItemNo); > WordStart := WordEnd; > if WordStart<1 then > exit; > while (WordStart-1>0) and not IsDelimiter(s[WordStart-1]) do > dec(WordStart); > s := Copy(s, WordStart, WordEnd-WordStart); > if s='ms$' then begin > rve.SetSelectionBounds(ItemNo, WordStart, ItemNo, WordEnd); > rve.InsertText('one of Bills products'); > end; > end; > > |
Powered by ABC Amber Outlook Express Converter