notepad2 컴파일 삽질기 부록#11 : 포트란 스킴 추가

회사에서 일을 하면서 포트란 소스를 C++로 변환할 일이 생겼다.
notepad2에서 포트란 스킴을 지원하는 줄 알았는데, 지금 보니 지원하지 않았다. 헐~

그래서 포트란 스킴을 추가하기로 했다.
notepad2에서 사용하는 Scintilla에서는 포트란 스킴은 지원하지만, 이를 notepad2에서 사용하지 않는 것이다.
따라서, 이를 사용하기 위해서는 조금만 수정하면 된다.

포트란 스킴을 사용하려면 아래와 같이 수정하면 된다.


1. Notepad2.rc 수정

아래와 같은 부분을 찾는다.
    63016                   "Batch Files"
    63017                   "Diff Files"
    63018                   "SQL Query"
    63019                   "Python Script"
    63020                   "Apache Config Files"
    63021                   "PowerShell Script"
END

여기에 아래와 같이 한 줄을 추가한다. 위치는 물론 END 바로 앞이며, 언어를 이미 추가한 경우 적절히 알아서 한다.
    63022                   "Fortran Source Code"
   63023                   "Fortran77 Source Code"


2. Styles.h 수정

아래와 같은 부분을 찾는다.
// Number of Lexers in pLexArray
#define NUMLEXERS 30

NUMLEXERS의 값을 둘 증가시킨다. 아래처럼.


#define NUMLEXERS 32


3. Styles.c 수정 #1

