「定型文を挿入」の版間の差分
編集の要約なし |
|||
| 51行目: | 51行目: | ||
editor.ActiveDocument.selection.InsertFromFile( file, 0 ); // 0 は文字エンコードの「自動選択」 | editor.ActiveDocument.selection.InsertFromFile( file, 0 ); // 0 は文字エンコードの「自動選択」 | ||
editor.ActiveDocument.selection.SetActivePoint( mePosLogical, 1, 1 ); // ドキュメントの先頭にカーソルを移動 | editor.ActiveDocument.selection.SetActivePoint( mePosLogical, 1, 1 ); // ドキュメントの先頭にカーソルを移動 | ||
</source> | |||
== 定型文ファイルのテキストをクリップボードに取り込む == | |||
定型文ファイルを一時的に開き、内容をコピーして閉じます。 | |||
<source lang="javascript"> | |||
#title = "定型文をコピー" | |||
#tooltip = "定型文ファイルの内容をクリップボードにコピーする" | |||
// #icon = "" | |||
// ■定型文ファイルを "フルパス" で指定する■ | |||
var file = "C:\\hoge\\Template.txt"; | |||
// ( \ はふたつ重ね \\ にすること) | |||
Redraw = false; | |||
editor.NewFile(); | |||
editor.OpenFile( file, 0 ); // 0 はエンコードの「自動選択」 | |||
ClipboardData.SetData( editor.ActiveDocument.Text ); | |||
editor.ActiveDocument.Close(); | |||
Redraw = true; | |||
</source> | </source> | ||
| 92行目: | 113行目: | ||
// ■「挿入...」ダイアログで起点にするフォルダを指定する■ | // ■「挿入...」ダイアログで起点にするフォルダを指定する■ | ||
var folder = "% | var folder = "%userprofile%\\desktop\\"; | ||
// (\ はふたつ重ね \\ にする / 末尾にも \\ を付ける) | // (\ はふたつ重ね \\ にする / 末尾にも \\ を付ける) | ||
// 起点フォルダを指定する必要がないならば folder = "" にしておく | // 起点フォルダを指定する必要がないならば folder = "" にしておく | ||
| 142行目: | 163行目: | ||
m.Add( "入力ダイアログでフルパスを指定(&D)..." , 2 ); | m.Add( "入力ダイアログでフルパスを指定(&D)..." , 2 ); | ||
// m.Add( "選択範囲の文字列(ファイルパス)から(&P)" , 3 ); | // m.Add( "選択範囲の文字列(ファイルパス)から(&P)" , 3 ); | ||
m.Add( "クリップボードの文字列(ファイルパス)から(& | m.Add( "クリップボードの文字列(ファイルパス)から(&B)" , 4 ); | ||
m.Add( "", 0, meMenuSeparator ); | m.Add( "", 0, meMenuSeparator ); | ||
m.Add( "定型文つき新規ドキュメント (&N)" , 5 ); | m.Add( "定型文つき新規ドキュメント(&N)" , 5 ); | ||
m.Add( "", 0, meMenuSeparator ); | m.Add( "", 0, meMenuSeparator ); | ||
| 156行目: | 177行目: | ||
m.Add( "", 0, meMenuSeparator ); | m.Add( "", 0, meMenuSeparator ); | ||
m.Add( "定型文ファイルの内容をコピー (&C)" , 6 ); | m.Add( "定型文ファイルの内容をコピー(&C)" , 6 ); | ||
var s = document.selection; | var s = document.selection; | ||
| 172行目: | 193行目: | ||
// ■「挿入」ダイアログで起点にするフォルダを指定する■ | // ■「挿入」ダイアログで起点にするフォルダを指定する■ | ||
var folder = "% | var folder = "%userprofile%\\desktop\\"; | ||
// (\ はふたつ重ね \\ にする / 末尾にも \\ を付ける) | // (\ はふたつ重ね \\ にする / 末尾にも \\ を付ける) | ||
// 起点フォルダを指定する必要がないならば "" にしておく | // 起点フォルダを指定する必要がないならば "" にしておく | ||
| 207行目: | 228行目: | ||
var st = s.Text.replace( /^\"|\"$/g , "" ); | var st = s.Text.replace( /^\"|\"$/g , "" ); | ||
file = ( st.match( /^[a-zA-Z]:\\/ ) ) ? st : file; | file = ( st.match( /^[a-zA-Z]:\\/ ) ) ? st : file; | ||
if ( file ) | if ( file ) { | ||
s.Delete(); | |||
s.InsertFromFile( file, 0 ); // 0 はエンコードの「自動選択」 | s.InsertFromFile( file, 0 ); // 0 はエンコードの「自動選択」 | ||
} | |||
break; | break; | ||
| 239行目: | 262行目: | ||
case 6: | case 6: | ||
// | // 定型文ファイルを一時的に開いてテキストをクリップボードに取り込む | ||
Redraw = false; | Redraw = false; | ||
editor.NewFile(); | editor.NewFile(); | ||
editor. | editor.OpenFile( file, 0 ); // 0 はエンコードの「自動選択」 | ||
ClipboardData.SetData( editor.ActiveDocument.Text ); | |||
editor.ActiveDocument.Close(); | editor.ActiveDocument.Close(); | ||
Redraw = true; | Redraw = true; | ||
break; | break; | ||
スポンサーリンク