「タグジャンプ」の版間の差分
ナビゲーションに移動
検索に移動
編集の要約なし |
複数エディタ(あるいはタブ無効状態)に対応 |
||
| 16行目: | 16行目: | ||
var docs = Editor.Documents; | var docs = Editor.Documents; | ||
var count = docs.Count; | var count = docs.Count; | ||
for( var i = 0 ; i < | for( var i = 0 ; i < Editors.Count ; ++i ){ | ||
var doc = docs.Item( | 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; | |||
} | |||
} | } | ||
} | } | ||
2014年6月17日 (火) 22:07時点における版
いわゆるタグジャンプを行います。
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 fso = new ActiveXObject( 'Scripting.FileSystemObject' );
var path = fso.GetAbsolutePathName( matched[1] );
var doc = FindDocument( path );
if( doc ){
// 既に開かれてるならアクティブにする
doc.Activate();
}else{
// まだ開いてないなら開く
Editor.NewFile();
Editor.OpenFile( path );
doc = FindDocument( path );
}
// 指定行に移動
if( doc ){
doc.selection.SetActivePoint( mePosLogical, 1, matched[2], false );
}
}
スポンサーリンク