내 홈피의 뒷받침을 해주고 있는 테터툴즈를 1.0.6.1로 업그레이드 하고 몇 가지 플러그인을 설치하였다. 테터의 개방된 구조를 지향하는 올바른 개발자 철학이 맘에 든다.
여러 플러그인 중에 가장 끌렸던 것은 소스의 Syntax Highlight 기능.
사실 이 사이트에 소스를 많이 올린 편은 아니지만, 올린 소스도 그다지 이쁘게 표현되지 않았던 것이 사실이다.
테터의 플러그인 페이지{.broken_link}에 가면 몇 가지가 있지만 가장 편하고 이뻐 보이는 것은 후리자 님이 만든 테터코드 하이라이트 플러그인 v0.93{.broken_link}이 었다.
적용예는 맨 밑에 있다. 아주 맘에 든다… 깔끔하고..
일단 이걸 하고, 내 홈피의 나머지 소스 부분 얼마 있진 않지만 거기도 다 이걸로 바꿔야 겠다. ㅎㅎㅎㅎ
에러코드 잡기
그런데 플러그인을 적용할 때 문제가 있었었다.
에러가 반환되었던 것… 후리자 님의 방법에 따라서 에러코드가 나오는 ch_main.js를 넣고 실행을 했었는데, 에러코드가 0이 나왔었고, 스크립트를 좀 뜯어봤더니 에러가 나는 곳은….
ch_main.js 의 41번째 라인에서.
iframe.contentWindow까지는 얻어오는 데 그 밑에 document 이하를 못 얻어오고, 얻어오고자 하면 익스플로러 아래의 상태줄에 Error 접근 권한이 없습니다. 이런 에러가 떳었다.
그러다가 어찌어찌 하다 보니.. 소스를 고치진 않았는데 그냥 되버렸다. 제대로 contentWindow도 얻어오고.. 희안했다. 답을 알았으면 후리자님 블로그에 댓글이라도 남길려고 했는데.. 어영부영 이상하게 되버려서 답을 적다가 말았다.
되서 좋긴 한데.. 그래도 뒤끝이…머쓱 머쓱.
후리자님도 디버깅을 할 환경이 안되서 못고치고 있는 것 같은데. 개발자는 에러를 재현할 수 있어야 디버깅 할 수 있는 것 아닌가…
적용예
-
// stltest.cpp : 콘솔 응용 프로그램에 대한 진입점을 정의합니다.
<li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">//</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #339900">#include “stdafx.h”</span> </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #339900">#include <vector></span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #339900">#include <algorithm></span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #339900">#include <math.h></span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #ff0000">// 테스트 데이터를 담고 있는 구조체</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">struct</span> test </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">int</span> idx; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">float</span> v1; </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #0000ff">float</span> v2; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">float</span> v3; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span>; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// remove_if의 조건문에 해당하는 함수</span> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #0000ff">bool</span> isgood<span style="color: #000000">(</span>test t<span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">if</span><span style="color: #000000">(</span>t.<span style="color: #00eeff">v1</span> + t.<span style="color: #00eeff">v2</span> + t.<span style="color: #00eeff">v3</span> < <span style="color: #0000dd">180</span><span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span>; </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">else</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// find_if의 조건문에 해당하는 함수</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">bool</span> findme<span style="color: #000000">(</span>test t<span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #0000ff">if</span><span style="color: #000000">(</span>t.<span style="color: #00eeff">idx</span> == <span style="color: #0000dd">99</span><span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">true</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">else</span> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">return</span> <span style="color: #0000ff">false</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #ff0000">// </span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">bool</span> sortrule<span style="color: #000000">(</span><span style="color: #0000ff">const</span> test& a1, <span style="color: #0000ff">const</span> test& a2<span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// return a1.idx < a2.idx;</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">return</span> <span style="color: #0000dd">sqrt</span><span style="color: #000000">(</span>a1.<span style="color: #00eeff">v1</span> * a1.<span style="color: #00eeff">v1</span> + a1.<span style="color: #00eeff">v2</span> * a1.<span style="color: #00eeff">v2</span> + a1.<span style="color: #00eeff">v3</span> * a1.<span style="color: #00eeff">v3</span><span style="color: #000000">)</span> < <span style="color: #0000dd">sqrt</span><span style="color: #000000">(</span>a2.<span style="color: #00eeff">v1</span> * a2.<span style="color: #00eeff">v1</span> + a2.<span style="color: #00eeff">v2</span> * a2.<span style="color: #00eeff">v2</span> + a2.<span style="color: #00eeff">v3</span> *a2.<span style="color: #00eeff">v3</span> <span style="color: #000000">)</span>; </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">void</span> printvalues<span style="color: #000000">(</span>std::<span style="color: #00eeff">vector</span><test>& tests<span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">char</span> str<span style="color: #000000">[</span><span style="color: #0000dd">80</span><span style="color: #000000">]</span>; </div> <li style="color: #000"> <div style="color: #666"> std::<span style="color: #00eeff">vector</span><test>::<span style="color: #00eeff">iterator</span> itr; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 값출력</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000dd">printf</span><span style="color: #000000">(</span><span style="color: #666666">“값출력 size of vector is %d<span style="color: #666666">n</span>“</span>, tests.<span style="color: #00eeff">size</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">for</span><span style="color: #000000">(</span>itr = tests.<span style="color: #00eeff">begin</span><span style="color: #000000">(</span><span style="color: #000000">)</span>; itr != tests.<span style="color: #00eeff">end</span><span style="color: #000000">(</span><span style="color: #000000">)</span>; itr++<span style="color: #000000">)</span> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000dd">sprintf</span><span style="color: #000000">(</span>str, <span style="color: #666666">“%d<span style="color: #666666">t</span>%3.3f<span style="color: #666666">t</span>%3.3f<span style="color: #666666">t</span>%3.3f<span style="color: #666666">n</span>“</span>, itr->idx, itr->v1, itr->v2, itr->v3<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000dd">printf</span><span style="color: #000000">(</span> str <span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">int</span> _tmain<span style="color: #000000">(</span><span style="color: #0000ff">int</span> argc, _TCHAR* argv<span style="color: #000000">[</span><span style="color: #000000">]</span><span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> std::<span style="color: #00eeff">vector</span><test> tests; </div> <li style="color: #069"> <div style="color: #666"> std::<span style="color: #00eeff">vector</span><test>::<span style="color: #00eeff">iterator</span> itr; </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 01. 값설정 –> push_back()을 사용한다.</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">for</span><span style="color: #000000">(</span><span style="color: #0000ff">float</span> i=<span style="color: #0000dd"></span>; i < <span style="color: #0000dd">10</span>; i++<span style="color: #000000">)</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">{</span> </div> <li style="color: #069"> <div style="color: #666"> test t; </div> <li style="color: #000"> <div style="color: #666"> t.<span style="color: #00eeff">idx</span> = <span style="color: #000000">(</span><span style="color: #0000ff">int</span><span style="color: #000000">)</span>i; </div> <li style="color: #069"> <div style="color: #666"> t.<span style="color: #00eeff">v1</span> = <span style="color: #0000dd">10</span>.0f * i; </div> <li style="color: #069"> <div style="color: #666"> t.<span style="color: #00eeff">v2</span> = <span style="color: #0000dd">20</span>.0f * i; </div> <li style="color: #069"> <div style="color: #666"> t.<span style="color: #00eeff">v3</span> = <span style="color: #0000dd">30</span>.0f * i; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #000"> <div style="color: #666"> tests.<span style="color: #00eeff">push_back</span><span style="color: #000000">(</span>t<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> printvalues<span style="color: #000000">(</span>tests<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 임의로 뒤집기</span> </div> <li style="color: #000"> <div style="color: #666"> random_shuffle<span style="color: #000000">(</span>tests.<span style="color: #00eeff">begin</span><span style="color: #000000">(</span><span style="color: #000000">)</span>, tests.<span style="color: #00eeff">end</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 02. 조건에 맞는 놈 지우기 –> remove_if()를 사용한다.</span> </div> <li style="color: #069"> <div style="color: #666"> tests.<span style="color: #00eeff">erase</span><span style="color: #000000">(</span>remove_if<span style="color: #000000">(</span>tests.<span style="color: #00eeff">begin</span><span style="color: #000000">(</span><span style="color: #000000">)</span>, tests.<span style="color: #00eeff">end</span><span style="color: #000000">(</span><span style="color: #000000">)</span>, isgood<span style="color: #000000">)</span>, tests.<span style="color: #00eeff">end</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> printvalues<span style="color: #000000">(</span>tests<span style="color: #000000">)</span>; <span style="color: #ff0000">// 값보자..</span> </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 03. 원하는 위치에 몇 놈집어넣기 –> insert()를 사용해서..</span> </div> <li style="color: #069"> <div style="color: #666"> test t = <span style="color: #000000">{</span> <span style="color: #0000dd">99</span>, <span style="color: #0000dd">444</span>.0f, <span style="color: #0000dd">555</span>.0f, <span style="color: #0000dd">666</span>.0f<span style="color: #000000">}</span>; </div> <li style="color: #069"> <div style="color: #666"> tests.<span style="color: #00eeff">insert</span><span style="color: #000000">(</span>tests.<span style="color: #00eeff">begin</span><span style="color: #000000">(</span><span style="color: #000000">)</span><span style="color: #0000dd">+4</span>, t<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> printvalues<span style="color: #000000">(</span>tests<span style="color: #000000">)</span>; </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 04. 바꾸기를 해보자 –> </span> </div> <li style="color: #069"> <div style="color: #666"> test t2 = <span style="color: #000000">{</span> <span style="color: #0000dd">199</span>, <span style="color: #0000dd">444</span>.0f, <span style="color: #0000dd">555</span>.0f, <span style="color: #0000dd">666</span>.0f<span style="color: #000000">}</span>; </div> <li style="color: #069"> <div style="color: #666"> itr = find_if<span style="color: #000000">(</span>tests.<span style="color: #00eeff">begin</span><span style="color: #000000">(</span><span style="color: #000000">)</span>, tests.<span style="color: #00eeff">end</span><span style="color: #000000">(</span><span style="color: #000000">)</span>, findme<span style="color: #000000">)</span>; <span style="color: #ff0000">// 이 놈을 찾아서</span> </div> <li style="color: #069"> <div style="color: #666"> tests.<span style="color: #00eeff">erase</span><span style="color: #000000">(</span>itr<span style="color: #000000">)</span>; <span style="color: #ff0000">// 지우고</span> </div> <li style="color: #000"> <div style="color: #666"> tests.<span style="color: #00eeff">insert</span><span style="color: #000000">(</span>itr, t2<span style="color: #000000">)</span>; <span style="color: #ff0000">// 그자리에 다른 놈을 넣어준 다음에</span> </div> <li style="color: #069"> <div style="color: #666"> printvalues<span style="color: #000000">(</span>tests<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// 05. sort를 해보자</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000dd">printf</span><span style="color: #000000">(</span><span style="color: #666666">“sort<span style="color: #666666">n</span>“</span><span style="color: #000000">)</span>; </div> <li style="color: #000"> <div style="color: #666"> sort<span style="color: #000000">(</span>tests.<span style="color: #00eeff">begin</span><span style="color: #000000">(</span><span style="color: #000000">)</span>, tests.<span style="color: #00eeff">end</span><span style="color: #000000">(</span><span style="color: #000000">)</span>,sortrule<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> printvalues<span style="color: #000000">(</span>tests<span style="color: #000000">)</span>; </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">/*</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000"> // 해당위치에 삽입하기</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000"> test t;</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000"> t.idx = (int)i;</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000"> t.v1 = 10.0f * i;</span> </div> <li style="color: #000"> <div style="color: #666"> <span style="color: #ff0000"> t.v2 = 20.0f * i;</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000"> t.v3 = 30.0f * i;</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">// tests.insert()</span> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #ff0000">*/</span> </div> <li style="color: #000"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #0000ff">return</span> <span style="color: #0000dd"></span>; </div> <li style="color: #069"> <div style="color: #666"> <span style="color: #000000">}</span> </div> <li style="color: #069"> <div style="color: #666"> </div> <li style="color: #069"> <div style="color: #666"> </div> </li></ol> </div>