jvcllaz: Make JvSpellChecker platform-independent

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@6238 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2018-03-12 10:04:11 +00:00
parent 6eb42439cf
commit 6ee65d5dbb
9 changed files with 114 additions and 132 deletions

View File

@ -4,9 +4,6 @@
<Version Value="11"/> <Version Value="11"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<General> <General>
<Flags>
<UseDefaultCompilerOptions Value="True"/>
</Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<Title Value="JvSpellCheckerDemo"/> <Title Value="JvSpellCheckerDemo"/>

View File

@ -1,14 +1,16 @@
program JvSpellCheckerDemo; program JvSpellCheckerDemo;
uses uses
Forms, Interfaces, Forms, Interfaces, LCLVersion,
MainFrm in 'MainFrm.pas' {frmMain}, MainFrm in 'MainFrm.pas' {frmMain},
JvSpellCheckerForm in 'JvSpellCheckerForm.pas' {frmSpellChecker}; JvSpellCheckerForm in 'JvSpellCheckerForm.pas' {frmSpellChecker};
{$R *.res} {$R *.res}
begin begin
{$IF LCL_FullVersion >= 1080000}
Application.Scaled := True; Application.Scaled := True;
{$ENDIF}
Application.Initialize; Application.Initialize;
Application.CreateForm(TfrmMain, frmMain); Application.CreateForm(TfrmMain, frmMain);
Application.CreateForm(TfrmSpellChecker, frmSpellChecker); Application.CreateForm(TfrmSpellChecker, frmSpellChecker);

View File

