diff --git a/CHANGELOG.md b/CHANGELOG.md index a093cafdd1..8dfe079edf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Append the nearest unique ancestor folder name to the document title if multiple documents with the same name are opened. - The new “prevent editing” option that prevents documents from being unintentionally edited. +- Introduce the `--readonly` (`-r`) option to the `cot` command-line tool to open documents as read-only. - Introduce the new AppleScript parameter `editable` to document objects. diff --git a/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/CotEditor.cshelpindex b/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/CotEditor.cshelpindex index c0f5c24fca..7781876db4 100644 Binary files a/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/CotEditor.cshelpindex and b/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/CotEditor.cshelpindex differ diff --git a/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/about_cot.html b/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/about_cot.html index effccff571..bfa9021057 100644 --- a/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/about_cot.html +++ b/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/about_cot.html @@ -51,6 +51,7 @@

Use with options

-w, --waitWait for opened file to be closed before returning to a prompt. + -r, --readonlyOpen documents as read-only. -n, --newCreate a new blank document. -s, --syntaxSet specific syntax to opened document. -l, --line <line>Jump to specific line in opened document. <line> is an integer specifying the number of line. diff --git a/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/howto_readonly.html b/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/howto_readonly.html index 88c782d7fe..b36d6351dd 100644 --- a/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/howto_readonly.html +++ b/CotEditor/Resources/CotEditor.help/Contents/Resources/en.lproj/pgs/howto_readonly.html @@ -11,6 +11,7 @@ +

Make read-only documents in CotEditor on Mac

@@ -25,11 +26,14 @@

Preventing from being edited

diff --git a/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/CotEditor.cshelpindex b/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/CotEditor.cshelpindex index c7cebb352d..f2fcdfab58 100644 Binary files a/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/CotEditor.cshelpindex and b/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/CotEditor.cshelpindex differ diff --git a/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/about_cot.html b/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/about_cot.html index a156a54c18..9b0be46f7f 100644 --- a/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/about_cot.html +++ b/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/about_cot.html @@ -52,6 +52,7 @@

オプションとともに使う

-w, --wait開いたファイルが閉じるまでコマンドの終了を待ちます。 + -r, --readonly書類を読み出し専用として開きます。 -n, --new空の新規書類を開きます。 -s, --syntax開いた書類に任意のシンタックスをセットします。 -l, --line <line>開いた書類の指定した行に移動します。<line>は行を指定する整数型です。 @@ -62,7 +63,7 @@

オプションとともに使う

-

--lineオプションと--columnは負の値を指定することもできます。そのとき、--lineオプションの場合は書類の末尾から、--columnオプションの場合は行の末尾からカウントがされます。

+

--lineオプションと--columnは負の値を指定することもできます。そのとき、--lineオプションの場合は書類の末尾から、--columnオプションの場合は行の末尾からカウントされます。

cotコマンド単体でCotEditorが起動します。

diff --git a/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/howto_readonly.html b/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/howto_readonly.html index 05758af7ff..722f784f35 100644 --- a/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/howto_readonly.html +++ b/CotEditor/Resources/CotEditor.help/Contents/Resources/ja.lproj/pgs/howto_readonly.html @@ -11,6 +11,7 @@ +

MacのCotEditorで読み出し専用の書類にする

@@ -29,7 +30,10 @@

編集不可にする

  • AppleScriptでdocumentオブジェクトのeditableプロパティをfalseにします。
  • -
  • 書類を読み出し専用で開くには、「ファイル」 > 「開く」を選択し、「開く」ダイアログの「読み出し専用で開く」チェックボックスを有効にする。
  • +
  • 書類を読み出し専用で開くには、以下のいずれかの操作を行います:
  • 編集不可の書類をふたたび編集可能にするには、「フォーマット」>「編集可能にする」と選択します。
  • diff --git a/CotEditor/Resources/cot b/CotEditor/Resources/cot index 5b7ea95450..471c745bad 100755 --- a/CotEditor/Resources/cot +++ b/CotEditor/Resources/cot @@ -9,7 +9,7 @@ Created by 1024jp on 2015-08-12. ------------------------------------------------------------------------------ -© 2015-2024 1024jp +© 2015-2025 1024jp Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -34,7 +34,7 @@ from subprocess import Popen, PIPE, CalledProcessError # meta data -__version__ = '2.10.1' +__version__ = '5.1.0' __description__ = 'command-line utility for CotEditor.' @@ -262,6 +262,11 @@ def parse_args(): default=False, help="do not bring the application to the foreground" ) + parser.add_argument('-r', '--readonly', + action='store_true', + default=False, + help="open the document as read-only" + ) parser.add_argument('-n', '--new', action='store_true', default=False, @@ -358,15 +363,20 @@ def main(args, stdin): # launch app.launch(background=args.background) + if app.tell('number of documents') == '0': + return + + # set read-only + if args.readonly: + for index in range(document_count): + app.tell_document('set editable to false', index + 1) + # set syntax - if args.syntax is not None and document_count > 0: + if args.syntax is not None: for index in range(document_count): app.tell_document('set coloring style to "{}"'.format(args.syntax), index + 1) - if app.tell('number of documents') == '0': - return - # jump to location if args.line is not None or args.column is not None: app.tell_document('jump to line {} column {}'.format(