OSDN Git Service

・「板一覧更新」で削除要請板のURLを強制的に変更する機能を追加
authorzako <zako@users.sourceforge.jp>
Sat, 18 Oct 2014 15:16:10 +0000 (00:16 +0900)
committerzako <zako@users.sourceforge.jp>
Sat, 18 Oct 2014 15:16:10 +0000 (00:16 +0900)
・「2ちゃんねるスレタイ検索」で広告表示エリアに注意書きを追加
・レスエディタがUnicodeモード時、[引用して貼り付け]でUnicode文字が化ける不具合を修正

Editor.pas
NewBoard.dfm
NewBoard.pas
Setting.pas
ThreadSearch.pas
WideMemo.pas

index 4588db7..8083c37 100644 (file)
@@ -1543,21 +1543,22 @@ var
 begin
 
        quote   := GikoSys.GetOEIndentChar;
-       s                       := TStringList.Create;
-       try
-               s.Text  := Clipboard.AsText;
 
-               for i := s.Count - 1 downto 0 do
-                       s[ i ]  := quote + s[ i ];
+    if (FUseUC = True) then begin
+        BodyEditUC.QuotePaste(quote);
+    end else begin
+        s                      := TStringList.Create;
+        try
+            s.Text     := Clipboard.AsText;
 
-        if (FUseUC = True) then
-                   BodyEditUC.SelText  := s.Text
-        else
-                   BodyEdit.SelText    := s.Text;
-       finally
-               s.Free;
-       end;
+            for i := s.Count - 1 downto 0 do
+                s[ i ] := quote + s[ i ];
 
+            BodyEdit.SelText    := s.Text;
+        finally
+            s.Free;
+        end;
+    end;
 end;
 
 procedure TEditorForm.SpaceToNBSPActionExecute(Sender: TObject);
index 9069dfc..f4edbbb 100644 (file)
@@ -3,7 +3,7 @@ object NewBoardDialog: TNewBoardDialog
   Top = 197
   BorderStyle = bsDialog
   Caption = #26495#19968#35239#26356#26032
-  ClientHeight = 329
+  ClientHeight = 346
   ClientWidth = 462
   Color = clBtnFace
   Font.Charset = SHIFTJIS_CHARSET
@@ -48,7 +48,7 @@ object NewBoardDialog: TNewBoardDialog
   end
   object UpdateButton: TButton
     Left = 220
-    Top = 300
+    Top = 316
     Width = 75
     Height = 21
     Caption = #26356#26032
@@ -57,7 +57,7 @@ object NewBoardDialog: TNewBoardDialog
   end
   object CloseButton: TButton
     Left = 380
-    Top = 300
+    Top = 316
     Width = 75
     Height = 21
     Caption = #38281#12376#12427
@@ -66,7 +66,7 @@ object NewBoardDialog: TNewBoardDialog
   end
   object StopButton: TButton
     Left = 300
-    Top = 300
+    Top = 316
     Width = 75
     Height = 21
     Caption = #20013#27490
@@ -84,13 +84,21 @@ object NewBoardDialog: TNewBoardDialog
   end
   object EditIgnoreListsButton: TButton
     Left = 8
-    Top = 299
+    Top = 315
     Width = 113
     Height = 21
     Caption = #38500#22806#12459#12486#12468#12522#12540#32232#38598
-    TabOrder = 5
+    TabOrder = 6
     OnClick = EditIgnoreListsButtonClick
   end
+  object SakuCheckBox: TCheckBox
+    Left = 8
+    Top = 288
+    Width = 361
+    Height = 17
+    Caption = #12300#21066#38500#35201#35531#12301#26495#12364#12300'saku'#12301#12398#22580#21512#12300'saku2ch'#12301#12395#32622#12365#25563#12360#12427'(&S)'
+    TabOrder = 5
+  end
   object Indy: TIdHTTP
     MaxLineAction = maException
     RecvBufferSize = 4096
index 8a3385e..1cf9497 100644 (file)
@@ -26,6 +26,7 @@ type
        Label13: TLabel;
        EditIgnoreListsButton: TButton;
        Label2: TLabel;
+    SakuCheckBox: TCheckBox;
                procedure UpdateButtonClick(Sender: TObject);
                procedure StopButtonClick(Sender: TObject);
                procedure CloseButtonClick(Sender: TObject);
@@ -193,6 +194,7 @@ var
        ini: TMemIniFile;
        oldURLs : TStringList;
        newURLs : TStringList;