@ -1,104 +1,107 @@
object frmSpellChecker: TfrmSpellChecker object frmSpellChecker: TfrmSpellChecker
Left = 338 Left = 338
Height = 334
Top = 177 Top = 177
Width = 384
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Spell check document' Caption = 'Spell check document'
ClientHeight = 334 ClientHeight = 334
ClientWidth = 384 ClientWidth = 384
Color = clBtnFace Color = clBtnFace
DefaultMonitor = dmDesktop DefaultMonitor = dmDesktop
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Shell Dlg 2'
Font.Style = []
FormStyle = fsStayOnTop FormStyle = fsStayOnTop
OldCreateOrder = False
Position = poMainFormCenter
Scaled = False
OnCreate = FormCreate OnCreate = FormCreate
OnShow = FormShow OnShow = FormShow
PixelsPerInch = 96 Position = poMainFormCenter
TextHeight = 13 LCLVersion = '1.9.0.0'
Scaled = False
object Label1: TLabel object Label1: TLabel
Left = 16 Left = 16
Height = 15
Top = 16 Top = 16
Width = 72 Width = 81
Height = 13
Caption = 'Not in wordlist:' Caption = 'Not in wordlist:'
ParentColor = False
end end
object Label2: TLabel object Label2: TLabel
Left = 16 Left = 16
Height = 15
Top = 102 Top = 102
Width = 62 Width = 67
Height = 13
Caption = 'Suggestions:' Caption = 'Suggestions:'
ParentColor = False
end end
object lblNoSuggestions: TLabel object lblNoSuggestions: TLabel
Left = 179 AnchorSideRight.Control = edNewWord
AnchorSideRight.Side = asrBottom
Left = 166
Height = 15
Top = 101 Top = 101
Width = 93 Width = 104
Height = 13 Anchors = [akTop, akRight]
Caption = '(nothing to display)' Caption = '(nothing to display)'
ParentColor = False
Visible = False Visible = False
end end
object Label3: TLabel object Label3: TLabel
Left = 16 Left = 16
Height = 15
Top = 56 Top = 56
Width = 65 Width = 70
Height = 13
Caption = 'Replace with:' Caption = 'Replace with:'
ParentColor = False
end end
object edNewWord: TEdit object edNewWord: TEdit
Left = 16 Left = 16
Height = 23
Top = 72 Top = 72
Width = 254 Width = 254
Height = 21 Anchors = [akTop, akLeft, akRight]
Anchors = [akLeft, akTop, akRight]
TabOrder = 1 TabOrder = 1
end end
object lbSuggestions: TListBox object lbSuggestions: TListBox
Left = 16 Left = 16
Height = 82
Top = 120 Top = 120
Width = 254 Width = 254
Height = 82 Anchors = [akTop, akLeft, akRight, akBottom]
Anchors = [akLeft, akTop, akRight, akBottom] ItemHeight = 0
ItemHeight = 13
TabOrder = 2
OnClick = lbSuggestionsClick OnClick = lbSuggestionsClick
TabOrder = 2
end end
object btnIgnore: TButton object btnIgnore: TButton
Left = 294 Left = 294
Height = 25
Top = 32 Top = 32
Width = 75 Width = 75
Height = 25
Action = acIgnore Action = acIgnore
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 3 TabOrder = 3
end end
object btnIgnoreAll: TButton object btnIgnoreAll: TButton
Left = 294 Left = 294
Height = 25
Top = 61 Top = 61
Width = 75 Width = 75
Height = 25
Action = acIgnoreAll Action = acIgnoreAll
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 4 TabOrder = 4
end end
object btnChange: TButton object btnChange: TButton
Left = 294 Left = 294
Height = 25
Top = 120 Top = 120
Width = 75 Width = 75
Height = 25
Action = acChange Action = acChange
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 5 TabOrder = 5
end end
object btnClose: TButton object btnClose: TButton
Left = 294 Left = 294
Top = 286
Width = 75
Height = 25 Height = 25
Top = 289
Width = 75
Action = acClose Action = acClose
Anchors = [akRight, akBottom] Anchors = [akRight, akBottom]
Cancel = True Cancel = True
@ -106,68 +109,78 @@
end end
object btnAdd: TButton object btnAdd: TButton
Left = 294 Left = 294
Height = 25
Top = 149 Top = 149
Width = 75 Width = 75
Height = 25
Action = acAdd Action = acAdd
Anchors = [akTop, akRight] Anchors = [akTop, akRight]
TabOrder = 6 TabOrder = 6
end end
object GroupBox1: TGroupBox object GroupBox1: TGroupBox
Left = 16 Left = 16
Top = 209
Width = 257
Height = 105 Height = 105
Top = 209
Width = 254
Anchors = [akLeft, akRight, akBottom] Anchors = [akLeft, akRight, akBottom]
Caption = ' Ignore: ' Caption = ' Ignore: '
ClientHeight = 85
ClientWidth = 250
TabOrder = 7 TabOrder = 7
object chkUpperCase: TCheckBox object chkUpperCase: TCheckBox
AnchorSideTop.Control = GroupBox1
Left = 24 Left = 24
Top = 23 Height = 19
Width = 207 Top = 4
Height = 17 Width = 118
BorderSpacing.Top = 4
Caption = '&UPPERCASE words' Caption = '&UPPERCASE words'
TabOrder = 0 TabOrder = 0
end end
object chkNumber: TCheckBox object chkNumber: TCheckBox
AnchorSideTop.Control = chkUpperCase
AnchorSideTop.Side = asrBottom
Left = 24 Left = 24
Top = 39 Height = 19
Width = 207 Top = 23
Height = 17 Width = 130
Caption = 'Words with &numbers' Caption = 'Words with &numbers'
TabOrder = 1 TabOrder = 1
end end
object chkURL: TCheckBox object chkURL: TCheckBox
AnchorSideTop.Control = chkNumber
AnchorSideTop.Side = asrBottom
Left = 24 Left = 24
Top = 55 Height = 19
Width = 207 Top = 42
Height = 17 Width = 135
Caption = 'Internet and file &paths' Caption = 'Internet and file &paths'
TabOrder = 2 TabOrder = 2
end end
object chkHTML: TCheckBox object chkHTML: TCheckBox
AnchorSideTop.Control = chkURL
AnchorSideTop.Side = asrBottom
Left = 24 Left = 24
Top = 71 Height = 19
Width = 207 Top = 61
Height = 17 Width = 82
Caption = 'HT&ML code' Caption = 'HT&ML code'
TabOrder = 3 TabOrder = 3
end end
end end
object edBadWord: TEdit object edBadWord: TEdit
Left = 16 Left = 16
Height = 23
Top = 32 Top = 32
Width = 254 Width = 254
Height = 21 Anchors = [akTop, akLeft, akRight]
Anchors = [akLeft, akTop, akRight]
Color = clBtnFace Color = clBtnFace
ReadOnly = True ReadOnly = True
TabOrder = 0 TabOrder = 0
end end
object alSpell: TActionList object alSpell: TActionList
OnUpdate = alSpellUpdate OnUpdate = alSpellUpdate
Left = 296 left = 296
Top = 224 top = 224
object acIgnore: TAction object acIgnore: TAction
Caption = '&Ignore' Caption = '&Ignore'
OnExecute = acIgnoreExecute OnExecute = acIgnoreExecute
@ -186,8 +199,8 @@
end end
object acClose: TAction object acClose: TAction
Caption = '&Close' Caption = '&Close'
ShortCut = 27
OnExecute = acCloseExecute OnExecute = acCloseExecute
ShortCut = 27
end end
end end
end end

View File

