「編集モードの自動選択」の版間の差分
Bleat版に関係ない記述を除去 |
正規表現を修正(エラーが出るため) |
||
| (同じ利用者による、間の1版が非表示) | |||
| 30行目: | 30行目: | ||
// イベント実行「ファイルを開いた時」または「アクティブな文書が変更された時」 | // イベント実行「ファイルを開いた時」または「アクティブな文書が変更された時」 | ||
// ----------------------------------------------------------------------------- | // ----------------------------------------------------------------------------- | ||
const type = { n:document.Name , f:document.FullName }; | const type = { | ||
n: document.Name, | |||
f: document.FullName | |||
}; | |||
//-----------------------------------設定------------------------------------ | //-----------------------------------設定------------------------------------ | ||
const n = type.f; // 検索対象の種類:type.n:ファイル名と拡張子 type.f:フルパス | const n = type.f; // 検索対象の種類:type.n:ファイル名と拡張子 type.f:フルパス | ||
const RO = "書禁"; // 書き換え禁止フラグ名(編集モード名と被る場合に変更してください) | const RO = "書禁"; // 書き換え禁止フラグ名(編集モード名と被る場合に変更してください) | ||
const m = [ | const m = [ | ||
// [ /ファイル名(正規表現可)/検索フラグ(省略可), "編集モード名(省略可)" , "書禁フラグ(省略可)" ], | // [/ファイル名(正規表現可)/検索フラグ(省略可), "編集モード名(省略可)", "書禁フラグ(省略可)"], | ||
[ /(readme|README)\.txt$/ , "Markdown" ], | [/(readme|README)\.txt$/, "Markdown"], | ||
[ / | [/青空文庫|[\\\/]book[\\\/]/i, "書禁"], | ||
[ /\\Mery\\Macros\\.+\.js$/i , "Mery_Macro_JS" ], | [/\\Mery\\Macros\\.+\.js$/i, "Mery_Macro_JS"], | ||
]; | ]; | ||
//-----------------------------------本体------------------------------------ | //-----------------------------------本体------------------------------------ | ||
for (let i = 0, imax = m.length; i < imax; i=(i+1)|0){ | for (let i = 0, imax = m.length; i < imax; i = (i + 1) | 0) { | ||
if (n.match(m[i][0])) { | if (n.match(m[i][0])) { | ||
if (m[i][1] != RO ){ | if (m[i][1] != RO) { | ||
editor.ActiveDocument.mode = m[i][1]; | editor.ActiveDocument.mode = m[i][1]; | ||
if ( m[i][2] === RO ) { | if (m[i][2] === RO) { | ||
editor.ActiveDocument.ReadOnly = true; | editor.ActiveDocument.ReadOnly = true; | ||
} | } | ||
} else { | } else { | ||
editor.ActiveDocument.ReadOnly = true; | |||
} | } | ||
break; | |||
} | } | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
スポンサーリンク