「タグジャンプ」の版間の差分
編集の要約なし |
SyntaxHighlightにcopyの追加 |
||
| (3人の利用者による、間の8版が非表示) | |||
| 1行目: | 1行目: | ||
いわゆるタグジャンプを行います。 | いわゆるタグジャンプを行います。 | ||
ジャンプ元文書が保存済みであれば、相対パスであっても移動できるかと思います。 | |||
c:\abc\def.ghi(123): ○○<br> | |||
..\..\abc\def.ghi(123): ○○ | |||
のような行にカーソルを合わせ実行すると、そのファイルを開きカッコ内で指定された行に移動します。 | |||
< | <syntaxhighlight lang="javascript" copy> | ||
// タグジャンプ | // タグジャンプ | ||
// NYSL | // NYSL | ||
| 13行目: | 15行目: | ||
function FindDocument( path ) | function FindDocument( path ) | ||
{ | { | ||
path = path. | path = path.toUpperCase(); | ||
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.toUpperCase() == path ){ | |||
return doc; | |||
} | |||
} | } | ||
} | } | ||
| 31行目: | 37行目: | ||
var matched = line.match( /^\s*(.+)\((\d+)\):/ ); | var matched = line.match( /^\s*(.+)\((\d+)\):/ ); | ||
if( matched && matched.length >= 3 ){ | if( matched && matched.length >= 3 ){ | ||
var path = matched[1]; | |||
var fso = new ActiveXObject( 'Scripting.FileSystemObject' ); | var fso = new ActiveXObject( 'Scripting.FileSystemObject' ); | ||
var path = fso.GetAbsolutePathName( | |||
// フルパスへ変換 | |||
var dir = Document.Path; | |||
if( dir && dir.length > 0 ){ | |||
var shell = new ActiveXObject( "WScript.Shell" ); | |||
var prev = shell.CurrentDirectory; | |||
shell.CurrentDirectory = dir; | |||
path = fso.GetAbsolutePathName( path ); | |||
shell.CurrentDirectory = prev; | |||
} | |||
var doc = FindDocument( path ); | var doc = FindDocument( path ); | ||
if( doc ){ | if( doc ){ | ||
// 既に開かれてるならアクティブにする | // 既に開かれてるならアクティブにする | ||
doc.Activate(); | doc.Activate(); | ||
}else{ | }else if( fso.FileExists( path ) ){ | ||
// まだ開いてないなら開く | // まだ開いてないなら開く | ||
Editor.NewFile(); | Editor.NewFile(); | ||
Editor.OpenFile( path ); | if( Editor.EnableTab ){ | ||
Editor.OpenFile( path ); | |||
} else { | |||
Editors.Item(Editors.Count-1).OpenFile( path ); | |||
} | |||
doc = FindDocument( path ); | doc = FindDocument( path ); | ||
} | } | ||
| 50行目: | 69行目: | ||
} | } | ||
} | } | ||
</ | </syntaxhighlight> | ||
スポンサーリンク