@ -29,10 +29,10 @@ unit JvSpellCheckerForm;
interface interface
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
//{$I jvcl.inc}
uses uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, LCLIntf, LMessages,
SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, JvSpellChecker, ActnList; Dialogs, StdCtrls, JvSpellChecker, ActnList;
type type
@ -94,6 +94,7 @@ type
ASpellChecker: TJvSpellChecker; ASpellChecker: TJvSpellChecker;
FOnReplaceText: TJvReplaceTextEvent; FOnReplaceText: TJvReplaceTextEvent;
FOnSelectText: TJvSelectTextEvent; FOnSelectText: TJvSelectTextEvent;
procedure AsyncClose(Data: PtrInt);
procedure CloseAndReport(ReportSuccess: boolean); procedure CloseAndReport(ReportSuccess: boolean);
function GetNextWord: boolean; function GetNextWord: boolean;
procedure DoReplaceText(Sender: TObject; StartIndex, ALength: integer; const NewText: string); procedure DoReplaceText(Sender: TObject; StartIndex, ALength: integer; const NewText: string);
@ -116,6 +117,11 @@ implementation
{$R *.lfm} {$R *.lfm}
procedure TfrmSpellChecker.AsyncClose(Data: PtrInt);
begin
Close;
end;
procedure TfrmSpellChecker.FormCreate(Sender: TObject); procedure TfrmSpellChecker.FormCreate(Sender: TObject);
var S:string; var S:string;
begin begin
@ -256,7 +262,8 @@ begin
S := 'There is nothing to spell check'; S := 'There is nothing to spell check';
ShowMessage(S); ShowMessage(S);
// delay since we might have been called from the OnShow event (can't close in OnShow) // delay since we might have been called from the OnShow event (can't close in OnShow)
PostMessage(Handle, WM_CLOSE, 0, 0); Application.QueueAsyncCall(@AsyncClose, 0);
// PostMessage(Handle, LM_CLOSE, 0, 0);
end; end;
procedure TfrmSpellChecker.acIgnoreExecute(Sender: TObject); procedure TfrmSpellChecker.acIgnoreExecute(Sender: TObject);

View File

@ -26,11 +26,13 @@
unit MainFrm; unit MainFrm;
{$mode objfpc}{$H+}
interface interface
uses uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Menus, ComCtrls, JvComponent; Dialogs, StdCtrls, Menus, ComCtrls;
type type
TfrmMain = class(TForm) TfrmMain = class(TForm)
@ -68,7 +70,9 @@ type
var var
frmMain: TfrmMain; frmMain: TfrmMain;
implementation implementation
uses uses
JvSpellCheckerForm; JvSpellCheckerForm;

View File

@ -30,14 +30,12 @@ Known Issues:
unit JvSpellChecker; unit JvSpellChecker;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
//{$I jvcl.inc}
interface interface
uses uses
SysUtils, Classes, SysUtils, Classes,
Windows, Controls, Messages, JvSpellIntf;
JvSpellIntf; //, JvComponentBase;
type type
TJvSpellChecker = class(TComponent) //TJvComponent) TJvSpellChecker = class(TComponent) //TJvComponent)
@ -69,20 +67,10 @@ type
property OnCanIgnore: TJvSpellCheckIgnoreEvent read GetCanIgnore write SetCanIgnore; property OnCanIgnore: TJvSpellCheckIgnoreEvent read GetCanIgnore write SetCanIgnore;
end; end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation implementation
uses uses
// JclStrings, // StrAddRef, StrDecRef
JvTypes, JvResources; JvTypes, JvResources;
// NOTE: hash table and soundex lookup code originally from Julian Bucknall's // NOTE: hash table and soundex lookup code originally from Julian Bucknall's

View File

@ -30,7 +30,6 @@ Known Issues:
unit JvSpellIntf; unit JvSpellIntf;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
//{$I jvcl.inc}
interface interface
@ -100,25 +99,7 @@ type
var var
CreateSpellChecker: function: IJvSpellChecker = nil; CreateSpellChecker: function: IJvSpellChecker = nil;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation implementation
{$IFDEF UNITVERSIONING}
initialization
RegisterUnitVersion(HInstance, UnitVersioning);
finalization
UnregisterUnitVersion(HInstance);
{$ENDIF UNITVERSIONING}
end. end.

View File

