OSDN Git Service

レスの書き込み時に tab や半角スペースを   に置換するようになった。
authoryoffy <yoffy>
Fri, 4 Jun 2004 08:06:56 +0000 (08:06 +0000)
committeryoffy <yoffy>
Fri, 4 Jun 2004 08:06:56 +0000 (08:06 +0000)
Editor.dfm
Editor.pas
Option.dfm
Option.pas
Setting.pas

index 5660e8e..1b6334e 100644 (file)
@@ -57,10 +57,10 @@ object EditorForm: TEditorForm
     Top = 30
     Width = 632
     Height = 297
-    ActivePage = EditorTab
+    ActivePage = PreviewTab
     Align = alClient
     MultiLine = True
-    TabIndex = 0
+    TabIndex = 1
     TabOrder = 0
     OnChange = EditorPageChange
     object EditorTab: TTabSheet
index 619285f..1e78591 100644 (file)
@@ -14,7 +14,7 @@ uses
        GikoSystem, GikoUtil, ImgList, Clipbrd, BoardGroup,
        IdAntiFreezeBase,       IdAntiFreeze, IdBaseComponent, IdComponent,
        IdTCPConnection, IdTCPClient, IdHTTP, ActnList, StdActns, IdIntercept,
-       IdLogBase, IdLogDebug, IdException, DateUtils;
+       IdLogBase, IdLogDebug, IdException, DateUtils, MojuUtils, bmRegExp;
 
 type
 //     TSetLayeredWindowAttributes = function(wnd: HWND; crKey: DWORD; bAlpha: BYTE; dwFlag: DWORD): Boolean; stdcall;
@@ -371,6 +371,7 @@ var
 
                                posTrip : Integer;
                                tripOrigin : string;
+       regexp  : TAWKStr;
 begin
        if FThreadItem = nil then begin
                No := '1';
@@ -380,9 +381,23 @@ begin
                Title := RepHtml(FThreadItem.Title);
        end;
 
+       body := BodyEdit.Text;
+       if GikoSys.Setting.SpaceToNBSP then begin
+               body := CustomStringReplace( body, #09, '&nbsp;&nbsp;&nbsp;&nbsp;' );
+               body := CustomStringReplace( body, '  ', '&nbsp;&nbsp;' );
+               body := CustomStringReplace( body, '&nbsp; ', '&nbsp;&nbsp;' );
+               regexp := TAWKStr.Create( nil );
+               try
+                       regexp.RegExp := '^ ';
+                       regexp.GSub( '\&nbsp;', body );
+               finally
+                       regexp.Free;
+               end;
+       end;
+
        Namae := RepHtml(NameComboBox.Text);
        Mail := RepHtml(MailComboBox.Text);
-       Body := RepHtml(BodyEdit.Text);
+       Body := RepHtml(body);
        Body := StringReplace(Body, #13#10, '<br>', [rfReplaceAll]);
        DateTime := FormatDateTime('yyyy/mm/dd(aaa) hh:nn', now);
 
@@ -780,6 +795,8 @@ var
        SendTime: Integer;
        Adjust: Integer;
        Board: TBoard;
+       body            : string;
+       regexp  : TAWKStr;
 begin
        if FThreadItem = nil then
                Board := FBoard
@@ -798,6 +815,21 @@ begin
                else
                        SendTime := GikoSys.DateTimeToInt(Board.LastGetTime);
        end;
+
+       body := BodyEdit.Text;
+       if GikoSys.Setting.SpaceToNBSP then begin
+               body := CustomStringReplace( body, #09, '&nbsp;&nbsp;&nbsp;&nbsp;' );
+               body := CustomStringReplace( body, '  ', '&nbsp;&nbsp;' );
+               body := CustomStringReplace( body, '&nbsp; ', '&nbsp;&nbsp;' );
+               regexp := TAWKStr.Create( nil );
+               try
+                       regexp.RegExp := '^ ';
+                       regexp.GSub( '\&nbsp;', body );
+               finally
+                       regexp.Free;
+               end;
+       end;
+
        SessionID := GikoSys.Dolib.SessionID;
        if SessionID <> '' then
                s := 'sid=' + HttpEncode(SessionID) + '&'
@@ -806,7 +838,7 @@ begin
        s := s + 'subject=&'
                                 + 'FROM=' + HttpEncode(NameComboBox.Text) + '&'
                                 + 'mail=' + HttpEncode(MailComboBox.Text) + '&'
-                                + 'MESSAGE=' + HttpEncode(BodyEdit.Text) + '&'
+                                + 'MESSAGE=' + HttpEncode(body) + '&'
                                 + 'bbs=' + Board.BBSID + '&'
                                 + 'time=' + IntToStr(SendTime) + '&';
        if FThreadItem = nil then begin
@@ -854,6 +886,8 @@ var
        Board: TBoard;
        rc: Integer;
        state : TGikoDownloadState;
+       body            : string;
+       regexp  : TAWKStr;
 begin
        if FWork then
                Exit;
@@ -887,10 +921,24 @@ begin
                end;
 
                if Board.IsBoardPlugInAvailable then begin
+                       body := BodyEdit.Text;
+                       if GikoSys.Setting.SpaceToNBSP then begin
+                               body := CustomStringReplace( body, #09, '&nbsp;&nbsp;&nbsp;&nbsp;' );
+                               body := CustomStringReplace( body, '  ', '&nbsp;&nbsp;' );
+                               body := CustomStringReplace( body, '&nbsp; ', '&nbsp;&nbsp;' );
+                               regexp := TAWKStr.Create( nil );
+                               try
+                                       regexp.RegExp := '^ ';
+                                       regexp.GSub( '\&nbsp;', body );
+                               finally
+                                       regexp.Free;
+                               end;
+                       end;
+
                        if FThreadItem = nil then begin
                                // \83X\83\8c\97§\82Ä
                                state := TGikoDownloadState( Board.BoardPlugIn.CreateThread(
-                                       DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, BodyEdit.Text ) );
+                                       DWORD( Board ), TitleEdit.Text, NameComboBox.Text, MailComboBox.Text, body ) );
 
                                if state = gdsComplete then begin
                                        GikoForm.PlaySound('ResEnd');
@@ -906,7 +954,7 @@ begin
                        end else begin
                                // \83\8c\83X
                                state := TGikoDownloadState( FThreadItem.BoardPlugIn.WriteThread(
-                                       DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, BodyEdit.Text ) );
+                                       DWORD( FThreadItem ), NameComboBox.Text, MailComboBox.Text, body ) );
 
                                if state = gdsComplete then begin
                                        GikoForm.PlaySound('ResEnd');
