Skip to content

Conversation

@neow021
Copy link

@neow021 neow021 commented Sep 3, 2025

Summary

This PR introduces a new option under App Rules that allows users to force the use of English symbols in specific applications.

Motivation

When using input methods in coding environments (e.g., VS Code), users often encounter unwanted full-width or localized symbols, which can cause syntax errors or inconsistent formatting.

Changes

  • Added a per-app setting to enforce English symbols
  • Applied transformation logic when the rule is enabled
  • Updated documentation and UI labels accordingly

Example

For instance, when enabled in VS Code:

  • Typing will be automatically replaced with ,
  • Typing will be replaced with .
  • Other full-width symbols will also be normalized

Notes

This feature is optional and only applies to apps explicitly configured by the user.

neow021 and others added 8 commits September 2, 2025 13:35
- Add forceAsciiPunctuation field to AppRule Core Data model
- Create PunctuationService for real-time punctuation interception
- Integrate punctuation rules with app switching in IndicatorVM
- Add UI toggle for ASCII punctuation in RulesApplicationDetail
- Add localization strings for English, Chinese, Japanese, Korean
- Force ASCII punctuation when Chinese IME is active in specified apps

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Fix Main Actor isolation issue in deinit method
- Replace ISPLogger.error with debug method (error method doesn't exist)
- Fix Unicode string type conversion from UInt32 to UInt16 for CGEvent API
- PunctuationService.swift already properly added to Xcode project

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add checkInputMonitoring() method to PermissionsVM following existing pattern
- Add isInputMonitoringEnabled property with automatic timer watching
- Add openInputMonitoringPreferences() to NSWorkspace extension
- Create InputMonitoringRequiredBadge component with orange styling
- Integrate permission check into PunctuationService.enable()
- Display permission badge in RulesApplicationDetail when needed
- Add localization strings for all supported languages

This provides elegant permission management that perfectly matches
the existing Enhanced Mode permission system architecture.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive functionality to automatically replace Chinese punctuation
with English punctuation based on per-app rules, improving productivity for
multilingual users coding or writing in apps like VS Code and WeChat.

Key Features:
• App-specific punctuation rules with UI controls
• Real-time CJKV input method detection
• Keyboard event interception and character replacement
• Comprehensive Input Monitoring permissions system
• Fixed development environment with workspace-relative builds

Technical Implementation:
• Extend AppRule Core Data model with forceAsciiPunctuation field
• Create PunctuationService for CGEvent-based keystroke interception
• Implement multi-strategy permission checking (IOHIDCheckAccess + CGEvent)
• Add InputMonitoringRequiredBadge UI component
• Configure proper entitlements and Info.plist for macOS permissions

Development Experience:
• Add Xcode Workspace with fixed DerivedData path
• Eliminate need for repeated permission authorization during development
• Provide helper script for easy permission setup

Bug Fixes:
• Correct keyCode mappings (43→comma, 47→period, 41→semicolon)
• Use .defaultTap instead of .listenOnly for event modification
• Use .privateState for clean event creation without modifier pollution

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Update all naming from "ASCII punctuation" to "English punctuation"
for better accuracy and clarity. The feature converts CJKV punctuation
to English punctuation marks, not strictly ASCII characters.

Core Changes:
• Rename forceAsciiPunctuation → forceEnglishPunctuation in Core Data model
• Update chinesePunctuationMap → cjkvToEnglishPunctuationMap in service
• Refactor all related method names and variables for consistency
• Update UI component state variables and handlers

Localization Updates:
• English: "Force English Punctuation"
• 简体中文: "强制使用英文标点符号"
• 繁体中文: "強制使用英文標點符號"
• 日本語: "英語句読点を強制使用"
• 한국어: "영어 구두점 강제 사용"

Technical Impact:
• No functional changes - purely naming improvements
• Better code readability and maintainability
• More accurate terminology throughout codebase
• Improved internationalization consistency

This refactoring improves code quality and prepares the foundation
for future enhancements like custom punctuation mapping.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Change "ASCII Punctuation" to "Punctuation" in section header
- Update localization strings across all 5 supported languages
- Maintain backward compatibility by keeping old keys
- Improve UI clarity by using simpler terminology

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
…Service

- Fix memory safety in CGEvent callback with proper nil checking
- Replace hardcoded virtualKey: 0 with original keyCode for proper event handling
- Ensure robust cleanup in deinit regardless of disable() call order
- Add input source caching to reduce system calls during rapid typing
- Remove problematic retry logic that could cause multiple concurrent attempts
- Add graceful error handling for permission revocations
- Fix Swift Actor isolation issue in deinit method

These fixes address production-critical crashes and performance bottlenecks
while maintaining full feature functionality and architectural integrity.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Remove auxiliary files that were helpful during development but aren't
needed in the main repository:
- FEATURE_ENGLISH_PUNCTUATION.md (development documentation)
- get_fixed_app_path.sh (development convenience script)
- Input Source Pro.xcworkspace (fixed build path configuration)
- .gitignore workspace-specific DerivedData rules

Core English punctuation feature remains intact with all functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Removed duplicate "Force ASCII Punctuation" entries from all localization files
as they had identical translations to "Force English Punctuation" and were unused
in the codebase.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@linpan
Copy link

linpan commented Oct 6, 2025

cool feat.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants