- Timestamp:
- May 19, 2015, 2:49:23 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/skaSpellCheck.pas
r1715 r1718 81 81 FOnAbort : TNotifyEvent; 82 82 FOnStateChange : TStateChangeEvent; 83 FIgnoreWordWdigits: boolean; 84 FIgnoreCaps: boolean; 83 85 84 86 function AddCustomWord(aWord: String; isInternal: Boolean = False): Boolean; … … 86 88 Function CurrentWordDetail(WithPosition: Boolean= True): String; 87 89 function GetActive: Boolean; 90 procedure GetOptions; 88 91 function GetStatus: TSpellState; 89 92 procedure Initialize; … … 93 96 procedure SetDictFileName(const Value: string); 94 97 procedure SetHighLightEdit(const Value: TEdit); 98 procedure SetOptions; 95 99 procedure SetSourceEdit(const Value: TRichEdit); 96 100 Function ShowMisSpelledWord:boolean; … … 100 104 procedure SaveForUndo(const Ignoring: Boolean=False); 101 105 procedure InformStatusChange; 106 procedure SetIgnoreCaps(const Value: boolean); 107 procedure SetIgnoreWordWdigits(const Value: boolean); 102 108 public 103 109 constructor Create(AOwner: TComponent); overload; override; … … 129 135 property Active: Boolean read GetActive write SetActive; 130 136 property AffixFileName: string read FAffixFileName write SetAffixFileName; 137 property IgnoreAllCaps: boolean read FIgnoreCaps write SetIgnoreCaps default true; 138 property IgnoreWordWithDigits:boolean read FIgnoreWordWdigits write SetIgnoreWordWdigits default true; 131 139 property CustDictionaryFile: String read FCustom write SetCustomDict; 132 140 property DictionaryFileName:string read FDictFileName write SetDictFileName; … … 162 170 CurrentMe: TskaHunSpellChecker; 163 171 implementation 164 uses messages, Dialogs, RichEdit, SHFolder, uHunSpellLib ;172 uses messages, Dialogs, RichEdit, SHFolder, uHunSpellLib, Registry; 165 173 166 174 procedure Register; … … 184 192 [mbYes, mbNo],0, mbNo) = 6); 185 193 186 if Result and (FUndoList.Count > 0) then 187 begin 194 if Result then 195 begin 196 if FUndoList.Count > 0 then 188 197 SourceTextControl.Text := FUndoList[0]; 189 FUndoList.Clear; 190 FUndoList.Add(SourceTextControl.Text); 191 end; 198 FUndoList.Clear; 199 FUndoList.Add(SourceTextControl.Text); 192 200 FIgnore.Clear; 193 201 FStatus := ssCancelled; … … 195 203 if Assigned(OnAbort) then 196 204 OnAbort(Self); 205 end; 197 206 end; 198 207 … … 363 372 FUndoList := TStringList.Create; 364 373 374 if csDesigning in componentState then 375 begin 376 IgnoreAllCaps := True; 377 IgnoreWordWithDigits := True; 378 end 379 else 380 GetOptions; 381 365 382 FStatus := ssInActive; 366 383 WaitForUser := False; … … 380 397 Result := '$$' + CurrentWord + '$$'; 381 398 if WithPosition then 382 Result := '$$' + IntToStr(FoundAt+1) + Result;399 Result :='$$' + IntToStr(CurrentLine) + '$$' + IntToStr(FoundAt+1) + Result; 383 400 end; 384 401 … … 396 413 except 397 414 end; 415 SetOptions; 398 416 finally 399 417 FCustDict.Free; … … 410 428 begin 411 429 Result := (FpointerHunLib <> nil); 430 end; 431 432 procedure TskaHunSpellChecker.GetOptions; 433 var 434 reg:TRegistry; 435 begin 436 reg:=TRegistry.Create; 437 try 438 reg.RootKey := HKEY_CURRENT_USER; 439 440 //first get the dicationary file name 441 Reg.OpenKey('\software\'+ ChangeFileExt(Application.ExeName,'') + '\skaHunSpellCheckOptions',True); 442 if reg.ValueExists('DicFileName') then 443 DictionaryFileName:=Reg.readString('DicFileName') 444 else 445 Reg.WriteString('DicFileName',DictionaryFileName); 446 447 //IgnoreAllCaps ? 448 if reg.ValueExists('IgnoreAllCaps') then 449 IgnoreAllCaps:=Reg.readBool('IgnoreAllCaps') 450 else 451 Reg.WriteBool('IgnoreAllCaps',IgnoreAllCaps); 452 453 454 //IgnoreWordsWithDigits ? 455 if reg.ValueExists('IgnoreWordWithDigits') then 456 IgnoreWordWithDigits:=Reg.readBool('IgnoreWordWithDigits') 457 else 458 Reg.WriteBool('IgnoreWordWithDigits',IgnoreWordWithDigits); 459 460 finally 461 Reg.Free; 462 end; 463 412 464 end; 413 465 … … 472 524 TextOut(dcForHndl, VisPoint.x, VisPoint.y, pchar(CurrentWord), WordLength); 473 525 end; 526 527 function WordIsIgnorable: Boolean; 528 var 529 i: Integer; 530 begin 531 if IgnoreAllCaps then 532 begin 533 Result := True; 534 for i := 1 to WordLength do 535 begin 536 Result := Result and (ord(CurrentWord[i]) in [65..90]); 537 end; 538 if Result then 539 exit; 540 end; 541 542 543 544 if IgnoreWordWithDigits then 545 begin 546 Result := False; 547 for i := 1 to WordLength do 548 begin 549 Result := Result or (ord(CurrentWord[i]) in [48..57]); 550 if Result then 551 break; 552 end; 553 end; 554 end; 474 555 begin 475 556 Result := False; … … 529 610 WordPos := i-WordLength; 530 611 CurrentWord := copy(CurrentText, WordPos, WordLength); 531 If ((FIgnore.IndexOf(CurrentWordDetail(True))< 0) //SingelIgnore 612 // if WordIsCorrect then 613 if (((FIgnore.IndexOf(CurrentWordDetail(True))< 0) //SingelIgnore 532 614 and (FIgnore.IndexOf(CurrentWordDetail(False))< 0) //IgnoreAll 533 and (IsMisspelled(CurrentWord))) Then 615 and (IsMisspelled(CurrentWord)))) 616 and (not WordIsIgnorable) then 617 534 618 begin 535 619 GetSuggestions(CurrentWord, SuggestionList.Items); … … 764 848 end; 765 849 850 procedure TskaHunSpellChecker.SetIgnoreCaps(const Value: boolean); 851 begin 852 if (FIgnoreCaps = Value) then 853 exit; 854 855 FIgnoreCaps := Value; 856 if SpellCheckState = ssChecking then 857 ReStart; 858 end; 859 860 procedure TskaHunSpellChecker.SetIgnoreWordWdigits(const Value: boolean); 861 begin 862 if (FIgnoreWordWdigits = Value) then 863 exit; 864 865 FIgnoreWordWdigits := Value; 866 if SpellCheckState = ssChecking then 867 ReStart; 868 869 end; 870 871 procedure TskaHunSpellChecker.SetOptions; 872 var 873 reg:TRegistry; 874 begin 875 reg:=TRegistry.Create; 876 try 877 reg.RootKey := HKEY_CURRENT_USER; 878 879 880 Reg.OpenKey('\software\'+ ChangeFileExt(Application.ExeName,'') + '\skaHunSpellCheckOptions',True); 881 882 //first save the dicationary file name 883 Reg.WriteString('DicFileName',DictionaryFileName); 884 885 //IgnoreAllCaps ? 886 Reg.WriteBool('IgnoreAllCaps',IgnoreAllCaps); 887 888 889 //IgnoreWordsWithDigits ? 890 Reg.WriteBool('IgnoreWordWithDigits',IgnoreWordWithDigits); 891 892 finally 893 Reg.Free; 894 end; 895 end; 896 766 897 Function RichEditWndProc(handle:HWnd;uMsg,wParam,lParam:longint):longint stdcall; 767 898 begin
Note:
See TracChangeset
for help on using the changeset viewer.