index 36faeb6..f4467bb 100644 (file)
@@ -51,9 +51,9 @@ object OptionDialog: TOptionDialog
     Top = 4
     Width = 509
     Height = 389
-    ActivePage = ThreadSheet
+    ActivePage = TabSheet5
     MultiLine = True
-    TabIndex = 5
+    TabIndex = 13
     TabOrder = 0
     OnChange = OptionTabChange
     object ConnectSheet: TTabSheet
@@ -1432,6 +1432,10 @@ object OptionDialog: TOptionDialog
         end
       end
     end
+    object TabSheet5: TTabSheet
+      Caption = #12456#12487#12451#12479
+      ImageIndex = 13
+    end
   end
   object ApplyButton: TButton
     Left = 424
index da29059..a7f75ae 100644 (file)
@@ -183,6 +183,7 @@ type
     GroupBox5: TGroupBox;
     BrowserMaxLabel: TLabel;
     BrowserMaxCombo: TComboBox;
+    TabSheet5: TTabSheet;
                procedure FormCreate(Sender: TObject);
                procedure FormDestroy(Sender: TObject);
                procedure ApplyButtonClick(Sender: TObject);
index d50a3e3..15595f5 100644 (file)
@@ -302,6 +302,9 @@ type
                //\83\8c\83X\83A\83\93\83J\81[\82ð\83N\83\8a\83b\83N\82µ\82Ä\83W\83\83\83\93\83v\82·\82é\82©
                FResAnchorJamp: Boolean;
 
+               // \83G\83f\83B\83^
+               FSpaceToNBSP    : Boolean;
+               
                function GetMainCoolSet(Index: Integer): TCoolSet;
                function GetBoardCoolSet(Index: Integer): TCoolSet;
                function GetBrowserCoolSet(Index: Integer): TCoolSet;
@@ -561,7 +564,10 @@ type
                property OddColor: TColor read FOddColor write FOddColor;
                property UseSamba: Boolean read FUseSamba write FUseSamba;
         property ResAnchorJamp: Boolean read FResAnchorJamp write FResAnchorJamp;
-       end;
+
+               // \83G\83f\83B\83^
+               property SpaceToNBSP    : Boolean       read FSpaceToNBSP write FSpaceToNBSP;
+end;
 
 
 
@@ -950,6 +956,9 @@ begin
                FShowNGLinesNum := ini.ReadBool('Abon','ShowNGLines',false);
                FAddResAnchor := ini.ReadBool('Abon','AddResAnchor',false);
         FDeleteSyria :=  ini.ReadBool('Abon','DeleteSyria',false);
+
+               // \83G\83f\83B\83^
+               FSpaceToNBSP    := ini.ReadBool( 'Editor', 'SpaceToNBSP', True );
        finally
                ini.Free;
        end;
@@ -1225,7 +1234,10 @@ begin
                                ini.WriteBool('Abon','Popup',FPopUpAbon);
                ini.WriteBool('Abon','ShowNGLines',FShowNGLinesNum);
                ini.WriteBool('Abon','AddResAnchor',FAddResAnchor);
-        ini.WriteBool('Abon','DeleteSyria',FDeleteSyria);
+                               ini.WriteBool('Abon','DeleteSyria',FDeleteSyria);
+
+               // \83G\83f\83B\83^
+               ini.WriteBool( 'Editor', 'SpaceToNBSP', FSpaceToNBSP );
 
                ini.UpdateFile;
        finally