• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javaandroidc++linuxc#objective-ccocoa誰得qtrubypythongamewindowsbathyscaphephpguic翻訳omegattwitterframeworktestbtronarduinovb.net計画中(planning stage)directxpreviewerゲームエンジンdom

ギコナビ


Commit MetaInfo

Revisione1e1871c0000b5cae6fb86519f383614af43cca6 (tree)
Time2007-02-13 01:06:36
Authorh677 <h677>
Commiterh677

Log Message

NGの処理を正規表現利用化にして、
ためしに組み込んでみた。

Change Summary

Incremental Difference

--- a/HTMLCreate.pas
+++ b/HTMLCreate.pas
@@ -99,7 +99,7 @@ var
9999 implementation
100100
101101 uses
102- Trip;
102+ Trip, NGWordUnit;
103103
104104 const
105105 URL_CHAR: string = '0123456789'
@@ -771,16 +771,22 @@ begin
771771
772772 if (Trim(ReadList[i]) <> '') then begin
773773 DivideStrLine(ReadList[i], @Res);
774- AddAnchorTag(@Res);
775- ConvRes(@Res, @ResLink);
776- Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
777-
778- if NewReceiveNo <= (i + 1) then
779- // V’…ƒŒƒX
780- html.Add(SkinedRes(SkinNewRes, @Res, IntToStr(i + 1)))
781- else
782- // ’ʏí‚̃ŒƒX
783- html.Add(SkinedRes(SkinRes, @Res, IntToStr(i + 1)));
774+ if (NGWordList.IsNG(@Res) = -1) then begin
775+ AddAnchorTag(@Res);
776+ ConvRes(@Res, @ResLink);
777+ Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
778+
779+ if NewReceiveNo <= (i + 1) then
780+ // V’…ƒŒƒX
781+ html.Add(SkinedRes(SkinNewRes, @Res, IntToStr(i + 1)))
782+ else
783+ // ’ʏí‚̃ŒƒX
784+ html.Add(SkinedRes(SkinRes, @Res, IntToStr(i + 1)));
785+ end else begin
786+{$IFDEF DEBUG}
787+ html.Add('<h4>‚ ‚ځ`‚ñ</h4>');
788+{$ENDIF}
789+ end;
784790 end;
785791
786792 if ThreadItem.Kokomade = (i + 1) then begin
@@ -858,16 +864,22 @@ begin
858864 if (Trim(ReadList[i]) <> '') then begin
859865 No := IntToStr(i + 1);
860866 DivideStrLine(ReadList[i], @Res);
861- AddAnchorTag(@Res);
862- ConvRes(@Res, @ResLink);
863- Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
864- if Res.FMailTo = '' then
865- html.Add(Format(FORMAT_NOMAIL, [No, No, No, Res.FName, Res.FDateTime, Res.FBody]))
866- else if GikoSys.Setting.ShowMail then
867- html.Add(Format(FORMAT_SHOWMAIL, [No, No, No, Res.FMailTo, Res.FName, Res.FMailTo, Res.FDateTime, Res.FBody]))
868- else
869- html.Add(Format(FORMAT_NOSHOW, [No, No, No, Res.FMailTo, Res.FName, Res.FDateTime, Res.FBody]));
870- end;
867+ if (NGWordList.IsNG(@Res) = -1) then begin
868+ AddAnchorTag(@Res);
869+ ConvRes(@Res, @ResLink);
870+ Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
871+ if Res.FMailTo = '' then
872+ html.Add(Format(FORMAT_NOMAIL, [No, No, No, Res.FName, Res.FDateTime, Res.FBody]))
873+ else if GikoSys.Setting.ShowMail then
874+ html.Add(Format(FORMAT_SHOWMAIL, [No, No, No, Res.FMailTo, Res.FName, Res.FMailTo, Res.FDateTime, Res.FBody]))
875+ else
876+ html.Add(Format(FORMAT_NOSHOW, [No, No, No, Res.FMailTo, Res.FName, Res.FDateTime, Res.FBody]));
877+ end;
878+ end else begin
879+{$IFDEF DEBUG}
880+ html.Add('<h4>‚ ‚ځ`‚ñ</h4>');
881+{$ENDIF}
882+ end;
871883
872884 if ThreadItem.Kokomade = (i + 1) then begin
873885 html.Add('<a name="koko"></a><div class="koko">ƒRƒR‚Ü‚Å“Ç‚ñ‚¾</div>');
@@ -922,6 +934,7 @@ begin
922934 if (Trim(ReadList[i]) <> '') then begin
923935 No := IntToStr(i + 1);
924936 DivideStrLine(ReadList[i], @Res);
937+
925938 AddAnchorTag(@Res);
926939 ConvRes(@Res, @ResLink);
927940 Res.FDateTime := AddBeProfileLink(Res.FDateTime, i + 1);
@@ -931,7 +944,12 @@ begin
931944 html.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> –¼‘OF<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> [' + Res.FMailTo + '] “Še“úF <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10)
932945 else
933946 html.Add('<a name="' + No + '"></a><dt><a href="menu:' + No + '">' + No + '</a> –¼‘OF<a href="mailto:' + Res.FMailTo + '"><b> ' + Res.FName + ' </B></a> “Še“úF <span class="date">' + Res.FDateTime+ '</span><br><dd>' + Res.Fbody + ' <br><br><br>'#13#10);
934- end;
947+ end else begin
948+{$IFDEF DEBUG}
949+ html.Add('<h4>‚ ‚ځ`‚ñ</h4>');
950+{$ENDIF}
951+ end;
952+
935953 if ThreadItem.Kokomade = (i + 1) then begin
936954 html.Add('</dl>');
937955 html.Add('<a name="koko"></a><table width="100%" bgcolor="#55AA55" cellpadding="0" cellspacing="1"><tr><td align="center" bgcolor="#77CC77" valign="middle"><font size="-1" color="#ffffff"><b>ƒRƒR‚Ü‚Å“Ç‚ñ‚¾</b></font></td></tr></table>');
@@ -976,7 +994,7 @@ begin
976994 ReadList.LoadFromFile(FileName);
977995 ReadList.EndUpdate;
978996 GikoSys.FAbon.IndividualAbon(ReadList, ChangeFileExt(FileName,'.NG'));
979- GikoSys.FAbon.Execute(ReadList); // ‚ ‚ځ`‚ñ‚µ‚Ä
997+ //GikoSys.FAbon.Execute(ReadList); // ‚ ‚ځ`‚ñ‚µ‚Ä
980998 GikoSys.FSelectResFilter.Execute(ReadList); //ƒŒƒX‚̃tƒBƒ‹ƒ^ƒŠƒ“ƒO‚ð‚·‚é
981999 if ThreadItem.Title = '' then begin
9821000 DivideStrLine(ReadList[0], @Res);
--- a/NGWordEdit.dfm
+++ b/NGWordEdit.dfm
@@ -13,7 +13,6 @@ object NGWordEditForm: TNGWordEditForm
1313 Menu = MainMenu1
1414 OldCreateOrder = False
1515 OnCreate = FormCreate
16- OnDestroy = FormDestroy
1716 PixelsPerInch = 96
1817 TextHeight = 12
1918 object Panel1: TPanel
@@ -158,6 +157,7 @@ object NGWordEditForm: TNGWordEditForm
158157 Height = 25
159158 Caption = #22793#26356
160159 TabOrder = 0
160+ OnClick = ModifiedNGButtonClick
161161 end
162162 object AddNGButton: TButton
163163 Left = 24
@@ -190,6 +190,7 @@ object NGWordEditForm: TNGWordEditForm
190190 RowSelect = True
191191 TabOrder = 2
192192 ViewStyle = vsReport
193+ OnSelectItem = GikoListView2SelectItem
193194 end
194195 end
195196 object MainMenu1: TMainMenu
--- a/NGWordEdit.pas
+++ b/NGWordEdit.pas
@@ -33,7 +33,6 @@ type
3333 Save1: TMenuItem;
3434 procedure Load1Click(Sender: TObject);
3535 procedure Save1Click(Sender: TObject);
36- procedure FormDestroy(Sender: TObject);
3736 procedure FormCreate(Sender: TObject);
3837 procedure GikoListView1SelectItem(Sender: TObject; Item: TListItem;
3938 Selected: Boolean);
@@ -42,9 +41,11 @@ type
4241 procedure AddButtonClick(Sender: TObject);
4342 procedure DeleteButtonClick(Sender: TObject);
4443 procedure ApplyButtonClick(Sender: TObject);
44+ procedure ModifiedNGButtonClick(Sender: TObject);
45+ procedure GikoListView2SelectItem(Sender: TObject; Item: TListItem;
46+ Selected: Boolean);
4547 private
4648 { Private éŒ¾ }
47- FNGWordList : TNGWordList;
4849 function AddNGWord(ngWord: TNGWords): TListItem;
4950 procedure AddWord(word: TNGWord);
5051 public
@@ -65,16 +66,20 @@ var
6566 fname : String;
6667 i: Integer;
6768 begin
68- fname := GikoSys.GetAppDir + 'ngwords.xml';
69- if (FNGWordList <> nil) then begin
70- FNGWordList.Free;
71- end else begin
72- FNGWordList := TNGWordList.Create;
73- end;
74- FNGWordList.LoadFromFile(fname);
75- GikoListView1.Items.Clear;
76- for i :=0 to FNGWordList.Count - 1 do begin
77- AddNGWord(TNGWords(FNGWordList.Items[i]));
69+ GikoListView2.Items.BeginUpdate;
70+ GikoListView1.Items.BeginUpdate;
71+ try
72+ GikoListView2.Items.Clear;
73+ GikoListView1.Items.Clear;
74+ fname := GikoSys.GetAppDir + 'ngwords.xml';
75+ NGWordList.LoadFromFile(fname);
76+
77+ for i :=0 to NGWordList.Count - 1 do begin
78+ AddNGWord(TNGWords(NGWordList.Items[i]));
79+ end;
80+ finally
81+ GikoListView1.Items.EndUpdate;
82+ GikoListView2.Items.EndUpdate;
7883 end;
7984 end;
8085 function TNGWordEditForm.AddNGWord(ngWord: TNGWords): TListItem;
@@ -90,23 +95,17 @@ end;
9095
9196 procedure TNGWordEditForm.Save1Click(Sender: TObject);
9297 begin
93- if (FNGWordList <> nil) then begin
94- FNGWordList.SaveToFrile(GikoSys.GetAppDir + 'ngwords2.xml');
95- end;
96-end;
97-
98-procedure TNGWordEditForm.FormDestroy(Sender: TObject);
99-begin
100- if (FNGWordList <> nil) then begin
101- FreeAndNil(FNGWordList);
98+ if (NGWordList <> nil) then begin
99+ NGWordList.SaveToFrile(GikoSys.GetAppDir + 'ngwords2.xml');
102100 end;
103101 end;
104102
105103 procedure TNGWordEditForm.FormCreate(Sender: TObject);
106104 var
107105 column1,column2: TListColumn;
106+ i: Integer;
108107 begin
109- GikoListView1.Columns.BeginUpdate;
108+ GikoListView1.Columns.BeginUpdate;
110109 column1 := GikoListView1.Columns.Add;
111110 column1.ImageIndex := -1;
112111 column1.Caption := '“§–¾';
@@ -133,6 +132,11 @@ begin
133132 column2.Width := 190;
134133 GikoListView2.Columns.EndUpdate;
135134
135+ GikoListView1.Items.BeginUpdate;
136+ for i :=0 to NGWordList.Count - 1 do begin
137+ AddNGWord(TNGWords(NGWordList.Items[i]));
138+ end;
139+ GikoListView1.Items.EndUpdate;
136140 end;
137141 // ã•”ƒŠƒXƒg‘I‘ðƒCƒxƒ“ƒg
138142 procedure TNGWordEditForm.GikoListView1SelectItem(Sender: TObject;
@@ -227,9 +231,9 @@ procedure TNGWordEditForm.AddButtonClick(Sender: TObject);
227231 var
228232 ngWords: TNGWords;
229233 begin
230- if (FNGWordList <> nil) then begin
234+ if (NGWordList <> nil) then begin
231235 ngWords := TNGWords.Create;
232- FNGWordList.Add(ngWords);
236+ NGWordList.Add(ngWords);
233237 GikoListView1.Selected := AddNGWord(ngWords);
234238 GikoListView1.SetFocus;
235239 end;
@@ -241,8 +245,8 @@ var
241245 begin
242246 // Œ»Ý‘I‘ð‚³‚ê‚Ä‚¢‚és‚ðŽæ“¾‚·‚é
243247 litem := GikoListView1.Selected;
244- if (litem <> nil) and (FNGWordList <> nil) then begin
245- FNGWordList.Delte( TNGWords(litem.Data));
248+ if (litem <> nil) and (NGWordList <> nil) then begin
249+ NGWordList.Delte( TNGWords(litem.Data));
246250 GikoListView1.DeleteSelected;
247251 end;
248252 end;
@@ -258,4 +262,43 @@ begin
258262 end;
259263 end;
260264
265+procedure TNGWordEditForm.ModifiedNGButtonClick(Sender: TObject);
266+var
267+ litem, litem2: TListItem;
268+begin
269+ // Œ»Ý‘I‘ð‚³‚ê‚Ä‚¢‚és‚ðŽæ“¾‚·‚é
270+ litem := GikoListView1.Selected;
271+ if (litem <> nil) then begin
272+ litem2 := GikoListView2.Selected;
273+ if litem2 <> nil then begin
274+ TNGWord(litem2.Data).NGType := TGikoNGType(ComboBox1.ItemIndex);
275+ TNGWord(litem2.Data).Word := NGWordEdit.Text;
276+ litem.SubItems.Clear;
277+ litem.SubItems.Add(TNGWords(litem.Data).ToString);
278+
279+ case Integer(TNGWord(litem2.Data).NGType) of
280+ Integer(gntAll): litem2.Caption := '‘S•”';
281+ Integer(gntName): litem2.Caption := '–¼‘O—“';
282+ Integer(gntMail): litem2.Caption := 'ƒ[ƒ‹—“';
283+ Integer(gntDateId):litem2.Caption := '“ú•tID—“';
284+ Integer(gntBody): litem2.Caption := '–{•¶';
285+ end;
286+ litem2.SubItems.Clear;
287+ litem2.SubItems.Add(TNGWord(litem2.Data).Word);
288+ end;
289+ end;
290+end;
291+
292+procedure TNGWordEditForm.GikoListView2SelectItem(Sender: TObject;
293+ Item: TListItem; Selected: Boolean);
294+var
295+ word : TNGWord;
296+ i: Integer;
297+begin
298+ if (Item <> nil) and (Item.Data <> nil) then begin
299+ word := TNGWord(item.Data);
300+ ComboBox1.ItemIndex := Ord(word.NGType);
301+ NGWordEdit.Text := word.Word;
302+ end;
303+end;
261304 end.
--- a/NGWordUnit.pas
+++ b/NGWordUnit.pas
@@ -3,7 +3,7 @@ unit NGWordUnit;
33 interface
44 uses
55 Windows,Messages, ShellAPI, SysUtils, Classes,StdCtrls,StrUtils,
6- GikoXMLDoc, GikoSystem;
6+ GikoXMLDoc, GikoSystem, bmRegExp;
77
88 type
99 //ƒŠƒXƒg‚Ì•\Ž¦ƒAƒCƒeƒ€‘I‘ð
@@ -32,6 +32,7 @@ type
3232 private
3333 FRank : Integer;
3434 FInvisible: Boolean;
35+ FAWKStr: TAWKStr;
3536 public
3637 constructor Create;
3738 procedure Free;
@@ -41,6 +42,7 @@ type
4142 function ToXMLString(): String;
4243 function ToString(): String;
4344 procedure Delete(word: TNGWord); overload;
45+ function IsNG(PRes : PResRec): Boolean;
4446 end;
4547
4648 {\
@@ -53,10 +55,12 @@ type
5355 procedure LoadFromFile(fileName: String);
5456 procedure SaveToFrile(fileName: String);
5557 procedure Delte(NGWords: TNGWords); overload;
56- function IsNG(PRes : PResRec): Boolean;
58+ function IsNG(PRes : PResRec): Integer;
5759 end;
5860
5961 function CompareRank(Item1, Item2: Pointer): Integer;
62+var
63+ NGWordList: TNGWordList;
6064
6165 implementation
6266
@@ -76,6 +80,7 @@ end;
7680 constructor TNGWords.Create;
7781 begin
7882 FRank := 0;
83+ FAWKStr := TAWKStr.Create(nil);
7984 end;
8085 procedure TNGWords.Free;
8186 var
@@ -84,6 +89,7 @@ begin
8489 for i := 0 to Count - 1 do begin
8590 TObject(Items[i]).Free;
8691 end;
92+ FAWKStr.Free;
8793 inherited Free;
8894 end;
8995 function TNGWords.ReadXMLElement(element :IXMLNode): Boolean;
@@ -144,19 +150,66 @@ begin
144150 end;
145151 end;
146152 end;
153+function TNGWords.IsNG(PRes : PResRec): Boolean;
154+var
155+ i, oLength: Integer;
156+ RStart, RLength: Integer;
157+ word: TNGWord;
158+begin
159+ Result := True;
160+ for i := 0 to Count - 1 do begin
161+ word := TNGWord(Items[i]);
162+ FAWKStr.RegExp := word.Word;
163+ case Ord(word.FNGType) of
164+ Ord(gntAll):
165+ begin
166+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FTitle),
167+ RStart, RLength) <> 0;
168+ if Result then break;
169+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FMailTo),
170+ RStart, RLength) <> 0;
171+ if Result then break;
172+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FName),
173+ RStart, RLength) <> 0;
174+ if Result then break;
175+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FDateTime),
176+ RStart, RLength) <> 0;
177+ if Result then break;
178+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FBody),
179+ RStart, RLength) <> 0;
180+ end;
181+ Ord(gntName):
182+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FName),
183+ RStart, RLength) <> 0;
184+ Ord(gntMail):
185+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FMailTo),
186+ RStart, RLength) <> 0;
187+ Ord(gntDateId):
188+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FDateTime),
189+ RStart, RLength) <> 0;
190+ Ord(gntBody):
191+ Result := FAWKStr.Match(FAWKStr.ProcessEscSeq(PRes.FBody),
192+ RStart, RLength) <> 0;
193+ end;
194+ if not Result then Exit;
195+ end;
196+end;
197+
198+
147199 procedure TNGWord.ReadXMLElement(element :IXMLNode);
148200 begin
149- FRank := StrToIntDef(element.Attributes['rank'],
150- MaxInt);
151- FNGType := TGikoNGType(StrToIntDef(
152- Trim(element.Attributes['ngtype']),
153- Integer(gntAll)));
201+ FRank := StrToIntDef(element.Attributes['rank'],
202+ MaxInt);
203+ FNGType := TGikoNGType(StrToIntDef(
204+ Trim(element.Attributes['ngtype']),
205+ Integer(gntAll)));
154206
155- FWord := Trim(element.Attributes['word']);
156- if FWord <> '' then begin
157- FWord := MojuUtils.UnSanitize( FWord );
158- end;
207+ FWord := Trim(element.Attributes['word']);
208+ if FWord <> '' then begin
209+ FWord := MojuUtils.UnSanitize( FWord );
210+ end;
159211 end;
212+
160213 function TNGWord.ToXMLString(): String;
161214 begin
162215 Result := '<NGWord ' +
@@ -255,13 +308,30 @@ begin
255308 end;
256309 end;
257310 //! NG”»’è
258-function TNGWordList.IsNG(PRes : PResRec): Boolean;
311+function TNGWordList.IsNG(PRes : PResRec): Integer;
259312 var
260313 i: Integer;
314+ tRes : TResRec;
261315 begin
262- for i := 0 to Count - 1 do begin
263- //
316+ Result := -1;
317+ if Count > 0 then begin
318+ for i := 0 to Count - 1 do begin
319+ if (TNGWords(Items[i]).IsNG(PRes)) then begin
320+ Result := i;
321+ break;
322+ end;
323+ end;
264324 end;
265325 end;
266326
327+// ƒVƒ“ƒOƒ‹ƒgƒ“‚̃Cƒ“ƒXƒ^ƒ“ƒX
328+initialization
329+ NGWordList := TNGWordList.Create;
330+
331+finalization
332+ if NGWordList <> nil then begin
333+ NGWordList.Free;
334+ NGWordList := nil;
335+ end;
336+
267337 end.