@ -1,64 +1,69 @@
object JvSpellerForm: TJvSpellerForm object JvSpellerForm: TJvSpellerForm
Left = 306 Left = 306
Height = 153
Top = 251 Top = 251
Width = 371
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Spelling checker' Caption = 'Spelling checker'
ClientHeight = 153 ClientHeight = 153
ClientWidth = 371 ClientWidth = 371
Color = clBtnFace Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
Font.Height = -11 LCLVersion = '1.9.0.0'
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
PixelsPerInch = 96
TextHeight = 13
object LblContext: TLabel object LblContext: TLabel
Left = 0 Left = 8
Top = 33
Width = 371
Height = 86 Height = 86
Hint = 'look ahead box' Hint = 'look ahead box'
Top = 33
Width = 355
Align = alClient Align = alClient
BorderSpacing.Left = 8
BorderSpacing.Right = 8
Caption = 'LblContext' Caption = 'LblContext'
ParentColor = False
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
WordWrap = True WordWrap = True
end end
object TextPanel: TPanel object TextPanel: TPanel
Left = 0 Left = 0
Height = 33
Top = 0 Top = 0
Width = 371 Width = 371
Height = 33
Align = alTop Align = alTop
BevelInner = bvRaised BevelInner = bvRaised
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 33
ClientWidth = 371
Font.Color = clWindowText
ParentFont = False
TabOrder = 0 TabOrder = 0
object TxtSpell: TEdit object TxtSpell: TEdit
Left = 7 Left = 8
Height = 23
Top = 7 Top = 7
Width = 293 Width = 293
Height = 21
TabOrder = 0 TabOrder = 0
Text = 'TxtSpell' Text = 'TxtSpell'
end end
end end
object ButtonPanel: TPanel object ButtonPanel: TPanel
Left = 0 Left = 0
Height = 34
Top = 119 Top = 119
Width = 371 Width = 371
Height = 34
Align = alBottom Align = alBottom
BevelInner = bvRaised BevelInner = bvRaised
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 34
ClientWidth = 371
TabOrder = 1 TabOrder = 1
object BtnSkip: TButton object BtnSkip: TButton
Left = 13 Left = 13
Top = 7
Width = 61
Height = 20 Height = 20
Hint = 'Skip this word' Hint = 'Skip this word'
Top = 7
Width = 61
Caption = '&Skip' Caption = '&Skip'
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
@ -66,10 +71,10 @@
end end
object BtnChange: TButton object BtnChange: TButton
Left = 228 Left = 228
Top = 7
Width = 60
Height = 20 Height = 20
Hint = 'Change to corrected word' Hint = 'Change to corrected word'
Top = 7
Width = 60
Caption = '&Change' Caption = '&Change'
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
@ -77,10 +82,10 @@
end end
object BtnCancel: TButton object BtnCancel: TButton
Left = 299 Left = 299
Top = 7
Width = 61
Height = 20 Height = 20
Hint = 'Abort all changes' Hint = 'Abort all changes'
Top = 7
Width = 61
Caption = 'Cancel' Caption = 'Cancel'
ModalResult = 2 ModalResult = 2
ParentShowHint = False ParentShowHint = False
@ -89,10 +94,10 @@
end end
object BtnAdd: TButton object BtnAdd: TButton
Left = 156 Left = 156
Top = 7
Width = 61
Height = 20 Height = 20
Hint = 'Add to user Dictionary' Hint = 'Add to user Dictionary'
Top = 7
Width = 61
Caption = '&Add' Caption = '&Add'
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
@ -100,10 +105,10 @@
end end
object BtnSkipAll: TButton object BtnSkipAll: TButton
Left = 85 Left = 85
Top = 7
Width = 60
Height = 20 Height = 20
Hint = 'Skip all, update and finish' Hint = 'Skip all, update and finish'
Top = 7
Width = 60
Caption = 'S&kip All' Caption = 'S&kip All'
ModalResult = 1 ModalResult = 1
ParentShowHint = False ParentShowHint = False

View File

@ -26,14 +26,11 @@ Known Issues:
unit JvSpellerForm; unit JvSpellerForm;
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
//{$I jvcl.inc}
interface interface
uses uses
SysUtils, Classes, Windows, Messages, Graphics, Controls, Forms, Dialogs, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;
StdCtrls, ExtCtrls,
JvComponent;
type type
TJvSpeller = class; TJvSpeller = class;
@ -89,23 +86,11 @@ type
property UserDictionary: TFileName read FUserDictionary write SetUserDictionary; property UserDictionary: TFileName read FUserDictionary write SetUserDictionary;
end; end;
{$IFDEF UNITVERSIONING}
const
UnitVersioning: TUnitVersionInfo = (
RCSfile: '$URL$';
Revision: '$Revision$';
Date: '$Date$';
LogPath: 'JVCL\run'
);
{$ENDIF UNITVERSIONING}
implementation implementation
uses uses
StrUtils, StrUtils,
{$IFNDEF COMPILER12_UP}
JvJCLUtils,
{$ENDIF ~COMPILER12_UP}
JvConsts, JvResources, JvTypes; JvConsts, JvResources, JvTypes;
{$R *.lfm} {$R *.lfm}