cc-pets 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@
4
4
 
5
5
  ## [Unreleased]
6
6
 
7
+ - 修复台词编辑器里 ⌘C/⌘V/⌘X/⌘A/⌘Z/⌘⇧Z 全部没反应。这些快捷键不是 `NSTextView` 自己
8
+ 处理的:按键先走 `NSApp.mainMenu` 的 `performKeyEquivalent:`,命中菜单项之后才沿响应者链
9
+ 发 `copy:` / `paste:` 这些消息。这个 app 是 `LSUIElement`,此前从没设过主菜单,所以全部
10
+ 落空。现在装一个只有「编辑」的主菜单——`LSUIElement` 按定义不显示自己的菜单栏,它只是
11
+ 一张快捷键路由表,用户看不见。菜单项的 target 一律留空交给响应者链,以后新加的文本框
12
+ 自动就有这些快捷键。
13
+ - 修复 `npm install` 失败:`package.json` 的 `files` 白名单逐个列 `Resources/` 下的文件,
14
+ 新增的 `Resources/phrases.default.txt` 没进去,发布包里没有这个文件,`build.sh` 拷贝那一步
15
+ 直接失败。本地从工作树构建看不出来,所以给发布包完整性测试补上了资源文件这一档。
16
+
7
17
  - 用户词库改名 `~/.cc-pets/phrases.txt` → `~/.cc-pets/speech.txt`。换名字是为了让"迁移过
8
18
  没有"变成一个平凡的判断(新文件在就是迁移过了)——靠猜内容特征(有没有 replace 行、
9
19
  缺不缺某个小节)都不可靠,用户改过之后更没法判断。
@@ -832,7 +832,51 @@ static NSString *const PetSpeechFrequencyChatty = @"chatty";
832
832
  }
833
833
  }
834
834
  }
835
+ // 建一个只有"编辑"的主菜单。
836
+ //
837
+ // ⌘C/⌘V/⌘A/⌘Z 不是 NSTextView 自己处理的:按键先走 NSApp.mainMenu 的
838
+ // performKeyEquivalent:,命中菜单项之后才沿响应者链发 copy: / paste: 这些消息。
839
+ // 这个 app 是 LSUIElement,之前从没设过主菜单,所以台词编辑器里这些快捷键全部落空。
840
+ //
841
+ // LSUIElement 等价于 NSApplicationActivationPolicyAccessory,按定义不显示自己的菜单栏,
842
+ // 所以这个菜单只是一张快捷键路由表,用户看不见它。桌宠面板是 NSNonactivatingPanel,
843
+ // 点它根本不激活 app,更碰不到这里。
844
+ //
845
+ // action 一律留给响应者链(target 为 nil),谁是第一响应者谁处理——写死 target 的话
846
+ // 编辑器之外的文本框就用不上了。
847
+ - (void)installEditMenu {
848
+ if (NSApp.mainMenu) return;
849
+ NSMenu *mainMenu = [NSMenu new];
850
+ NSMenuItem *editItem = [mainMenu addItemWithTitle:@"编辑" action:nil keyEquivalent:@""];
851
+ NSMenu *editMenu = [[NSMenu alloc] initWithTitle:@"编辑"];
852
+
853
+ NSArray<NSArray *> *entries = @[
854
+ @[@"撤销", NSStringFromSelector(@selector(undo:)), @"z", @(NSEventModifierFlagCommand)],
855
+ @[@"重做", NSStringFromSelector(@selector(redo:)), @"z",
856
+ @(NSEventModifierFlagCommand | NSEventModifierFlagShift)],
857
+ @[@"-", @"", @"", @0],
858
+ @[@"剪切", NSStringFromSelector(@selector(cut:)), @"x", @(NSEventModifierFlagCommand)],
859
+ @[@"拷贝", NSStringFromSelector(@selector(copy:)), @"c", @(NSEventModifierFlagCommand)],
860
+ @[@"粘贴", NSStringFromSelector(@selector(paste:)), @"v", @(NSEventModifierFlagCommand)],
861
+ @[@"删除", NSStringFromSelector(@selector(delete:)), @"", @0],
862
+ @[@"全选", NSStringFromSelector(@selector(selectAll:)), @"a", @(NSEventModifierFlagCommand)],
863
+ ];
864
+ for (NSArray *entry in entries) {
865
+ if ([entry[0] isEqualToString:@"-"]) {
866
+ [editMenu addItem:NSMenuItem.separatorItem];
867
+ continue;
868
+ }
869
+ NSMenuItem *item = [editMenu addItemWithTitle:entry[0]
870
+ action:NSSelectorFromString(entry[1]) keyEquivalent:entry[2]];
871
+ item.keyEquivalentModifierMask = (NSEventModifierFlags)[entry[3] unsignedIntegerValue];
872
+ }
873
+ editItem.submenu = editMenu;
874
+ NSApp.mainMenu = mainMenu;
875
+ }
876
+
835
877
  - (void)applicationDidFinishLaunching:(NSNotification *)notification {
878
+ // 没有主菜单的话,台词编辑器里 ⌘C/⌘V/⌘A/⌘Z 全部没反应。
879
+ [self installEditMenu];
836
880
  // 台词全在这个文件里,代码里没有第二份。首次启动先从出厂词库拷一份出来,
837
881
  // 否则新装的桌宠一句话都不会说。
838
882
  PetPhrasesEnsureFileExists();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cc-pets",
3
- "version": "1.4.3",
3
+ "version": "1.4.4",
4
4
  "description": "A native macOS desktop pet for Codex CLI and Claude Code",
5
5
  "author": "wangxinyusqn",
6
6
  "license": "MIT",