Changeset 1718 for cprs/branches
- Timestamp:
- May 19, 2015, 2:49:23 PM (10 years ago)
- Location:
- cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/Demo/fHunSpell.dfm
r1715 r1718 16 16 OnActivate = FormActivate 17 17 OnClose = FormClose 18 OnCloseQuery = FormCloseQuery 18 19 OnCreate = FormCreate 19 20 PixelsPerInch = 96 … … 197 198 object RichEdit1: TRichEdit 198 199 Left = 3 199 Top = 57200 Top = 76 200 201 Width = 726 201 Height = 205202 Height = 186 202 203 Lines.Strings = ( 203 204 'Type orr Paste heree the text ' … … 228 229 OnClick = btnCloseClick 229 230 end 231 object cbIgnoreAllCaps: TCheckBox 232 Left = 131 233 Top = 54 234 Width = 178 235 Height = 17 236 Caption = 'Ignore words in &UpperCase' 237 TabOrder = 6 238 OnClick = cbIgnoreAllCapsClick 239 end 240 object cbIgnoreDigit: TCheckBox 241 Left = 339 242 Top = 53 243 Width = 166 244 Height = 17 245 Caption = 'Ignore words with &digits' 246 TabOrder = 7 247 OnClick = cbIgnoreDigitClick 248 end 230 249 object OpenDialog1: TOpenDialog 231 250 DefaultExt = '*.Dict' -
cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/Demo/fHunSpell.pas
r1715 r1718 62 62 btnAbort: TButton; 63 63 btnUndo: TButton; 64 cbIgnoreAllCaps: TCheckBox; 65 cbIgnoreDigit: TCheckBox; 64 66 procedure FormCreate(Sender: TObject); 65 67 procedure btnIgnoreOnceClick(Sender: TObject); … … 88 90 procedure lblDictionariesURLClick(Sender: TObject); 89 91 procedure lstSuggestionsDblClick(Sender: TObject); 92 procedure cbIgnoreAllCapsClick(Sender: TObject); 93 procedure cbIgnoreDigitClick(Sender: TObject); 94 procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); 90 95 private 91 96 { Private declarations } … … 296 301 end; 297 302 303 procedure TfrmHunSpell.cbIgnoreAllCapsClick(Sender: TObject); 304 begin 305 if SpellCheck1.IgnoreAllCaps <> cbIgnoreAllCaps.Checked then 306 SpellCheck1.IgnoreAllCaps := cbIgnoreAllCaps.Checked; 307 end; 308 309 procedure TfrmHunSpell.cbIgnoreDigitClick(Sender: TObject); 310 begin 311 if SpellCheck1.IgnoreWordWithDigits <> cbIgnoreDigit.Checked then 312 SpellCheck1.IgnoreWordWithDigits := cbIgnoreDigit.Checked; 313 end; 314 298 315 procedure TfrmHunSpell.edtDictionaryEnter(Sender: TObject); 299 316 begin … … 308 325 NoEngineOpted := True; 309 326 end; 327 328 if cbIgnoreAllCaps.Checked <> SpellCheck1.IgnoreAllCaps then 329 cbIgnoreAllCaps.Checked := SpellCheck1.IgnoreAllCaps; 330 331 if cbIgnoreDigit.Checked <> SpellCheck1.IgnoreWordWithDigits then 332 cbIgnoreDigit.Checked := SpellCheck1.IgnoreWordWithDigits; 310 333 end; 311 334 … … 320 343 else 321 344 ShowMessage(TX_SPELL_CANCELLED) ; } 345 end; 346 347 procedure TfrmHunSpell.FormCloseQuery(Sender: TObject; var CanClose: Boolean); 348 begin 349 CanClose := (SpellCheck1.SpellCheckState <> ssChecking) 350 or (SpellCheck1.AbortSpellCheck(True)); 351 if CanClose then 352 ModalResult := mrCancel; 322 353 end; 323 354 -
cprs/branches/HealthSevak-CPRS/CPRS-Lib/Hans SpellCheck/skaHunSpellChecker.dproj
r1715 r1718 38 38 39 39 40 41 42 43 40 <Excluded_Packages Name="C:\Documents and Settings\All Users\Documents\RAD Studio\5.0\Bpl\XWB_R2007.bpl">VistA RPC Broker Runtime Package</Excluded_Packages> 44 41 <Excluded_Packages Name="E:\WVEHR\branches\HealthSevak-CPRS\BDK50\Packages\XWB_D2007.bpl">File E:\WVEHR\branches\HealthSevak-CPRS\BDK50\Packages\XWB_D2007.bpl not found</Excluded_Packages> … … 51 48 <MainSource>MainSource</MainSource> 52 49 </DelphiCompile> 53 <DCCReference Include=" Demo\rtl.dcp" />54 <DCCReference Include=" Demo\vcl.dcp" />50 <DCCReference Include="C:\Documents and Settings\sunil\rtl.dcp" /> 51 <DCCReference Include="C:\Documents and Settings\sunil\vcl.dcp" /> 55 52 <DCCReference Include="skaSpellCheck.pas" /> 56 53 <DCCReference Include="uHunSpellLib.pas" /> -
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.