Chapter 04 · Editing and files编辑与文件編輯與檔案

File operations文件操作檔案操作

Open, save, save as, recent files, drag and drop, file properties and atomic writes.打开、保存、另存为、最近文件、拖拽、文件属性与原子写入。開啟、儲存、另存新檔、最近檔案、拖曳、檔案屬性與原子寫入。

Opening

  • Open: ⌘O with multi-selection support. Opening a file that is already open switches to its tab instead of duplicating it.
  • Drag and drop: drop files onto the window or the tab bar.
  • Recent files: the last 10 files, with a command to clear the list.
  • File menu: recent entries live under the standard file menu, alongside New, Save and Print.

Saving

ActionShortcutBehaviour
Save⌘SWrites in place. Refuses to write a truncated version of an oversized buffer.
Save As⌘⇧SThe extension is resolved before the panel closes, so saving without typing one still works.
Save All⌘⌥SSaves every modified document.
Print⌘PStandard macOS print panel.

Atomic writes

Saving writes to a temporary file and then moves it into place. If the process is interrupted mid-write, the previous version remains intact. BOM handling is preserved and is never duplicated on repeated saves.

File properties

The properties panel shows the absolute path, size, modification time, line count and character count. It is read-only; use it to confirm which file a tab actually points at after a Save As.

Closing

  • Close the current tab: ⌘⌥W.
  • Close the window: ⌘W.
  • Close all tabs from the toolbar or the tab context menu. Modified documents prompt individually.

Failure behaviour

A failed save is reported with a dialog and a log entry; it is never silent. The most common cause in a sandboxed app is writing to a location that was not authorised through a panel.

打开

  • 打开:⌘O,支持多选。重复打开同一文件会切换到已有标签,而不是再开一个。
  • 拖拽:把文件拖到窗口或标签栏即可打开。
  • 最近文件:保留最近 10 条,并提供清除命令。
  • 文件菜单:最近文件位于标准文件菜单内,与新建、保存、打印并列。

保存

操作快捷键行为
保存⌘S就地写入;超大缓冲区拒绝写截断版本。
另存为⌘⇧S扩展名在面板关闭前确定,所以不输入扩展名也能正常保存。
全部保存⌘⌥S保存所有已修改文档。
打印⌘P系统打印面板。

原子写入

保存时先写临时文件,再移动到目标位置。写入过程中断时,原文件保持完整。BOM 会正确保留,重复保存不会叠加。

文件属性

属性面板显示绝对路径、大小、修改时间、行数与字符数。面板只读;「另存为」之后用它确认标签实际指向的文件。

关闭

  • 关闭当前标签:⌘⌥W。
  • 关闭窗口:⌘W。
  • 关闭全部:工具栏或标签右键菜单,已修改的文档会逐个询问。

失败行为

保存失败会弹提示并写入日志,不会静默失败。沙盒应用最常见的原因是写入了未经面板授权的位置。

開啟

  • 開啟:⌘O,支援多選。重復開啟同一檔案會切換到已有標籤,而不是再開一個。
  • 拖曳:把檔案拖到視窗或標籤欄即可開啟。
  • 最近檔案:保留最近 10 條,並提供清除命令。
  • 檔案選單:最近檔案位於標準檔案選單內,與新建、儲存、列印並列。

儲存

操作快速鍵行為
儲存⌘S就地寫入;超大緩衝區拒絕寫截斷版本。
另存新檔⌘⇧S副檔名在面板關閉前確定,所以不輸入副檔名也能正常儲存。
全部儲存⌘⌥S儲存所有已修改文件。
列印⌘P系統列印面板。

原子寫入

儲存時先寫臨時檔案,再移動到目標位置。寫入過程中斷時,原檔案保持完整。BOM 會正確保留,重復儲存不會疊加。

檔案屬性

屬性面板顯示絕對路徑、大小、修改時間、行數與字元數。面板只讀;「另存新檔」之後用它確認標籤實際指向的檔案。

關閉

  • 關閉當前標籤:⌘⌥W。
  • 關閉視窗:⌘W。
  • 關閉全部:工具列或標籤右鍵選單,已修改的文件會逐個詢問。

失敗行為

儲存失敗會彈提示並寫入日誌,不會靜默失敗。沙盒應用最常見的原因是寫入了未經面板授權的位置。