「タグジャンプ」の版間の差分
ナビゲーションに移動
検索に移動
タブ無効化時にタブが閉じられてしまうのを修正 |
相対パスの扱いがおかしかったので修正 |
||
| 9行目: | 9行目: | ||
// タグジャンプ | // タグジャンプ | ||
// NYSL | // NYSL | ||
// ファイルパスからドキュメントを開く | // ファイルパスからドキュメントを開く | ||
function FindDocument( path ) | function FindDocument( path ) | ||
| 30行目: | 30行目: | ||
return null; | return null; | ||
} | } | ||
// カーソル行からファイルパスと行番号検索 | // カーソル行からファイルパスと行番号検索 | ||
var line = Document.GetLine( Document.selection.GetActivePointY(mePosLogical) ); | var line = Document.GetLine( Document.selection.GetActivePointY(mePosLogical) ); | ||
| 36行目: | 36行目: | ||
if( matched && matched.length >= 3 ){ | if( matched && matched.length >= 3 ){ | ||
// 念のためフルパスに変換 | // 念のためフルパスに変換 | ||
var shell = new ActiveXObject( "WScript.Shell" ); | |||
var prev_curdir = shell.CurrentDirectory; | |||
shell.CurrentDirectory = Document.Path; | |||
var fso = new ActiveXObject( 'Scripting.FileSystemObject' ); | var fso = new ActiveXObject( 'Scripting.FileSystemObject' ); | ||
var path = fso.GetAbsolutePathName( matched[1] ); | var path = fso.GetAbsolutePathName( matched[1] ); | ||
shell.CurrentDirectory = prev_curdir; | |||
var doc = FindDocument( path ); | var doc = FindDocument( path ); | ||
if( doc ){ | if( doc ){ | ||
2015年7月23日 (木) 12:05時点における版
いわゆるタグジャンプを行います。
c:\abc\def.ghi(123): ○○
のような行にカーソルを合わせ実行するとそのファイルを開き、その行に移動します。
// タグジャンプ
// NYSL
// ファイルパスからドキュメントを開く
function FindDocument( path )
{
path = path.toLowerCase();
var docs = Editor.Documents;
var count = docs.Count;
for( var i = 0 ; i < Editors.Count ; ++i ){
var docs = Editors.Item(i).Documents;
var count = docs.Count;
for( var j = 0 ; j < count ; ++j ){
var doc = docs.Item(j);
if( doc ){
if( doc.FullName.toLowerCase() == path ){
return doc;
}
}
}
}
return null;
}
// カーソル行からファイルパスと行番号検索
var line = Document.GetLine( Document.selection.GetActivePointY(mePosLogical) );
var matched = line.match( /^\s*(.+)\((\d+)\):/ );
if( matched && matched.length >= 3 ){
// 念のためフルパスに変換
var shell = new ActiveXObject( "WScript.Shell" );
var prev_curdir = shell.CurrentDirectory;
shell.CurrentDirectory = Document.Path;
var fso = new ActiveXObject( 'Scripting.FileSystemObject' );
var path = fso.GetAbsolutePathName( matched[1] );
shell.CurrentDirectory = prev_curdir;
var doc = FindDocument( path );
if( doc ){
// 既に開かれてるならアクティブにする
doc.Activate();
}else{
// まだ開いてないなら開く
Editor.NewFile();
if( Editor.EnableTab ){
Editor.OpenFile( path );
} else {
Editors.Item(Editors.Count-1).OpenFile( path );
}
doc = FindDocument( path );
}
// 指定行に移動
if( doc ){
doc.selection.SetActivePoint( mePosLogical, 1, matched[2], false );
}
}
スポンサーリンク