+    SakuIdx: Integer;
 begin
        Change := False;
        MessageMemo.Lines.Add('\90V\94Â\81A\94ÂURL\95Ï\8dX\83`\83F\83b\83N\82ð\8aJ\8en\82µ\82Ü\82·');
@@ -273,6 +275,11 @@ begin
                                                if i <> 0 then begin
                                                        URL := Trim(Copy(tmp, 1, i - 1));
                                                        Title := Copy(tmp, i + 1, Length(tmp));
+                            if (SakuCheckBox.Checked = True) and (Title = '\8dí\8f\9c\97v\90¿') then begin
+                                SakuIdx := Pos('.2ch.net/saku/', URL);
+                                if (SakuIdx > 0) then
+                                    URL := Copy(URL, 1, SakuIdx - 1) + '.2ch.net/saku2ch/';
+                            end;
                             // BBSs\82ª\8bó\91Î\8dô
                             if Length(BBSs) = 0 then begin
                                 Board := nil;
@@ -395,6 +402,8 @@ begin
                BoardURLComboBox.ItemIndex := 0;
        end;
        SetIgnoreCategory(false);
+
+    SakuCheckBox.Checked := GikoSys.Setting.SakuBoard;
 end;
 //\94Â\8dX\90V\82Ì\8f\9c\8aO\83J\83e\83S\83\8a\83\8a\83X\83g\82Ì\93o\98^
 {['\82¨\82·\82·\82ß', '\93Á\95Ê\8aé\89æ', '\82Ü\82¿\82a\82a\82r', '\83`\83\83\83b\83g', '\82¨\8aG\82©\82«', '\89^\89c\88Ä\93à', '\83c\81[\83\8b\97Þ', '\91¼\82Ì\83T\83C\83g']}
@@ -458,6 +467,7 @@ end;
 procedure TNewBoardDialog.FormClose(Sender: TObject;
   var Action: TCloseAction);
 begin
+    GikoSys.Setting.SakuBoard := SakuCheckBox.Checked;
        IgnoreLists.Free;
 end;
 //! \83\8d\81[\83J\83\8b\83t\83@\83C\83\8b\82ð\83\8d\81[\83h\82·\82é
index 194e699..7b9a6a4 100644 (file)
@@ -470,6 +470,8 @@ type
         FUseGobakuCheck: Boolean;
         //! Unicode\94Å\83G\83f\83B\83^
         FUseUnicode: Boolean;
+        //! \8dí\8f\9c\97v\90¿\94Â\82ð\93Á\95Ê\88µ\82¢
+        FSakuBoard: Boolean;
 
                //! \83X\83\8c\83^\83C\8c\9f\8dõ\83E\83B\83\93\83h\83E
                FThrdSrchTop: Integer;
@@ -867,6 +869,8 @@ type
         property UseGobakuCheck: Boolean read FUseGobakuCheck write FUseGobakuCheck;
         //! Unicode\94Å\83G\83f\83B\83^
         property UseUnicode: Boolean read FUseUnicode write FUseUnicode;
+        //! \8dí\8f\9c\97v\90¿\94Â\82ð\93Á\95Ê\88µ\82¢
+        property SakuBoard: Boolean read FSakuBoard write FSakuBoard;
                //! \83X\83\8c\83^\83C\8c\9f\8dõ\83E\83B\83\93\83h\83E
                //! \83X\83\8c\83^\83C\8c\9f\8dõ\83E\83B\83\93\83h\83E
                property ThrdSrchTop: Integer read FThrdSrchTop write FThrdSrchTop;
@@ -1362,6 +1366,9 @@ begin
                //\97\9a\97ð\82Ì\8dÅ\91å\95Û\91\8c\8f\90\94
                FMaxRecordCount := Max(ini.ReadInteger('Recode', 'Max', 100), 1);
 
+        //! \8dí\8f\9c\97v\90¿\94Â\82ð\93Á\95Ê\88µ\82¢
+        FSakuBoard := ini.ReadBool('NewBoard', 'SakuSpecial', True);
+
                // \93ü\97Í\83A\83V\83X\83g
                FInputAssistFormTop := ini.ReadInteger('IAtWindowsSize', 'Top', 0);
                FInputAssistFormLeft := ini.ReadInteger('IAtWindowsSize', 'Left', 0);
@@ -1781,6 +1788,9 @@ begin
         ini.WriteBool( 'Editor', 'UseGobakuCheck', FUseGobakuCheck );
         ini.WriteBool( 'Editor', 'UseUnicode', FUseUnicode );
 
