핸들러 기능 참고 http://nscc4.tistory.com/4, http://nscc4.tistory.com/50



1. 핸들러에 저장시 <br>태그 넣기와 2. Sync 태그를 대문자로 바꾸기는 기능을 매크로에서 써보겠습니다.


매크로에서 사용가능한 명령어 http://nscc4.tistory.com/19





1. 저장시 <br> 넣기 매크로로 쓰기

http://nscc4.tistory.com/50 이 코드에서 var부터 복사해서 매크로에 넣어 쓰시면 됩니다.


var
  ClearTagFlag: Boolean;
  CommentTagFlag: Boolean; //주석 태그 체크
  StartTagFlag: Boolean;
  LoopVar: Integer;//줄번호
  CurrentLine: WideString; //현재 줄
  NextLine: WideString; //다음 줄

  AddBRCount: Integer; //<br> 추가 개수
begin

  ClearTagFlag := False;
  StartTagFlag := False;
  For LoopVar := 0 To CC_CURRENTLINECOUNT-2 Do
  Begin

     CurrentLine := TrimW(CC_GETLINETEXT(LoopVar));
     NextLine := TrimW(CC_GETLINETEXT(LoopVar+1));
// 싱크 중간 긴 주석문에 <br> 안 들어가게 하는 체크문
     If (CommentTagFlag) and (Pos('-->', CurrentLine) > 0) or (CommentTagFlag) and (Pos('-->', NextLine) > 0) Then CommentTagFlag := False;

     If CC_ISSYNCLINE(LoopVar) Then
     Begin
        If Not StartTagFlag Then StartTagFlag := True;
        Continue;
     End;
    
     If Not StartTagFlag Then Continue;

     If CC_ISSYNCLINE(LoopVar+1) Then
        Continue;

// 대사, &nbsp; 아래 줄에 공백일 때 <br> 안 들어가게 하는 if문
     If (CurrentLine = '') or (CurrentLine = '&nbsp;') or (NextLine = '') or (NextLine = '&nbsp;') Then
     Begin
        ClearTagFlag := True;
        Continue;
     End;

// 싱크 중간 긴 주석문에 <br> 안 들어가게 하는 체크문
     If (Pos('<!--', CurrentLine) > 0) or (Pos('<!--', NextLine) > 0) Then CommentTagFlag := True;
     If (CommentTagFlag) and (Pos('-->', CurrentLine) > 0) or (CommentTagFlag) and (Pos('-->', NextLine) > 0) Then CommentTagFlag := False;

     If (Pos('-->', CurrentLine) > 0) and (Pos('-->', CurrentLine) > Length(CurrentLine)-3) or (Pos('-->', NextLine) > 0) and (Pos('-->', NextLine) > Length(NextLine)-3) Then Continue;
     If (CurrentLine <> '') or (CurrentLine <> '&nbsp;') or (NextLine <> '') or (NextLine <> '&nbsp;') Then ClearTagFlag := False;

     If ClearTagFlag or CommentTagFlag Then Continue;

     If (Pos('</BODY', UpperCase(CurrentLine)) <> 0) or (Pos('</BODY', UpperCase(NextLine)) <> 0) Then Break;

     If UpperCase( Copy(CurrentLine, Length(CurrentLine)-3, 4) ) <> '<BR>' Then
     Begin
        CC_MODIFYLINE(LoopVar, CurrentLine+'<BR>');
        AddBRCount := AddBRCount + 1;
     End;

  End;

//핸들러로 <br> 추가 개수가 1개 이상이면 메시지박스 출력,
//<br> 1개라도 추가한 게 없으면 메세지박스 안 뜨게 했습니다.
if AddBRCount > 0 then ShowMessage('총 '+IntToStr(AddBRCount) + ' 개의 <BR> 태그가 추가되었습니다.');

end; 


2. Sync태그 대문자로 바꾸기 매크로로 쓰기

http://nscc4.tistory.com/50 이 코드에서 이 코드에서 var부터 복사해서 매크로에 넣어 쓰시면 됩니다.


var
  LoopVar: Integer;
  CurrentLine: WideString;   
begin
  For LoopVar := 0 To CC_CURRENTLINECOUNT-1 Do
  Begin
     CurrentLine := TrimW(CC_GETLINETEXT(LoopVar));

     If Pos('<SYNC', UpperCase(CurrentLine)) > 0 Then
     Begin       
        CurrentLine := CC_STRINGREPLACE(CurrentLine, '<SYNC', '<SYNC');
        CC_MODIFYLINE(LoopVar, CurrentLine);
     End;
  End;
end;


Posted by 투명인간취급
,