trichview.support
Re: Find character near |
Author |
Message |
Sergey Tkachenko |
Posted: 11/14/2003 16:26:21 While it's possible to do it using SearchText, there is a simpler and more efficient solution. Download the file http://www.trichview.com/resources/spell/rvspell.zip This archive contains wrappers for various spell-checkers, but you do not need them. You need only one unit - RVWordEnum.pas - containing the class TRVWordEnumerator. This class allows to enumerate all words in the document (from cursor or from the beginning). You need to create a descendant class checking if the word is all-digits and apply some formatting to it. Below is how to do it: type TNumberColorer = class (TRVWordEnumerator) private FEdit: TCustomRichViewEdit; public procedure Run(Edit: TCustomRichViewEdit); function ProcessWord: Boolean; override; end; function TNumberColorer.ProcessWord: Boolean; var i: Integer; AllDigits: Boolean; begin Result := True; AllDigits := True; for i := 1 to Length(FWord) do if not (FWord[i] in ['0'..'9']) then begin AllDigits := False; break; end; if not AllDigits then exit; SelectCurrentWord; FEdit.ApplyTextStyle(1); // or ApplyStyleConversion or whatever end; procedure TNumberColorer.Run(Edit: TCustomRichViewEdit); begin FEdit := Edit; inherited Run(Edit, rvesFromStart); end; procedure TForm1.Button5Click(Sender: TObject); var nc: TNumberColorer; begin LockWindowUpdate(rve.Handle); nc := TNumberColorer.Create; try nc.Run(rve); finally nc.Free; LockWindowUpdate(0); end; end; |
Powered by ABC Amber Outlook Express Converter