+        //! \8dí\8f\9c\97v\90¿\94Â\82ð\93Á\95Ê\88µ\82¢
+        ini.WriteBool('NewBoard', 'SakuSpecial', FSakuBoard);
+
                 //\83^\83u\8e©\93®\95Û\91
                ini.WriteBool('TabAuto', 'TabAutoLoadSave', FTabAutoLoadSave);
         ini.WriteString('Thread', 'LastCloseTabURL', FLastCloseTabURL);
index db30e1c..b3e451f 100644 (file)
@@ -92,6 +92,8 @@ function ConvertINetString(lpdwMode: LPDWORD;
 var
   ThreadSrch: TThreadSrch = nil;
 const
+    HTML_HD: String = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"><title></title></head><body>';
+    HTML_FT: String = '</body></html>';
     ENC_SJIS: DWORD = 932;
     ENC_UTF8: DWORD = 65001;
 
@@ -339,9 +341,6 @@ begin
 end;
 
 function TThreadSrch.ParsJson(JsonStream: TMemoryStream): Boolean;
-const
-    HTML_HD: String = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=Shift_JIS"><title></title></head><body>';
-    HTML_FT: String = '</body></html>';
 var
     vJsonObj: TlkJsonObject;
     vCm: TlkJSONbase;
@@ -614,6 +613,8 @@ begin
 end;
 
 procedure TThreadSrch.FormShow(Sender: TObject);
+const
+    HTML_INF = '<font size="-1">\8c\9f\8dõ\82·\82é\82Æ\81A\82±\82±\82É http://dig.2ch.net/ \82©\82ç\82Ì\8dL\8d\90\82ª\95\\8e¦\82³\82ê\82Ü\82·\81B<br>\8dL\8d\90\82Ì\93à\97e\81A\8eû\89v\82È\82Ç\82É\82Â\82¢\82Ä\83M\83R\83i\83r\8aJ\94­\8eÒ\82Í\88ê\90Ø\8aÖ\92m\82µ\82Ä\82¨\82è\82Ü\82¹\82ñ\81B</font>';
 var
     Ini: TIniFile;
     Sec: TStringList;
@@ -643,6 +644,7 @@ begin
     PnlBbsName.Caption := '';
     PnlBbsId.Caption := '';
 //    CmBrowser.Navigate('about:blank');
+    SetCm(HTML_HD + HTML_INF + HTML_FT);
 
     PopMenuBbs.Items.Clear;
     BbsNmList.Clear;
index 803f31b..5bf94bb 100644 (file)
@@ -13,12 +13,15 @@ private
     function GetWideText: WideString;
     function GetEncodeText: AnsiString;
     procedure SetEncodeText(SrcText: AnsiString);
+    function SetClipboard(SrcText: WideString): Boolean;
+    function GetClipboard(IsClear: Boolean): WideString;
 protected
     procedure CreateWindowHandle(const Params: TCreateParams); override;
 public
     constructor Create(AOwner: TComponent); override;
     procedure Free;
     procedure InsertText(InsText: WideString);
+    procedure QuotePaste(QuoteStr: AnsiString);
     property EncodeText: AnsiString read GetEncodeText write SetEncodeText;
 end;
 
@@ -57,9 +60,6 @@ var
 //    BufUCSize: Integer;
     PosS: LongWord;
     PosE: LongWord;
-    TextUC: WideString;
-    MemHandle: HGLOBAL;
-    TextP: PWideChar;
 begin
 //    Len := GetWindowTextLengthW(Handle);
 //    Len := Perform(WM_GETTEXTLENGTH, 0, 0);
@@ -77,19 +77,7 @@ begin
        SendMessage(Handle, WM_COPY, 0, 0);
        SendMessage(Handle, EM_SETSEL, WPARAM(PosS), LPARAM(PosE));
 
-    if (OpenClipboard(Handle) = True) then begin
-        MemHandle := GetClipboardData(CF_UNICODETEXT);
-        if (MemHandle <> 0) then begin
-            TextP := PWideChar(GlobalLock(MemHandle));
-            if not (TextP = nil) then begin
-                TextUC := WideString(TextP);
-                GlobalUnlock(MemHandle);
-            end;
-        end;
-        EmptyClipboard;
-        CloseClipboard;
-    end;
-    Result := TextUC;
+    Result := GetClipboard(True);
 end;
 
 function TWideMemo.GetEncodeText: AnsiString;
@@ -165,17 +153,63 @@ begin
     SetWindowTextW(Handle, PWideChar(TextUC));
 end;
 
-procedure TWideMemo.InsertText(InsText: WideString);
+function TWideMemo.SetClipboard(SrcText: WideString): Boolean;
 var
     LenUC: Integer;
     BufUC: PWideChar;
     BufUCSize: Integer;
+    MemHandle: HGLOBAL;
+    CopySize: Integer;
+begin
+    LenUC := Length(SrcText);
+    CopySize := LenUC * SizeOf(WideChar);
+    BufUCSize := (LenUC + 1) * SizeOf(WideChar);
+    MemHandle := GlobalAlloc(GMEM_DDESHARE or GMEM_MOVEABLE, BufUCSize);
+    BufUC := GlobalLock(MemHandle);
+    ZeroMemory(BufUC, BufUCSize);
+    CopyMemory(BufUC, PWideChar(SrcText), CopySize);
+    GlobalUnlock(MemHandle);
+
+    if (OpenClipboard(Handle) = True) then begin
+        EmptyClipboard;
+        SetClipboardData(CF_UNICODETEXT, MemHandle);
+        CloseClipboard;
+        Result := True;
+    end else begin
+        GlobalFree(MemHandle);
+        Result := False;
+    end;
+end;
+
+function TWideMemo.GetClipboard(IsClear: Boolean): WideString;
+var
+    TextGet: WideString;
+    MemHandle: HGLOBAL;
+    TextP: PWideChar;
+begin
+    if (OpenClipboard(Handle) = True) then begin
+        MemHandle := GetClipboardData(CF_UNICODETEXT);
+        if (MemHandle <> 0) then begin
+            TextP := PWideChar(GlobalLock(MemHandle));
+            if not (TextP = nil) then begin
+                TextGet := WideString(TextP);
+                GlobalUnlock(MemHandle);
+            end;
+        end;
+        if (IsClear = True) then
+            EmptyClipboard;
+        CloseClipboard;
+    end;
+    Result := TextGet;
+end;
+
+procedure TWideMemo.InsertText(InsText: WideString);
+var
 //    SelS: LongWord;
 //    SelE: LongWord;
 //    FullText: WideString;
 //    AftCurPos: LongInt;
-    MemHandle: HGLOBAL;
-    CopySize: Integer;
+    TextOrg: WideString;
 begin
 (*
     FullText := GetWideText;
@@ -195,25 +229,44 @@ begin
     SendMessageW(Handle, EM_SETSEL, AftCurPos, AftCurPos);
 *)
 
-    LenUC := Length(InsText);
-    CopySize := LenUC * SizeOf(WideChar);
-    BufUCSize := (LenUC + 1) * SizeOf(WideChar);
-    MemHandle := GlobalAlloc(GMEM_DDESHARE or GMEM_MOVEABLE, BufUCSize);
-    BufUC := GlobalLock(MemHandle);
-    ZeroMemory(BufUC, BufUCSize);
-    CopyMemory(BufUC, PWideChar(InsText), CopySize);
-    GlobalUnlock(MemHandle);
+    TextOrg := GetClipboard(False);
 
-    if (OpenClipboard(Handle) = True) then begin
-        EmptyClipboard;
-        SetClipboardData(CF_UNICODETEXT, MemHandle);
-        CloseClipboard;
+    if (SetClipboard(InsText) = True) then begin
 
         SendMessageW(Handle, WM_PASTE, 0, 0);
-    end else begin
-        GlobalFree(MemHandle);
+
+        SetClipboard(TextOrg);
     end;
+
     Change;
 end;
 
+procedure TWideMemo.QuotePaste(QuoteStr: AnsiString);
+var
+    TextDst: WideString;
+    TextSrc: WideString;
+    QuoteUC: WideString;
+    RetChar: WideString;
+    Ret: Integer;
+begin
+    TextSrc := GetClipboard(False);
+    QuoteUC := QuoteStr;
+    RetChar := AnsiString(#13#10);
+
+    while (Length(TextSrc) > 0) do begin
+        Ret := Pos(RetChar, TextSrc);
+        if (Ret < 1) then begin // \89ü\8ds\82È\82µ
+            TextDst := TextDst + QuoteUC + TextSrc;
+            Break;
+        end;
+
+        // \89ü\8ds\82Ü\82Å\82Ì1\8ds
+        TextDst := TextDst + QuoteUC + Copy(TextSrc, 1, Ret + 1);
+        Delete(TextSrc, 1, Ret + 1);
+    end;
+
+    if (Length(TextDst) > 0) then
+        InsertText(TextDst);
+end;
+
 end.