아래와 같은 부분을 찾는다.
// This array holds all the lexers...
PEDITLEXER pLexArray[NUMLEXERS] =
{
  &lexDefault,

바로 앞에 아래와 같은 코드를 추가한다.



// FORTRAN added by BLUEnLIVE - 25th June 2010
KEYWORDLIST KeyWords_FORTRAN = {
"abs achar acos acosd adjustl adjustr aimag aimax0 aimin0 aint ajmax0 "
"ajmin0 akmax0 akmin0 all allocated alog alog10 amax0 amax1 amin0 amin1 "
"amod anint any asin asind associated atan atan2 atan2d atand bitest bitl "
"bitlr bitrl bjtest bit_size bktest break btest cabs ccos cdabs cdcos cdexp "
"cdlog cdsin cdsqrt ceiling cexp char clog cmplx conjg cos cosd cosh count "
"cpu_time cshift csin csqrt dabs dacos dacosd dasin dasind datan datan2 "
"datan2d datand date date_and_time dble dcmplx dconjg dcos dcosd dcosh "
"dcotan ddim dexp dfloat dflotk dfloti dflotj digits dim dimag dint dlog "
"dlog10 dmax1 dmin1 dmod dnint dot_product dprod dreal dsign dsin dsind "
"dsinh dsqrt dtan dtand dtanh eoshift epsilon errsns exp exponent float "
"floati floatj floatk floor fraction free huge iabs iachar iand ibclr ibits "
"ibset ichar idate idim idint idnint ieor ifix iiabs iiand iibclr iibits "
"iibset iidim iidint iidnnt iieor iifix iint iior iiqint iiqnnt iishft "
"iishftc iisign ilen imax0 imax1 imin0 imin1 imod index inint inot int "
"int1 int2 int4 int8 iqint iqnint ior ishft ishftc isign isnan izext jiand "
"jibclr jibits jibset jidim jidint jidnnt jieor jifix jint jior jiqint jiqnnt "
"jishft jishftc jisign jmax0 jmax1 jmin0 jmin1 jmod jnint jnot jzext kiabs "
"kiand kibclr kibits kibset kidim kidint kidnnt kieor kifix kind kint kior "
"kishft kishftc kisign kmax0 kmax1 kmin0 kmin1 kmod knint knot kzext lbound "
"leadz len len_trim lenlge lge lgt lle llt log log10 logical lshift malloc "
"matmul max max0 max1 maxexponent maxloc maxval merge min min0 min1 "
"minexponent minloc minval mod modulo mvbits nearest nint not nworkers "
"number_of_processors pack popcnt poppar precision present product radix "
"random random_number random_seed range real repeat reshape rrspacing rshift "
"scale scan secnds selected_int_kind selected_real_kind set_exponent shape "
"sign sin sind sinh size sizeof sngl snglq spacing spread sqrt sum "
"system_clock tan tand tanh tiny transfer transpose trim ubound unpack verify",
"access action advance allocatable allocate apostrophe assign assignment "
"associate asynchronous backspace bind blank blockdata call case character "
"class close common complex contains continue cycle data deallocate decimal "
"delim default dimension direct do dowhile double doubleprecision else elseif "
"elsewhere encoding end endassociate endblockdata enddo endfile endforall "
"endfunction endif endinterface endmodule endprogram endselect endsubroutine "
"endtype endwhere entry eor equivalence err errmsg exist exit external file "
"flush fmt forall form format formatted function go goto id if implicit in "
"include inout integer inquire intent interface intrinsic iomsg iolength "
"iostat kind len logical module name named namelist nextrec nml none nullify "
"number only open opened operator optional out pad parameter pass pause "
"pending pointer pos position precision print private program protected "
"public quote read readwrite real rec recl recursive result return rewind "
"save select selectcase selecttype sequential sign size stat status stop "
"stream subroutine target then to type unformatted unit use value volatile "
"wait where while write",
"", "", "", "", "", "", "" };

EDITLEXER lexFORTRAN = { SCLEX_FORTRAN, 63022, L"Fortran Source Code", L"f; for; f90; f95", L"", &KeyWords_FORTRAN, {
    { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
    { SCE_F_COMMENT, 63127, L"Comment", L"italics; fore:#008000", L"" },
    { SCE_F_NUMBER, 63130, L"Number", L"bold; fore:#0000FF", L"" },
    { MULTI_STYLE(SCE_F_STRING1,SCE_F_STRING2,SCE_F_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" },
    { MULTI_STYLE(SCE_F_OPERATOR,SCE_F_OPERATOR,0,0), 63132, L"Operator", L"bold", L"" },
    { SCE_F_IDENTIFIER, 63281, L"Identifier", L"bold; fore:#C80000", L"" },
    { SCE_F_WORD, 63236, L"Word", L"fore:#0000A0; bold", L"" },
    { SCE_F_WORD2, 63260, L"Word2", L"fore:#0000FF; bold", L"" },
    { SCE_F_WORD3, 63203, L"Word3", L"fore:#008000; bold", L"" },
    { SCE_F_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
    { SCE_F_LABEL, 63235, L"Label", L"fore:#000000; back:#FFFFD1; bold", L"" },
    { SCE_F_CONTINUATION, 63257, L"Continuation", L"back:#FFC0C0", L"" },
    { -1, 00000, L"", L"", L"" } } };

EDITLEXER lexFORTRAN77 = { SCLEX_F77, 63023, L"Fortran77 Source Code", L"f77", L"", &KeyWords_FORTRAN, {
    { STYLE_DEFAULT, 63126, L"Default", L"", L"" },
    { SCE_F_COMMENT, 63127, L"Comment", L"italics; fore:#008000", L"" },
    { SCE_F_NUMBER, 63130, L"Number", L"bold; fore:#0000FF", L"" },
    { MULTI_STYLE(SCE_F_STRING1,SCE_F_STRING2,SCE_F_STRINGEOL,0), 63131, L"String", L"fore:#008000", L"" },
    { MULTI_STYLE(SCE_F_OPERATOR,SCE_F_OPERATOR,0,0), 63132, L"Operator", L"bold", L"" },
    { SCE_F_IDENTIFIER, 63281, L"Identifier", L"bold; fore:#C80000", L"" },
    { SCE_F_WORD, 63236, L"Word", L"fore:#0000A0; bold", L"" },
    { SCE_F_WORD2, 63260, L"Word2", L"fore:#0000FF; bold", L"" },
    { SCE_F_WORD3, 63203, L"Word3", L"fore:#008000; bold", L"" },
    { SCE_F_PREPROCESSOR, 63133, L"Preprocessor", L"fore:#FF8000", L"" },
    { SCE_F_LABEL, 63235, L"Label", L"fore:#000000; back:#FFFFD1; bold", L"" },
    { SCE_F_CONTINUATION, 63257, L"Continuation", L"back:#FFC0C0", L"" },
    { -1, 00000, L"", L"", L"" } } };

여기서 48, 63행의 63022, 63023은 위의 1번에서 추가한 값과 똑같아야 한다.


4. Styles.c 수정 #2


위의 3번에서 찾은 내용은 아래와 같이 생겼다.

PEDITLEXER pLexArray[NUMLEXERS] =
{
  &lexDefault,
  &lexHTML,
  &lexXML,
  &lexCSS,
  &lexJS,
  &lexVBS,

이 배열의 맨 마지막에 아래와 같은 내용을 추가한다.


  &lexFORTRAN,
  &lexFORTRAN77


이러한 수정이 적용된 화면은 아래와 같다.

포트란이 지원되는 메모장2!