マクロ開発


コンパイルエラーの場所にジャンプ

(2010-11-15 (月) 20:50:28)
Text-Cのコンパイルエラーした箇所にジャンプする。 エラー、警告が複数ある場合、実行するごとに順番にジャンプしていく。


#include <windows.h>
#include <text.h>

// #define DEBUG

HTEXT getstatus()
{
	HWND wf = wtoolfind(ID_PRINT);
	if(!wf) return 0;
	return wgetv(GetWindow(GetWindow(wf, GW_CHILD),GW_CHILD)).text;
}

BOOL iscurbottom(HTEXT text)
{
	IFILE addr = getadr(text);
	BOOL ret = !jumpnextpara(text);
	jumpadr(text, addr);
	return ret;
}

#ifdef DEBUG
_errsample {
	printf(
\\"..**** コンパイルエラーのサンプル ****
file: c:\wz\macro\sample.c
wz://text.h(99): 警告のテスト。99行目にジャンプ。
wz://text.h(999): error[11] エラーのテスト。999行目にジャンプ。
wz://text.h(199): 警告のテスト。199行目にジャンプ。
wz://text.h(1999): error[11] エラーのテスト。1999行目にジャンプ。
..**** ここまで ****
");
}
#endif

jumpmacroerror {
	HTEXT text = getfocus();
	HTEXT status = getstatus();
	
	// カーソルが最下行なら 最後の -compile- 部分にジャンプ	
	// そうでないならその位置から次のエラー部分にジャンプ
	if(iscurbottom(status))
	{ 
		if(!jumpend(status) || !search(status, "^-compile-$", SEARCH_PREV | SEARCH_RE)) return;
	}
	
	HTEXT re = renew(\"^(.*)\((\d+)\):\s(.*)$", 0);
	if(!research(re, status, 0))
	{
		tipprintf("エラーはありません");
		jumpend(status);
		status.v.getcur();
		return;
	}
	
#ifdef DEBUG
//	printf("file:%s\nline:%s\nmsg:%s\n\n", regettag(re, 1), regettag(re, 2), regettag(re, 3));
#endif
	
	statprintf("%s", regettag(re, 3));
	tipprintf("%s", regettag(re, 3));
			
	openfileeditor(regettag(re, 1), textprintf("-jmpara(%s)", regettag(re, 2)));
	status.v.getcur();
}

main {
	jumptomacroerror();
}